Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
target-i386: Prepare CPU socket/core abstraction
Short of generic recursive device realization, realize cores and threads recursively. Signed-off-by: Andreas Färber <afaerber@suse.de>
- Loading branch information
Showing
5 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* x86 CPU core abstraction | ||
* | ||
* Copyright (c) 2015 SUSE Linux GmbH | ||
*/ | ||
|
||
#include "hw/i386/cpu-core.h" | ||
|
||
static int x86_cpu_core_realize_child(Object *child, void *opaque) | ||
{ | ||
Error **errp = opaque; | ||
Error *local_err = NULL; | ||
|
||
object_property_set_bool(child, true, "realized", &local_err); | ||
error_propagate(errp, local_err); | ||
|
||
return local_err != NULL ? 1 : 0; | ||
} | ||
|
||
static void x86_cpu_core_realize(DeviceState *dev, Error **errp) | ||
{ | ||
/* XXX generic */ | ||
object_child_foreach(OBJECT(dev), x86_cpu_core_realize_child, errp); | ||
} | ||
|
||
static void x86_cpu_core_class_init(ObjectClass *oc, void *data) | ||
{ | ||
DeviceClass *dc = DEVICE_CLASS(oc); | ||
|
||
dc->realize = x86_cpu_core_realize; | ||
} | ||
|
||
static const TypeInfo x86_cpu_core_type_info = { | ||
.name = TYPE_X86_CPU_CORE, | ||
.parent = TYPE_DEVICE, | ||
.instance_size = sizeof(X86CPUCore), | ||
.class_init = x86_cpu_core_class_init, | ||
}; | ||
|
||
static void x86_cpu_core_register_types(void) | ||
{ | ||
type_register_static(&x86_cpu_core_type_info); | ||
} | ||
|
||
type_init(x86_cpu_core_register_types) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* x86 CPU socket abstraction | ||
* | ||
* Copyright (c) 2015 SUSE Linux GmbH | ||
*/ | ||
|
||
#include "hw/i386/cpu-socket.h" | ||
|
||
static int x86_cpu_socket_realize_child(Object *child, void *opaque) | ||
{ | ||
Error **errp = opaque; | ||
Error *local_err = NULL; | ||
|
||
object_property_set_bool(child, true, "realized", &local_err); | ||
error_propagate(errp, local_err); | ||
|
||
return local_err != NULL ? 1 : 0; | ||
} | ||
|
||
static void x86_cpu_socket_realize(DeviceState *dev, Error **errp) | ||
{ | ||
/* XXX generic */ | ||
object_child_foreach(OBJECT(dev), x86_cpu_socket_realize_child, errp); | ||
} | ||
|
||
static void x86_cpu_socket_class_init(ObjectClass *oc, void *data) | ||
{ | ||
DeviceClass *dc = DEVICE_CLASS(oc); | ||
|
||
dc->realize = x86_cpu_socket_realize; | ||
} | ||
|
||
static const TypeInfo x86_cpu_socket_type_info = { | ||
.name = TYPE_X86_CPU_SOCKET, | ||
.parent = TYPE_CPU_SOCKET, | ||
.instance_size = sizeof(X86CPUSocket), | ||
.class_init = x86_cpu_socket_class_init, | ||
}; | ||
|
||
static void x86_cpu_socket_register_types(void) | ||
{ | ||
type_register_static(&x86_cpu_socket_type_info); | ||
} | ||
|
||
type_init(x86_cpu_socket_register_types) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* x86 CPU core abstraction | ||
* | ||
* Copyright (c) 2015 SUSE Linux GmbH | ||
*/ | ||
#ifndef HW_I386_CPU_CORE_H | ||
#define HW_I386_CPU_CORE_H | ||
|
||
#include "hw/qdev.h" | ||
|
||
#ifdef TARGET_X86_64 | ||
#define TYPE_X86_CPU_CORE "x86_64-cpu-core" | ||
#else | ||
#define TYPE_X86_CPU_CORE "i386-cpu-core" | ||
#endif | ||
|
||
#define X86_CPU_CORE(obj) \ | ||
OBJECT_CHECK(X86CPUCore, (obj), TYPE_X86_CPU_CORE) | ||
|
||
typedef struct X86CPUCore { | ||
/*< private >*/ | ||
DeviceState parent_obj; | ||
/*< public >*/ | ||
} X86CPUCore; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* x86 CPU socket abstraction | ||
* | ||
* Copyright (c) 2015 SUSE Linux GmbH | ||
*/ | ||
#ifndef HW_I386_CPU_SOCKET_H | ||
#define HW_I386_CPU_SOCKET_H | ||
|
||
#include "hw/cpu/socket.h" | ||
#include "cpu-core.h" | ||
|
||
#ifdef TARGET_X86_64 | ||
#define TYPE_X86_CPU_SOCKET "x86_64-cpu-socket" | ||
#else | ||
#define TYPE_X86_CPU_SOCKET "i386-cpu-socket" | ||
#endif | ||
|
||
#define X86_CPU_SOCKET(obj) \ | ||
OBJECT_CHECK(X86CPUSocket, (obj), TYPE_X86_CPU_SOCKET) | ||
|
||
typedef struct X86CPUSocket { | ||
/*< private >*/ | ||
DeviceState parent_obj; | ||
/*< public >*/ | ||
|
||
X86CPUCore core[0]; | ||
} X86CPUSocket; | ||
|
||
#endif |