[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 47/66] target-ppc: Register all types for TARGET_PPCEM
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PATCH 47/66] target-ppc: Register all types for TARGET_PPCEMB |
Date: |
Fri, 8 Mar 2013 21:06:49 +0100 |
From: Andreas Färber <address@hidden>
Don't attempt to suppress registration of CPU types, since the criteria
is actually a property of the class and should thus become a field.
Since we can't check a field set in a class_init function before
registering the type that leads to execution of that function, guard the
-cpu class lookup instead and suppress exposing these classes in -cpu ?
and in QMP.
In case someone tries to hot-add an incompatible CPU via device_add,
error out in realize.
Signed-off-by: Andreas Färber <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
target-ppc/translate_init.c | 43 ++++++++++++++++++++++++++++++++++---------
1 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 06df161..ca56028 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7876,14 +7876,6 @@ enum {
/* PowerPC CPU definitions */
#define POWERPC_DEF_PREFIX(pvr, svr, type) \
glue(glue(glue(glue(pvr, _), svr), _), type)
-#if defined(TARGET_PPCEMB)
-#define POWERPC_DEF_CONDITION(type) \
- if (glue(POWERPC_MMU_, type) != POWERPC_MMU_BOOKE) { \
- return; \
- }
-#else
-#define POWERPC_DEF_CONDITION(type)
-#endif
#define POWERPC_DEF_SVR(_name, _pvr, _svr, _type) \
static void \
glue(POWERPC_DEF_PREFIX(_pvr, _svr, _type), _cpu_class_init) \
@@ -7912,7 +7904,6 @@ enum {
static void \
glue(POWERPC_DEF_PREFIX(_pvr, _svr, _type), _cpu_register_types)(void) \
{ \
- POWERPC_DEF_CONDITION(_type) \
type_register_static( \
&glue(POWERPC_DEF_PREFIX(_pvr, _svr, _type), _cpu_type_info)); \
} \
@@ -10040,6 +10031,15 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error
**errp)
}
}
+#if defined(TARGET_PPCEMB)
+ if (pcc->mmu_model != POWERPC_MMU_BOOKE) {
+ error_setg(errp, "CPU does not possess a BookE MMU. "
+ "Please use qemu-system-ppc or qemu-system-ppc64 instead "
+ "or choose another CPU model.");
+ return;
+ }
+#endif
+
create_ppc_opcodes(cpu, &local_err);
if (local_err != NULL) {
error_propagate(errp, local_err);
@@ -10239,6 +10239,12 @@ static gint ppc_cpu_compare_class_pvr(gconstpointer a,
gconstpointer b)
return -1;
}
+#if defined(TARGET_PPCEMB)
+ if (pcc->mmu_model != POWERPC_MMU_BOOKE) {
+ return -1;
+ }
+#endif
+
return pcc->pvr == pvr ? 0 : -1;
}
@@ -10261,8 +10267,14 @@ static gint ppc_cpu_compare_class_name(gconstpointer
a, gconstpointer b)
{
ObjectClass *oc = (ObjectClass *)a;
const char *name = b;
+#if defined(TARGET_PPCEMB)
+ PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
+#endif
if (strncasecmp(name, object_class_get_name(oc), strlen(name)) == 0 &&
+#if defined(TARGET_PPCEMB)
+ pcc->mmu_model == POWERPC_MMU_BOOKE &&
+#endif
strcmp(object_class_get_name(oc) + strlen(name),
"-" TYPE_POWERPC_CPU) == 0) {
return 0;
@@ -10381,6 +10393,12 @@ static void ppc_cpu_list_entry(gpointer data, gpointer
user_data)
const char *typename = object_class_get_name(oc);
char *name;
+#if defined(TARGET_PPCEMB)
+ if (pcc->mmu_model != POWERPC_MMU_BOOKE) {
+ return;
+ }
+#endif
+
name = g_strndup(typename,
strlen(typename) - strlen("-" TYPE_POWERPC_CPU));
(*s->cpu_fprintf)(s->file, "PowerPC %-16s PVR %08x\n",
@@ -10421,6 +10439,13 @@ static void ppc_cpu_defs_entry(gpointer data, gpointer
user_data)
const char *typename;
CpuDefinitionInfoList *entry;
CpuDefinitionInfo *info;
+#if defined(TARGET_PPCEMB)
+ PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
+
+ if (pcc->mmu_model != POWERPC_MMU_BOOKE) {
+ return;
+ }
+#endif
typename = object_class_get_name(oc);
info = g_malloc0(sizeof(*info));
--
1.6.0.2
- [Qemu-ppc] [PATCH 33/66] target-ppc: Extract MPC82xx alias, (continued)
- [Qemu-ppc] [PATCH 33/66] target-ppc: Extract MPC82xx alias, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 22/66] target-ppc: Extract 750 aliases, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 24/66] target-ppc: Extract 603e alias, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 31/66] target-ppc: Extract e300 alias, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 42/66] target-ppc: Extract POWER7 alias, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 39/66] target-ppc: Extract MPC8240 alias, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 01/66] pseries: Add cleanup hook for PAPR virtual LAN device, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 30/66] target-ppc: Extract MPC83xx aliases, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 40/66] target-ppc: Extract 405GPe alias, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 38/66] target-ppc: Extract MPC5200/MPC5200B aliases, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 47/66] target-ppc: Register all types for TARGET_PPCEMB,
Alexander Graf <=
- [Qemu-ppc] [PATCH 41/66] target-ppc: Extract 970 aliases, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 35/66] target-ppc: Extract MPC82xx aliases to *_HiP4, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 54/66] target-ppc: Change "POWER7" CPU alias, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 59/66] target-ppc: Fix PPC_DUMP_SPR_ACCESS build, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 43/66] target-ppc: Get model name from type name, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 28/66] target-ppc: Extract MPC85xx aliases, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 37/66] target-ppc: Extract MPC52xx alias, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 36/66] target-ppc: Extract MPC82xx_HiP{3, 4} aliases, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 34/66] target-ppc: Extract MPC8247/MPC8248/MPC8270-80 aliases, Alexander Graf, 2013/03/08
- [Qemu-ppc] [PATCH 61/66] PPC: xnu kernel expects FLUSH to be cleared on STOP, Alexander Graf, 2013/03/08