bsd-user: align use of mmap_lock to that of linux-user
[qemu/ar7.git] / hw / cpu / core.c
blob2bf960d6a8fe222588019639b09308abc8d1f620
1 /*
2 * CPU core abstract device
4 * Copyright (C) 2016 Bharata B Rao <bharata@linux.vnet.ibm.com>
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9 #include "hw/cpu/core.h"
10 #include "qapi/visitor.h"
11 #include "qapi/error.h"
12 #include "sysemu/cpus.h"
14 static void core_prop_get_core_id(Object *obj, Visitor *v, const char *name,
15 void *opaque, Error **errp)
17 CPUCore *core = CPU_CORE(obj);
18 int64_t value = core->core_id;
20 visit_type_int(v, name, &value, errp);
23 static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
24 void *opaque, Error **errp)
26 CPUCore *core = CPU_CORE(obj);
27 Error *local_err = NULL;
28 int64_t value;
30 visit_type_int(v, name, &value, &local_err);
31 if (local_err) {
32 error_propagate(errp, local_err);
33 return;
36 core->core_id = value;
39 static void core_prop_get_nr_threads(Object *obj, Visitor *v, const char *name,
40 void *opaque, Error **errp)
42 CPUCore *core = CPU_CORE(obj);
43 int64_t value = core->nr_threads;
45 visit_type_int(v, name, &value, errp);
48 static void core_prop_set_nr_threads(Object *obj, Visitor *v, const char *name,
49 void *opaque, Error **errp)
51 CPUCore *core = CPU_CORE(obj);
52 Error *local_err = NULL;
53 int64_t value;
55 visit_type_int(v, name, &value, &local_err);
56 if (local_err) {
57 error_propagate(errp, local_err);
58 return;
61 core->nr_threads = value;
64 static void cpu_core_instance_init(Object *obj)
66 CPUCore *core = CPU_CORE(obj);
68 object_property_add(obj, "core-id", "int", core_prop_get_core_id,
69 core_prop_set_core_id, NULL, NULL, NULL);
70 object_property_add(obj, "nr-threads", "int", core_prop_get_nr_threads,
71 core_prop_set_nr_threads, NULL, NULL, NULL);
72 core->nr_threads = smp_threads;
75 static void cpu_core_class_init(ObjectClass *oc, void *data)
77 DeviceClass *dc = DEVICE_CLASS(oc);
79 set_bit(DEVICE_CATEGORY_CPU, dc->categories);
82 static const TypeInfo cpu_core_type_info = {
83 .name = TYPE_CPU_CORE,
84 .parent = TYPE_DEVICE,
85 .abstract = true,
86 .class_init = cpu_core_class_init,
87 .instance_size = sizeof(CPUCore),
88 .instance_init = cpu_core_instance_init,
91 static void cpu_core_register_types(void)
93 type_register_static(&cpu_core_type_info);
96 type_init(cpu_core_register_types)