Skip to content

Commit d69fcbd

Browse files
danielhbalistair23
authored andcommitted
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 <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Bin Meng <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Message-Id: <[email protected]> Signed-off-by: Alistair Francis <[email protected]>
1 parent 1246022 commit d69fcbd

File tree

2 files changed

+40
-41
lines changed

2 files changed

+40
-41
lines changed

hw/riscv/boot.c

+40-40
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,46 @@ target_ulong riscv_load_firmware(const char *firmware_filename,
173173
exit(1);
174174
}
175175

176+
static void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry)
177+
{
178+
const char *filename = machine->initrd_filename;
179+
uint64_t mem_size = machine->ram_size;
180+
void *fdt = machine->fdt;
181+
hwaddr start, end;
182+
ssize_t size;
183+
184+
g_assert(filename != NULL);
185+
186+
/*
187+
* We want to put the initrd far enough into RAM that when the
188+
* kernel is uncompressed it will not clobber the initrd. However
189+
* on boards without much RAM we must ensure that we still leave
190+
* enough room for a decent sized initrd, and on boards with large
191+
* amounts of RAM we must avoid the initrd being so far up in RAM
192+
* that it is outside lowmem and inaccessible to the kernel.
193+
* So for boards with less than 256MB of RAM we put the initrd
194+
* halfway into RAM, and for boards with 256MB of RAM or more we put
195+
* the initrd at 128MB.
196+
*/
197+
start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
198+
199+
size = load_ramdisk(filename, start, mem_size - start);
200+
if (size == -1) {
201+
size = load_image_targphys(filename, start, mem_size - start);
202+
if (size == -1) {
203+
error_report("could not load ramdisk '%s'", filename);
204+
exit(1);
205+
}
206+
}
207+
208+
/* Some RISC-V machines (e.g. opentitan) don't have a fdt. */
209+
if (fdt) {
210+
end = start + size;
211+
qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", start);
212+
qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", end);
213+
}
214+
}
215+
176216
target_ulong riscv_load_kernel(MachineState *machine,
177217
RISCVHartArrayState *harts,
178218
target_ulong kernel_start_addr,
@@ -234,46 +274,6 @@ target_ulong riscv_load_kernel(MachineState *machine,
234274
return kernel_entry;
235275
}
236276

237-
void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry)
238-
{
239-
const char *filename = machine->initrd_filename;
240-
uint64_t mem_size = machine->ram_size;
241-
void *fdt = machine->fdt;
242-
hwaddr start, end;
243-
ssize_t size;
244-
245-
g_assert(filename != NULL);
246-
247-
/*
248-
* We want to put the initrd far enough into RAM that when the
249-
* kernel is uncompressed it will not clobber the initrd. However
250-
* on boards without much RAM we must ensure that we still leave
251-
* enough room for a decent sized initrd, and on boards with large
252-
* amounts of RAM we must avoid the initrd being so far up in RAM
253-
* that it is outside lowmem and inaccessible to the kernel.
254-
* So for boards with less than 256MB of RAM we put the initrd
255-
* halfway into RAM, and for boards with 256MB of RAM or more we put
256-
* the initrd at 128MB.
257-
*/
258-
start = kernel_entry + MIN(mem_size / 2, 128 * MiB);
259-
260-
size = load_ramdisk(filename, start, mem_size - start);
261-
if (size == -1) {
262-
size = load_image_targphys(filename, start, mem_size - start);
263-
if (size == -1) {
264-
error_report("could not load ramdisk '%s'", filename);
265-
exit(1);
266-
}
267-
}
268-
269-
/* Some RISC-V machines (e.g. opentitan) don't have a fdt. */
270-
if (fdt) {
271-
end = start + size;
272-
qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", start);
273-
qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", end);
274-
}
275-
}
276-
277277
/*
278278
* This function makes an assumption that the DRAM interval
279279
* 'dram_base' + 'dram_size' is contiguous.

include/hw/riscv/boot.h

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ target_ulong riscv_load_kernel(MachineState *machine,
4848
target_ulong firmware_end_addr,
4949
bool load_initrd,
5050
symbol_fn_t sym_cb);
51-
void riscv_load_initrd(MachineState *machine, uint64_t kernel_entry);
5251
uint64_t riscv_compute_fdt_addr(hwaddr dram_start, uint64_t dram_size,
5352
MachineState *ms);
5453
void riscv_load_fdt(hwaddr fdt_addr, void *fdt);

0 commit comments

Comments
 (0)