All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC qom-cpu v3] target-ppc: Introduce unrealizefn for PowerPCCPU
@ 2013-01-20  8:16 Andreas Färber
  0 siblings, 0 replies; only message in thread
From: Andreas Färber @ 2013-01-20  8:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Alexander Graf, open list:PowerPC,
	Andreas Färber, David Gibson

Use it to clean up the opcode table, resolving a former TODO from Jocelyn.
Also switch from malloc() to g_malloc().

Signed-off-by: Andreas Färber <afaerber@suse.de>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Markus Armbruster <armbru@redhat.com>
---
 Based on my "CPUState QOM realizefn support" series v2 (1.5 material).

 From "QOM'ify Power Architecture CPU" v2:
 * Implemented unrealizefn instead of finalizefn, to address rejection by dwg:
   create_new_table() is not called from the instance initializer.

 v1 -> v2:
 * Replace cpu_ppc_close() and its TODO with an implementation as a finalizefn.

 target-ppc/translate_init.c |   16 +++++++++++++++-
 1 Datei geändert, 15 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 786d871..2385571 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -9641,7 +9641,7 @@ static int create_new_table (opc_handler_t **table, unsigned char idx)
 {
     opc_handler_t **tmp;
 
-    tmp = malloc(0x20 * sizeof(opc_handler_t));
+    tmp = g_malloc(0x20 * sizeof(opc_handler_t));
     fill_new_table(tmp, 0x20);
     table[idx] = (opc_handler_t *)((uintptr_t)tmp | PPC_INDIRECT);
 
@@ -10236,6 +10236,19 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)
 #endif
 }
 
+static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp)
+{
+    PowerPCCPU *cpu = POWERPC_CPU(dev);
+    CPUPPCState *env = &cpu->env;
+    int i;
+
+    for (i = 0; i < 0x40; i++) {
+        if (env->opcodes[i] != &invalid_handler) {
+            g_free(env->opcodes[i]);
+        }
+    }
+}
+
 static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b)
 {
     ObjectClass *oc = (ObjectClass *)a;
@@ -10568,6 +10581,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data)
 
     pcc->parent_realize = dc->realize;
     dc->realize = ppc_cpu_realizefn;
+    dc->unrealize = ppc_cpu_unrealizefn;
 
     pcc->parent_reset = cc->reset;
     cc->reset = ppc_cpu_reset;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-20  9:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-20  8:16 [Qemu-devel] [RFC qom-cpu v3] target-ppc: Introduce unrealizefn for PowerPCCPU Andreas Färber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.