aboutsummaryrefslogtreecommitdiff
path: root/hw/riscv/virt.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/riscv/virt.c')
-rw-r--r--hw/riscv/virt.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index de2efccebf..a5bc7353b4 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -1274,7 +1274,23 @@ static void virt_machine_done(Notifier *notifier, void *data)
s->fw_cfg = create_fw_cfg(machine);
rom_set_fw(s->fw_cfg);
- if (machine->kernel_filename) {
+ if (drive_get(IF_PFLASH, 0, 1)) {
+ /*
+ * S-mode FW like EDK2 will be kept in second plash (unit 1).
+ * When both kernel, initrd and pflash options are provided in the
+ * command line, the kernel and initrd will be copied to the fw_cfg
+ * table and opensbi will jump to the flash address which is the
+ * entry point of S-mode FW. It is the job of the S-mode FW to load
+ * the kernel and initrd using fw_cfg table.
+ *
+ * If only pflash is given but not -kernel, then it is the job of
+ * of the S-mode firmware to locate and load the kernel.
+ * In either case, the next_addr for opensbi will be the flash address.
+ */
+ riscv_setup_firmware_boot(machine);
+ kernel_entry = virt_memmap[VIRT_FLASH].base +
+ virt_memmap[VIRT_FLASH].size / 2;
+ } else if (machine->kernel_filename) {
kernel_start_addr = riscv_calc_kernel_start_addr(&s->soc[0],
firmware_end_addr);