Skip to contentSkip to conversation

Mac99 (CHRP?) support

RFC PATCH In review Blue Swirl 5 participants 10 messages Feb 7, 2009 – Feb 8, 2009 Kbuild

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

RFC PATCH 1/1 Mac99 (CHRP?) support

Hi,

This set of patches adds basic support for Mac99 Qemu machine, provided by ppc_chrp.c. I've used the device tree of iMac DV ('99) as reference:
http://penguinppc.org/historical/dev-trees-html/imac-dv-99.html

The patches changes the machine to use OpenBIOS instead of OHW and otherwise breaks OHW assumptions. On OpenBIOS side there are still some missing bits.

Comments welcome.

arch/ppc/qemu/ldscript +1 -1
Index: openbios-quilt/arch/ppc/qemu/ldscript
===================================================================
@@ -7,7 +7,7 @@
 
 /* As NVRAM is at 0xfff04000, the .text needs to be after that
  */
-TEXT_ADDR = 0xfff06000;
+TEXT_ADDR = 0xfff08000;
 
 /* Hard reset vector address
  */
drivers/macio.c +60 -9

115 lines not on this page · raw message

drivers/macio.h +2 -1
Index: openbios-quilt/drivers/macio.h
===================================================================
@@ -1,4 +1,5 @@
 extern phandle_t pic_handle;
 
-void ob_macio_init(const char *path, uint32_t addr);
+void ob_macio_heathrow_init(const char *path, uint32_t addr);
+void ob_macio_keylargo_init(const char *path, uint32_t addr);
 void macio_nvram_init(const char *path, uint32_t addr);
drivers/pci.c +12 -2
Index: openbios-quilt/drivers/pci.c
===================================================================
@@ -419,16 +419,26 @@
 	set_property(dev, "ranges", (char *)props, ncells * sizeof(cell));
 }
 
-int macio_config_cb (const pci_config_t *config)
+int macio_heathrow_config_cb (const pci_config_t *config)
 {
 	pci_set_ranges(config);
 
 #ifdef CONFIG_DRIVER_MACIO
-	ob_macio_init(config->path, config->assigned[0] & ~0x0000000F);
+        ob_macio_heathrow_init(config->path, config->assigned[0] & ~0x0000000F);
 #endif
 	return 0;
 }
 
+int macio_keylargo_config_cb (const pci_config_t *config)
+{
+        pci_set_ranges(config);
+
+#ifdef CONFIG_DRIVER_MACIO
+        ob_macio_keylargo_init(config->path, config->assigned[0] & ~0x0000000F);
+#endif
+        return 0;
+}
+
 int vga_config_cb (const pci_config_t *config)
 {
 	if (config->assigned[0] != 0x00000000)
drivers/pci_database.c +3 -3
Index: openbios-quilt/drivers/pci_database.c
===================================================================
@@ -1071,21 +1071,21 @@
         PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_343S1201,
         "mac-io", "mac-io", "AAPL,343S1201", "heathrow\0",
         1, 1, 1,
-        &macio_config_cb, NULL,
+        &macio_heathrow_config_cb, NULL,
     },
     /* Paddington Mac I/O */
     {
         PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_343S1211,
         "mac-io", "mac-io", "AAPL,343S1211", "paddington\0heathrow\0",
         1, 1, 1,
-        &macio_config_cb, NULL,
+        &macio_heathrow_config_cb, NULL,
     },
     /* KeyLargo Mac I/O */
     {
         PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_KEYL,
         "mac-io", "mac-io", "AAPL,Keylargo", "Keylargo\0",
         1, 1, 2,
-        &macio_config_cb, NULL,
+        &macio_keylargo_config_cb, NULL,
     },
     {
         0xFFFF, 0xFFFF,
drivers/pci_database.h +2 -1
Index: openbios-quilt/drivers/pci_database.h
===================================================================
@@ -27,7 +27,8 @@
 
 extern int ide_config_cb2(const pci_config_t *config);
 extern int eth_config_cb(const pci_config_t *config);
-extern int macio_config_cb(const pci_config_t *config);
+extern int macio_heathrow_config_cb(const pci_config_t *config);
+extern int macio_keylargo_config_cb(const pci_config_t *config);
 extern int vga_config_cb(const pci_config_t *config);
 extern int host_config_cb(const pci_config_t *config);
 extern int bridge_config_cb(const pci_config_t *config);
hw/ppc_chrp.c +12 -11
Index: qemu/hw/ppc_chrp.c
===================================================================
@@ -32,10 +32,12 @@
 #include "net.h"
 #include "sysemu.h"
 #include "boards.h"
+#include "fw_cfg.h"
 #include "escc.h"
 
 #define MAX_IDE_BUS 2
 #define VGA_BIOS_SIZE 65536
+#define CFG_ADDR 0xf0000510
 
 /* debug UniNorth */
 //#define DEBUG_UNIN
@@ -104,6 +106,7 @@
     int ppc_boot_device;
     int index;
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
+    void *fw_cfg;
     void *dbdma;
 
     linux_boot = (kernel_filename != NULL);
@@ -143,20 +146,16 @@
     /* allocate and load BIOS */
     bios_offset = qemu_ram_alloc(BIOS_SIZE);
     if (bios_name == NULL)
-        bios_name = BIOS_FILENAME;
+        bios_name = PROM_FILENAME;
     snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
-    bios_size = load_image(buf, phys_ram_base + bios_offset);
+    cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM);
+
+    /* Load OpenBIOS (ELF) */
+    bios_size = load_elf(buf, 0, NULL, NULL, NULL);
     if (bios_size < 0 || bios_size > BIOS_SIZE) {
         cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
         exit(1);
     }
