[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 10/10] hw/riscv/boot.c: make riscv_load_initrd() static
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH v2 10/10] hw/riscv/boot.c: make riscv_load_initrd() static |
Date: |
Wed, 28 Dec 2022 09:42:42 -0300 |
The only remaining caller is riscv_load_kernel() 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>
---
hw/riscv/boot.c | 76 ++++++++++++++++++++---------------------
include/hw/riscv/boot.h | 1 -
2 files changed, 38 insertions(+), 39 deletions(-)
diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
index 95f780a228..87c4e5f3a2 100644
--- a/hw/riscv/boot.c
+++ b/hw/riscv/boot.c
@@ -171,6 +171,44 @@ target_ulong riscv_load_firmware(const char
*firmware_filename,
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;
+
+ /*
+ * 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 kernel_start_addr,
symbol_fn_t sym_cb)
@@ -220,44 +258,6 @@ out:
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;
-
- /*
- * 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);
- }
-}
-
uint64_t riscv_load_fdt(hwaddr dram_base, uint64_t mem_size, void *fdt)
{
uint64_t temp, fdt_addr;
diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h
index f94653a09b..afebc50830 100644
--- a/include/hw/riscv/boot.h
+++ b/include/hw/riscv/boot.h
@@ -46,7 +46,6 @@ target_ulong riscv_load_firmware(const char
*firmware_filename,
target_ulong riscv_load_kernel(MachineState *machine,
target_ulong firmware_end_addr,
symbol_fn_t sym_cb);
-void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry);
uint64_t riscv_load_fdt(hwaddr dram_start, uint64_t dram_size, void *fdt);
void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState
*harts,
hwaddr saddr,
--
2.38.1
- [PATCH v2 00/10] riscv: opensbi boot test and cleanups, Daniel Henrique Barboza, 2022/12/28
- [PATCH v2 01/10] tests/avocado: add RISC-V opensbi boot test, Daniel Henrique Barboza, 2022/12/28
- [PATCH v2 04/10] hw/riscv/spike.c: load initrd right after riscv_load_kernel(), Daniel Henrique Barboza, 2022/12/28
- [PATCH v2 03/10] hw/riscv/sifive_u: use 'fdt' from MachineState, Daniel Henrique Barboza, 2022/12/28
- [PATCH v2 06/10] hw/riscv: write bootargs 'chosen' FDT after riscv_load_kernel(), Daniel Henrique Barboza, 2022/12/28
- [PATCH v2 02/10] hw/riscv/spike: use 'fdt' from MachineState, Daniel Henrique Barboza, 2022/12/28
- [PATCH v2 05/10] hw/riscv: write initrd 'chosen' FDT inside riscv_load_initrd(), Daniel Henrique Barboza, 2022/12/28
- [PATCH v2 07/10] hw/riscv/boot.c: use MachineState in riscv_load_initrd(), Daniel Henrique Barboza, 2022/12/28
- [PATCH v2 10/10] hw/riscv/boot.c: make riscv_load_initrd() static,
Daniel Henrique Barboza <=
- [PATCH v2 08/10] hw/riscv/boot.c: use MachineState in riscv_load_kernel(), Daniel Henrique Barboza, 2022/12/28
- [PATCH v2 09/10] hw/riscv/boot.c: consolidate all kernel init in riscv_load_kernel(), Daniel Henrique Barboza, 2022/12/28