From: BALATON Zoltan <balaton@eik.bme.hu>
To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
Daniel Henrique Barboza <danielhb413@gmail.com>,
clg@kaod.org, philmd@linaro.org
Subject: [PATCH v3] ppc/amigaone: Allow running AmigaOS without firmware image
Date: Tue, 28 Nov 2023 02:32:53 +0100 (CET) [thread overview]
Message-ID: <20231128013253.80524756078@zero.eik.bme.hu> (raw)
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
next reply other threads:[~2023-11-28 1:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-28 1:32 BALATON Zoltan [this message]
2023-11-28 12:47 ` [PATCH v3] ppc/amigaone: Allow running AmigaOS without firmware image 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231128013253.80524756078@zero.eik.bme.hu \
--to=balaton@eik.bme.hu \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=npiggin@gmail.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.