From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQJZb-0004H4-M3 for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:05:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQJZV-0001T2-5v for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:05:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9372) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQJZU-0001Rj-MW for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:05:41 -0400 From: Igor Mammedov Date: Mon, 22 Oct 2012 17:03:16 +0200 Message-Id: <1350918203-25198-31-git-send-email-imammedo@redhat.com> In-Reply-To: <1350918203-25198-1-git-send-email-imammedo@redhat.com> References: <1350918203-25198-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 30/37] target-i386: convert "model" to static property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, ehabkost@redhat.com, jan.kiszka@siemens.com, Don@CloudSwitch.com, mdroth@linux.vnet.ibm.com, blauwirbel@gmail.com, stefanha@redhat.com, pbonzini@redhat.com, afaerber@suse.de Signed-off-by: Igor Mammedov --- - in addition use error_setg() instead of error_set() --- target-i386/cpu.c | 83 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 69c179a..308dc4c 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -486,6 +486,50 @@ PropertyInfo qdev_prop_stepping = { #define DEFINE_PROP_STEPPING(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_stepping, uint32_t) +static void x86_cpuid_version_get_model(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + X86CPU *cpu = X86_CPU(obj); + CPUX86State *env = &cpu->env; + int64_t value; + + value = (env->cpuid_version >> 4) & 0xf; + value |= ((env->cpuid_version >> 16) & 0xf) << 4; + visit_type_int(v, &value, name, errp); +} + +static void x86_cpuid_version_set_model(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + X86CPU *cpu = X86_CPU(obj); + CPUX86State *env = &cpu->env; + const int64_t min = 0; + const int64_t max = 0xff; + int64_t value; + + visit_type_int(v, &value, name, errp); + if (error_is_set(errp)) { + return; + } + if (value < min || value > max) { + error_setg(errp, "Property %s.%s doesn't take value %" PRId64 " (min" + "imum: %" PRId64 ", maximum: %" PRId64, + object_get_typename(obj), name, value, min, max); + return; + } + + env->cpuid_version &= ~0xf00f0; + env->cpuid_version |= ((value & 0xf) << 4) | ((value >> 4) << 16); +} + +PropertyInfo qdev_prop_model = { + .name = "uint32", + .get = x86_cpuid_version_get_model, + .set = x86_cpuid_version_set_model, +}; +#define DEFINE_PROP_MODEL(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_model, uint32_t) + static Property cpu_x86_properties[] = { DEFINE_PROP_BIT("f-fpu", X86CPU, env.cpuid_features, 0, false), DEFINE_PROP_BIT("f-vme", X86CPU, env.cpuid_features, 1, false), @@ -609,6 +653,7 @@ static Property cpu_x86_properties[] = { DEFINE_PROP_TSC_FREQ("tsc-frequency", X86CPU, env.tsc_khz), DEFINE_PROP_MODEL_ID("model-id"), DEFINE_PROP_STEPPING("stepping", X86CPU, env.cpuid_version), + DEFINE_PROP_MODEL("model", X86CPU, env.cpuid_version), DEFINE_PROP_END_OF_LIST(), }; @@ -1359,41 +1404,6 @@ static void x86_cpuid_version_set_family(Object *obj, Visitor *v, void *opaque, } } -static void x86_cpuid_version_get_model(Object *obj, Visitor *v, void *opaque, - const char *name, Error **errp) -{ - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; - int64_t value; - - value = (env->cpuid_version >> 4) & 0xf; - value |= ((env->cpuid_version >> 16) & 0xf) << 4; - visit_type_int(v, &value, name, errp); -} - -static void x86_cpuid_version_set_model(Object *obj, Visitor *v, void *opaque, - const char *name, Error **errp) -{ - X86CPU *cpu = X86_CPU(obj); - CPUX86State *env = &cpu->env; - const int64_t min = 0; - const int64_t max = 0xff; - int64_t value; - - visit_type_int(v, &value, name, errp); - if (error_is_set(errp)) { - return; - } - if (value < min || value > max) { - error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, "", - name ? name : "null", value, min, max); - return; - } - - env->cpuid_version &= ~0xf00f0; - env->cpuid_version |= ((value & 0xf) << 4) | ((value >> 4) << 16); -} - static void cpudef_2_x86_cpu(X86CPU *cpu, x86_def_t *def, Error **errp) { CPUX86State *env = &cpu->env; @@ -2261,9 +2271,6 @@ static void x86_cpu_initfn(Object *obj) object_property_add(obj, "family", "int", x86_cpuid_version_get_family, x86_cpuid_version_set_family, NULL, NULL, NULL); - object_property_add(obj, "model", "int", - x86_cpuid_version_get_model, - x86_cpuid_version_set_model, NULL, NULL, NULL); env->cpuid_apic_id = env->cpu_index; -- 1.7.11.7