From patchwork Fri Aug 18 10:08:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 9908239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9FE71600CC for ; Fri, 18 Aug 2017 10:17:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F17428BA7 for ; Fri, 18 Aug 2017 10:17:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 803DE28C83; Fri, 18 Aug 2017 10:17:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B945128BA7 for ; Fri, 18 Aug 2017 10:17:17 +0000 (UTC) Received: from localhost ([::1]:40649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dieL6-0002Wc-M6 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Aug 2017 06:17:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dieDO-00045F-Mh for qemu-devel@nongnu.org; Fri, 18 Aug 2017 06:09:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dieDN-0000ew-EM for qemu-devel@nongnu.org; Fri, 18 Aug 2017 06:09:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60400) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dieDN-0000cw-69 for qemu-devel@nongnu.org; Fri, 18 Aug 2017 06:09:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4A3E581DFD for ; Fri, 18 Aug 2017 10:09:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4A3E581DFD Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id C40D45D743 for ; Fri, 18 Aug 2017 10:09:15 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 18 Aug 2017 12:08:44 +0200 Message-Id: <1503050939-227939-13-git-send-email-imammedo@redhat.com> In-Reply-To: <1503050939-227939-1-git-send-email-imammedo@redhat.com> References: <1503050939-227939-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 18 Aug 2017 10:09:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.11 12/27] m68k: replace cpu_m68k_init() with cpu_generic_init() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP call register_m68k_insns() at realize time which makes cpu_m68k_init() typical object creation function. As result we can replace it with cpu_generic_init() which does the same job, reducing code duplication a bit. Signed-off-by: Igor Mammedov Tested-by: Thomas Huth Acked-by: Laurent Vivier --- target/m68k/cpu.h | 3 +-- hw/m68k/an5206.c | 2 +- hw/m68k/mcf5208.c | 2 +- target/m68k/cpu.c | 2 ++ target/m68k/helper.c | 20 -------------------- 5 files changed, 5 insertions(+), 24 deletions(-) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 38a7e11..d936547 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -163,7 +163,6 @@ int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void m68k_tcg_init(void); void m68k_cpu_init_gdb(M68kCPU *cpu); -M68kCPU *cpu_m68k_init(const char *cpu_model); /* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */ @@ -322,7 +321,7 @@ void register_m68k_insns (CPUM68KState *env); #define TARGET_PHYS_ADDR_SPACE_BITS 32 #define TARGET_VIRT_ADDR_SPACE_BITS 32 -#define cpu_init(cpu_model) CPU(cpu_m68k_init(cpu_model)) +#define cpu_init(cpu_model) cpu_generic_init(TYPE_M68K_CPU, cpu_model) #define cpu_signal_handler cpu_m68k_signal_handler #define cpu_list m68k_cpu_list diff --git a/hw/m68k/an5206.c b/hw/m68k/an5206.c index c762441..7b9b15d 100644 --- a/hw/m68k/an5206.c +++ b/hw/m68k/an5206.c @@ -42,7 +42,7 @@ static void an5206_init(MachineState *machine) if (!cpu_model) { cpu_model = "m5206"; } - cpu = cpu_m68k_init(cpu_model); + cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model)); if (!cpu) { error_report("Unable to find m68k CPU definition"); exit(1); diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index f4b1387..1a0f180 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -232,7 +232,7 @@ static void mcf5208evb_init(MachineState *machine) if (!cpu_model) { cpu_model = "m5208"; } - cpu = cpu_m68k_init(cpu_model); + cpu = M68K_CPU(cpu_generic_init(TYPE_M68K_CPU, cpu_model)); if (!cpu) { fprintf(stderr, "Unable to find m68k CPU definition\n"); exit(1); diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index a14b6dd..55bf24b 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -230,6 +230,8 @@ static void m68k_cpu_realizefn(DeviceState *dev, Error **errp) M68kCPUClass *mcc = M68K_CPU_GET_CLASS(dev); Error *local_err = NULL; + register_m68k_insns(&cpu->env); + cpu_exec_realizefn(cs, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); diff --git a/target/m68k/helper.c b/target/m68k/helper.c index caae291..7e50ff5 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -156,26 +156,6 @@ static int m68k_fpu_gdb_set_reg(CPUM68KState *env, uint8_t *mem_buf, int n) return 0; } -M68kCPU *cpu_m68k_init(const char *cpu_model) -{ - M68kCPU *cpu; - CPUM68KState *env; - ObjectClass *oc; - - oc = cpu_class_by_name(TYPE_M68K_CPU, cpu_model); - if (oc == NULL) { - return NULL; - } - cpu = M68K_CPU(object_new(object_class_get_name(oc))); - env = &cpu->env; - - register_m68k_insns(env); - - object_property_set_bool(OBJECT(cpu), true, "realized", NULL); - - return cpu; -} - void m68k_cpu_init_gdb(M68kCPU *cpu) { CPUState *cs = CPU(cpu);