Received: by 2002:a05:6512:3aa:0:0:0:0 with SMTP id v10csp4991472lfp; Mon, 17 Feb 2020 03:50:36 -0800 (PST) X-Google-Smtp-Source: APXvYqxwCimN7fwKfJj5aY9/xpnyEwzoeterw8M/LQoM+gTwKAlbG2ZBrje6k7L+mJzry6Rk6rg4 X-Received: by 2002:ac8:60d5:: with SMTP id i21mr12816802qtm.341.1581940236503; Mon, 17 Feb 2020 03:50:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581940236; cv=none; d=google.com; s=arc-20160816; b=UgFL+v0zzo+b341p+Eti+ZfJbtQVzgA3f3aBtpAV71wjMS5Xd74ObQejDbcTgLVHWw zoZNqgpJKmd2c6zFkzgT1PGzNQohNEuZedG53PzPX3MN78uYgsgEHWXflFRu0nno2N41 zsX0Lkl2I2AM9nSWXYfHu6/CbiRxjtkXRWRaaV0PcWiSHtNxcqd61PFPhceLfUlYkKzA IqivSyEkZ0x3l+E8yE7JiXa0Ia1PhybyqARWJZGbzoudhPjxUf+neuIDZqw6afbkp7by vs/B2m8FUPr5zB7x6Cl6jx6v0V+cpPYOhNOaWoKE/2qhv9Z3EDtLVs3UTIsK3xi6P+xU WA1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=3UiEjEXttuM7t0xfD+phHvJNwF4QMG2Y+xuMq2THqy8=; b=D8a9HnDUF4fcnZ46lZmCEigN2ZN8DxAG59Vkq7tqFnOrpy7gLjO70pAdzdRpvQD0BR 2sJcclM1Vg2F7C24s5371fUO8U5ninSGuUcvrHcR8xQJhmGzr3kmCEBpJeFR/RnGOrii YuHXV5q4vozN+kZwS0zQacyUtVLTG47f/IA8s3hY0/RRR0GlcA9HCVZe1wkKdFwfHv+/ 2XxJQekUvFaEN8lpEyWlghhJx1Z/xyq6Ad5eCObu89QraBk55wITb/wWxYz+rookPBjV aWEcLD0xw107aPUcBKAoWtrfKXjYojedjB9Fxub5wY9PYwrKUQUTl65VHx4MIUEwIb0m Gfsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=nfBTBu4k; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amsat.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m18si187633qke.285.2020.02.17.03.50.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Feb 2020 03:50:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=nfBTBu4k; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amsat.org Received: from localhost ([::1]:44154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3ev5-0004iK-S6 for alex.bennee@linaro.org; Mon, 17 Feb 2020 06:50:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40644) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3eqP-0006Ys-4y for qemu-devel@nongnu.org; Mon, 17 Feb 2020 06:45:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3eqN-0002Qi-LJ for qemu-devel@nongnu.org; Mon, 17 Feb 2020 06:45:45 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34753) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j3eqN-0002Q7-Em; Mon, 17 Feb 2020 06:45:43 -0500 Received: by mail-wr1-x444.google.com with SMTP id n10so17385980wrm.1; Mon, 17 Feb 2020 03:45:43 -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=3UiEjEXttuM7t0xfD+phHvJNwF4QMG2Y+xuMq2THqy8=; b=nfBTBu4k1ml1skKW92aonJI6EY7SGTutu+amIEpRNTWBW//lrsFj6chx1hinP7lqF0 /GoTEjoFWL6oxduseO7xScOUdgmId/IT+3+w7BBlYKJq0R2X6xoxDkctXDaXAOjVrpD3 RV7dBXOgF5w26vN/U49JEctKqpDOscxw0jqLiRUbSqgsEcm2CqSRsaiZXtztIS69W8OK Agf58/JmUseO3wiagTFFC/GCiOhyDFpkyTDrxH2MdUaDlk0Jbl49n2ZaJTQ5T2OZdMoh 0ZutvSapnWRqhgPBHhBIWmXxjE+5s6zGxSXNsMb/gC8iFD1+kr3P83ng3V8KtDNk9itx CurA== 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=3UiEjEXttuM7t0xfD+phHvJNwF4QMG2Y+xuMq2THqy8=; b=G2k5Tscb7vGd0obc1MnL3/q47ZQFtOhJMp0BVtveHq4sxIPB+YJcZL9n6pJ5RxJUwk qpust/pUVfk245ic02pJclvKpFNYbnhQCxdrr8DZA5B/wmk6mKMPFvS8J2+VOQHwUjrk u2d0QLZKPmAc2YAITRJxT7yC4aQIgy+/t0H+S3JyY46t5J8E3e6f7jVgE51p59QzTsjH ucmuinicGTWyBApVUmPdD5CP9p+9OxZoMl2YIktZnEQkUa6KCK33TE3E/j0gz1rFRb+e qsYBgTfgxGTecFw2XqgTWIb7Mw82eRYCWtGNBIWdf9FDc5JTpb71sGVp0um3kNZXu4wQ jWOA== X-Gm-Message-State: APjAAAX75CTcjARpVo4/v8E59Ce9fjfIS88Hc2MHy2pWOVJmj+ZLhWjM LOzDm0es1gpbRAZq1htPsRiQ1g71L1s= X-Received: by 2002:a5d:6a88:: with SMTP id s8mr21712664wru.173.1581939942103; Mon, 17 Feb 2020 03:45:42 -0800 (PST) Received: from x1w.redhat.com (78.red-88-21-202.staticip.rima-tde.net. [88.21.202.78]) by smtp.gmail.com with ESMTPSA id i2sm268149wmb.28.2020.02.17.03.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 03:45:41 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 05/13] hw/arm/raspi: Remove use of the 'version' value in the board code Date: Mon, 17 Feb 2020 12:45:25 +0100 Message-Id: <20200217114533.17779-6-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200217114533.17779-1-f4bug@amsat.org> References: <20200217114533.17779-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: 8bit 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, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Luc Michel Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-devel" X-TUID: sRo4qPK4PNUM 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é --- 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 b628dadf34..fff501affb 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -98,11 +98,6 @@ static RaspiProcessorId board_processor_id(uint32_t board_rev) return proc_id; } -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 arm_boot_info *info) cpu_set_pc(cs, info->smp_loader_start); } -static void setup_boot(MachineState *machine, int version, size_t ram_size) +static void setup_boot(MachineState *machine, RaspiProcessorId processor_id, + size_t ram_size) { static struct arm_boot_info binfo; int r; @@ -210,12 +206,13 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) binfo.ram_size = ram_size; binfo.nb_cpus = machine->smp.cpus; - if (version <= 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 <= 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 vectors + * 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 = BOARDSETUP_ADDR; binfo.write_board_setup = write_board_setup; @@ -223,10 +220,10 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) binfo.secure_boot = true; } - /* Pi2 and Pi3 requires SMP setup */ - if (version >= 2) { + /* BCM2836 and BCM2837 requires SMP setup */ + if (processor_id >= PROCESSOR_ID_BCM2836) { binfo.smp_loader_start = SMPBOOT_ADDR; - if (version == 2) { + if (processor_id == PROCESSOR_ID_BCM2836) { binfo.write_secondary_boot = write_smpboot; } else { binfo.write_secondary_boot = write_smpboot64; @@ -238,7 +235,13 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) * the normal Linux boot process */ if (machine->firmware) { - hwaddr firmware_addr = version == 3 ? FIRMWARE_ADDR_3 : FIRMWARE_ADDR_2; + hwaddr firmware_addr; + + if (processor_id == PROCESSOR_ID_BCM2837) { + firmware_addr = FIRMWARE_ADDR_3; + } else { + firmware_addr = FIRMWARE_ADDR_2; + } /* load the firmware image (typically kernel.img) */ r = load_image_targphys(machine->firmware, firmware_addr, ram_size - firmware_addr); @@ -259,7 +262,6 @@ static void raspi_machine_init(MachineState *machine) RaspiMachineClass *mc = RASPI_MACHINE_GET_CLASS(machine); RaspiMachineState *s = RASPI_MACHINE(machine); uint32_t board_rev = mc->board_rev; - int version = board_version(board_rev); uint64_t ram_size = board_ram_size(board_rev); uint32_t vcram_size; DriveInfo *di; @@ -303,7 +305,8 @@ static void raspi_machine_init(MachineState *machine) vcram_size = 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); } static void raspi_machine_class_common_init(MachineClass *mc, -- 2.21.1