[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/18] hw/arm/raspi: Remove use of the 'version' value in the boar
From: |
Peter Maydell |
Subject: |
[PULL 18/18] hw/arm/raspi: Remove use of the 'version' value in the board code |
Date: |
Thu, 1 Oct 2020 15:47:59 +0100 |
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
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 <peter.maydell@linaro.org>
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20200924111808.77168-9-f4bug@amsat.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/raspi.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index ae98a2fbfca..b5b30f0f38f 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)
{
RaspiMachineState *s = RASPI_MACHINE(machine);
int r;
@@ -210,12 +206,13 @@ static void setup_boot(MachineState *machine, int
version, size_t ram_size)
s->binfo.ram_size = ram_size;
s->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.
*/
s->binfo.board_setup_addr = BOARDSETUP_ADDR;
s->binfo.write_board_setup = write_board_setup;
@@ -223,10 +220,10 @@ static void setup_boot(MachineState *machine, int
version, size_t ram_size)
s->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) {
s->binfo.smp_loader_start = SMPBOOT_ADDR;
- if (version == 2) {
+ if (processor_id == PROCESSOR_ID_BCM2836) {
s->binfo.write_secondary_boot = write_smpboot;
} else {
s->binfo.write_secondary_boot = write_smpboot64;
@@ -260,7 +257,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;
@@ -301,7 +297,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.20.1
- [PULL 07/18] target/arm: Fix SVE splice, (continued)
- [PULL 07/18] target/arm: Fix SVE splice, Peter Maydell, 2020/10/01
- [PULL 08/18] hw/arm/raspi: Define various blocks base addresses, Peter Maydell, 2020/10/01
- [PULL 09/18] hw/arm/bcm2835: Add more unimplemented peripherals, Peter Maydell, 2020/10/01
- [PULL 10/18] hw/arm/raspi: Remove ignore_memory_transaction_failures on the raspi2, Peter Maydell, 2020/10/01
- [PULL 11/18] hw/arm/raspi: Display the board revision in the machine description, Peter Maydell, 2020/10/01
- [PULL 13/18] hw/arm/raspi: Move arm_boot_info structure to RaspiMachineState, Peter Maydell, 2020/10/01
- [PULL 12/18] hw/arm/raspi: Load the firmware on the first core, Peter Maydell, 2020/10/01
- [PULL 15/18] hw/arm/raspi: Use more specific machine names, Peter Maydell, 2020/10/01
- [PULL 14/18] hw/arm/raspi: Avoid using TypeInfo::class_data pointer, Peter Maydell, 2020/10/01
- [PULL 17/18] hw/arm/raspi: Use RaspiProcessorId to set the firmware load address, Peter Maydell, 2020/10/01
- [PULL 18/18] hw/arm/raspi: Remove use of the 'version' value in the board code,
Peter Maydell <=
- [PULL 16/18] hw/arm/raspi: Introduce RaspiProcessorId enum, Peter Maydell, 2020/10/01
- Re: [PULL 00/18] target-arm queue, Peter Maydell, 2020/10/01