Skip to contentSkip to conversation

PPC: Support flags -boot, -uuid and -kernel using fw_cfg

PATCH In review Blue Swirl 2 participants 5 messages Dec 21, 2008

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

PATCH 1/1 PPC: Support flags -boot, -uuid and -kernel using fw_cfg

Hi,

These two patches (Qemu/OpenBIOS) add support for giving OpenBIOS/PPC a boot device with -boot command line flag, use a UUID (print only) and call a preloaded kernel. These are passed from Qemu to OpenBIOS using the firmware configuration device and NVRAM.

Using the -boot switch works, but I can't boot anything yet so it's not very well tested. UUID works, but it's not added to the device tree. Kernel crashes after the first instruction, maybe the memory size probe corrupts memory.

Quoted 6 lines
Quoted 6 lines

=============================================================
OpenBIOS 1.0RC1 [Dec 21 2008 11:55] Configuration device id QEMU version 1 machine id 2
CPUs: 1
UUID: 12345678-1234-abcd-7654-123456789abc Initializing PCI devices...

Quoted 8 lines
Quoted 8 lines

0:0.0 - 1057:2 - /pci/pci - pci
0:1.0 - 1234:1111 - /pci/QEMU,VGA - QEMU,VGA 0:2.0 - 10ec:8029 - /pci/NE2000 - NE2000 0:3.0 - 1095:646 - /pci/pci-ata - pci-ata
ata-1: [io ports 0x100-0x107,0x182]
drive1 [ATAPI cdrom]: QEMU DVD-ROM
ata-2: [io ports 0x200-0x207,0x282] 0:4.0 - 106b:17 - /pci/mac-io - mac-io

No disk found.

Quoted 1 line
Quoted 1 line

[ppc] Kernel already loaded (0x01000000 + 0x003cadc8)

hw/ppc_oldworld.c +14 -0
Index: qemu/hw/ppc_oldworld.c
===================================================================
@@ -32,9 +32,17 @@
 #include "isa.h"
 #include "pci.h"
 #include "boards.h"
+#include "fw_cfg.h"
 
 #define MAX_IDE_BUS 2
 #define VGA_BIOS_SIZE 65536
+#define BIOS_CFG_IOPORT 0x510
+
+enum {
+    ARCH_PREP = 0,
+    ARCH_MAC99,
+    ARCH_HEATHROW,
+};
 
 /* temporary frame buffer OSI calls for the video.x driver. The right
    solution is to modify the driver to use VGA PCI I/Os */
@@ -128,6 +136,7 @@
     int ppc_boot_device;
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     int index;
+    void *fw_cfg;
 
     linux_boot = (kernel_filename != NULL);
 
@@ -363,6 +372,11 @@
 
     /* Special port to get debug messages from Open-Firmware */
     register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