-    bios_size = (bios_size + 0xfff) & ~0xfff;
-    if (bios_size > 0x00080000) {
-        /* As the NVRAM is located at 0xFFF04000, we cannot use 1 MB BIOSes */
-        cpu_abort(env, "Mac99 hardware can not handle 1 MB BIOS\n");
-    }
-    cpu_register_physical_memory((uint32_t)(-bios_size),
-                                 bios_size, bios_offset | IO_MEM_ROM);
 
     /* allocate and load VGA BIOS */
     vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE);
@@ -349,8 +348,10 @@
                          graphic_width, graphic_height, graphic_depth);
     /* No PCI init: the BIOS will do it */
 
-    /* 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_MAC99);
 }
 
 QEMUMachine core99_machine = {
hw/ppc_chrp.c +1 -21
Index: qemu/hw/ppc_chrp.c
===================================================================
@@ -93,12 +93,8 @@
     ram_addr_t ram_offset, vga_ram_offset, bios_offset, vga_bios_offset;
     uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
     PCIBus *pci_bus;
-    nvram_t nvram;
-#if 0
     MacIONVRAMState *nvr;
     int nvram_mem_index;
-#endif
-    m48t59_t *m48t59;
     int vga_bios_size, bios_size;
     qemu_irq *dummy_irq;
     int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
@@ -325,27 +321,11 @@
 
     if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
         graphic_depth = 15;
-#if 0 /* XXX: this is ugly but needed for now, or OHW won't boot */
+
     /* The NewWorld NVRAM is not located in the MacIO device */
     nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 1);
     pmac_format_nvram_partition(nvr, 0x2000);
     macio_nvram_map(nvr, 0xFFF04000);
-    nvram.opaque = nvr;
-    nvram.read_fn = &macio_nvram_read;
-    nvram.write_fn = &macio_nvram_write;
-#else
-    m48t59 = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
-    nvram.opaque = m48t59;
-    nvram.read_fn = &m48t59_read;
-    nvram.write_fn = &m48t59_write;
-#endif
-    PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "MAC99", ram_size,
-                         ppc_boot_device, kernel_base, kernel_size,
-                         kernel_cmdline,
-                         initrd_base, initrd_size,
-                         /* XXX: need an option to load a NVRAM image */
-                         0,
-                         graphic_width, graphic_height, graphic_depth);
     /* No PCI init: the BIOS will do it */
 
     fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
