[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 07/12] hw/arm: Load -bios image as a boot ROM for npcm7xx
From: |
Havard Skinnemoen |
Subject: |
[PATCH v3 07/12] hw/arm: Load -bios image as a boot ROM for npcm7xx |
Date: |
Fri, 26 Jun 2020 16:55:14 -0700 |
If a -bios option is specified on the command line, load the image into
the internal ROM memory region, which contains the first instructions
run by the CPU after reset.
A minimal Apache-2.0-licensed boot ROM can be found at
https://github.com/google/vbootrom
It is by no means feature complete, but it is enough to launch the
Nuvoton bootblock[1] from offset 0 in the flash, which in turn will
launch u-boot and finally the Linux kernel.
[1] https://github.com/Nuvoton-Israel/bootblock
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
---
hw/arm/npcm7xx_boards.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
index c82d9e018b..ca33262a59 100644
--- a/hw/arm/npcm7xx_boards.c
+++ b/hw/arm/npcm7xx_boards.c
@@ -18,8 +18,11 @@
#include "hw/arm/boot.h"
#include "hw/arm/npcm7xx.h"
#include "hw/core/cpu.h"
+#include "hw/loader.h"
#include "qapi/error.h"
+#include "qemu-common.h"
#include "qemu/units.h"
+#include "sysemu/sysemu.h"
#define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7
#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff
@@ -33,6 +36,25 @@ static struct arm_boot_info npcm7xx_binfo = {
.board_id = -1,
};
+static void npcm7xx_load_bootrom(NPCM7xxState *soc)
+{
+ if (bios_name) {
+ g_autofree char *filename = NULL;
+ int ret;
+
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+ if (!filename) {
+ error_report("Could not find ROM image '%s'", bios_name);
+ exit(1);
+ }
+ ret = load_image_mr(filename, &soc->irom);
+ if (ret < 0) {
+ error_report("Failed to load ROM image '%s'", filename);
+ exit(1);
+ }
+ }
+}
+
static void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc)
{
NPCM7xxClass *sc = NPCM7XX_GET_CLASS(soc);
@@ -65,7 +87,7 @@ static void npcm750_evb_init(MachineState *machine)
NPCM7xxState *soc;
soc = npcm7xx_create_soc(machine, NPCM750_EVB_POWER_ON_STRAPS);
-
+ npcm7xx_load_bootrom(soc);
npcm7xx_load_kernel(machine, soc);
}
@@ -74,7 +96,7 @@ static void quanta_gsj_init(MachineState *machine)
NPCM7xxState *soc;
soc = npcm7xx_create_soc(machine, QUANTA_GSJ_POWER_ON_STRAPS);
-
+ npcm7xx_load_bootrom(soc);
npcm7xx_load_kernel(machine, soc);
}
--
2.27.0.212.ge8ba1cc988-goog
- [PATCH v3 00/12] Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines, Havard Skinnemoen, 2020/06/26
- [PATCH v3 01/12] npcm7xx: Add config symbol, Havard Skinnemoen, 2020/06/26
- [PATCH v3 02/12] hw/misc: Add NPCM7xx System Global Control Registers device model, Havard Skinnemoen, 2020/06/26
- [PATCH v3 04/12] hw/timer: Add NPCM7xx Timer device model, Havard Skinnemoen, 2020/06/26
- [PATCH v3 03/12] hw/misc: Add NPCM7xx Clock Controller device model, Havard Skinnemoen, 2020/06/26
- [PATCH v3 05/12] hw/arm: Add NPCM730 and NPCM750 SoC models, Havard Skinnemoen, 2020/06/26
- [PATCH v3 06/12] hw/arm: Add two NPCM7xx-based machines, Havard Skinnemoen, 2020/06/26
- [PATCH v3 07/12] hw/arm: Load -bios image as a boot ROM for npcm7xx,
Havard Skinnemoen <=
- [PATCH v3 08/12] hw/nvram: NPCM7xx OTP device model, Havard Skinnemoen, 2020/06/26
- [PATCH v3 09/12] hw/mem: Stubbed out NPCM7xx Memory Controller model, Havard Skinnemoen, 2020/06/26
- [PATCH v3 10/12] hw/ssi: NPCM7xx Flash Interface Unit device model, Havard Skinnemoen, 2020/06/26
- [PATCH v3 11/12] hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj, Havard Skinnemoen, 2020/06/26
- [PATCH v3 12/12] docs/system: Add Nuvoton machine documentation, Havard Skinnemoen, 2020/06/26
- Re: [PATCH v3 00/12] Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines, no-reply, 2020/06/26