mirror of https://github.com/xemu-project/xemu.git
hw/riscv/boot.c: make riscv_load_initrd() static
The only remaining caller is riscv_load_kernel_and_initrd() which belongs to the same file. Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20230206140022.2748401-4-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
This commit is contained in:
parent
487d73fc47
commit
8b64475bd5
|
@ -173,6 +173,46 @@ target_ulong riscv_load_firmware(const char *firmware_filename,
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry)
|
||||||
|
{
|
||||||
|
const char *filename = machine->initrd_filename;
|
||||||
|
uint64_t mem_size = machine->ram_size;
|
||||||
|
void *fdt = machine->fdt;
|
||||||
|
hwaddr start, end;
|
||||||
|
ssize_t size;
|
||||||
|
|
||||||
|
g_assert(filename != NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We want to put the initrd far enough into RAM that when the
|
||||||
|
* kernel is uncompressed it will not clobber the initrd. However
|
||||||
|
* on boards without much RAM we must ensure that we still leave
|
||||||
|
* enough room for a decent sized initrd, and on boards with large
|
||||||
|
* amounts of RAM we must avoid the initrd being so far up in RAM
|
||||||
|
* that it is outside lowmem and inaccessible to the kernel.
|
||||||
|
* So for boards with less than 256MB of RAM we put the initrd
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
size = load_ramdisk(filename, start, mem_size - start);
|
||||||
|
if (size == -1) {
|
||||||
|
size = load_image_targphys(filename, start, mem_size - start);
|
||||||
|
if (size == -1) {
|
||||||
|
error_report("could not load ramdisk '%s'", filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Some RISC-V machines (e.g. opentitan) don't have a fdt. */
|
||||||
|
if (fdt) {
|
||||||
|
end = start + size;
|
||||||
|
qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", start);
|
||||||
|
qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
target_ulong riscv_load_kernel(MachineState *machine,
|
target_ulong riscv_load_kernel(MachineState *machine,
|
||||||
RISCVHartArrayState *harts,
|
RISCVHartArrayState *harts,
|
||||||
target_ulong kernel_start_addr,
|
target_ulong kernel_start_addr,
|
||||||
|
@ -234,46 +274,6 @@ out:
|
||||||
return kernel_entry;
|
return kernel_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry)
|
|
||||||
{
|
|
||||||
const char *filename = machine->initrd_filename;
|
|
||||||
uint64_t mem_size = machine->ram_size;
|
|
||||||
void *fdt = machine->fdt;
|
|
||||||
hwaddr start, end;
|
|
||||||
ssize_t size;
|
|
||||||
|
|
||||||
g_assert(filename != NULL);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We want to put the initrd far enough into RAM that when the
|
|
||||||
* kernel is uncompressed it will not clobber the initrd. However
|
|
||||||
* on boards without much RAM we must ensure that we still leave
|
|
||||||
* enough room for a decent sized initrd, and on boards with large
|
|
||||||
* amounts of RAM we must avoid the initrd being so far up in RAM
|
|
||||||
* that it is outside lowmem and inaccessible to the kernel.
|
|
||||||
* So for boards with less than 256MB of RAM we put the initrd
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
size = load_ramdisk(filename, start, mem_size - start);
|
|
||||||
if (size == -1) {
|
|
||||||
size = load_image_targphys(filename, start, mem_size - start);
|
|
||||||
if (size == -1) {
|
|
||||||
error_report("could not load ramdisk '%s'", filename);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Some RISC-V machines (e.g. opentitan) don't have a fdt. */
|
|
||||||
if (fdt) {
|
|
||||||
end = start + size;
|
|
||||||
qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", start);
|
|
||||||
qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function makes an assumption that the DRAM interval
|
* This function makes an assumption that the DRAM interval
|
||||||
* 'dram_base' + 'dram_size' is contiguous.
|
* 'dram_base' + 'dram_size' is contiguous.
|
||||||
|
|
|
@ -48,7 +48,6 @@ target_ulong riscv_load_kernel(MachineState *machine,
|
||||||
target_ulong firmware_end_addr,
|
target_ulong firmware_end_addr,
|
||||||
bool load_initrd,
|
bool load_initrd,
|
||||||
symbol_fn_t sym_cb);
|
symbol_fn_t sym_cb);
|
||||||
void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry);
|
|
||||||
uint64_t riscv_compute_fdt_addr(hwaddr dram_start, uint64_t dram_size,
|
uint64_t riscv_compute_fdt_addr(hwaddr dram_start, uint64_t dram_size,
|
||||||
MachineState *ms);
|
MachineState *ms);
|
||||||
void riscv_load_fdt(hwaddr fdt_addr, void *fdt);
|
void riscv_load_fdt(hwaddr fdt_addr, void *fdt);
|
||||||
|
|
Loading…
Reference in New Issue