* [PATCH 0/2] hw/mips/boston: Initrd support
@ 2022-08-13 16:27 Jiaxun Yang
2022-08-13 16:27 ` [PATCH 1/2] hw/mips/boston: Support initrd for ELF kernel Jiaxun Yang
2022-08-13 16:27 ` [PATCH 2/2] hw/mips/boston: Pack fdt in fdt filter Jiaxun Yang
0 siblings, 2 replies; 6+ messages in thread
From: Jiaxun Yang @ 2022-08-13 16:27 UTC (permalink / raw)
To: f4bug; +Cc: qemu-devel, Jiaxun Yang
Hi all,
Just a small addition to make boston board easier to use :-)
Thanks
- Jiaxun
Jiaxun Yang (2):
mips/boston: Support initrd for ELF kernel
hw/mips/boston: Pack fdt in fdt filter
hw/mips/boston.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
--
2.32.1 (Apple Git-133)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] hw/mips/boston: Support initrd for ELF kernel
2022-08-13 16:27 [PATCH 0/2] hw/mips/boston: Initrd support Jiaxun Yang
@ 2022-08-13 16:27 ` Jiaxun Yang
2022-08-13 16:27 ` [PATCH 2/2] hw/mips/boston: Pack fdt in fdt filter Jiaxun Yang
1 sibling, 0 replies; 6+ messages in thread
From: Jiaxun Yang @ 2022-08-13 16:27 UTC (permalink / raw)
To: f4bug; +Cc: qemu-devel, Jiaxun Yang
When loading ELF kernel we can just load out initrd after DTB
and append initrd information to DeviceTree's chosen node.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
hw/mips/boston.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index d2ab9da1a0..5145179951 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -73,6 +73,8 @@ struct BostonState {
hwaddr kernel_entry;
hwaddr fdt_base;
+ hwaddr initrd_base;
+ hwaddr initrd_end;
};
enum {
@@ -383,6 +385,14 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
return NULL;
}
+ if (s->initrd_base) {
+ qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
+ s->initrd_base);
+
+ qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
+ s->initrd_end);
+ }
+
ram_low_sz = MIN(256 * MiB, machine->ram_size);
ram_high_sz = machine->ram_size - ram_low_sz;
qemu_fdt_setprop_sized_cells(fdt, "/memory@0", "reg",
@@ -804,6 +814,35 @@ static void boston_mach_init(MachineState *machine)
dtb_file_data = create_fdt(s, boston_memmap, &dt_size);
}
+ if (machine->initrd_filename) {
+ /* We want to leave low 128 MiB memory for kernelrelocation */
+ hwaddr initrd_paddr = MAX(128 * MiB,
+ QEMU_ALIGN_UP(dtb_paddr + dt_size,
+ 64 * KiB));
+ int maxsz = boston_memmap[BOSTON_LOWDDR].size - initrd_paddr;
+
+ if (maxsz <= 0) {
+ error_report("no space left for ramdisk '%s'",
+ machine->initrd_filename);
+ exit(1);
+ }
+
+ int size = load_ramdisk(machine->initrd_filename,
+ initrd_paddr, maxsz);
+ if (size < 0) {
+ size = load_image_targphys(machine->initrd_filename,
+ initrd_paddr, maxsz);
+ if (size < 0) {
+ error_report("could not load ramdisk '%s'",
+ machine->initrd_filename);
+ exit(1);
+ }
+ }
+
+ s->initrd_base = initrd_paddr;
+ s->initrd_end = s->initrd_base + size;
+ }
+
dtb_load_data = boston_fdt_filter(s, dtb_file_data,
NULL, &dtb_vaddr);
--
2.32.1 (Apple Git-133)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] hw/mips/boston: Pack fdt in fdt filter
2022-08-13 16:27 [PATCH 0/2] hw/mips/boston: Initrd support Jiaxun Yang
2022-08-13 16:27 ` [PATCH 1/2] hw/mips/boston: Support initrd for ELF kernel Jiaxun Yang
@ 2022-08-13 16:27 ` Jiaxun Yang
2022-08-16 0:44 ` Philippe Mathieu-Daudé via
1 sibling, 1 reply; 6+ messages in thread
From: Jiaxun Yang @ 2022-08-13 16:27 UTC (permalink / raw)
To: f4bug; +Cc: qemu-devel, Jiaxun Yang
FDT can be awfully fat after series of modifications in fdt
filter. Just pack it up before add to ram.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
hw/mips/boston.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 5145179951..a40f193f78 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -400,6 +400,7 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
1, boston_memmap[BOSTON_HIGHDDR].base + ram_low_sz,
1, ram_high_sz);
+ fdt_pack(fdt);
fdt = g_realloc(fdt, fdt_totalsize(fdt));
qemu_fdt_dumpdtb(fdt, fdt_sz);
--
2.32.1 (Apple Git-133)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] hw/mips/boston: Pack fdt in fdt filter
2022-08-13 16:27 ` [PATCH 2/2] hw/mips/boston: Pack fdt in fdt filter Jiaxun Yang
@ 2022-08-16 0:44 ` Philippe Mathieu-Daudé via
2022-08-16 11:46 ` Jiaxun Yang
0 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-08-16 0:44 UTC (permalink / raw)
To: Jiaxun Yang; +Cc: qemu-devel, David Gibson, Alistair Francis
On 13/8/22 18:27, Jiaxun Yang wrote:
> FDT can be awfully fat after series of modifications in fdt
> filter. Just pack it up before add to ram.
>
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> hw/mips/boston.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/hw/mips/boston.c b/hw/mips/boston.c
> index 5145179951..a40f193f78 100644
> --- a/hw/mips/boston.c
> +++ b/hw/mips/boston.c
> @@ -400,6 +400,7 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
> 1, boston_memmap[BOSTON_HIGHDDR].base + ram_low_sz,
> 1, ram_high_sz);
>
> + fdt_pack(fdt);
> fdt = g_realloc(fdt, fdt_totalsize(fdt));
> qemu_fdt_dumpdtb(fdt, fdt_sz);
>
Why not pack by default in qemu_fdt_dumpdtb()?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] hw/mips/boston: Pack fdt in fdt filter
2022-08-16 0:44 ` Philippe Mathieu-Daudé via
@ 2022-08-16 11:46 ` Jiaxun Yang
2022-08-18 2:48 ` David Gibson
0 siblings, 1 reply; 6+ messages in thread
From: Jiaxun Yang @ 2022-08-16 11:46 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, David Gibson, Alistair Francis
> 2022年8月16日 01:44,Philippe Mathieu-Daudé <f4bug@amsat.org> 写道:
>
> On 13/8/22 18:27, Jiaxun Yang wrote:
>> FDT can be awfully fat after series of modifications in fdt
>> filter. Just pack it up before add to ram.
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> ---
>> hw/mips/boston.c | 1 +
>> 1 file changed, 1 insertion(+)
>> diff --git a/hw/mips/boston.c b/hw/mips/boston.c
>> index 5145179951..a40f193f78 100644
>> --- a/hw/mips/boston.c
>> +++ b/hw/mips/boston.c
>> @@ -400,6 +400,7 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
>> 1, boston_memmap[BOSTON_HIGHDDR].base + ram_low_sz,
>> 1, ram_high_sz);
>> + fdt_pack(fdt);
>> fdt = g_realloc(fdt, fdt_totalsize(fdt));
>> qemu_fdt_dumpdtb(fdt, fdt_sz);
>>
>
> Why not pack by default in qemu_fdt_dumpdtb()?
qemu_fdt_dumpdtb() is explicitly a function for debugging purpose.
Donno if it’s wise to hijack it.
Thanks.
---
Jiaxun Yang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] hw/mips/boston: Pack fdt in fdt filter
2022-08-16 11:46 ` Jiaxun Yang
@ 2022-08-18 2:48 ` David Gibson
0 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2022-08-18 2:48 UTC (permalink / raw)
To: Jiaxun Yang; +Cc: Philippe Mathieu-Daudé, qemu-devel, Alistair Francis
[-- Attachment #1: Type: text/plain, Size: 1401 bytes --]
On Tue, Aug 16, 2022 at 12:46:46PM +0100, Jiaxun Yang wrote:
>
>
> > 2022年8月16日 01:44,Philippe Mathieu-Daudé <f4bug@amsat.org> 写道:
> >
> > On 13/8/22 18:27, Jiaxun Yang wrote:
> >> FDT can be awfully fat after series of modifications in fdt
> >> filter. Just pack it up before add to ram.
> >> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> >> ---
> >> hw/mips/boston.c | 1 +
> >> 1 file changed, 1 insertion(+)
> >> diff --git a/hw/mips/boston.c b/hw/mips/boston.c
> >> index 5145179951..a40f193f78 100644
> >> --- a/hw/mips/boston.c
> >> +++ b/hw/mips/boston.c
> >> @@ -400,6 +400,7 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
> >> 1, boston_memmap[BOSTON_HIGHDDR].base + ram_low_sz,
> >> 1, ram_high_sz);
> >> + fdt_pack(fdt);
> >> fdt = g_realloc(fdt, fdt_totalsize(fdt));
> >> qemu_fdt_dumpdtb(fdt, fdt_sz);
> >>
> >
> > Why not pack by default in qemu_fdt_dumpdtb()?
>
> qemu_fdt_dumpdtb() is explicitly a function for debugging purpose.
> Donno if it’s wise to hijack it.
Agreed. Having this modify the dtb sounds like a very bad idea.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-08-18 6:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-13 16:27 [PATCH 0/2] hw/mips/boston: Initrd support Jiaxun Yang
2022-08-13 16:27 ` [PATCH 1/2] hw/mips/boston: Support initrd for ELF kernel Jiaxun Yang
2022-08-13 16:27 ` [PATCH 2/2] hw/mips/boston: Pack fdt in fdt filter Jiaxun Yang
2022-08-16 0:44 ` Philippe Mathieu-Daudé via
2022-08-16 11:46 ` Jiaxun Yang
2022-08-18 2:48 ` David Gibson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.