From patchwork Fri Aug 18 10:08:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 9908249 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 2466A600CC for ; Fri, 18 Aug 2017 10:20:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1554028BA6 for ; Fri, 18 Aug 2017 10:20:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08EA728BA8; Fri, 18 Aug 2017 10:20:26 +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 852BC28C84 for ; Fri, 18 Aug 2017 10:20:25 +0000 (UTC) Received: from localhost ([::1]:40684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dieO6-0005IE-6T for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Aug 2017 06:20:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dieDM-00043L-Va for qemu-devel@nongnu.org; Fri, 18 Aug 2017 06:09:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dieDL-0000cQ-Tm for qemu-devel@nongnu.org; Fri, 18 Aug 2017 06:09:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45332) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dieDL-0000aq-KA for qemu-devel@nongnu.org; Fri, 18 Aug 2017 06:09:15 -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 AB50B4ACA7 for ; Fri, 18 Aug 2017 10:09:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AB50B4ACA7 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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 2F18F61297 for ; Fri, 18 Aug 2017 10:09:14 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 18 Aug 2017 12:08:42 +0200 Message-Id: <1503050939-227939-11-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.38]); Fri, 18 Aug 2017 10:09:14 +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 10/27] alpha: replace cpu_alpha_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 cpu_alpha_init() used to provide default fallback if invalid (i.e. non existent) cpu_model were provided. dp264 machine provides its own default so sole user of fallback is [bsd|linux]-user targets which specifies 'any' cpu model that fallbacks to "ev67" in cpu_alpha_init(). Push fallback handling into alpha_cpu_class_by_name() and replace cpu_alpha_init() with cpu_generic_init(). Signed-off-by: Igor Mammedov Acked-by: Richard Henderson --- PS: tested only linux-user as I don't have bsd box to test on --- target/alpha/cpu.h | 4 +--- hw/alpha/dp264.c | 8 ++++++-- target/alpha/cpu.c | 20 +++++--------------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index e95be2b..0738e97 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -468,9 +468,7 @@ enum { void alpha_translate_init(void); -AlphaCPU *cpu_alpha_init(const char *cpu_model); - -#define cpu_init(cpu_model) CPU(cpu_alpha_init(cpu_model)) +#define cpu_init(cpu_model) cpu_generic_init(TYPE_ALPHA_CPU, cpu_model) void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf); /* you can call this signal handler from your SIGBUS and SIGSEGV diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 3b307ad..1c5a177 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -51,7 +51,7 @@ static int clipper_pci_map_irq(PCIDevice *d, int irq_num) static void clipper_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; - const char *cpu_model = machine->cpu_model; + const char *cpu_model = machine->cpu_model ? machine->cpu_model : "ev67"; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; @@ -67,7 +67,11 @@ static void clipper_init(MachineState *machine) /* Create up to 4 cpus. */ memset(cpus, 0, sizeof(cpus)); for (i = 0; i < smp_cpus; ++i) { - cpus[i] = cpu_alpha_init(cpu_model ? cpu_model : "ev67"); + cpus[i] = ALPHA_CPU(cpu_generic_init(TYPE_ALPHA_CPU, cpu_model)); + if (!cpus[i]) { + error_report("Unable to find CPU definition"); + exit(1); + } } cpus[0]->env.trap_arg0 = ram_size; diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 76150f4..1ea597b 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -155,24 +155,14 @@ static ObjectClass *alpha_cpu_class_by_name(const char *cpu_model) if (oc != NULL && object_class_is_abstract(oc)) { oc = NULL; } - return oc; -} - -AlphaCPU *cpu_alpha_init(const char *cpu_model) -{ - AlphaCPU *cpu; - ObjectClass *cpu_class; - cpu_class = alpha_cpu_class_by_name(cpu_model); - if (cpu_class == NULL) { - /* Default to ev67; no reason not to emulate insns by default. */ - cpu_class = object_class_by_name(TYPE("ev67")); + /* TODO: remove match everything nonsense */ + /* Default to ev67; no reason not to emulate insns by default. */ + if (!oc) { + oc = object_class_by_name(TYPE("ev67")); } - cpu = ALPHA_CPU(object_new(object_class_get_name(cpu_class))); - - object_property_set_bool(OBJECT(cpu), true, "realized", NULL); - return cpu; + return oc; } static void ev4_cpu_initfn(Object *obj)