hw/unin_pci.c +2 -13
Index: qemu/hw/unin_pci.c
===================================================================
@@ -44,22 +44,13 @@
                                          uint32_t val)
 {
     UNINState *s = opaque;
-    int i;
 
     UNIN_DPRINTF("config_writel addr " TARGET_FMT_plx " val %x\n", addr, val);
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap32(val);
 #endif
 
-    for (i = 11; i < 32; i++) {
-        if ((val & (1 << i)) != 0)
-            break;
-    }
-#if 0
-    s->config_reg = 0x80000000 | (1 << 16) | (val & 0x7FC) | (i << 11);
-#else
-    s->config_reg = 0x80000000 | (0 << 16) | (val & 0x7FC) | (i << 11);
-#endif
+    s->config_reg = val;
 }
 
 static uint32_t pci_unin_main_config_readl (void *opaque,
@@ -67,10 +58,8 @@
 {
     UNINState *s = opaque;
     uint32_t val;
-    int devfn;
 
-    devfn = (s->config_reg >> 8) & 0xFF;
-    val = (1 << (devfn >> 3)) | ((devfn & 0x07) << 8) | (s->config_reg & 0xFC);
+    val = s->config_reg;
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap32(val);
 #endif
hw/ppc_chrp.c +4 -6
Index: qemu/hw/ppc_chrp.c
===================================================================
@@ -98,7 +98,7 @@
     int vga_bios_size, bios_size;
     qemu_irq *dummy_irq;
     int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
-    int ide_mem_index[2];
+    int ide_mem_index[3];
     int ppc_boot_device;
     int index;
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
@@ -298,12 +298,10 @@
             hd[i] = NULL;
     }
     dbdma = DBDMA_init(&dbdma_mem_index);
-#if 1
     ide_mem_index[0] = pmac_ide_init(&hd[0], pic[0x13], dbdma, 0x14, pic[0x01]);
-    ide_mem_index[1] = pmac_ide_init(&hd[2], pic[0x14], dbdma, 0x16, pic[0x02]);
-#else
-    pci_cmd646_ide_init(pci_bus, &hd[0], 0);
-#endif
+    ide_mem_index[1] = pmac_ide_init(&hd[1], pic[0x14], dbdma, 0x15, pic[0x02]);
+    ide_mem_index[2] = pmac_ide_init(&hd[2], pic[0x15], dbdma, 0x16, pic[0x03]);
+
     /* cuda also initialize ADB */
     cuda_init(&cuda_mem_index, pic[0x19]);
 
target-ppc/cpu.h +2 -1
Index: qemu/target-ppc/cpu.h
===================================================================
@@ -66,7 +66,8 @@
 
 #define TARGET_HAS_ICE 1
 
-#if defined (TARGET_PPC64)
+/* Load a 32 bit BIOS also on 64 bit machines */
+#if defined (TARGET_PPC64) && defined(CONFIG_USER_ONLY)
 #define ELF_MACHINE     EM_PPC64
 #else
 #define ELF_MACHINE     EM_PPC
hw/ppc_oldworld.c +0 -7
Index: qemu/hw/ppc_oldworld.c
===================================================================
@@ -152,13 +152,6 @@
         qemu_register_reset(&cpu_ppc_reset, env);
         envs[i] = env;
     }
-    if (env->nip < 0xFFF80000) {
-        /* Special test for PowerPC 601:
-         * the boot vector is at 0xFFF00100, then we need a 1MB BIOS.
-         * But the NVRAM is located at 0xFFF04000...
-         */
-        cpu_abort(env, "G3 Beige Mac hardware can not handle 1 MB BIOS\n");
-    }
 
     /* allocate RAM */
     if (ram_size > (2047 << 20)) {
hw/ppc_chrp.c +0 -7
Index: qemu/hw/ppc_chrp.c
===================================================================
@@ -124,13 +124,6 @@
         qemu_register_reset(&cpu_ppc_reset, env);
         envs[i] = env;
     }
-    if (env->nip < 0xFFF80000) {
-        /* Special test for PowerPC 601:
-         * the boot vector is at 0xFFF00100, then we need a 1MB BIOS.
-         * But the NVRAM is located at 0xFFF04000...
-         */
-        cpu_abort(env, "Mac99 hardware can not handle 1 MB BIOS\n");
-    }
 
     /* allocate RAM */
     ram_offset = qemu_ram_alloc(ram_size);
#1 lore raw
Quoted 1 line · Blue Swirl

Hi,

Hi!

Quoted 1 line

This set of patches adds basic support for Mac99 Qemu machine,

As you ask the question in the subject, this machine is a NewWorld machine, and not a CHRP one. I think we don't really want to provide a CHRP emulated machine, so the best is probably to rename ppc_chrp.c into ppc_newworld.c.

Quoted 9 lines

provided by ppc_chrp.c. I've used the device tree of iMac DV ('99) as reference:
http://penguinppc.org/historical/dev-trees-html/imac-dv-99.html

The patches changes the machine to use OpenBIOS instead of OHW and otherwise breaks OHW assumptions. On OpenBIOS side there are still some missing bits.

Comments welcome.

Great work.

I gave a quick look at the patches, they looks fine. However I still experience some problem with the PowerMac IDE emulation, especially with recent kernels, so until it is fixed (Laurent is working on that) I think we should keep the CMD646 as a default.

Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
author
#2 lore raw
Quoted 5 lines · Aurelien Jarno
Quoted 1 line · Blue Swirl

Hi,

Hi!

Quoted 7 lines
Quoted 1 line

This set of patches adds basic support for Mac99 Qemu machine,

As you ask the question in the subject, this machine is a NewWorld
machine, and not a CHRP one. I think we don't really want to provide a CHRP emulated machine, so the best is probably to rename ppc_chrp.c into ppc_newworld.c.

True. I think RS6000 series were closest to CHRP, not iMac.

The rename does not affect OHW status, so it could be done immediately.

Quoted 11 lines
Quoted 9 lines

provided by ppc_chrp.c. I've used the device tree of iMac DV ('99) as reference:
http://penguinppc.org/historical/dev-trees-html/imac-dv-99.html

The patches changes the machine to use OpenBIOS instead of OHW and otherwise breaks OHW assumptions. On OpenBIOS side there are still some missing bits.

Comments welcome.

Quoted 6 lines

Great work.

