[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 24/32] target-ppc: Introduce unrealizefn for PowerPCCP
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PATCH 24/32] target-ppc: Introduce unrealizefn for PowerPCCPU |
Date: |
Sun, 30 Jun 2013 03:45:01 +0200 |
From: Andreas Färber <address@hidden>
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 <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
target-ppc/cpu.h | 4 +++-
target-ppc/translate_init.c | 16 +++++++++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index aa1d013..0ede077 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -886,6 +886,8 @@ struct ppc_segment_page_sizes {
/* The whole PowerPC CPU context */
#define NB_MMU_MODES 3
+#define PPC_CPU_OPCODES_LEN 0x40
+
struct CPUPPCState {
/* First are the most commonly used resources
* during translated code execution
@@ -1039,7 +1041,7 @@ struct CPUPPCState {
/* Those resources are used only during code translation */
/* opcode handlers */
- opc_handler_t *opcodes[0x40];
+ opc_handler_t *opcodes[PPC_CPU_OPCODES_LEN];
/* Those resources are used only in QEMU core */
target_ulong hflags; /* hflags is a MSR & HFLAGS_MASK */
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index f365ad8..f01e9e7 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7256,7 +7256,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);
@@ -7864,6 +7864,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 < PPC_CPU_OPCODES_LEN; 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;
@@ -8251,6 +8264,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.8.1.4
- [Qemu-ppc] [PATCH 23/32] booke_ppc: limit booke timer to max when timeout overflow, (continued)
- [Qemu-ppc] [PATCH 23/32] booke_ppc: limit booke timer to max when timeout overflow, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 11/32] intc/openpic_kvm: Fix QOM and build issues, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 30/32] PPC: Newworld: Add second uninorth control register set, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 28/32] PPC: Add clock-frequency export for Mac machines, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 21/32] pseries: Update MAINTAINERS information, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 04/32] openpic: factor out some common defines into openpic.h, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 20/32] target-ppc kvm: save cr register, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 17/32] target-ppc: Change default machine for 64-bit, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 25/32] PPC: Add dump_mmu() for 6xx, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 31/32] mac-io: Add escc-legacy memory alias region, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 24/32] target-ppc: Introduce unrealizefn for PowerPCCPU,
Alexander Graf <=
- [Qemu-ppc] [PATCH 27/32] PPC: Introduce an alias cache for faster lookups, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 32/32] PPC: Ignore writes to L2CR, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 18/32] spapr-rtas: add CPU argument to RTAS calls, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 15/32] target-ppc: Drop redundant flags assignments from CPU families, Alexander Graf, 2013/06/29
- [Qemu-ppc] [PATCH 08/32] kvm/openpic: in-kernel mpic support, Alexander Graf, 2013/06/29