summaryrefslogtreecommitdiffstats
path: root/hw/arm/allwinner-h3.c
diff options
context:
space:
mode:
authorNiek Linnenbank2020-03-11 23:18:46 +0100
committerPeter Maydell2020-03-12 17:27:33 +0100
commita80beb160d4e89937b0afccb146a9f3247f88588 (patch)
tree32fc5c006474a8fd5138cd7486aedb988e92347c /hw/arm/allwinner-h3.c
parenthw/arm/allwinner-h3: add EMAC ethernet device (diff)
downloadqemu-a80beb160d4e89937b0afccb146a9f3247f88588.tar.gz
qemu-a80beb160d4e89937b0afccb146a9f3247f88588.tar.xz
qemu-a80beb160d4e89937b0afccb146a9f3247f88588.zip
hw/arm/allwinner-h3: add Boot ROM support
A real Allwinner H3 SoC contains a Boot ROM which is the first code that runs right after the SoC is powered on. The Boot ROM is responsible for loading user code (e.g. a bootloader) from any of the supported external devices and writing the downloaded code to internal SRAM. After loading the SoC begins executing the code written to SRAM. This commits adds emulation of the Boot ROM firmware setup functionality by loading user code from SD card in the A1 SRAM. While the A1 SRAM is 64KiB, we limit the size to 32KiB because the real H3 Boot ROM also rejects sizes larger than 32KiB. For reference, this behaviour is documented by the Linux Sunxi project wiki at: https://linux-sunxi.org/BROM#U-Boot_SPL_limitations Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20200311221854.30370-11-nieklinnenbank@gmail.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/arm/allwinner-h3.c')
-rw-r--r--hw/arm/allwinner-h3.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
index d1245d2b01..a9767c70c0 100644
--- a/hw/arm/allwinner-h3.c
+++ b/hw/arm/allwinner-h3.c
@@ -29,6 +29,7 @@
#include "hw/char/serial.h"
#include "hw/misc/unimp.h"
#include "hw/usb/hcd-ehci.h"
+#include "hw/loader.h"
#include "sysemu/sysemu.h"
#include "hw/arm/allwinner-h3.h"
@@ -170,6 +171,22 @@ enum {
AW_H3_GIC_NUM_SPI = 128
};
+void allwinner_h3_bootrom_setup(AwH3State *s, BlockBackend *blk)
+{
+ const int64_t rom_size = 32 * KiB;
+ g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size);
+
+ if (blk_pread(blk, 8 * KiB, buffer, rom_size) < 0) {
+ error_setg(&error_fatal, "%s: failed to read BlockBackend data",
+ __func__);
+ return;
+ }
+
+ rom_add_blob("allwinner-h3.bootrom", buffer, rom_size,
+ rom_size, s->memmap[AW_H3_SRAM_A1],
+ NULL, NULL, NULL, NULL, false);
+}
+
static void allwinner_h3_init(Object *obj)
{
AwH3State *s = AW_H3(obj);