On 9/2/25 10:28, Jamin Lin wrote:
Hi Cédric
Subject: Re: [SPAM] [PATCH v1 01/21] hw/arm/aspeed_ast27x0-fc: Support
VBootRom
On 7/17/25 05:40, Jamin Lin wrote:
Introduces support for loading a vbootrom image into the dedicated
vbootrom memory region in the AST2700 Full Core machine.
Additionally, it implements a mechanism to extract the content of
fmc_cs0 flash data(backend file) and copy it into the memory-mapped
region corresponding to ASPEED_DEV_SPI_BOOT.
Signed-off-by: Jamin Lin <jamin_...@aspeedtech.com>
---
hw/arm/aspeed_ast27x0-fc.c | 75
++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/hw/arm/aspeed_ast27x0-fc.c b/hw/arm/aspeed_ast27x0-fc.c
index 7087be4288..e2eee6183f 100644
--- a/hw/arm/aspeed_ast27x0-fc.c
+++ b/hw/arm/aspeed_ast27x0-fc.c
@@ -11,6 +11,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
+#include "qemu/datadir.h"
#include "qapi/error.h"
#include "system/block-backend.h"
#include "system/system.h"
@@ -35,6 +36,7 @@ struct Ast2700FCState {
MemoryRegion ca35_memory;
MemoryRegion ca35_dram;
+ MemoryRegion ca35_boot_rom;
MemoryRegion ssp_memory;
MemoryRegion tsp_memory;
@@ -55,12 +57,65 @@ struct Ast2700FCState {
#define AST2700FC_HW_STRAP2 0x00000003
#define AST2700FC_FMC_MODEL "w25q01jvq"
#define AST2700FC_SPI_MODEL "w25q512jv"
+#define VBOOTROM_FILE_NAME "ast27x0_bootrom.bin"
+
+static void ast2700fc_ca35_load_vbootrom(AspeedSoCState *soc,
+ const char *bios_name,
Error
+**errp) {
+ 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 vbootrom image '%s'",
bios_name);
+ return;
+ }
+
+ ret = load_image_mr(filename, &soc->vbootrom);
+ if (ret < 0) {
+ error_setg(errp, "Failed to load vbootrom image '%s'",
bios_name);
+ return;
+ }
+}
+
+static void ast2700fc_ca35_write_boot_rom(DriveInfo *dinfo, hwaddr addr,
+ size_t rom_size, Error
+**errp) {
+ BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
+ g_autofree void *storage = NULL;
+ int64_t size;
+
+ /*
+ * The block backend size should have already been 'validated' by
+ * the creation of the m25p80 object.
+ */
+ size = blk_getlength(blk);
+ if (size <= 0) {
+ error_setg(errp, "failed to get flash size");
+ return;
+ }
+
+ if (rom_size > size) {
+ rom_size = size;
+ }
+
+ storage = g_malloc0(rom_size);
+ if (blk_pread(blk, 0, rom_size, storage, 0) < 0) {
+ error_setg(errp, "failed to read the initial flash content");
+ return;
+ }
+
+ rom_add_blob_fixed("aspeed.boot_rom", storage, rom_size, addr); }
The above is duplicated code. Could we try to have common routines instead ?
Thanks for your review and suggestion.
Per our earlier discussion, we plan to refactor hw/arm/aspeed.c. As a first
step, I can move the vbootrom helpers into a common source file so they can be
reused by other boards.
Do you have a preference for the filename?
hw/arm/aspeed_utils.c (with a small header in include/hw/arm/aspeed_utils.h),
There is a aspeed_soc_common.c file for such helpers.
Thanks,
C.