I gave a quick look at the patches, they looks fine. However I still experience some problem with the PowerMac IDE emulation, especially with recent kernels, so until it is fixed (Laurent is working on that) I think we should keep the CMD646 as a default.

OK¸ I'll change that part and send new patches.

author
#3 lore raw
Quoted 33 lines · Blue Swirl
Quoted 5 lines · Aurelien Jarno
Quoted 1 line · Blue Swirl

Hi,

Hi!

Quoted 7 lines
Quoted 1 line

This set of patches adds basic support for Mac99 Qemu machine,

As you ask the question in the subject, this machine is a NewWorld
machine, and not a CHRP one. I think we don't really want to provide a CHRP emulated machine, so the best is probably to rename ppc_chrp.c into ppc_newworld.c.

True. I think RS6000 series were closest to CHRP, not iMac.

The rename does not affect OHW status, so it could be done immediately.

Quoted 13 lines
Quoted 9 lines

provided by ppc_chrp.c. I've used the device tree of iMac DV ('99) as reference:
http://penguinppc.org/historical/dev-trees-html/imac-dv-99.html

The patches changes the machine to use OpenBIOS instead of OHW and otherwise breaks OHW assumptions. On OpenBIOS side there are still some missing bits.

Comments welcome.

Great work.

Quoted 7 lines
Quoted 4 lines

I gave a quick look at the patches, they looks fine. However I still experience some problem with the PowerMac IDE emulation, especially with recent kernels, so until it is fixed (Laurent is working on that) I think we should keep the CMD646 as a default.

OK¸ I'll change that part and send new patches.

This new set of patches perform the rename (to be replaced with SVN operation). CMD646 is used instead of pmac ide.

Debian 4.0 R6 cd image boots, installer starts but keyboard does not work (probably because OpenBIOS doesn't advertise OpenPic).

The 6th patch is not wanted, it just switches CMD646 back to pmac, but it's there if someone wants to play.

Should these be committed or do we want to wait for more OpenBIOS updates? At least the OpenBIOS patch, patch #0 and patch #5 are harmless.

arch/ppc/qemu/ldscript +1 -1
Index: openbios-quilt/arch/ppc/qemu/ldscript
===================================================================
@@ -7,7 +7,7 @@
 
 /* As NVRAM is at 0xfff04000, the .text needs to be after that
  */
-TEXT_ADDR = 0xfff06000;
+TEXT_ADDR = 0xfff08000;
 
 /* Hard reset vector address
  */
drivers/macio.c +60 -9

115 lines not on this page · raw message

drivers/macio.h +2 -1
Index: openbios-quilt/drivers/macio.h
===================================================================
@@ -1,4 +1,5 @@
 extern phandle_t pic_handle;
 
-void ob_macio_init(const char *path, uint32_t addr);
+void ob_macio_heathrow_init(const char *path, uint32_t addr);
+void ob_macio_keylargo_init(const char *path, uint32_t addr);
 void macio_nvram_init(const char *path, uint32_t addr);
drivers/pci.c +12 -2
Index: openbios-quilt/drivers/pci.c
===================================================================
@@ -419,16 +419,26 @@
 	set_property(dev, "ranges", (char *)props, ncells * sizeof(cell));
 }
 
-int macio_config_cb (const pci_config_t *config)
+int macio_heathrow_config_cb (const pci_config_t *config)
 {
 	pci_set_ranges(config);
 
 #ifdef CONFIG_DRIVER_MACIO
-	ob_macio_init(config->path, config->assigned[0] & ~0x0000000F);
+        ob_macio_heathrow_init(config->path, config->assigned[0] & ~0x0000000F);
 #endif
 	return 0;
 }
 
