ppc/amigaone: Allow running AmigaOS without firmware image
PATCH v2 1/1 ppc/amigaone: Allow running AmigaOS without firmware image
The machine uses a modified U-Boot under GPL license but the sources of it are lost with only a binary available so it cannot be included in QEMU. Allow running without the firmware image with -bios none which can be used when calling a boot loader directly and thus simplifying booting guests. We need a small routine that AmigaOS calls from ROM which is added in this case to allow booting AmigaOS without external firmware image.
---
v2: Unfortunately AmigaOS needs some additional ROM part which is added Please merge for 8.2 as it allows booting AmigaOS simpler without having to download separate firmware.
hw/ppc/amigaone.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
hw/ppc/amigaone.c +17 -3
@@ -40,6 +40,16 @@#define PROM_ADDR 0xfff00000#define PROM_SIZE (512 * KiB) +/* AmigaOS calls this routine from ROM, use this if -bios none */ +static const char dummy_fw[] = { +0x38 ,0x00 ,0x00 ,0x08 ,/* li r0,8 */ +0x7c ,0x09 ,0x03 ,0xa6 ,/* mtctr r0 */ +0x54 ,0x63 ,0xf8 ,0x7e ,/* srwi r3,r3,1 */ +0x42 ,0x00 ,0xff ,0xfc ,/* bdnz 0x8 */ +0x7c ,0x63 ,0x18 ,0xf8 ,/* not r3,r3 */ +0x4e ,0x80 ,0x00 ,0x20 ,/* blr */ +}; +static void amigaone_cpu_reset (void *opaque) {PowerPCCPU *cpu = opaque;
@@ -94,17 +104,21 @@ static void amigaone_init(MachineState *machine) }/* allocate and load firmware */ + rom =g_new (MemoryRegion,1 ); +memory_region_init_rom (rom,NULL ,"rom" ,PROM_SIZE , &error_fatal); +memory_region_add_subregion (get_system_memory (),PROM_ADDR , rom); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , fwname);if (filename) { - rom =g_new (MemoryRegion,1 ); -memory_region_init_rom (rom,NULL ,"rom" ,PROM_SIZE , &error_fatal); -memory_region_add_subregion (get_system_memory (),PROM_ADDR , rom); sz =load_image_targphys (filename,PROM_ADDR ,PROM_SIZE );if (sz <=0 || sz >PROM_SIZE ) {error_report ("Could not load firmware '%s'" , filename);exit (1 ); }g_free (filename); + }else if (!strcmp (fwname,"none" )) { +address_space_write_rom (&address_space_memory,0xfff7ff80 , +MEMTXATTRS_UNSPECIFIED , dummy_fw, +ARRAY_SIZE (dummy_fw)); }else if (!qtest_enabled ()) {error_report ("Could not find firmware '%s'" , fwname);exit (1 );
Signature · 1 line
2.30.9
Quoted 8 lines · BALATON Zoltan
The machine uses a modified U-Boot under GPL license but the sources of it are lost with only a binary available so it cannot be included in QEMU. Allow running without the firmware image with -bios none which can be used when calling a boot loader directly and thus simplifying booting guests. We need a small routine that AmigaOS calls from ROM which is added in this case to allow booting AmigaOS without external firmware image.
Quoted 5 lines
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Unfortunately AmigaOS needs some additional ROM part which is added Please merge for 8.2 as it allows booting AmigaOS simpler without having to download separate firmware.
How to test this?
Quoted 11 lines
hw/ppc/amigaone.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)hw/ppc/amigaone.c +0
-0@@ -40,6 +40,16 @@#define PROM_ADDR 0xfff00000#define PROM_SIZE (512 * KiB)
hw/ppc/amigaone.c line 51
Quoted 10 lines
hw/ppc/amigaone.c +9
-0+/* AmigaOS calls this routine from ROM, use this if -bios none */ +static const char dummy_fw[] = { +0x38 ,0x00 ,0x00 ,0x08 ,/* li r0,8 */ +0x7c ,0x09 ,0x03 ,0xa6 ,/* mtctr r0 */ +0x54 ,0x63 ,0xf8 ,0x7e ,/* srwi r3,r3,1 */ +0x42 ,0x00 ,0xff ,0xfc ,/* bdnz 0x8 */ +0x7c ,0x63 ,0x18 ,0xf8 ,/* not r3,r3 */ +0x4e ,0x80 ,0x00 ,0x20 ,/* blr */ +};
This is clever, but does anything else create blobs like this? It could be put into a .S in pc-bios, which might be a bit more consistent.
We might make a ppc/ subdirectory under there, but that's for another time.
Thanks,
Nick
Quoted 29 lines
hw/ppc/amigaone.c +8
-3+static void amigaone_cpu_reset (void *opaque) {PowerPCCPU *cpu = opaque;@@ -94,17 +104,21 @@ static void amigaone_init(MachineState *machine) }/* allocate and load firmware */ + rom =g_new (MemoryRegion,1 ); +memory_region_init_rom (rom,NULL ,"rom" ,PROM_SIZE , &error_fatal); +memory_region_add_subregion (get_system_memory (),PROM_ADDR , rom); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , fwname);if (filename) { - rom =g_new (MemoryRegion,1 ); -memory_region_init_rom (rom,NULL ,"rom" ,PROM_SIZE , &error_fatal); -memory_region_add_subregion (get_system_memory (),PROM_ADDR , rom); sz =load_image_targphys (filename,PROM_ADDR ,PROM_SIZE );if (sz <=0 || sz >PROM_SIZE ) {error_report ("Could not load firmware '%s'" , filename);exit (1 ); }g_free (filename); + }else if (!strcmp (fwname,"none" )) { +address_space_write_rom (&address_space_memory,0xfff7ff80 , +MEMTXATTRS_UNSPECIFIED , dummy_fw, +ARRAY_SIZE (dummy_fw)); }else if (!qtest_enabled ()) {error_report ("Could not find firmware '%s'" , fwname);exit (1 );
Quoted 9 lines · Nicholas Piggin
Quoted 8 lines · BALATON Zoltan
The machine uses a modified U-Boot under GPL license but the sources of it are lost with only a binary available so it cannot be included in QEMU. Allow running without the firmware image with -bios none which can be used when calling a boot loader directly and thus simplifying booting guests. We need a small routine that AmigaOS calls from ROM which is added in this case to allow booting AmigaOS without external firmware image.
Quoted 7 lines
Quoted 5 lines
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Unfortunately AmigaOS needs some additional ROM part which is added Please merge for 8.2 as it allows booting AmigaOS simpler without having to download separate firmware.How to test this?
You can check with -M amigaone -bios none then from QEMU monitor (qemu) xp/10i 0xfff7ff80
Quoted 11 lines
Quoted 11 lines
hw/ppc/amigaone.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)hw/ppc/amigaone.c +0
-0@@ -40,6 +40,16 @@#define PROM_ADDR 0xfff00000#define PROM_SIZE (512 * KiB)
Quoted 11 lines
hw/ppc/amigaone.c line 51
Quoted 9 lines
hw/ppc/amigaone.c +9
-0+/* AmigaOS calls this routine from ROM, use this if -bios none */ +static const char dummy_fw[] = { +0x38 ,0x00 ,0x00 ,0x08 ,/* li r0,8 */ +0x7c ,0x09 ,0x03 ,0xa6 ,/* mtctr r0 */ +0x54 ,0x63 ,0xf8 ,0x7e ,/* srwi r3,r3,1 */ +0x42 ,0x00 ,0xff ,0xfc ,/* bdnz 0x8 */ +0x7c ,0x63 ,0x18 ,0xf8 ,/* not r3,r3 */ +0x4e ,0x80 ,0x00 ,0x20 ,/* blr */ +};This is clever, but does anything else create blobs like this?
There are some examples in hw/mips/{loongson3_virt.c, malta.c} at least and maybe others that put code in guest memory. If this was longer than this few instructions I'd consider putting it in a binary but this seems simpler for such small code.
Quoted 5 lines
It could be put into a .S in pc-bios, which might be a bit more consistent.
We might make a ppc/ subdirectory under there, but that's for another time.
Maybe later we could reorganise these unless it's really necessary to change this for 8.2 now. (The mips boards and some arm and riscv machines seem to use rom_add_blob_fixed() which sould show up in info roms under monitor so maybe I could look at changing to use that now if you think it would be better that way.)
Regards,
BALATON Zoltan
Quoted 35 lines
Thanks,
NickQuoted 29 lines
hw/ppc/amigaone.c +8
-3+static void amigaone_cpu_reset (void *opaque) {PowerPCCPU *cpu = opaque;@@ -94,17 +104,21 @@ static void amigaone_init(MachineState *machine) }/* allocate and load firmware */ + rom =g_new (MemoryRegion,1 ); +memory_region_init_rom (rom,NULL ,"rom" ,PROM_SIZE , &error_fatal); +memory_region_add_subregion (get_system_memory (),PROM_ADDR , rom); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , fwname);if (filename) { - rom =g_new (MemoryRegion,1 ); -memory_region_init_rom (rom,NULL ,"rom" ,PROM_SIZE , &error_fatal); -memory_region_add_subregion (get_system_memory (),PROM_ADDR , rom); sz =load_image_targphys (filename,PROM_ADDR ,PROM_SIZE );if (sz <=0 || sz >PROM_SIZE ) {error_report ("Could not load firmware '%s'" , filename);exit (1 ); }g_free (filename); + }else if (!strcmp (fwname,"none" )) { +address_space_write_rom (&address_space_memory,0xfff7ff80 , +MEMTXATTRS_UNSPECIFIED , dummy_fw, +ARRAY_SIZE (dummy_fw)); }else if (!qtest_enabled ()) {error_report ("Could not find firmware '%s'" , fwname);exit (1 );
Quoted 16 lines · BALATON Zoltan
Quoted 15 lines · Nicholas Piggin
Quoted 13 lines · BALATON Zoltan
The machine uses a modified U-Boot under GPL license but the sources of it are lost with only a binary available so it cannot be included in QEMU. Allow running without the firmware image with -bios none which can be used when calling a boot loader directly and thus simplifying booting guests. We need a small routine that AmigaOS calls from ROM which is added in this case to allow booting AmigaOS without external firmware image.
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Unfortunately AmigaOS needs some additional ROM part which is added Please merge for 8.2 as it allows booting AmigaOS simpler without having to download separate firmware.
Quoted 4 lines
Quoted 1 line
How to test this?
You can check with -M amigaone -bios none then from QEMU monitor (qemu) xp/10i
0xfff7ff80
Okay, so to fully test it you really need a non-free AmigaOS image?
And, how does a user know how or when to use this? Should it just be default if there is no bios binary found?
Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
hw/ppc/amigaone.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)hw/ppc/amigaone.c +0
-0@@ -40,6 +40,16 @@#define PROM_ADDR 0xfff00000#define PROM_SIZE (512 * KiB)Quoted 11 lines
hw/ppc/amigaone.c line 51
Quoted 9 lines
hw/ppc/amigaone.c +9
-0+/* AmigaOS calls this routine from ROM, use this if -bios none */ +static const char dummy_fw[] = { +0x38 ,0x00 ,0x00 ,0x08 ,/* li r0,8 */ +0x7c ,0x09 ,0x03 ,0xa6 ,/* mtctr r0 */ +0x54 ,0x63 ,0xf8 ,0x7e ,/* srwi r3,r3,1 */ +0x42 ,0x00 ,0xff ,0xfc ,/* bdnz 0x8 */ +0x7c ,0x63 ,0x18 ,0xf8 ,/* not r3,r3 */ +0x4e ,0x80 ,0x00 ,0x20 ,/* blr */ +};This is clever, but does anything else create blobs like this?
Quoted 4 lines
There are some examples in
hw/mips/{loongson3_virt.c,malta.c} at least and maybe others that put code in guest memory. If this was longer than this few instructions I'd consider putting it in a binary but this seems simpler for such small code.
Thanks, compiling blob inline looks fine then.
It's 0x80 bytes from the end of prom AFAIKS. Should you make that PROM_ADDR + PROM_SIZE - 0x80 instead of hard coding it?
Quoted 9 lines
Quoted 6 lines
It could be put into a .S in pc-bios, which might be a bit more consistent.
We might make a ppc/ subdirectory under there, but that's for another time.
Maybe later we could reorganise these unless it's really necessary to change this for 8.2 now.
Nah that's fine.
Quoted 4 lines
(The mips boards and some arm and riscv machines
seem to userom_add_blob_fixed()which sould show up in info roms under monitor so maybe I could look at changing to use that now if you think it would be better that way.)
I'm not sure, I don't think it's necessary if your minimal patch works.
I'll do a PR for 8.2 for SLOF and Skiboot updates, so happy to include this as well.
Thanks,
Nick
Quoted 39 lines
Regards,
BALATON ZoltanQuoted 35 lines
Thanks,
NickQuoted 29 lines
hw/ppc/amigaone.c +8
-3+static void amigaone_cpu_reset (void *opaque) {PowerPCCPU *cpu = opaque;@@ -94,17 +104,21 @@ static void amigaone_init(MachineState *machine) }/* allocate and load firmware */ + rom =g_new (MemoryRegion,1 ); +memory_region_init_rom (rom,NULL ,"rom" ,PROM_SIZE , &error_fatal); +memory_region_add_subregion (get_system_memory (),PROM_ADDR , rom); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , fwname);if (filename) { - rom =g_new (MemoryRegion,1 ); -memory_region_init_rom (rom,NULL ,"rom" ,PROM_SIZE , &error_fatal); -memory_region_add_subregion (get_system_memory (),PROM_ADDR , rom); sz =load_image_targphys (filename,PROM_ADDR ,PROM_SIZE );if (sz <=0 || sz >PROM_SIZE ) {error_report ("Could not load firmware '%s'" , filename);exit (1 ); }g_free (filename); + }else if (!strcmp (fwname,"none" )) { +address_space_write_rom (&address_space_memory,0xfff7ff80 , +MEMTXATTRS_UNSPECIFIED , dummy_fw, +ARRAY_SIZE (dummy_fw)); }else if (!qtest_enabled ()) {error_report ("Could not find firmware '%s'" , fwname);exit (1 );
Quoted 17 lines · Nicholas Piggin
Quoted 16 lines · BALATON Zoltan
Quoted 15 lines · Nicholas Piggin
Quoted 13 lines · BALATON Zoltan
The machine uses a modified U-Boot under GPL license but the sources of it are lost with only a binary available so it cannot be included in QEMU. Allow running without the firmware image with -bios none which can be used when calling a boot loader directly and thus simplifying booting guests. We need a small routine that AmigaOS calls from ROM which is added in this case to allow booting AmigaOS without external firmware image.
Signed-off-by BALATON Zoltan <[email protected]>---
v2: Unfortunately AmigaOS needs some additional ROM part which is added Please merge for 8.2 as it allows booting AmigaOS simpler without having to download separate firmware.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
How to test this?
You can check with -M amigaone -bios none then from QEMU monitor (qemu) xp/10i
0xfff7ff80Okay, so to fully test it you really need a non-free AmigaOS image?
I'm afraid yes, it's hard to test without AmigaOS otherwise as that's the only thing that seems to need this.
Quoted 2 lines
And, how does a user know how or when to use this? Should it just be default if there is no bios binary found?
It could be the default without -bios, that could also allow removing the qtest special case than. Maybe it's easier for users so I'll change that in v2.
Quoted 28 lines
Quoted 23 lines
Quoted 11 lines
Quoted 11 lines
hw/ppc/amigaone.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)hw/ppc/amigaone.c +0
-0@@ -40,6 +40,16 @@#define PROM_ADDR 0xfff00000#define PROM_SIZE (512 * KiB)Quoted 11 lines
hw/ppc/amigaone.c line 51
Quoted 9 lines
hw/ppc/amigaone.c +9
-0+/* AmigaOS calls this routine from ROM, use this if -bios none */ +static const char dummy_fw[] = { +0x38 ,0x00 ,0x00 ,0x08 ,/* li r0,8 */ +0x7c ,0x09 ,0x03 ,0xa6 ,/* mtctr r0 */ +0x54 ,0x63 ,0xf8 ,0x7e ,/* srwi r3,r3,1 */ +0x42 ,0x00 ,0xff ,0xfc ,/* bdnz 0x8 */ +0x7c ,0x63 ,0x18 ,0xf8 ,/* not r3,r3 */ +0x4e ,0x80 ,0x00 ,0x20 ,/* blr */ +};This is clever, but does anything else create blobs like this?
Quoted 4 lines
There are some examples in
hw/mips/{loongson3_virt.c,malta.c} at least and maybe others that put code in guest memory. If this was longer than this few instructions I'd consider putting it in a binary but this seems simpler for such small code.
Quoted 4 lines
Thanks, compiling blob inline looks fine then.
It's
0x80bytes from the end of prom AFAIKS. Should you make thatPROM_ADDR+PROM_SIZE-0x80instead of hard coding it?
I thought about that after sending the patch, I'll change it too.
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
It could be put into a .S in pc-bios, which might be a bit more consistent.
We might make a ppc/ subdirectory under there, but that's for another time.
Maybe later we could reorganise these unless it's really necessary to change this for 8.2 now.
Quoted 8 lines
Nah that's fine.
Quoted 4 lines
(The mips boards and some arm and riscv machines
seem to userom_add_blob_fixed()which sould show up in info roms under monitor so maybe I could look at changing to use that now if you think it would be better that way.)I'm not sure, I don't think it's necessary if your minimal patch works.
It works but just for consistency with other similar machines I'll consider trying rom_add_blob_fixed() now that there will be another iteration.
Quoted 2 lines
I'll do a PR for 8.2 for SLOF and Skiboot updates, so happy to include this as well.
Thanks, I'll only have time to do a v2 later but still before the next rc due tomorrow.
There are some more data around this function in ROM that I'm not sure would be needed but don't know how to verify what AmigaOS accesses. I've tried enabling memory_region* traces but those only seem to log io regions, ram and rom region accesses are probably just memory reads so not traced. Then I've tried adding watch points in gdb like this:
(gdb) watch *(char [0x80000])*0xfff00000
value requires 524288 bytes, which is more than max-value-size (gdb) show max-value-size
Maximum value size is 65536 bytes.
(gdb) watch *(char [0x10000])*0xfff00000
Hardware watchpoint 1: *(char [0x10000])*0xfff00000 (gdb) watch *(char [0x10000])*0xfff10000
Hardware watchpoint 2: *(char [0x10000])*0xfff10000 (gdb) watch *(char [0x10000])*0xfff20000
Hardware watchpoint 3: *(char [0x10000])*0xfff20000 (gdb) watch *(char [0x10000])*0xfff30000
Hardware watchpoint 4: *(char [0x10000])*0xfff30000 (gdb) watch *(char [0x10000])*0xfff40000
Hardware watchpoint 5: *(char [0x10000])*0xfff40000 (gdb) watch *(char [0x10000])*0xfff50000
Hardware watchpoint 6: *(char [0x10000])*0xfff50000 (gdb) watch *(char [0x10000])*0xfff60000
Hardware watchpoint 7: *(char [0x10000])*0xfff60000 (gdb) watch *(char [0x10000])*0xfff70000
Hardware watchpoint 8: *(char [0x10000])*0xfff70000
but they are not firing even for the code known to be accessed so not sure how to trace rom access. Maybe I'll need to temporarily make it an io region to be able to trace access to it. Any better idea for that? That way I could check that no other parts of the rom are needed. With just this routine it boots but wanted to make sure nothing else is needed later.
Regards,
BALATON Zoltan
Quoted 5 lines
I'm not sure, I don't think it's necessary if your minimal patch works.
I'll do a PR for 8.2 for SLOF and Skiboot updates, so happy to include this as well.
I think this is a bit late for 8.2 to change FW images, well, at least SLOF and skiboot. Are the new versions fixing something critical ?
Thanks,
C.
Quoted 8 lines · Cédric Le Goater
Quoted 5 lines
I'm not sure, I don't think it's necessary if your minimal patch works.
I'll do a PR for 8.2 for SLOF and Skiboot updates, so happy to include this as well.
I think this is a bit late for 8.2 to change FW images, well, at least SLOF and skiboot. Are the new versions fixing something critical ?
Ah okay. Well then I can put them in next instead.
SLOF has a fix for virtio console over reboots, pretty minimal. skiboot has some bug fixes but it's a bigger change and maybe not so important for QEMU.
Could they be merged in next release and SLOF tagged with stable?
I think this amigaone patch could still be merged since it's only touching a new machine and it's fixing an issue of missing firmware.
Thanks,
Nick
Quoted 7 lines · Nicholas Piggin
Quoted 6 lines · Cédric Le Goater
Quoted 5 lines
I'm not sure, I don't think it's necessary if your minimal patch works.
I'll do a PR for 8.2 for SLOF and Skiboot updates, so happy to include this as well.
Quoted 6 lines
Quoted 2 lines
I think this is a bit late for 8.2 to change FW images, well, at least SLOF and skiboot. Are the new versions fixing something critical ?
Ah okay. Well then I can put them in next instead.
SLOF has a fix for virtio console over reboots, pretty minimal.
I see that commit dd4d4ea0add9 has :
Looks good for 8.2
Quoted 2 lines
skiboot has some bug fixes but it's a bigger change and maybe not so important for QEMU.> Could they be merged in next release
yes. it seems skiboot should be merged with chiptod support in 9.0.
Quoted 4 lines
and SLOF tagged with stable?
I think this amigaone patch could still be merged since it's only touching a new machine and it's fixing an issue of missing firmware.
ARM does something similar with roms. See hw/arm/boot.c file.
It will need a "Fixes" tag.
Thanks,
C.
Quoted 9 lines · Cédric Le Goater
Quoted 6 lines · Nicholas Piggin
Quoted 5 lines · Cédric Le Goater
Quoted 5 lines
I'm not sure, I don't think it's necessary if your minimal patch works.
I'll do a PR for 8.2 for SLOF and Skiboot updates, so happy to include this as well.
Quoted 6 lines
Quoted 2 lines
I think this amigaone patch could still be merged since it's only touching a new machine and it's fixing an issue of missing firmware.
ARM does something similar with roms. See
hw/arm/boot.cfile.It will need a "Fixes" tag.
Quoted 26 lines · Cédric Le Goater
Quoted 7 lines · Nicholas Piggin
Quoted 6 lines · Cédric Le Goater
Quoted 5 lines
I'm not sure, I don't think it's necessary if your minimal patch works.
I'll do a PR for 8.2 for SLOF and Skiboot updates, so happy to include this as well.
Quoted 6 lines
Quoted 2 lines
I think this is a bit late for 8.2 to change FW images, well, at least SLOF and skiboot. Are the new versions fixing something critical ?
Ah okay. Well then I can put them in next instead.
SLOF has a fix for virtio console over reboots, pretty minimal.
I see that commit
dd4d4ea0add9has :Fixes cf28264 ("virtio-serial: Rework shutdown sequence")Looks good for 8.2
Quoted 2 lines
skiboot has some bug fixes but it's a bigger change and maybe not so important for QEMU.> Could they be merged in next release
yes. it seems skiboot should be merged with chiptod support in 9.0.
Quoted 8 lines
Quoted 4 lines
and SLOF tagged with stable?
I think this amigaone patch could still be merged since it's only touching a new machine and it's fixing an issue of missing firmware.
ARM does something similar with roms. See
hw/arm/boot.cfile.It will need a "Fixes" tag.
That would be
as the only commit for this machine so far was the one that added it.
Regards,
BALATON Zoltan