* [PATCH v3] ppc/amigaone: Allow running AmigaOS without firmware image
@ 2023-11-28 1:32 BALATON Zoltan
2023-11-28 12:47 ` Cédric Le Goater
0 siblings, 1 reply; 5+ messages in thread
From: BALATON Zoltan @ 2023-11-28 1:32 UTC (permalink / raw)
To: qemu-devel, qemu-ppc
Cc: Nicholas Piggin, Daniel Henrique Barboza, clg, philmd
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 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 <balaton@eik.bme.hu>
---
v3: Instead of -bios none do this when no -bios option given, use
constants for address and rom_add_blob_fixed() to add dummy_fw.
This makes both code and usage a bit simpler.
hw/ppc/amigaone.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/hw/ppc/amigaone.c b/hw/ppc/amigaone.c
index 992a55e632..ddfa09457a 100644
--- a/hw/ppc/amigaone.c
+++ b/hw/ppc/amigaone.c
@@ -36,10 +36,19 @@
* -device VGA,romfile=VGABIOS-lgpl-latest.bin
* from http://www.nongnu.org/vgabios/ instead.
*/
-#define PROM_FILENAME "u-boot-amigaone.bin"
#define PROM_ADDR 0xfff00000
#define PROM_SIZE (512 * KiB)
+/* AmigaOS calls this routine from ROM, use this if no firmware loaded */
+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;
@@ -60,8 +69,6 @@ static void amigaone_init(MachineState *machine)
PowerPCCPU *cpu;
CPUPPCState *env;
MemoryRegion *rom, *pci_mem, *mr;
- const char *fwname = machine->firmware ?: PROM_FILENAME;
- char *filename;
ssize_t sz;
PCIBus *pci_bus;
Object *via;
@@ -94,20 +101,24 @@ static void amigaone_init(MachineState *machine)
}
/* allocate and load firmware */
- 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);
+ 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);
+ if (!machine->firmware) {
+ rom_add_blob_fixed("dummy-fw", dummy_fw, sizeof(dummy_fw),
+ PROM_ADDR + PROM_SIZE - 0x80);
+ } else {
+ g_autofree char *filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
+ machine->firmware);
+ if (!filename) {
+ error_report("Could not find firmware '%s'", machine->firmware);
+ exit(1);
+ }
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 (!qtest_enabled()) {
- error_report("Could not find firmware '%s'", fwname);
- exit(1);
}
/* Articia S */
--
2.30.9
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v3] ppc/amigaone: Allow running AmigaOS without firmware image
2023-11-28 1:32 [PATCH v3] ppc/amigaone: Allow running AmigaOS without firmware image BALATON Zoltan
@ 2023-11-28 12:47 ` Cédric Le Goater
2023-11-29 22:49 ` BALATON Zoltan
0 siblings, 1 reply; 5+ messages in thread
From: Cédric Le Goater @ 2023-11-28 12:47 UTC (permalink / raw)
To: BALATON Zoltan, qemu-devel, qemu-ppc
Cc: Nicholas Piggin, Daniel Henrique Barboza, philmd
On 11/28/23 02:32, BALATON Zoltan wrote:
> 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 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 <balaton@eik.bme.hu>
Since this is 8.2 material :
Fixes: d9656f860a38 ("hw/ppc: Add emulation of AmigaOne XE board")
Thanks,
C.
> ---
> v3: Instead of -bios none do this when no -bios option given, use
> constants for address and rom_add_blob_fixed() to add dummy_fw.
> This makes both code and usage a bit simpler.
>
> hw/ppc/amigaone.c | 35 +++++++++++++++++++++++------------
> 1 file changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/hw/ppc/amigaone.c b/hw/ppc/amigaone.c
> index 992a55e632..ddfa09457a 100644
> --- a/hw/ppc/amigaone.c
> +++ b/hw/ppc/amigaone.c
> @@ -36,10 +36,19 @@
> * -device VGA,romfile=VGABIOS-lgpl-latest.bin
> * from http://www.nongnu.org/vgabios/ instead.
> */
> -#define PROM_FILENAME "u-boot-amigaone.bin"
> #define PROM_ADDR 0xfff00000
> #define PROM_SIZE (512 * KiB)
>
> +/* AmigaOS calls this routine from ROM, use this if no firmware loaded */
> +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;
> @@ -60,8 +69,6 @@ static void amigaone_init(MachineState *machine)
> PowerPCCPU *cpu;
> CPUPPCState *env;
> MemoryRegion *rom, *pci_mem, *mr;
> - const char *fwname = machine->firmware ?: PROM_FILENAME;
> - char *filename;
> ssize_t sz;
> PCIBus *pci_bus;
> Object *via;
> @@ -94,20 +101,24 @@ static void amigaone_init(MachineState *machine)
> }
>
> /* allocate and load firmware */
> - 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);
> + 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);
> + if (!machine->firmware) {
> + rom_add_blob_fixed("dummy-fw", dummy_fw, sizeof(dummy_fw),
> + PROM_ADDR + PROM_SIZE - 0x80);
> + } else {
> + g_autofree char *filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
> + machine->firmware);
> + if (!filename) {
> + error_report("Could not find firmware '%s'", machine->firmware);
> + exit(1);
> + }
> 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 (!qtest_enabled()) {
> - error_report("Could not find firmware '%s'", fwname);
> - exit(1);
> }
>
> /* Articia S */
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3] ppc/amigaone: Allow running AmigaOS without firmware image
2023-11-28 12:47 ` Cédric Le Goater
@ 2023-11-29 22:49 ` BALATON Zoltan
2023-11-30 11:03 ` Nicholas Piggin
0 siblings, 1 reply; 5+ messages in thread
From: BALATON Zoltan @ 2023-11-29 22:49 UTC (permalink / raw)
To: Nicholas Piggin
Cc: qemu-devel, qemu-ppc, Cédric Le Goater,
Daniel Henrique Barboza, philmd
[-- Attachment #1: Type: text/plain, Size: 4186 bytes --]
On Tue, 28 Nov 2023, Cédric Le Goater wrote:
> On 11/28/23 02:32, BALATON Zoltan wrote:
>> 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 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 <balaton@eik.bme.hu>
>
> Since this is 8.2 material :
>
>
> Fixes: d9656f860a38 ("hw/ppc: Add emulation of AmigaOne XE board")
This has missed rc2 but I hope there still will be a pull request before
rc3 which is the last chance now. I've sent a v4 which simpilifies the
inserted code as I've found there's no need to do it like in the rom as
the only place it's called from just cares about the result.
I forgot the Fixes tag again, sorry, but the one above is still the same.
Regards,
BALATON Zoltan
>
>
> Thanks,
>
> C.
>
>
>
>> ---
>> v3: Instead of -bios none do this when no -bios option given, use
>> constants for address and rom_add_blob_fixed() to add dummy_fw.
>> This makes both code and usage a bit simpler.
>>
>> hw/ppc/amigaone.c | 35 +++++++++++++++++++++++------------
>> 1 file changed, 23 insertions(+), 12 deletions(-)
>>
>> diff --git a/hw/ppc/amigaone.c b/hw/ppc/amigaone.c
>> index 992a55e632..ddfa09457a 100644
>> --- a/hw/ppc/amigaone.c
>> +++ b/hw/ppc/amigaone.c
>> @@ -36,10 +36,19 @@
>> * -device VGA,romfile=VGABIOS-lgpl-latest.bin
>> * from http://www.nongnu.org/vgabios/ instead.
>> */
>> -#define PROM_FILENAME "u-boot-amigaone.bin"
>> #define PROM_ADDR 0xfff00000
>> #define PROM_SIZE (512 * KiB)
>> +/* AmigaOS calls this routine from ROM, use this if no firmware loaded
>> */
>> +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;
>> @@ -60,8 +69,6 @@ static void amigaone_init(MachineState *machine)
>> PowerPCCPU *cpu;
>> CPUPPCState *env;
>> MemoryRegion *rom, *pci_mem, *mr;
>> - const char *fwname = machine->firmware ?: PROM_FILENAME;
>> - char *filename;
>> ssize_t sz;
>> PCIBus *pci_bus;
>> Object *via;
>> @@ -94,20 +101,24 @@ static void amigaone_init(MachineState *machine)
>> }
>> /* allocate and load firmware */
>> - 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);
>> + 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);
>> + if (!machine->firmware) {
>> + rom_add_blob_fixed("dummy-fw", dummy_fw, sizeof(dummy_fw),
>> + PROM_ADDR + PROM_SIZE - 0x80);
>> + } else {
>> + g_autofree char *filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
>> + machine->firmware);
>> + if (!filename) {
>> + error_report("Could not find firmware '%s'",
>> machine->firmware);
>> + exit(1);
>> + }
>> 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 (!qtest_enabled()) {
>> - error_report("Could not find firmware '%s'", fwname);
>> - exit(1);
>> }
>> /* Articia S */
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3] ppc/amigaone: Allow running AmigaOS without firmware image
2023-11-29 22:49 ` BALATON Zoltan
@ 2023-11-30 11:03 ` Nicholas Piggin
2023-11-30 13:18 ` BALATON Zoltan
0 siblings, 1 reply; 5+ messages in thread
From: Nicholas Piggin @ 2023-11-30 11:03 UTC (permalink / raw)
To: BALATON Zoltan
Cc: qemu-devel, qemu-ppc, Cédric Le Goater,
Daniel Henrique Barboza, philmd
On Thu Nov 30, 2023 at 8:49 AM AEST, BALATON Zoltan wrote:
> On Tue, 28 Nov 2023, Cédric Le Goater wrote:
> > On 11/28/23 02:32, BALATON Zoltan wrote:
> >> 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 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 <balaton@eik.bme.hu>
> >
> > Since this is 8.2 material :
> >
> >
> > Fixes: d9656f860a38 ("hw/ppc: Add emulation of AmigaOne XE board")
>
> This has missed rc2 but I hope there still will be a pull request before
> rc3 which is the last chance now. I've sent a v4 which simpilifies the
Sigh, yes a few hiccups but I will send a PR with your v3 and a SLOF
update.
> inserted code as I've found there's no need to do it like in the rom as
> the only place it's called from just cares about the result.
>
> I forgot the Fixes tag again, sorry, but the one above is still the same.
That's okay I added it. I'll just keep v3 since I have done some
tests with it. If it matches the the old rom then it seems like
a good starting point anyway, can always patch it later.
Thanks,
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v3] ppc/amigaone: Allow running AmigaOS without firmware image
2023-11-30 11:03 ` Nicholas Piggin
@ 2023-11-30 13:18 ` BALATON Zoltan
0 siblings, 0 replies; 5+ messages in thread
From: BALATON Zoltan @ 2023-11-30 13:18 UTC (permalink / raw)
To: Nicholas Piggin
Cc: qemu-devel, qemu-ppc, Cédric Le Goater,
Daniel Henrique Barboza, philmd
[-- Attachment #1: Type: text/plain, Size: 1726 bytes --]
On Thu, 30 Nov 2023, Nicholas Piggin wrote:
> On Thu Nov 30, 2023 at 8:49 AM AEST, BALATON Zoltan wrote:
>> On Tue, 28 Nov 2023, Cédric Le Goater wrote:
>>> On 11/28/23 02:32, BALATON Zoltan wrote:
>>>> 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 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 <balaton@eik.bme.hu>
>>>
>>> Since this is 8.2 material :
>>>
>>>
>>> Fixes: d9656f860a38 ("hw/ppc: Add emulation of AmigaOne XE board")
>>
>> This has missed rc2 but I hope there still will be a pull request before
>> rc3 which is the last chance now. I've sent a v4 which simpilifies the
>
> Sigh, yes a few hiccups but I will send a PR with your v3 and a SLOF
> update.
>
>> inserted code as I've found there's no need to do it like in the rom as
>> the only place it's called from just cares about the result.
>>
>> I forgot the Fixes tag again, sorry, but the one above is still the same.
>
> That's okay I added it. I'll just keep v3 since I have done some
> tests with it. If it matches the the old rom then it seems like
> a good starting point anyway, can always patch it later.
The only change is the code in it so it should not change any test results
but v3 could work too, it just now seems unnecessary to include that much
code when the short version is the same. Anyway, eiher v3 or v4 is OK.
Regards,
BALATON Zoltan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-30 13:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-28 1:32 [PATCH v3] ppc/amigaone: Allow running AmigaOS without firmware image BALATON Zoltan
2023-11-28 12:47 ` Cédric Le Goater
2023-11-29 22:49 ` BALATON Zoltan
2023-11-30 11:03 ` Nicholas Piggin
2023-11-30 13:18 ` BALATON Zoltan
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.