+int macio_keylargo_config_cb (const pci_config_t *config)
+{
+        pci_set_ranges(config);
+
+#ifdef CONFIG_DRIVER_MACIO
+        ob_macio_keylargo_init(config->path, config->assigned[0] & ~0x0000000F);
+#endif
+        return 0;
+}
+
 int vga_config_cb (const pci_config_t *config)
 {
 	if (config->assigned[0] != 0x00000000)
drivers/pci_database.c +3 -3
Index: openbios-quilt/drivers/pci_database.c
===================================================================
@@ -1071,21 +1071,21 @@
         PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_343S1201,
         "mac-io", "mac-io", "AAPL,343S1201", "heathrow\0",
         1, 1, 1,
-        &macio_config_cb, NULL,
+        &macio_heathrow_config_cb, NULL,
     },
     /* Paddington Mac I/O */
     {
         PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_343S1211,
         "mac-io", "mac-io", "AAPL,343S1211", "paddington\0heathrow\0",
         1, 1, 1,
-        &macio_config_cb, NULL,
+        &macio_heathrow_config_cb, NULL,
     },
     /* KeyLargo Mac I/O */
     {
         PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_KEYL,
         "mac-io", "mac-io", "AAPL,Keylargo", "Keylargo\0",
         1, 1, 2,
-        &macio_config_cb, NULL,
+        &macio_keylargo_config_cb, NULL,
     },
     {
         0xFFFF, 0xFFFF,
drivers/pci_database.h +2 -1
Index: openbios-quilt/drivers/pci_database.h
===================================================================
@@ -27,7 +27,8 @@
 
 extern int ide_config_cb2(const pci_config_t *config);
 extern int eth_config_cb(const pci_config_t *config);
-extern int macio_config_cb(const pci_config_t *config);
+extern int macio_heathrow_config_cb(const pci_config_t *config);
+extern int macio_keylargo_config_cb(const pci_config_t *config);
 extern int vga_config_cb(const pci_config_t *config);
 extern int host_config_cb(const pci_config_t *config);
 extern int bridge_config_cb(const pci_config_t *config);
Makefile.target +1 -1
Index: qemu/Makefile.target
===================================================================
@@ -594,7 +594,7 @@
 # OldWorld PowerMac
 OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o
 # NewWorld PowerMac
-OBJS+= unin_pci.o ppc_chrp.o
+OBJS+= unin_pci.o ppc_newworld.o
 # PowerPC 4xx boards
 OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
 OBJS+= ppc440.o ppc440_bamboo.o
hw/ppc_chrp.c deleted +0 -362

362 lines not on this page · raw message

hw/ppc_newworld.c new file +362 -0

362 lines not on this page · raw message

hw/ppc_newworld.c +12 -11
Index: qemu/hw/ppc_newworld.c
===================================================================
@@ -32,10 +32,12 @@
 #include "net.h"
 #include "sysemu.h"
 #include "boards.h"
+#include "fw_cfg.h"
 #include "escc.h"
 
 #define MAX_IDE_BUS 2
 #define VGA_BIOS_SIZE 65536
+#define CFG_ADDR 0xf0000510
 
 /* debug UniNorth */
 //#define DEBUG_UNIN
@@ -104,6 +106,7 @@
     int ppc_boot_device;
     int index;
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
+    void *fw_cfg;
     void *dbdma;
 
     linux_boot = (kernel_filename != NULL);
@@ -143,20 +146,16 @@
     /* allocate and load BIOS */
     bios_offset = qemu_ram_alloc(BIOS_SIZE);
     if (bios_name == NULL)
-        bios_name = BIOS_FILENAME;
+        bios_name = PROM_FILENAME;
     snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
-    bios_size = load_image(buf, phys_ram_base + bios_offset);
+    cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM);
+
+    /* Load OpenBIOS (ELF) */
+    bios_size = load_elf(buf, 0, NULL, NULL, NULL);
     if (bios_size < 0 || bios_size > BIOS_SIZE) {
         cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
         exit(1);
     }
-    bios_size = (bios_size + 0xfff) & ~0xfff;
-    if (bios_size > 0x00080000) {
-        /* As the NVRAM is located at 0xFFF04000, we cannot use 1 MB BIOSes */
-        cpu_abort(env, "Mac99 hardware can not handle 1 MB BIOS\n");
-    }
-    cpu_register_physical_memory((uint32_t)(-bios_size),
-                                 bios_size, bios_offset | IO_MEM_ROM);
 
     /* allocate and load VGA BIOS */
     vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE);
@@ -349,8 +348,10 @@
                          graphic_width, graphic_height, graphic_depth);
     /* No PCI init: the BIOS will do it */
 
-    /* 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_MAC99);
 }
 
 QEMUMachine core99_machine = {
hw/ppc_newworld.c +1 -21
Index: qemu/hw/ppc_newworld.c
===================================================================
@@ -93,12 +93,8 @@
     ram_addr_t ram_offset, vga_ram_offset, bios_offset, vga_bios_offset;
     uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
     PCIBus *pci_bus;
-    nvram_t nvram;
-#if 0
     MacIONVRAMState *nvr;
     int nvram_mem_index;
-#endif
-    m48t59_t *m48t59;
     int vga_bios_size, bios_size;
     qemu_irq *dummy_irq;
     int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
@@ -325,27 +321,11 @@
 
     if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8)
         graphic_depth = 15;
-#if 0 /* XXX: this is ugly but needed for now, or OHW won't boot */
+
     /* The NewWorld NVRAM is not located in the MacIO device */
     nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 1);
     pmac_format_nvram_partition(nvr, 0x2000);
     macio_nvram_map(nvr, 0xFFF04000);