+
+    fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0);
+    fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
+    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW);
 }
 
 QEMUMachine heathrow_machine = {
arch/ppc/qemu/init.c +54 -0

72 lines not on this page · raw message

arch/ppc/qemu/main.c +49 -0

78 lines not on this page · raw message

#1 lore raw
Quoted 26 lines · Blue Swirl

Hi,

These two patches (Qemu/OpenBIOS) add support for giving OpenBIOS/PPC a boot device with -boot command line flag, use a UUID (print only) and call a preloaded kernel. These are passed from Qemu to OpenBIOS using the firmware configuration device and NVRAM.

Using the -boot switch works, but I can't boot anything yet so it's not very well tested. UUID works, but it's not added to the device tree. Kernel crashes after the first instruction, maybe the memory size probe corrupts memory.

Quoted 6 lines
Quoted 6 lines

=============================================================
OpenBIOS 1.0RC1 [Dec 21 2008 11:55] Configuration device id QEMU version 1 machine id 2
CPUs: 1
UUID: 12345678-1234-abcd-7654-123456789abc Initializing PCI devices...

Quoted 8 lines
Quoted 8 lines

0:0.0 - 1057:2 - /pci/pci - pci
0:1.0 - 1234:1111 - /pci/QEMU,VGA - QEMU,VGA 0:2.0 - 10ec:8029 - /pci/NE2000 - NE2000 0:3.0 - 1095:646 - /pci/pci-ata - pci-ata
ata-1: [io ports 0x100-0x107,0x182]
drive1 [ATAPI cdrom]: QEMU DVD-ROM
ata-2: [io ports 0x200-0x207,0x282] 0:4.0 - 106b:17 - /pci/mac-io - mac-io

Quoted 3 lines

No disk found.

Quoted 1 line
Quoted 1 line

[ppc] Kernel already loaded (0x01000000 + 0x003cadc8)

<q_ppc_use_fw_cfg.diff><o_ppc_use_fw_cfg.diff>

The ISA IO base depends on the architecture, so I don't think you can use I/O port to read the architecture from the fw cfg device.

Regards,
Laurent
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay

author
#2 lore raw
Quoted 39 lines · Laurent Vivier
Quoted 8 lines · Blue Swirl

Hi,

These two patches (Qemu/OpenBIOS) add support for giving OpenBIOS/PPC a boot device with -boot command line flag, use a UUID (print only) and call a preloaded kernel. These are passed from Qemu to OpenBIOS using the firmware configuration device and NVRAM.

Quoted 8 lines

Using the -boot switch works, but I can't boot anything yet so it's not very well tested. UUID works, but it's not added to the device tree. Kernel crashes after the first instruction, maybe the memory size probe corrupts memory.

Quoted 2 lines
Quoted 2 lines

=============================================================

Quoted 18 lines
Quoted 6 lines
Quoted 6 lines

OpenBIOS 1.0RC1 [Dec 21 2008 11:55] Configuration device id QEMU version 1 machine id 2
CPUs: 1
UUID: 12345678-1234-abcd-7654-123456789abc Initializing PCI devices...
0:0.0 - 1057:2 - /pci/pci - pci

Quoted 9 lines
Quoted 8 lines

0:1.0 - 1234:1111 - /pci/QEMU,VGA - QEMU,VGA 0:2.0 - 10ec:8029 - /pci/NE2000 - NE2000 0:3.0 - 1095:646 - /pci/pci-ata - pci-ata
ata-1: [io ports 0x100-0x107,0x182]
drive1 [ATAPI cdrom]: QEMU DVD-ROM
ata-2: [io ports 0x200-0x207,0x282] 0:4.0 - 106b:17 - /pci/mac-io - mac-io

No disk found.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

[ppc] Kernel already loaded (0x01000000 + 0x003cadc8)

<q_ppc_use_fw_cfg.diff><o_ppc_use_fw_cfg.diff>

The ISA IO base depends on the architecture, so I don't think you can use
I/O port to read the architecture from the fw cfg device.

I noticed that too, it was the first thing I tried but it never worked. Is it possible to try different base addresses for the port and then use the one which responds with the correct signature? Or does the PCI need to be completely initialized?

Alternatively we could use MMIO at a fixed address.

#3 lore raw
Quoted 46 lines · Blue Swirl
Quoted 45 lines · Laurent Vivier
Quoted 8 lines · Blue Swirl

Hi,

These two patches (Qemu/OpenBIOS) add support for giving OpenBIOS/PPC a boot device with -boot command line flag, use a UUID (print only) and call a preloaded kernel. These are passed from Qemu to OpenBIOS using the firmware configuration device and NVRAM.

Quoted 8 lines

Using the -boot switch works, but I can't boot anything yet so it's not very well tested. UUID works, but it's not added to the device tree. Kernel crashes after the first instruction, maybe the memory size probe corrupts memory.

Quoted 2 lines
Quoted 2 lines

=============================================================

Quoted 23 lines
Quoted 6 lines
Quoted 6 lines

OpenBIOS 1.0RC1 [Dec 21 2008 11:55] Configuration device id QEMU version 1 machine id 2
CPUs: 1
UUID: 12345678-1234-abcd-7654-123456789abc Initializing PCI devices...
0:0.0 - 1057:2 - /pci/pci - pci

Quoted 9 lines
Quoted 8 lines

0:1.0 - 1234:1111 - /pci/QEMU,VGA - QEMU,VGA 0:2.0 - 10ec:8029 - /pci/NE2000 - NE2000 0:3.0 - 1095:646 - /pci/pci-ata - pci-ata
ata-1: [io ports 0x100-0x107,0x182]
drive1 [ATAPI cdrom]: QEMU DVD-ROM
ata-2: [io ports 0x200-0x207,0x282] 0:4.0 - 106b:17 - /pci/mac-io - mac-io

No disk found.

Quoted 4 lines
Quoted 3 lines

[ppc] Kernel already loaded (0x01000000 + 0x003cadc8)

<q_ppc_use_fw_cfg.diff><o_ppc_use_fw_cfg.diff>

Quoted 7 lines
Quoted 2 lines

The ISA IO base depends on the architecture, so I don't think you can use I/O port to read the architecture from the fw cfg device.

I noticed that too, it was the first thing I tried but it never worked. Is it possible to try different base addresses for the port and then use the one which responds with the correct signature? Or does the PCI need to be completely initialized?

OpenHackWare reads the architecture from an NVRAM device.
The NVRAM is also located in the ISA IO space, but it scan all possible ISA I/O base, i.e. 0x80000000, 0xfe000000 and 0xf2000000.

If we just don't want be worst than OHW, we can do that too with an fw cfg device instead of an NVRAM.

Regards,
Laurent
----------------------- Laurent Vivier ---------------------- "The best way to predict the future is to invent it."
- Alan Kay

author
#4 lore raw
In reply to Laurent Vivier
Quoted 39 lines · Laurent Vivier
Quoted 8 lines · Blue Swirl

Hi,

These two patches (Qemu/OpenBIOS) add support for giving OpenBIOS/PPC a boot device with -boot command line flag, use a UUID (print only) and call a preloaded kernel. These are passed from Qemu to OpenBIOS using the firmware configuration device and NVRAM.

Quoted 8 lines

Using the -boot switch works, but I can't boot anything yet so it's not very well tested. UUID works, but it's not added to the device tree. Kernel crashes after the first instruction, maybe the memory size probe corrupts memory.

Quoted 2 lines
Quoted 2 lines

=============================================================

Quoted 18 lines
Quoted 6 lines
Quoted 6 lines

OpenBIOS 1.0RC1 [Dec 21 2008 11:55] Configuration device id QEMU version 1 machine id 2
CPUs: 1
UUID: 12345678-1234-abcd-7654-123456789abc Initializing PCI devices...
0:0.0 - 1057:2 - /pci/pci - pci

Quoted 9 lines
Quoted 8 lines

0:1.0 - 1234:1111 - /pci/QEMU,VGA - QEMU,VGA 0:2.0 - 10ec:8029 - /pci/NE2000 - NE2000 0:3.0 - 1095:646 - /pci/pci-ata - pci-ata
ata-1: [io ports 0x100-0x107,0x182]
drive1 [ATAPI cdrom]: QEMU DVD-ROM
ata-2: [io ports 0x200-0x207,0x282] 0:4.0 - 106b:17 - /pci/mac-io - mac-io

No disk found.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

[ppc] Kernel already loaded (0x01000000 + 0x003cadc8)

<q_ppc_use_fw_cfg.diff><o_ppc_use_fw_cfg.diff>

The ISA IO base depends on the architecture, so I don't think you can use
I/O port to read the architecture from the fw cfg device.

This version uses MMIO so we can check the architecture early.

hw/ppc_oldworld.c +14 -0
Index: qemu/hw/ppc_oldworld.c
===================================================================
@@ -32,9 +32,17 @@
 #include "isa.h"
 #include "pci.h"
 #include "boards.h"
+#include "fw_cfg.h"
 
 #define MAX_IDE_BUS 2
 #define VGA_BIOS_SIZE 65536
+#define CFG_ADDR 0xf0000510
+
+enum {
+    ARCH_PREP = 0,
+    ARCH_MAC99,
+    ARCH_HEATHROW,
+};
 
 /* temporary frame buffer OSI calls for the video.x driver. The right
    solution is to modify the driver to use VGA PCI I/Os */
@@ -128,6 +136,7 @@
     int ppc_boot_device;
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     int index;
+    void *fw_cfg;
 
     linux_boot = (kernel_filename != NULL);
 
@@ -363,6 +372,11 @@
 
     /* Special port to get debug messages from Open-Firmware */
     register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
+
+    fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
+    fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
+    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
+    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW);
 }
 
 QEMUMachine heathrow_machine = {
arch/ppc/qemu/init.c +68 -1

90 lines not on this page · raw message

arch/ppc/qemu/main.c +51 -0

80 lines not on this page · raw message