diff mbox series

[v2,07/12] hw/arm: Load -bios image as a boot ROM for npcm7xx

Message ID 20200611223016.259837-8-hskinnemoen@google.com (mailing list archive)
State New, archived
Headers show
Series Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines | expand

Commit Message

Havard Skinnemoen June 11, 2020, 10:30 p.m. UTC
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

Change-Id: I41eae4fc7786d33f532c14087e930bf1b5012562
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
---
 hw/arm/npcm7xx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Cédric Le Goater June 17, 2020, 4:01 p.m. UTC | #1
On 6/12/20 12:30 AM, Havard Skinnemoen wrote:
> 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

you might want to consider adding this rom to QEMU also.


> 
> 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
> 
> Change-Id: I41eae4fc7786d33f532c14087e930bf1b5012562
> Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
> Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
> ---
>  hw/arm/npcm7xx.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
> index a5dbf08c00..417bc16b5c 100644
> --- a/hw/arm/npcm7xx.c
> +++ b/hw/arm/npcm7xx.c
> @@ -22,6 +22,7 @@
>  #include "hw/misc/unimp.h"
>  #include "hw/qdev-properties.h"
>  #include "qapi/error.h"
> +#include "qemu-common.h"
>  #include "qemu/units.h"
>  #include "sysemu/sysemu.h"
>  
> @@ -270,6 +271,22 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
>      }
>      memory_region_add_subregion(get_system_memory(), NPCM7XX_ROM_BA, &s->irom);
>  
> +    if (bios_name) {
> +        g_autofree char *filename = NULL;
> +        int ret;
> +
> +        filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
> +        if (!filename) {
> +            error_setg(errp, "Could not find ROM image '%s'", bios_name);
> +            return;
> +        }
> +        ret = load_image_mr(filename, &s->irom);
> +        if (ret < 0) {
> +            error_setg(errp, "Failed to load ROM image '%s'", filename);
> +            return;
> +        }
> +    }
> +

I think this belongs to the machine init routine and not the soc.



>      /* External DDR4 SDRAM */
>      memory_region_add_subregion(get_system_memory(), NPCM7XX_DRAM_BA, s->dram);
>  }
>
diff mbox series

Patch

diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
index a5dbf08c00..417bc16b5c 100644
--- a/hw/arm/npcm7xx.c
+++ b/hw/arm/npcm7xx.c
@@ -22,6 +22,7 @@ 
 #include "hw/misc/unimp.h"
 #include "hw/qdev-properties.h"
 #include "qapi/error.h"
+#include "qemu-common.h"
 #include "qemu/units.h"
 #include "sysemu/sysemu.h"
 
@@ -270,6 +271,22 @@  static void npcm7xx_realize(DeviceState *dev, Error **errp)
     }
     memory_region_add_subregion(get_system_memory(), NPCM7XX_ROM_BA, &s->irom);
 
+    if (bios_name) {
+        g_autofree char *filename = NULL;
+        int ret;
+
+        filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+        if (!filename) {
+            error_setg(errp, "Could not find ROM image '%s'", bios_name);
+            return;
+        }
+        ret = load_image_mr(filename, &s->irom);
+        if (ret < 0) {
+            error_setg(errp, "Failed to load ROM image '%s'", filename);
+            return;
+        }
+    }
+
     /* External DDR4 SDRAM */
     memory_region_add_subregion(get_system_memory(), NPCM7XX_DRAM_BA, s->dram);
 }