-    nvram.opaque = nvr;
-    nvram.read_fn = &macio_nvram_read;
-    nvram.write_fn = &macio_nvram_write;
-#else
-    m48t59 = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59);
-    nvram.opaque = m48t59;
-    nvram.read_fn = &m48t59_read;
-    nvram.write_fn = &m48t59_write;
-#endif
-    PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "MAC99", ram_size,
-                         ppc_boot_device, kernel_base, kernel_size,
-                         kernel_cmdline,
-                         initrd_base, initrd_size,
-                         /* XXX: need an option to load a NVRAM image */
-                         0,
-                         graphic_width, graphic_height, graphic_depth);
     /* No PCI init: the BIOS will do it */
 
     fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
hw/unin_pci.c +2 -13
Index: qemu/hw/unin_pci.c
===================================================================
@@ -44,22 +44,13 @@
                                          uint32_t val)
 {
     UNINState *s = opaque;
-    int i;
 
     UNIN_DPRINTF("config_writel addr " TARGET_FMT_plx " val %x\n", addr, val);
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap32(val);
 #endif
 
-    for (i = 11; i < 32; i++) {
-        if ((val & (1 << i)) != 0)
-            break;
-    }
-#if 0
-    s->config_reg = 0x80000000 | (1 << 16) | (val & 0x7FC) | (i << 11);
-#else
-    s->config_reg = 0x80000000 | (0 << 16) | (val & 0x7FC) | (i << 11);
-#endif
+    s->config_reg = val;
 }
 
 static uint32_t pci_unin_main_config_readl (void *opaque,
@@ -67,10 +58,8 @@
 {
     UNINState *s = opaque;
     uint32_t val;
-    int devfn;
 
-    devfn = (s->config_reg >> 8) & 0xFF;
-    val = (1 << (devfn >> 3)) | ((devfn & 0x07) << 8) | (s->config_reg & 0xFC);
+    val = s->config_reg;
 #ifdef TARGET_WORDS_BIGENDIAN
     val = bswap32(val);
 #endif
hw/ppc_newworld.c +3 -8
Index: qemu/hw/ppc_newworld.c
===================================================================
@@ -98,7 +98,6 @@
     int vga_bios_size, bios_size;
     qemu_irq *dummy_irq;
     int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
-    int ide_mem_index[2];
     int ppc_boot_device;
     int index;
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
@@ -298,12 +297,8 @@
             hd[i] = NULL;
     }
     dbdma = DBDMA_init(&dbdma_mem_index);
-#if 1
-    ide_mem_index[0] = pmac_ide_init(&hd[0], pic[0x13], dbdma, 0x14, pic[0x01]);
-    ide_mem_index[1] = pmac_ide_init(&hd[2], pic[0x14], dbdma, 0x16, pic[0x02]);
-#else
-    pci_cmd646_ide_init(pci_bus, &hd[0], 0);
-#endif
+    pci_cmd646_ide_init(pci_bus, hd, 0);
+
     /* cuda also initialize ADB */
     cuda_init(&cuda_mem_index, pic[0x19]);
 
@@ -312,7 +307,7 @@
 
 
     macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem_index,
-               dbdma_mem_index, cuda_mem_index, NULL, 2, ide_mem_index,
+               dbdma_mem_index, cuda_mem_index, NULL, 0, NULL,
                escc_mem_index);
 
     if (usb_enabled) {
target-ppc/cpu.h +2 -1
Index: qemu/target-ppc/cpu.h
===================================================================
@@ -66,7 +66,8 @@
 
 #define TARGET_HAS_ICE 1
 
-#if defined (TARGET_PPC64)
+/* Load a 32 bit BIOS also on 64 bit machines */
+#if defined (TARGET_PPC64) && defined(CONFIG_USER_ONLY)
 #define ELF_MACHINE     EM_PPC64
 #else
 #define ELF_MACHINE     EM_PPC
hw/ppc_oldworld.c +0 -7
Index: qemu/hw/ppc_oldworld.c
===================================================================
@@ -152,13 +152,6 @@
         qemu_register_reset(&cpu_ppc_reset, env);
         envs[i] = env;
     }
-    if (env->nip < 0xFFF80000) {
-        /* Special test for PowerPC 601:
-         * the boot vector is at 0xFFF00100, then we need a 1MB BIOS.
-         * But the NVRAM is located at 0xFFF04000...
-         */
-        cpu_abort(env, "G3 Beige Mac hardware can not handle 1 MB BIOS\n");
-    }
 
     /* allocate RAM */
     if (ram_size > (2047 << 20)) {
hw/ppc_newworld.c +0 -7
Index: qemu/hw/ppc_newworld.c
===================================================================
@@ -123,13 +123,6 @@
         qemu_register_reset(&cpu_ppc_reset, env);
         envs[i] = env;
     }
-    if (env->nip < 0xFFF80000) {
-        /* Special test for PowerPC 601:
-         * the boot vector is at 0xFFF00100, then we need a 1MB BIOS.
-         * But the NVRAM is located at 0xFFF04000...
-         */
-        cpu_abort(env, "Mac99 hardware can not handle 1 MB BIOS\n");
-    }
 
     /* allocate RAM */
     ram_offset = qemu_ram_alloc(ram_size);
