Skip to content

Commit

Permalink
hw/riscv: Extend the kernel loading support
Browse files Browse the repository at this point in the history
Extend the RISC-V kernel loader to support Image and uImage files.
A Linux kernel can now be booted with:

    qemu-system-riscv64 -machine virt -bios fw_jump.bin -kernel Image

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
  • Loading branch information
alistair23 authored and palmer-dabbelt committed Jun 27, 2019
1 parent b304222 commit 395fd69
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions hw/riscv/boot.c
Expand Up @@ -56,12 +56,22 @@ target_ulong riscv_load_kernel(const char *kernel_filename)
uint64_t kernel_entry, kernel_high;

if (load_elf(kernel_filename, NULL, NULL, NULL,
&kernel_entry, NULL, &kernel_high, 0, EM_RISCV, 1, 0) < 0) {
error_report("could not load kernel '%s'", kernel_filename);
exit(1);
&kernel_entry, NULL, &kernel_high, 0, EM_RISCV, 1, 0) > 0) {
return kernel_entry;
}

return kernel_entry;
if (load_uimage_as(kernel_filename, &kernel_entry, NULL, NULL,
NULL, NULL, NULL) > 0) {
return kernel_entry;
}

if (load_image_targphys_as(kernel_filename, KERNEL_BOOT_ADDRESS,
ram_size, NULL) > 0) {
return KERNEL_BOOT_ADDRESS;
}

error_report("could not load kernel '%s'", kernel_filename);
exit(1);
}

hwaddr riscv_load_initrd(const char *filename, uint64_t mem_size,
Expand Down

0 comments on commit 395fd69

Please sign in to comment.