hw/block/fdc: Convert from FLOPPY_DPRINTF() macro to trace events
[qemu/ar7.git] / hw / cpu / core.c
blob7e42e2c87a50ba664953ee94fe3da834d1976876
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 "qemu/osdep.h"
10 #include "hw/cpu/core.h"
11 #include "qapi/visitor.h"
12 #include "qapi/error.h"
13 #include "sysemu/cpus.h"
15 static void core_prop_get_core_id(Object *obj, Visitor *v, const char *name,
16 void *opaque, Error **errp)
18 CPUCore *core = CPU_CORE(obj);
19 int64_t value = core->core_id;
21 visit_type_int(v, name, &value, errp);
24 static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name,
25 void *opaque, Error **errp)
27 CPUCore *core = CPU_CORE(obj);
28 Error *local_err = NULL;
29 int64_t value;
31 visit_type_int(v, name, &value, &local_err);
32 if (local_err) {
33 error_propagate(errp, local_err);
34 return;
37 if (value < 0) {
38 error_setg(errp, "Invalid core id %"PRId64, value);
39 return;
42 core->core_id = value;
45 static void core_prop_get_nr_threads(Object *obj, Visitor *v, const char *name,
46 void *opaque, Error **errp)
48 CPUCore *core = CPU_CORE(obj);
49 int64_t value = core->nr_threads;
51 visit_type_int(v, name, &value, errp);
54 static void core_prop_set_nr_threads(Object *obj, Visitor *v, const char *name,
55 void *opaque, Error **errp)
57 CPUCore *core = CPU_CORE(obj);
58 Error *local_err = NULL;
59 int64_t value;
61 visit_type_int(v, name, &value, &local_err);
62 if (local_err) {
63 error_propagate(errp, local_err);
64 return;
67 core->nr_threads = value;
70 static void cpu_core_instance_init(Object *obj)
72 CPUCore *core = CPU_CORE(obj);
74 object_property_add(obj, "core-id", "int", core_prop_get_core_id,
75 core_prop_set_core_id, NULL, NULL, NULL);
76 object_property_add(obj, "nr-threads", "int", core_prop_get_nr_threads,
77 core_prop_set_nr_threads, NULL, NULL, NULL);
78 core->nr_threads = smp_threads;
81 static void cpu_core_class_init(ObjectClass *oc, void *data)
83 DeviceClass *dc = DEVICE_CLASS(oc);
85 set_bit(DEVICE_CATEGORY_CPU, dc->categories);
88 static const TypeInfo cpu_core_type_info = {
89 .name = TYPE_CPU_CORE,
90 .parent = TYPE_DEVICE,
91 .abstract = true,
92 .class_init = cpu_core_class_init,
93 .instance_size = sizeof(CPUCore),
94 .instance_init = cpu_core_instance_init,
97 static void cpu_core_register_types(void)
99 type_register_static(&cpu_core_type_info);
102 type_init(cpu_core_register_types)