hw/ppc_newworld.c +5 -2
Index: qemu/hw/ppc_newworld.c
===================================================================
@@ -98,6 +98,7 @@
     int vga_bios_size, bios_size;
     qemu_irq *dummy_irq;
     int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
+    int ide_mem_index[3];
     int ppc_boot_device;
     int index;
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
@@ -290,7 +291,9 @@
             hd[i] = NULL;
     }
     dbdma = DBDMA_init(&dbdma_mem_index);
-    pci_cmd646_ide_init(pci_bus, hd, 0);
+    ide_mem_index[0] = pmac_ide_init(&hd[0], pic[0x13], dbdma, 0x14, pic[0x01]);
+    ide_mem_index[1] = pmac_ide_init(&hd[1], pic[0x14], dbdma, 0x15, pic[0x02]);
+    ide_mem_index[2] = pmac_ide_init(&hd[2], pic[0x15], dbdma, 0x16, pic[0x03]);
 
     /* cuda also initialize ADB */
     cuda_init(&cuda_mem_index, pic[0x19]);
@@ -300,7 +303,7 @@
 
 
     macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem_index,
-               dbdma_mem_index, cuda_mem_index, NULL, 0, NULL,
+               dbdma_mem_index, cuda_mem_index, NULL, 2, ide_mem_index,
                escc_mem_index);
 
     if (usb_enabled) {
#4 lore raw

Should't we stay emulating the machines as they were?

If we are emulating a Macintosh, it should have whatever controllers the Macintosh had.
If they does not work, specially for booting a third party system, they should be repared, and not be substitued for another one not used on that machine.

Tried to boot any Mac OS?

Quoted 65 lines · Blue Swirl
Quoted 33 lines · Blue Swirl
Quoted 5 lines · Aurelien Jarno
Quoted 1 line · Blue Swirl

Hi,

Hi!

Quoted 7 lines
Quoted 1 line

This set of patches adds basic support for Mac99 Qemu machine,

As you ask the question in the subject, this machine is a NewWorld machine, and not a CHRP one. I think we don't really want to provide a CHRP emulated machine, so the best is probably to rename ppc_chrp.c into ppc_newworld.c.

True. I think RS6000 series were closest to CHRP, not iMac.

The rename does not affect OHW status, so it could be done immediately.

Quoted 13 lines
Quoted 9 lines

provided by ppc_chrp.c. I've used the device tree of iMac DV ('99) as reference:
http://penguinppc.org/historical/dev-trees-html/imac-dv-99.html

The patches changes the machine to use OpenBIOS instead of OHW and otherwise breaks OHW assumptions. On OpenBIOS side there are still some missing bits.

Comments welcome.

Great work.

Quoted 7 lines
Quoted 4 lines

I gave a quick look at the patches, they looks fine. However I still experience some problem with the PowerMac IDE emulation, especially with recent kernels, so until it is fixed (Laurent is working on that) I think we should keep the CMD646 as a default.

OK¸ I'll change that part and send new patches.

This new set of patches perform the rename (to be replaced with SVN operation). CMD646 is used instead of pmac ide.

Debian 4.0 R6 cd image boots, installer starts but keyboard does not work (probably because OpenBIOS doesn't advertise OpenPic).

The 6th patch is not wanted, it just switches CMD646 back to pmac, but it's there if someone wants to play.

Should these be committed or do we want to wait for more OpenBIOS updates? At least the OpenBIOS patch, patch #0 and patch #5 are harmless.
<o_newworld_support.diff

Quoted 1 line

<q_0_rename_chrp_newworld.diff

Quoted 1 line

<q_1_newworld_use_openbios.diff

Quoted 1 line

<q_2_newworld_use_mac_nvram.diff

Quoted 1 line

<q_3_fix_unin_config.diff

Quoted 1 line

<q_4b_newworld_use_cmd646.diff><q_5_load_32bit_bios.diff><q_6_newworld_use_pmac_ide.diff>

author
#5 lore raw
Quoted 7 lines · Natalia Portillo

Should't we stay emulating the machines as they were?

If we are emulating a Macintosh, it should have whatever controllers the
Macintosh had.
If they does not work, specially for booting a third party system, they
should be repared, and not be substitued for another one not used on that machine.

This is just temporary until the pmac ide is fixed. Isn't it also possible that even with the real machine a user may have added a CMD646 PCI card and connected all drives to it?

Quoted 1 line

Tried to boot any Mac OS?

No, are there free and preferably open source boot CD images somewhere?

#7 lore raw
In reply to Blue Swirl
Quoted 40 lines · Blue Swirl
Quoted 39 lines · Blue Swirl
Quoted 5 lines · Aurelien Jarno
Quoted 1 line · Blue Swirl

Hi,

Hi!

Quoted 7 lines
Quoted 1 line

This set of patches adds basic support for Mac99 Qemu machine,

As you ask the question in the subject, this machine is a NewWorld
machine, and not a CHRP one. I think we don't really want to provide a CHRP emulated machine, so the best is probably to rename ppc_chrp.c into ppc_newworld.c.

True. I think RS6000 series were closest to CHRP, not iMac.

The rename does not affect OHW status, so it could be done immediately.

Quoted 17 lines
Quoted 9 lines

provided by ppc_chrp.c. I've used the device tree of iMac DV ('99) as reference:
http://penguinppc.org/historical/dev-trees-html/imac-dv-99.html

