On Mon, 16 Jun 2025, Philippe Mathieu-Daudé wrote:
On 11/3/25 13:58, Nicholas Piggin wrote:
From: BALATON Zoltan <bala...@eik.bme.hu>

Add support for -kernel, -initrd and -append command line options.

Signed-off-by: BALATON Zoltan <bala...@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npig...@gmail.com>
Message-ID: <489b1be5d95d5153e924c95b0691b8b53f9ffb9e.1740673173.git.bala...@eik.bme.hu>
Signed-off-by: Nicholas Piggin <npig...@gmail.com>
---
  hw/ppc/amigaone.c | 113 +++++++++++++++++++++++++++++++++++++++++++++-
  1 file changed, 112 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/amigaone.c b/hw/ppc/amigaone.c
index 1c6f2a944d..359f5fa125 100644
--- a/hw/ppc/amigaone.c
+++ b/hw/ppc/amigaone.c


@@ -301,6 +362,56 @@ static void amigaone_init(MachineState *machine)
      }
pci_ide_create_devs(PCI_DEVICE(object_resolve_path_component(via, "ide")));
      pci_vga_init(pci_bus);
+
+    if (!machine->kernel_filename) {
+        return;
+    }
+
+    /* handle -kernel, -initrd, -append options and emulate U-Boot */
+    bi = g_new0(struct boot_info, 1);
+    cpu->env.load_info = bi;
+
+    loadaddr = MIN(machine->ram_size, 256 * MiB);
+    bi->bd_info = loadaddr - 8 * MiB;
+    create_bd_info(bi->bd_info, machine->ram_size);
+    bi->stack = bi->bd_info - 64 * KiB - 8;
+
+    if (machine->kernel_cmdline && machine->kernel_cmdline[0]) {
+        size_t len = strlen(machine->kernel_cmdline);
+
+        loadaddr = bi->bd_info + 1 * MiB;
+ cpu_physical_memory_write(loadaddr, machine->kernel_cmdline, len + 1);

This patch introduces a call to a legacy API (documented since at least
2017 in commit b7ecba0f6f6: "docs/devel/loads-stores.rst: Document our
various load and store APIs").

It does not say deprecated but only if you're in a device you probably need something else as this implicitly operates on system address space and does not report errors. But we're in a machine here and there's nothing to be done for a failure which is not expected at this point.

Can we load via &address_space_memory instead?

I guess we could but that would just make this line much longer and less readable. There are plenty of places using this still so unless it's about to be removed I'd leave it as it is. Get back to this when it's the last instance.

Regards,
BALATON Zoltan

Reply via email to