From nobody Thu Nov 13 18:05:16 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581794330034969.8535207673044; Sat, 15 Feb 2020 11:18:50 -0800 (PST) Received: from localhost ([::1]:53786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j32xk-0005bX-Qu for importer@patchew.org; Sat, 15 Feb 2020 14:18:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35268) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j32uw-0008KM-Pp for qemu-devel@nongnu.org; Sat, 15 Feb 2020 14:15:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j32uv-0004GR-CE for qemu-devel@nongnu.org; Sat, 15 Feb 2020 14:15:54 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j32uv-0004Fy-5b; Sat, 15 Feb 2020 14:15:53 -0500 Received: by mail-wr1-x444.google.com with SMTP id k11so14895819wrd.9; Sat, 15 Feb 2020 11:15:53 -0800 (PST) Received: from localhost.localdomain (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id o9sm9678605wrw.20.2020.02.15.11.15.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vgwXjH0kKbScO8AvLlOooEIEzKYchoKqFxh3C7QVSgQ=; b=WAlitRsdK6XnOlQKldpaZlsLFM9ctdqv5lYmOk/dewrTKLt09P0W9wnfioy/qL6Unt Z07m2DLtrzRm3gFpbL0WCMiUEcciscTZthcOqCAM5zP/PkeW4v1lC/CqoPbanoNyfWet 0X4FkiNt4APsKFwDeKKs2oXbNjtgZxkV7dz5/JFcEXO1DwHubFUghODGFAshrS1NkcE0 FXnYkTV92PITd86nLz2wcu/01g+uBU7P/WjE7G1ZOaDfcuXVzI19tTLbOXhBLaHptv5F fWQsJZu+qYD9lXZrDgTLEwi9oCIapbYJf30sGbbDfVqF49sFrTfN2PGftskrJ/mu8laV UMhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=vgwXjH0kKbScO8AvLlOooEIEzKYchoKqFxh3C7QVSgQ=; b=lwPQ/dvBhbXlUF0FVyeAReS7uUiqtstY3terr42K3yV2cBWCjnEX/eZPgTw5BjCx1w 82NcXYbCYYQtVKwIhvG4qcEbWJMUNffM7gox2Y6acjG+t/98LlIZDPYHdqmAFnKd/Ywu N5NqDuyFBuEF1a+r/D+x0KvSWzj5LliotHw4S9rWymTey5mO7Gwn0f2rUWcU3CJB4qOi +LypMc9i34imNYn2nsEoyhCV7qkEeaVIMNhlftiMyTtEJMiZHzjwswVOoBjtJdjjZSgM klpILuZFREs1TqJzMjbbiFWuKfxAH7EqsdT4FRygOop+3dwwFq7hpoi2PxgpnwVXi2aP VweQ== X-Gm-Message-State: APjAAAVCYSYu/MqQ3da5N/2unj2c35WLeNWXtQHEOEo4yB4Fd8ZXJMO0 ex/Ah4y316kGRqUT4dFLWnuwCEOgpOg= X-Google-Smtp-Source: APXvYqyYSozLG0aJ8qKSWG7+IEjy/pY1GiR6aZ6fveYZSi5+7N0D+HMplynzPI+ZqvzkKVVNFLUQ1g== X-Received: by 2002:adf:fd87:: with SMTP id d7mr11837100wrr.226.1581794151975; Sat, 15 Feb 2020 11:15:51 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 04/12] hw/arm/raspi: Remove use of the 'version' value in the board code Date: Sat, 15 Feb 2020 20:15:35 +0100 Message-Id: <20200215191543.3235-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200215191543.3235-1-f4bug@amsat.org> References: <20200215191543.3235-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann , qemu-arm@nongnu.org, Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We expected the 'version' ID to match the board processor ID, but this is not always true (for example boards with revision id 0xa02042/0xa22042 are Raspberry Pi 2 with a BCM2837 SoC). This was not important because we were not modelling them, but since the recent refactor now allow to model these boards, it is safer to check the processor id directly. Remove the version check. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/raspi.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index aa0a7e6276..38829195c5 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -98,11 +98,6 @@ static RaspiProcessorId board_processor_id(uint32_t boar= d_rev) return proc_id; } =20 -static int board_version(uint32_t board_rev) -{ - return board_processor_id(board_rev) + 1; -} - static const char *board_soc_type(uint32_t board_rev) { return soc_property[board_processor_id(board_rev)].type; @@ -201,7 +196,8 @@ static void reset_secondary(ARMCPU *cpu, const struct a= rm_boot_info *info) cpu_set_pc(cs, info->smp_loader_start); } =20 -static void setup_boot(MachineState *machine, int version, size_t ram_size) +static void setup_boot(MachineState *machine, RaspiProcessorId processor_i= d, + size_t ram_size) { static struct arm_boot_info binfo; int r; @@ -210,12 +206,13 @@ static void setup_boot(MachineState *machine, int ver= sion, size_t ram_size) binfo.ram_size =3D ram_size; binfo.nb_cpus =3D machine->smp.cpus; =20 - if (version <=3D 2) { - /* The rpi1 and 2 require some custom setup code to run in Secure - * mode before booting a kernel (to set up the SMC vectors so - * that we get a no-op SMC; this is used by Linux to call the + if (processor_id <=3D PROCESSOR_ID_BCM2836) { + /* + * The BCM2835 and BCM2836 require some custom setup code to run + * in Secure mode before booting a kernel (to set up the SMC vecto= rs + * so that we get a no-op SMC; this is used by Linux to call the * firmware for some cache maintenance operations. - * The rpi3 doesn't need this. + * The BCM2837 doesn't need this. */ binfo.board_setup_addr =3D BOARDSETUP_ADDR; binfo.write_board_setup =3D write_board_setup; @@ -223,10 +220,10 @@ static void setup_boot(MachineState *machine, int ver= sion, size_t ram_size) binfo.secure_boot =3D true; } =20 - /* Pi2 and Pi3 requires SMP setup */ - if (version >=3D 2) { + /* BCM2836 and BCM2837 requires SMP setup */ + if (processor_id >=3D PROCESSOR_ID_BCM2836) { binfo.smp_loader_start =3D SMPBOOT_ADDR; - if (version =3D=3D 2) { + if (processor_id =3D=3D PROCESSOR_ID_BCM2836) { binfo.write_secondary_boot =3D write_smpboot; } else { binfo.write_secondary_boot =3D write_smpboot64; @@ -238,7 +235,13 @@ static void setup_boot(MachineState *machine, int vers= ion, size_t ram_size) * the normal Linux boot process */ if (machine->firmware) { - hwaddr firmware_addr =3D version =3D=3D 3 ? FIRMWARE_ADDR_3 : FIRM= WARE_ADDR_2; + hwaddr firmware_addr; + + if (processor_id =3D=3D PROCESSOR_ID_BCM2837) { + firmware_addr =3D FIRMWARE_ADDR_3; + } else { + firmware_addr =3D FIRMWARE_ADDR_2; + } /* load the firmware image (typically kernel.img) */ r =3D load_image_targphys(machine->firmware, firmware_addr, ram_size - firmware_addr); @@ -259,7 +262,6 @@ static void raspi_machine_init(MachineState *machine) RaspiMachineClass *mc =3D RASPI_MACHINE_GET_CLASS(machine); RaspiMachineState *s =3D RASPI_MACHINE(machine); uint32_t board_rev =3D mc->board_rev; - int version =3D board_version(board_rev); uint64_t ram_size =3D board_ram_size(board_rev); uint32_t vcram_size; DriveInfo *di; @@ -303,7 +305,8 @@ static void raspi_machine_init(MachineState *machine) =20 vcram_size =3D object_property_get_uint(OBJECT(&s->soc), "vcram-size", &error_abort); - setup_boot(machine, version, machine->ram_size - vcram_size); + setup_boot(machine, board_processor_id(mc->board_rev), + machine->ram_size - vcram_size); } =20 static void raspi_machine_class_common_init(MachineClass *mc, --=20 2.21.1