From patchwork Wed May 24 14:59:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 685359 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp297748wrt; Wed, 24 May 2023 08:00:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5J+R+7X5NDEtT4p0tMiEVwYc/jAoJLN7o2fPhPCGYE2oaZ6Sx1vQIoDFCzqT4o/kDiTEyO X-Received: by 2002:a05:620a:7e4:b0:75b:23a1:366a with SMTP id k4-20020a05620a07e400b0075b23a1366amr6050628qkk.43.1684940434273; Wed, 24 May 2023 08:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684940434; cv=none; d=google.com; s=arc-20160816; b=DyS1691v6IBdVc925WxQhAweacBTwhiDJ+L/qSehn3ch+2SDvylQA7derr3JipgKX5 +uZaoPqWFqm1OXAMzMPFG9rkZw13oz3Ru1KEwGrO1A4QE5oDHkqRLxjyDuQF5AAaFQU0 THijsVwVMhYDbyQwl0DYbsipI+UWyQvsF6AgXkCeNhdydl6/pOPyH4pYHRGnHw7UTW59 hJVjW1Ts9g7h4jjyZVgkhlL7NLHczFHUGJUvAnU5EH2aNcSmknBv1B/5JlLbcOhawHWg pCbVwdP/IrHq4XCp6jt3wtXcjO25/1cUneTonnamtW5shm5Xwoy3HDP1GN5xjZFgrsHc jf1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CfORvZBj5XwZqX1kEUcED15b0r2EiIZE5rk0MEhjkUo=; b=qFxmKZzYyy6hBPMiCK8PzfWc+EI24zGtbtBWNtWG/E6gK5IUQJS0HjHilzBktJM7sy KRFz784Tpcbqy5JcgMrpE2qqg9447ybMlSG4zLn+1lbz6+rAiLwldZNeYfRLr2dIgRup pBh07tMifkUMft3GHyxcLLKu4ripViLn+9Go68ZTaC/7L+DwkJXPICGV9QJwWT18QCMy rsf9DDvNxsgNDq0w6LYxwsMGx/dIZAxXwzdMHGYN8LKPjk0/oudJTNHziYqiIkPapoIz cpcaG8LVS33GvxkzcLp79PRuxmhGaw8GnTpLZ3XxpBR9G0qv5t6xmAUeVjrOVTS9ibru CWeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mq9JmfFV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x21-20020ae9f815000000b0075c6a873e8csi117227qkh.271.2023.05.24.08.00.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 May 2023 08:00:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mq9JmfFV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1pxs-0006VB-Pf; Wed, 24 May 2023 10:59:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1pxl-0006Mg-7H for qemu-devel@nongnu.org; Wed, 24 May 2023 10:59:41 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1pxi-0006E9-5J for qemu-devel@nongnu.org; Wed, 24 May 2023 10:59:40 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-30a1fdde3d6so924128f8f.0 for ; Wed, 24 May 2023 07:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684940376; x=1687532376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CfORvZBj5XwZqX1kEUcED15b0r2EiIZE5rk0MEhjkUo=; b=mq9JmfFVIPtMkazqFVBrVylL5+DHxpG5GJ4QiW7FgaaC9d400bIeiRKryf3Uexuf85 avPFTOrfFNooiHadQFcUCWI+JgSPKvGMa0o5lQ2BwM5ZacfESNRffxQjjB94pBOvNOCb 4GJfKMzezb+HmrbKepN0nRGAA6shDl2SvqRxPEkoBwOYibu4P4geCnPUpi1L/kMjf/Eg 1zeKNdNbNCPnkkNgE4l17X1p+hQkOGYnKR2cFO9wnAuedj1Ly8UfrEqT5tykeR0+2m9l aNMKmFll2t67K8zyg0dHK8WtK82G431Qw4IjBGAfuyUBG19/HJM99vMlHQk1QGZHpp++ pZeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684940376; x=1687532376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CfORvZBj5XwZqX1kEUcED15b0r2EiIZE5rk0MEhjkUo=; b=FPvXhGoF1q+jVS0tJCa5VgxR44MIKuMLf0wHoBNbjwalVyPth8qIBoxnk8+jHC+rA+ G5MJALuiKr25EI1CbHJUyDtkf2GFrfFxgiit+Nt9Wr5Q1HTE8uD/udbRlRYmzyLhH2cV 3VK3yUHh+evtvHIcrDIWH1iD6lIrDOXTWAHZMViIp6WrUz1dVvT+aMCfCBj1sM/eOhBu 9kYed+S0PIwp33Pl5pLlPLHcgNFxHVZWt9vXYZh8+wURgxVxHikHmjgNmyxcAuWL58wS BM26F9onSscoQRcKqaiTvnJGKYY0/3RTM/yEjovh9RfNWLp9AaBo/Xt8TCwLJxU89WLV 97cw== X-Gm-Message-State: AC+VfDzJSvn6ZClOmogc1QpUSeYhb1aTf35kzDAEqKYDYO0zX9mS2o90 xS6WE5FJIkGnyR7O2ilZvW9T/NUt95hnGcb1jVAEaA== X-Received: by 2002:a5d:6852:0:b0:2f9:4fe9:74bb with SMTP id o18-20020a5d6852000000b002f94fe974bbmr55626wrw.40.1684940376052; Wed, 24 May 2023 07:59:36 -0700 (PDT) Received: from localhost.localdomain (fac34-h02-176-184-31-193.dsl.sta.abo.bbox.fr. [176.184.31.193]) by smtp.gmail.com with ESMTPSA id c14-20020a056000104e00b00307b5376b2csm14621462wrx.90.2023.05.24.07.59.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 24 May 2023 07:59:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , qemu-arm@nongnu.org, Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 05/10] hw/arm/realview: Move 'board_id' to RealviewMachineClass Date: Wed, 24 May 2023 16:59:01 +0200 Message-Id: <20230524145906.33156-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230524145906.33156-1-philmd@linaro.org> References: <20230524145906.33156-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Instead of having each machine instance resolve its board ID, set it once in their class_init() handler. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/arm/realview.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 6970e8a469..c354ce0cfa 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -32,6 +32,8 @@ struct RealviewMachineClass { MachineClass parent_obj; + + int board_id; }; typedef struct RealviewMachineClass RealviewMachineClass; @@ -49,7 +51,6 @@ static struct arm_boot_info realview_binfo = { .smp_bootreg_addr = SMP_BOOTREG_ADDR, }; -/* The following two lists must be consistent. */ enum realview_board_type { BOARD_EB, BOARD_EB_MPCORE, @@ -57,13 +58,6 @@ enum realview_board_type { BOARD_PBX_A9, }; -static const int realview_board_id[] = { - 0x33b, - 0x33b, - 0x769, - 0x76d -}; - static void split_irq_from_named(DeviceState *src, const char* outname, qemu_irq out1, qemu_irq out2) { DeviceState *splitter = qdev_new(TYPE_SPLIT_IRQ); @@ -81,6 +75,7 @@ static void split_irq_from_named(DeviceState *src, const char* outname, static void realview_init(MachineState *machine, enum realview_board_type board_type) { + RealviewMachineClass *rmc = REALVIEW_MACHINE_GET_CLASS(machine); ARMCPU *cpu = NULL; CPUARMState *env; MemoryRegion *sysmem = get_system_memory(); @@ -385,7 +380,7 @@ static void realview_init(MachineState *machine, memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, ram_hack); realview_binfo.ram_size = ram_size; - realview_binfo.board_id = realview_board_id[board_type]; + realview_binfo.board_id = rmc->board_id; realview_binfo.loader_start = (board_type == BOARD_PB_A8 ? 0x70000000 : 0); arm_load_kernel(ARM_CPU(first_cpu), machine, &realview_binfo); } @@ -420,41 +415,49 @@ static void realview_common_class_init(ObjectClass *oc, void *data) static void realview_eb_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); + RealviewMachineClass *rmc = REALVIEW_MACHINE_CLASS(oc); mc->desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)"; mc->init = realview_eb_init; mc->block_default_type = IF_SCSI; mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926"); + rmc->board_id = 0x33b; } static void realview_eb_mpcore_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); + RealviewMachineClass *rmc = REALVIEW_MACHINE_CLASS(oc); mc->desc = "ARM RealView Emulation Baseboard (ARM11MPCore)"; mc->init = realview_eb_mpcore_init; mc->block_default_type = IF_SCSI; mc->max_cpus = 4; mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm11mpcore"); + rmc->board_id = 0x33b; } static void realview_pb_a8_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); + RealviewMachineClass *rmc = REALVIEW_MACHINE_CLASS(oc); mc->desc = "ARM RealView Platform Baseboard for Cortex-A8"; mc->init = realview_pb_a8_init; mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8"); + rmc->board_id = 0x769; } static void realview_pbx_a9_class_init(ObjectClass *oc, void *data) { MachineClass *mc = MACHINE_CLASS(oc); + RealviewMachineClass *rmc = REALVIEW_MACHINE_CLASS(oc); mc->desc = "ARM RealView Platform Baseboard Explore for Cortex-A9"; mc->init = realview_pbx_a9_init; mc->max_cpus = 4; mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9"); + rmc->board_id = 0x76d; } static const TypeInfo realview_machine_types[] = {