[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-riscv] [PATCH v2 2/4] RISC-V: refactor initrd loading
From: |
Alistair Francis |
Subject: |
Re: [Qemu-riscv] [PATCH v2 2/4] RISC-V: refactor initrd loading |
Date: |
Mon, 17 Dec 2018 19:03:55 +0000 |
On Sun, 2018-12-16 at 18:12 -0500, Stefan O'Rear wrote:
> Signed-off-by: Michael Clark <address@hidden>
> Signed-off-by: Stefan O'Rear <address@hidden>
> ---
> hw/riscv/boot.c | 48 ++++++++++++++++++++++++++++++++---------------
> -
> 1 file changed, 32 insertions(+), 16 deletions(-)
>
> diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
> index 1e4d017..54e3139 100644
> --- a/hw/riscv/boot.c
> +++ b/hw/riscv/boot.c
> @@ -25,6 +25,13 @@
> #include "elf.h"
> #include "hw/riscv/boot.h"
>
> +#define RISCV_BOOT_DEBUG 0
> +
> +#define boot_debug(fs, ...) \
> + if (RISCV_BOOT_DEBUG) { \
> + fprintf(stderr, "boot: %s: "fs, __func__, ##__VA_ARGS__); \
This should be using qemu_log() instead of fprintf().
> + }
> +
> static uint64_t load_kernel(const char *kernel_filename)
> {
> uint64_t kernel_entry, kernel_high;
> @@ -38,10 +45,10 @@ static uint64_t load_kernel(const char
> *kernel_filename)
> return kernel_entry;
> }
>
> -static hwaddr load_initrd(const char *filename, uint64_t mem_size,
> - uint64_t kernel_entry, hwaddr *start)
> +static void riscv_load_initrd(const char *filename, uint64_t
> mem_size,
> + hwaddr firmware_entry, void *fdt)
> {
> - int size;
> + uint64_t start, size;
start will have to depend on the bitlength of the target.
Alistair
>
> /* We want to put the initrd far enough into RAM that when the
> * kernel is uncompressed it will not clobber the initrd.
> However
> @@ -53,33 +60,42 @@ static hwaddr load_initrd(const char *filename,
> uint64_t mem_size,
> * halfway into RAM, and for boards with 256MB of RAM or more we
> put
> * the initrd at 128MB.
> */
> - *start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
> + start = firmware_entry + MIN(mem_size / 2, 128 * MiB);
>
> - size = load_ramdisk(filename, *start, mem_size - *start);
> + size = load_ramdisk(filename, start, mem_size - start);
> if (size == -1) {
> - size = load_image_targphys(filename, *start, mem_size -
> *start);
> + size = load_image_targphys(filename, start, mem_size -
> start);
> if (size == -1) {
> error_report("could not load ramdisk '%s'", filename);
> exit(1);
> }
> }
> - return *start + size;
> +
> + boot_debug("start=0x" TARGET_FMT_plx " end=0x" TARGET_FMT_plx
> "\n",
> + start, start + size);
> +
> + /*
> + * pass initrd load address via device-tree to kernel
> + *
> + * linux-kernel reads the initrd address from device-tree
> + */
> + if (fdt) {
> + qemu_fdt_setprop_cells(fdt, "/chosen", "linux,initrd-end",
> + (start + size) >> 32, start + size);
> + qemu_fdt_setprop_cells(fdt, "/chosen", "linux,initrd-start",
> + start >> 32, start);
> + }
> }
>
> void riscv_load_firmware_kernel_initrd(MachineState *machine, void
> *fdt)
> {
> if (machine->kernel_filename) {
> - uint64_t kernel_entry = load_kernel(machine-
> >kernel_filename);
> + uint64_t firmware_entry = load_kernel(machine-
> >kernel_filename);
>
> if (machine->initrd_filename) {
> - hwaddr start;
> - hwaddr end = load_initrd(machine->initrd_filename,
> - machine->ram_size,
> kernel_entry,
> - &start);
> - qemu_fdt_setprop_cell(fdt, "/chosen",
> - "linux,initrd-start", start);
> - qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-
> end",
> - end);
> + /* load separate initrd */
> + riscv_load_initrd(machine->initrd_filename, machine-
> >ram_size,
> + firmware_entry, fdt);
> }
> }
> }
- [Qemu-riscv] [PATCH v2 0/4] Support separate -firmware and -kernel, Stefan O'Rear, 2018/12/16
- [Qemu-riscv] [PATCH v2 1/4] RISC-V: Move firmware loading logic to a separate file, Stefan O'Rear, 2018/12/16
- [Qemu-riscv] [PATCH v2 2/4] RISC-V: refactor initrd loading, Stefan O'Rear, 2018/12/16
- Re: [Qemu-riscv] [PATCH v2 2/4] RISC-V: refactor initrd loading,
Alistair Francis <=
- [Qemu-riscv] [PATCH v2 3/4] RISC-V: Honor entry point in loaded ELF firmware, Stefan O'Rear, 2018/12/16
- [Qemu-riscv] [PATCH v2 4/4] RISC-V: Support separate firmware and kernel payload, Stefan O'Rear, 2018/12/16
- Re: [Qemu-riscv] [PATCH v2 0/4] Support separate -firmware and -kernel, Alistair Francis, 2018/12/17