aboutsummaryrefslogtreecommitdiff
path: root/hw/riscv/boot.c
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@wdc.com>2020-10-13 17:17:33 -0700
committerAlistair Francis <alistair.francis@wdc.com>2020-10-22 12:00:22 -0700
commit38bc4e34f29b913d28a8d2abcf2bf74a4a4a816e (patch)
treeb32fdca754d2b62043f812157b1a199075fca2fc /hw/riscv/boot.c
parentc40778429157afbd9ba2236f1e06ca24d980cdfe (diff)
downloadqemu-38bc4e34f29b913d28a8d2abcf2bf74a4a4a816e.zip
qemu-38bc4e34f29b913d28a8d2abcf2bf74a4a4a816e.tar.gz
qemu-38bc4e34f29b913d28a8d2abcf2bf74a4a4a816e.tar.bz2
hw/riscv: Load the kernel after the firmware
Instead of loading the kernel at a hardcoded start address, let's load the kernel at the next aligned address after the end of the firmware. This should have no impact for current users of OpenSBI, but will allow loading a noMMU kernel at the start of memory. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com> Reviewed-by: Bin Meng <bin.meng@windriver.com> Tested-by: Bin Meng <bin.meng@windriver.com> Message-id: 46c00c4f15b42feb792090e3d74359e180a6d954.1602634524.git.alistair.francis@wdc.com
Diffstat (limited to 'hw/riscv/boot.c')
-rw-r--r--hw/riscv/boot.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
index 5dea644..9b3fe3f 100644
--- a/hw/riscv/boot.c
+++ b/hw/riscv/boot.c
@@ -33,10 +33,8 @@
#include <libfdt.h>
#if defined(TARGET_RISCV32)
-# define KERNEL_BOOT_ADDRESS 0x80400000
#define fw_dynamic_info_data(__val) cpu_to_le32(__val)
#else
-# define KERNEL_BOOT_ADDRESS 0x80200000
#define fw_dynamic_info_data(__val) cpu_to_le64(__val)
#endif
@@ -49,6 +47,15 @@ bool riscv_is_32_bit(MachineState *machine)
}
}
+target_ulong riscv_calc_kernel_start_addr(MachineState *machine,
+ target_ulong firmware_end_addr) {
+ if (riscv_is_32_bit(machine)) {
+ return QEMU_ALIGN_UP(firmware_end_addr, 4 * MiB);
+ } else {
+ return QEMU_ALIGN_UP(firmware_end_addr, 2 * MiB);
+ }
+}
+
target_ulong riscv_find_and_load_firmware(MachineState *machine,
const char *default_machine_firmware,
hwaddr firmware_load_addr,
@@ -123,7 +130,9 @@ target_ulong riscv_load_firmware(const char *firmware_filename,
exit(1);
}
-target_ulong riscv_load_kernel(const char *kernel_filename, symbol_fn_t sym_cb)
+target_ulong riscv_load_kernel(const char *kernel_filename,
+ target_ulong kernel_start_addr,
+ symbol_fn_t sym_cb)
{
uint64_t kernel_entry;
@@ -138,9 +147,9 @@ target_ulong riscv_load_kernel(const char *kernel_filename, symbol_fn_t sym_cb)
return kernel_entry;
}
- if (load_image_targphys_as(kernel_filename, KERNEL_BOOT_ADDRESS,
+ if (load_image_targphys_as(kernel_filename, kernel_start_addr,
ram_size, NULL) > 0) {
- return KERNEL_BOOT_ADDRESS;
+ return kernel_start_addr;
}
error_report("could not load kernel '%s'", kernel_filename);