[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 36/46] hw/arm/raspi: Extract the RAM size from the board revision
From: |
Peter Maydell |
Subject: |
[PULL 36/46] hw/arm/raspi: Extract the RAM size from the board revision |
Date: |
Thu, 13 Feb 2020 14:41:35 +0000 |
From: Philippe Mathieu-Daudé <address@hidden>
The board revision encode the amount of RAM. Add a helper
to extract the RAM size, and use it.
Since the amount of RAM is fixed (it is impossible to physically
modify to have more or less RAM), do not allow sizes different
than the one anounced by the manufacturer.
Acked-by: Igor Mammedov <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Message-id: address@hidden
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
---
hw/arm/raspi.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index f285e2988fc..dcd8d2d6d38 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -13,6 +13,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
+#include "qemu/cutils.h"
#include "qapi/error.h"
#include "cpu.h"
#include "hw/arm/bcm2836.h"
@@ -49,6 +50,12 @@ FIELD(REV_CODE, MANUFACTURER, 16, 4);
FIELD(REV_CODE, MEMORY_SIZE, 20, 3);
FIELD(REV_CODE, STYLE, 23, 1);
+static uint64_t board_ram_size(uint32_t board_rev)
+{
+ assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
+ return 256 * MiB << FIELD_EX32(board_rev, REV_CODE, MEMORY_SIZE);
+}
+
static int board_processor_id(uint32_t board_rev)
{
assert(FIELD_EX32(board_rev, REV_CODE, STYLE)); /* Only new style */
@@ -191,15 +198,17 @@ static void raspi_init(MachineState *machine, uint32_t
board_rev)
{
RasPiState *s = g_new0(RasPiState, 1);
int version = board_version(board_rev);
+ uint64_t ram_size = board_ram_size(board_rev);
uint32_t vcram_size;
DriveInfo *di;
BlockBackend *blk;
BusState *bus;
DeviceState *carddev;
- if (machine->ram_size > 1 * GiB) {
- error_report("Requested ram size is too large for this machine: "
- "maximum is 1GB");
+ if (machine->ram_size != ram_size) {
+ char *size_str = size_to_str(ram_size);
+ error_report("Invalid RAM size, should be %s", size_str);
+ g_free(size_str);
exit(1);
}
--
2.20.1
- [PULL 30/46] hw/arm: ast2400/ast2500: Wire up EHCI controllers, (continued)
- [PULL 30/46] hw/arm: ast2400/ast2500: Wire up EHCI controllers, Peter Maydell, 2020/02/13
- [PULL 28/46] target/arm: Implement UAO semantics, Peter Maydell, 2020/02/13
- [PULL 29/46] target/arm: Enable ARMv8.2-UAO in -cpu max, Peter Maydell, 2020/02/13
- [PULL 31/46] hw/arm: ast2600: Wire up EHCI controllers, Peter Maydell, 2020/02/13
- [PULL 32/46] hw/char/exynos4210_uart: Fix memleaks in exynos4210_uart_init, Peter Maydell, 2020/02/13
- [PULL 38/46] hw/arm/raspi: Trivial code movement, Peter Maydell, 2020/02/13
- [PULL 33/46] hw/arm/raspi: Use BCM2708 machine type with pre Device Tree kernels, Peter Maydell, 2020/02/13
- [PULL 34/46] hw/arm/raspi: Correct the board descriptions, Peter Maydell, 2020/02/13
- [PULL 37/46] hw/arm/raspi: Extract the processor type from the board revision, Peter Maydell, 2020/02/13
- [PULL 35/46] hw/arm/raspi: Extract the version from the board revision, Peter Maydell, 2020/02/13
- [PULL 36/46] hw/arm/raspi: Extract the RAM size from the board revision,
Peter Maydell <=
- [PULL 42/46] hw/arm/raspi: Set default RAM size to size encoded in board revision, Peter Maydell, 2020/02/13
- [PULL 44/46] hw/arm/raspi: Use a unique raspi_machine_class_init() method, Peter Maydell, 2020/02/13
- [PULL 41/46] hw/arm/raspi: Let class_init() directly call raspi_machine_init(), Peter Maydell, 2020/02/13
- [PULL 43/46] hw/arm/raspi: Extract the board model from the board revision, Peter Maydell, 2020/02/13
- [PULL 45/46] hw/arm/raspi: Extract the cores count from the board revision, Peter Maydell, 2020/02/13
- [PULL 39/46] hw/arm/raspi: Make machines children of abstract RaspiMachineClass, Peter Maydell, 2020/02/13
- [PULL 40/46] hw/arm/raspi: Make board_rev a field of RaspiMachineClass, Peter Maydell, 2020/02/13
- [PULL 46/46] target/arm: Implement ARMv8.1-VMID16 extension, Peter Maydell, 2020/02/13
- Re: [PULL 00/46] target-arm queue, Peter Maydell, 2020/02/14