From patchwork Sun Jan 20 08:16:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 213947 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C0B722C007A for ; Sun, 20 Jan 2013 20:44:44 +1100 (EST) Received: from localhost ([::1]:57426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwrSE-0003iC-Ci for incoming@patchwork.ozlabs.org; Sun, 20 Jan 2013 04:44:42 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TwrMA-0002Ik-Vl for qemu-devel@nongnu.org; Sun, 20 Jan 2013 04:38:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TwrM6-0007h1-64 for qemu-devel@nongnu.org; Sun, 20 Jan 2013 04:38:26 -0500 Received: from cantor2.suse.de ([195.135.220.15]:46203 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Twq5A-0008EO-OP; Sun, 20 Jan 2013 03:16:50 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 1BC78A341E; Sun, 20 Jan 2013 09:16:46 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sun, 20 Jan 2013 09:16:23 +0100 Message-Id: <1358669783-4401-1-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Markus Armbruster , Alexander Graf , "open list:PowerPC" , =?UTF-8?q?Andreas=20F=C3=A4rber?= , David Gibson Subject: [Qemu-devel] [RFC qom-cpu v3] target-ppc: Introduce unrealizefn for PowerPCCPU X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Cc: David Gibson Cc: Markus Armbruster --- 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;