The patches changes the machine to use OpenBIOS instead of OHW and otherwise breaks OHW assumptions. On OpenBIOS side there are still some missing bits.

Comments welcome.

Great work.

I gave a quick look at the patches, they looks fine. However I still experience some problem with the PowerMac IDE emulation, especially with recent kernels, so until it is fixed (Laurent is working on that) I think we should keep the CMD646 as a default.

Quoted 7 lines
Quoted 1 line

OK¸ I'll change that part and send new patches.

This new set of patches perform the rename (to be replaced with SVN operation). CMD646 is used instead of pmac ide.

Debian 4.0 R6 cd image boots, installer starts but keyboard does not work (probably because OpenBIOS doesn't advertise OpenPic).

That may be the problem. Alternatively, note that NewWorld machine are not suppose to support ADB bus, so maybe the kernel is disabling that part. We should switch the keyboard and the mouse to USB as on real machines. We already have the code on the QEMU side, so it should be easy. On the OpenBIOS side the code to support an USB keyboard is probably more complicated.

Quoted 6 lines

The 6th patch is not wanted, it just switches CMD646 back to pmac, but it's there if someone wants to play.

Should these be committed or do we want to wait for more OpenBIOS updates? At least the OpenBIOS patch, patch #0 and patch #5 are harmless.

For QEMU, I think there is no problem with that. For OpenBIOS, I think as long as the patches don't break the OldWorld platform, they can be applied.

Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#8 lore raw
Quoted 3 lines · Aurelien Jarno

Alternatively, note that NewWorld machine are
not suppose to support ADB bus, so maybe the kernel is disabling that part.

I'm not entirely certain about that - I seem to recall that at least some PowerBook G4s had their keyboard and trackpad connected through an internal ADB connection. For instance, if you look at <http://tstotts.net/linux/gentoopb.html>, it describes a particular _Aluminium_ PowerBook G4 as having a back-lit ADB keyboard.

// Christian Brunschen

author
#9 lore raw
In reply to Aurelien Jarno
Quoted 50 lines · Aurelien Jarno
Quoted 40 lines · Blue Swirl
Quoted 39 lines · Blue Swirl
Quoted 5 lines · Aurelien Jarno
Quoted 1 line · Blue Swirl

Hi,

Hi!

Quoted 7 lines
Quoted 1 line

This set of patches adds basic support for Mac99 Qemu machine,

As you ask the question in the subject, this machine is a NewWorld
machine, and not a CHRP one. I think we don't really want to provide a CHRP emulated machine, so the best is probably to rename ppc_chrp.c into ppc_newworld.c.

True. I think RS6000 series were closest to CHRP, not iMac.

The rename does not affect OHW status, so it could be done immediately.

Quoted 17 lines
Quoted 9 lines

provided by ppc_chrp.c. I've used the device tree of iMac DV ('99) as reference:
http://penguinppc.org/historical/dev-trees-html/imac-dv-99.html

The patches changes the machine to use OpenBIOS instead of OHW and otherwise breaks OHW assumptions. On OpenBIOS side there are still some missing bits.

Comments welcome.

Great work.

I gave a quick look at the patches, they looks fine. However I still experience some problem with the PowerMac IDE emulation, especially with recent kernels, so until it is fixed (Laurent is working on that) I think we should keep the CMD646 as a default.

Quoted 7 lines
Quoted 1 line

OK¸ I'll change that part and send new patches.

This new set of patches perform the rename (to be replaced with SVN operation). CMD646 is used instead of pmac ide.

Debian 4.0 R6 cd image boots, installer starts but keyboard does not work (probably because OpenBIOS doesn't advertise OpenPic).

Quoted 6 lines

That may be the problem. Alternatively, note that NewWorld machine are
not suppose to support ADB bus, so maybe the kernel is disabling that part. We should switch the keyboard and the mouse to USB as on real machines. We already have the code on the QEMU side, so it should be easy. On the OpenBIOS side the code to support an USB keyboard is probably more complicated.

Well, I just found out that even without any USB support in OpenBIOS, Linux finds the OHCI device and then the keyboard and mouse connected to it, so keyboard works using the same Debian image.