[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 27/37] target-i386: convert "tsc-frequency" to stati
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 27/37] target-i386: convert "tsc-frequency" to static property |
Date: |
Mon, 22 Oct 2012 17:03:13 +0200 |
Signed-off-by: Igor Mammedov <address@hidden>
---
* in addition use error_setg() instead of error_set()
---
target-i386/cpu.c | 75 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 41 insertions(+), 34 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index a1790aa..8d3f4cc 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -351,6 +351,46 @@ PropertyInfo qdev_prop_vendor = {
#define DEFINE_PROP_VENDOR(_n, _s, _f)
\
DEFINE_PROP(_n, _s, _f, qdev_prop_vendor, uint32_t)
+static void x86_cpuid_get_tsc_freq(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ X86CPU *cpu = X86_CPU(obj);
+ int64_t value;
+
+ value = cpu->env.tsc_khz * 1000;
+ visit_type_int(v, &value, name, errp);
+}
+
+static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ X86CPU *cpu = X86_CPU(obj);
+ const int64_t min = 0;
+ const int64_t max = INT64_MAX;
+ int64_t value;
+
+ visit_type_freq(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;
+ }
+
+ cpu->env.tsc_khz = value / 1000;
+}
+
+PropertyInfo qdev_prop_tsc_freq = {
+ .name = "int32",
+ .get = x86_cpuid_get_tsc_freq,
+ .set = x86_cpuid_set_tsc_freq,
+};
+#define DEFINE_PROP_TSC_FREQ(_n, _s, _f)
\
+ DEFINE_PROP(_n, _s, _f, qdev_prop_tsc_freq, int32_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),
@@ -471,6 +511,7 @@ static Property cpu_x86_properties[] = {
DEFINE_PROP_CHECK("check"),
DEFINE_PROP_ENFORCE("enforce"),
DEFINE_PROP_VENDOR("vendor", X86CPU, env.cpuid_vendor1),
+ DEFINE_PROP_TSC_FREQ("tsc-frequency", X86CPU, env.tsc_khz),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1329,37 +1370,6 @@ static void x86_cpuid_set_model_id(Object *obj, const
char *model_id,
}
}
-static void x86_cpuid_get_tsc_freq(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- X86CPU *cpu = X86_CPU(obj);
- int64_t value;
-
- value = cpu->env.tsc_khz * 1000;
- visit_type_int(v, &value, name, errp);
-}
-
-static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
- const char *name, Error **errp)
-{
- X86CPU *cpu = X86_CPU(obj);
- const int64_t min = 0;
- const int64_t max = INT64_MAX;
- int64_t value;
-
- visit_type_freq(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;
- }
-
- cpu->env.tsc_khz = value / 1000;
-}
-
static void cpudef_2_x86_cpu(X86CPU *cpu, x86_def_t *def, Error **errp)
{
CPUX86State *env = &cpu->env;
@@ -2236,9 +2246,6 @@ static void x86_cpu_initfn(Object *obj)
object_property_add_str(obj, "model-id",
x86_cpuid_get_model_id,
x86_cpuid_set_model_id, NULL);
- object_property_add(obj, "tsc-frequency", "int",
- x86_cpuid_get_tsc_freq,
- x86_cpuid_set_tsc_freq, NULL, NULL, NULL);
env->cpuid_apic_id = env->cpu_index;
--
1.7.11.7
- Re: [Qemu-devel] [PATCH v2] target-i386: use static properties to list CPUID features, (continued)
Re: [Qemu-devel] [PATCH 36/37] target-i386: use static properties to list CPUID features, Don Slutz, 2012/10/23
[Qemu-devel] [PATCH 37/37] target-i386: cleanup cpu_x86_find_by_name(), only fill x86_def_t in it, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 26/37] target-i386: convert "vendor" property to static property, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 30/37] target-i386: convert "model" to static property, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 24/37] target-i386: use define for cpuid vendor string size, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 09/37] qdev: export qdev_prop_find() and allow it to be used with DeviceClass instead of Object, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 27/37] target-i386: convert "tsc-frequency" to static property,
Igor Mammedov <=
[Qemu-devel] [PATCH 15/37] target-i386: set default value of "hypervisor" feature using static property, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 22/37] target-i386: convert 'hv_vapic' to static property, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 05/37] target-i386: move out CPU features initialization in separate func, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 32/37] target-i386: use static properties for setting cpuid features, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 29/37] target-i386: convert "stepping" to static property, Igor Mammedov, 2012/10/22