From cormac at c-obrien.org Tue Aug 18 18:17:28 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Tue, 18 Aug 2015 13:17:28 -0500 Subject: [OpenBIOS] [PATCH 0/5] Mac OS 9 compatibility improvements Message-ID: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> This patchset significantly improves OpenBIOS's ability to boot OS 9, adding ESCC legacy ports, reworking ADB interaction with QEMU and fixing IDE controller interaction with the OS. Note that the patch to interpreter.fs is a temporary measure pending a fix that Mark is writing, and that RTAS must be disabled for the OS to boot. Signed-off-by: Cormac O'Brien Cormac O'Brien (5): interpreter.fs: allow evaluate to split words on CR as well as LF ppc: fix up power-mgt properties ppc: add ESCC legacy support ppc: fix CUDA ADB packet header format ppc: fix up IDE device tree and control transfer arch/ppc/qemu/methods.c | 2 + drivers/cuda.c | 17 +++++++-- drivers/escc.c | 85 +++++++++++++++++++++++++++++++++--------- drivers/escc.h | 2 + drivers/ide.c | 33 ++++++++++++++-- drivers/pci.c | 6 +++ forth/bootstrap/interpreter.fs | 2 +- 7 files changed, 121 insertions(+), 26 deletions(-) -- 2.5.0 From cormac at c-obrien.org Tue Aug 18 18:17:29 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Tue, 18 Aug 2015 13:17:29 -0500 Subject: [OpenBIOS] [PATCH 1/5] interpreter.fs: allow evaluate to split words on CR as well as LF In-Reply-To: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> Message-ID: <1439921853-1029-2-git-send-email-cormac@c-obrien.org> Otherwise the Forth intepreter fails due to lack of buffer space when trying to execute large boot scripts on platforms that use CR instead of LF for line endings (particularly MacOS 9). Signed-off-by: Mark Cave-Ayland Signed-off-by: Cormac O'Brien --- forth/bootstrap/interpreter.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forth/bootstrap/interpreter.fs b/forth/bootstrap/interpreter.fs index 5187058..5c3e469 100644 --- a/forth/bootstrap/interpreter.fs +++ b/forth/bootstrap/interpreter.fs @@ -163,7 +163,7 @@ defer outer-interpreter : evaluate ( str len -- ?? ) 2dup + -rot over + over do - i c@ 0a = if + i c@ dup 0a = swap 0d = or if i over - (evaluate) i 1+ -- 2.5.0 From cormac at c-obrien.org Tue Aug 18 18:17:30 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Tue, 18 Aug 2015 13:17:30 -0500 Subject: [OpenBIOS] [PATCH 2/5] ppc: fix up power-mgt properties In-Reply-To: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> Message-ID: <1439921853-1029-3-git-send-email-cormac@c-obrien.org> Modify some basic device tree properties to more accurately emulate a real Mac machine. Signed-off-by: Cormac O'Brien --- drivers/cuda.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cuda.c b/drivers/cuda.c index 9555dea..f117b0b 100644 --- a/drivers/cuda.c +++ b/drivers/cuda.c @@ -380,7 +380,8 @@ powermgt_init(char *path) ph = find_dev(buf); set_property(ph, "device_type", "power-mgt", 10); - set_property(ph, "compatible", "power-mgt", 10); + set_property(ph, "mgt-kind", "min-consumption-pwm-led", strlen("min-consumption-pwm-led") + 1); + set_property(ph, "compatible", "cuda", strlen("cuda") + 1); } cuda_t *cuda_init (const char *path, phys_addr_t base) -- 2.5.0 From cormac at c-obrien.org Tue Aug 18 18:17:31 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Tue, 18 Aug 2015 13:17:31 -0500 Subject: [OpenBIOS] [PATCH 3/5] ppc: add ESCC legacy support In-Reply-To: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> Message-ID: <1439921853-1029-4-git-send-email-cormac@c-obrien.org> Mac OS 9 requires that the host provide escc-legacy serial ports, so we add them here to get further in the boot process. Signed-off-by: Cormac O'Brien --- drivers/escc.c | 85 +++++++++++++++++++++++++++++++++++++++++++++------------- drivers/escc.h | 2 ++ drivers/pci.c | 6 +++++ 3 files changed, 75 insertions(+), 18 deletions(-) diff --git a/drivers/escc.c b/drivers/escc.c index 240043b..972b06a 100644 --- a/drivers/escc.c +++ b/drivers/escc.c @@ -380,12 +380,22 @@ ob_zs_init(phys_addr_t base, uint64_t offset, int intr, int slave, int keyboard) static void escc_add_channel(const char *path, const char *node, phys_addr_t addr, - uint32_t offset) + int esnum) { char buf[64], tty[32]; phandle_t dnode, aliases; - int len; - cell props[2]; + + cell props[10]; + int offset; + int legacy; + + switch (esnum) { + case 2: offset = 1; legacy = 0; break; + case 3: offset = 0; legacy = 0; break; + case 4: offset = 1; legacy = 1; break; + case 5: offset = 0; legacy = 1; break; + default: return; + } /* add device */ @@ -411,16 +421,28 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "device_type", "serial", strlen("serial") + 1); - snprintf(buf, sizeof(buf), "ch-%s", node); - len = strlen(buf) + 1; - snprintf(buf + len, sizeof(buf) - len, "CHRP,es2"); - set_property(dnode, "compatible", buf, len + 9); - - props[0] = IO_ESCC_OFFSET + offset * 0x20; - props[1] = 0x00000020; - set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); + snprintf(buf, sizeof(buf), "chrp,es%d", esnum); + set_property(dnode, "compatible", buf, 9); + + if (legacy) { + props[0] = IO_ESCC_LEGACY_OFFSET + offset * 0x4; + props[1] = 0x00000001; + props[2] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 2; + props[3] = 0x00000001; + props[4] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 6; + props[5] = 0x00000001; + set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); + } else { + props[0] = IO_ESCC_OFFSET + offset * 0x20; + props[1] = 0x00000020; + set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); + } - props[0] = addr + IO_ESCC_OFFSET + offset * 0x20; + if (legacy) { + props[0] = addr + IO_ESCC_LEGACY_OFFSET + offset * 0x4; + } else { + props[0] = addr + IO_ESCC_OFFSET + offset * 0x20; + } OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell))); @@ -429,14 +451,17 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, (char *)&props, 1 * sizeof(cell))); props[0] = (0x24) + offset; - props[1] = 0; + props[1] = 4 + (offset * 2); + props[2] = 5 + (offset * 2); NEWWORLD(set_property(dnode, "interrupts", - (char *)&props, 2 * sizeof(cell))); + (char *)&props, 3 * sizeof(cell))); device_end(); - uart_init_line((unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20, - CONFIG_SERIAL_SPEED); + if (!legacy) { + uart_init_line((unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20, + CONFIG_SERIAL_SPEED); + } } void @@ -467,10 +492,34 @@ escc_init(const char *path, phys_addr_t addr) fword("finish-device"); - escc_add_channel(buf, "a", addr, 1); - escc_add_channel(buf, "b", addr, 0); + escc_add_channel(buf, "a", addr, 2); + escc_add_channel(buf, "b", addr, 3); escc_serial_dev = (unsigned char *)addr + IO_ESCC_OFFSET + (CONFIG_SERIAL_PORT ? 0 : 0x20); + + push_str(path); + fword("find-device"); + fword("new-device"); + + push_str("escc-legacy"); + fword("device-name"); + + snprintf(buf, sizeof(buf), "%s/escc-legacy", path); + + dnode = find_dev(buf); + + set_int_property(dnode, "#address-cells", 1); + props[0] = __cpu_to_be32(IO_ESCC_LEGACY_OFFSET); + props[1] = __cpu_to_be32(IO_ESCC_LEGACY_SIZE); + set_property(dnode, "reg", (char *)&props, sizeof(props)); + set_property(dnode, "device_type", "escc-legacy", + strlen("escc-legacy") + 1); + set_property(dnode, "compatible", "chrp,es1", 9); + + fword("finish-device"); + + escc_add_channel(buf, "a", addr, 4); + escc_add_channel(buf, "b", addr, 5); } #endif diff --git a/drivers/escc.h b/drivers/escc.h index caaf00d..e73f267 100644 --- a/drivers/escc.h +++ b/drivers/escc.h @@ -1,6 +1,8 @@ #define IO_ESCC_SIZE 0x00001000 #define IO_ESCC_OFFSET 0x00013000 +#define IO_ESCC_LEGACY_SIZE 0x00001000 +#define IO_ESCC_LEGACY_OFFSET 0x00012000 #define ZS_REGS 8 diff --git a/drivers/pci.c b/drivers/pci.c index 366f4a1..a68e9dc 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -1420,6 +1420,12 @@ static void ob_pci_host_set_interrupt_map(phandle_t host) target_node = find_dev("/pci/mac-io/escc/ch-b"); set_int_property(target_node, "interrupt-parent", dnode); + target_node = find_dev("/pci/mac-io/escc-legacy/ch-a"); + set_int_property(target_node, "interrupt-parent", dnode); + + target_node = find_dev("/pci/mac-io/escc-legacy/ch-b"); + set_int_property(target_node, "interrupt-parent", dnode); + /* QEMU only emulates 2 of the 3 ata buses currently */ /* On a new world Mac these are not numbered but named by the * ATA version they support. Thus we have: ata-3, ata-3, ata-4 -- 2.5.0 From cormac at c-obrien.org Tue Aug 18 18:17:32 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Tue, 18 Aug 2015 13:17:32 -0500 Subject: [OpenBIOS] [PATCH 4/5] ppc: fix CUDA ADB packet header format In-Reply-To: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> Message-ID: <1439921853-1029-5-git-send-email-cormac@c-obrien.org> Previous versions of QEMU use a 2-byte header for CUDA ADB packets where it should have used a 3-byte one, so this commit allows cuda_adb_req() to differentiate between the two formats and act accordingly. Signed-off-by: Cormac O'Brien --- drivers/cuda.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/cuda.c b/drivers/cuda.c index f117b0b..6f5536a 100644 --- a/drivers/cuda.c +++ b/drivers/cuda.c @@ -144,8 +144,18 @@ static int cuda_adb_req (void *host, const uint8_t *snd_buf, int len, // CUDA_DPRINTF("len: %d %02x\n", len, snd_buf[0]); len = cuda_request(host, ADB_PACKET, snd_buf, len, buffer); if (len > 1 && buffer[0] == ADB_PACKET) { - pos = buffer + 2; - len -= 2; + /* QEMU's previous model used a 2-byte header where it should use a + * 3-byte one, so we check to see what kind of header we ought to use. + */ + if (len > 2 && buffer[2] == snd_buf[0]) { + /* Correct 3-byte header */ + pos = buffer + 3; + len -= 3; + } else { + /* Old 2-byte header */ + pos = buffer + 2; + len -= 2; + } } else { pos = buffer + 1; len = -1; -- 2.5.0 From cormac at c-obrien.org Tue Aug 18 18:17:33 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Tue, 18 Aug 2015 13:17:33 -0500 Subject: [OpenBIOS] [PATCH 5/5] ppc: fix up IDE device tree and control transfer In-Reply-To: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> Message-ID: <1439921853-1029-6-git-send-email-cormac@c-obrien.org> Mac OS 9 is finicky about devices having the correct properties, so we change some IDE data to more closely model a real Mac. We also add ide_exit() to ciface_quiesce() to properly prepare the drives for transferring control to the operating system. Signed-off-by: Cormac O'Brien --- arch/ppc/qemu/methods.c | 2 ++ drivers/ide.c | 33 +++++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/arch/ppc/qemu/methods.c b/arch/ppc/qemu/methods.c index cb72bc1..adf3ea2 100644 --- a/arch/ppc/qemu/methods.c +++ b/arch/ppc/qemu/methods.c @@ -109,11 +109,13 @@ NODE_METHODS( tty ) = { DECLARE_NODE( ciface, 0, 0, "+/openprom/client-services" ); +extern void ide_exit(void); /* ( -- ) */ static void ciface_quiesce( unsigned long args[], unsigned long ret[] ) { usb_exit(); + ide_exit(); #if 0 unsigned long msr; /* This seems to be the correct thing to do - but I'm not sure */ diff --git a/drivers/ide.c b/drivers/ide.c index 327c64a..a064bb8 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -1581,6 +1581,11 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) set_property(dnode, "compatible", (is_oldworld() ? "heathrow-ata" : "keylargo-ata"), 13); + set_property(dnode, "model", ((current_channel == 3) ? + "ata-3" : "ata-4"), 6); + + set_property(dnode, "AAPL,connector", "ata", 4); + props[0] = 0x00000526; props[1] = 0x00000085; props[2] = 0x00000025; @@ -1589,8 +1594,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) props[5] = 0x00000000; props[6] = 0x00000000; props[7] = 0x00000000; - OLDWORLD(set_property(dnode, "AAPL,pio-timing", - (char *)&props, 8*sizeof(props[0]))); + set_property(dnode, "AAPL,pio-timing", + (char *)&props, 8*sizeof(props[0])); /* The first interrupt entry is the ide interrupt, the second the dbdma interrupt */ @@ -1634,8 +1639,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) (char *)&props, 2*sizeof(props[0]))); props[0] = 0; - OLDWORLD(set_property(dnode, "AAPL,bus-id", (char*)props, - 1 * sizeof(props[0]))); + set_property(dnode, "AAPL,bus-id", (char*)props, + 1 * sizeof(props[0])); IDE_DPRINTF(DEV_NAME": [io ports 0x%lx]\n", current_channel, chan->mmio); @@ -1683,3 +1688,23 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) return 0; } #endif /* CONFIG_DRIVER_MACIO */ + +void ide_exit(void); +void ide_exit(void) +{ + struct ide_channel *current; + + current = channels; + while (current) { + struct ide_drive *drive; + int i; + + for (i = 0; i < 2; i++) { + drive = ¤t->drives[i]; + ob_ide_select_drive(drive); + ob_ide_software_reset(drive); + ob_ide_device_type_check(drive); + } + current = current->next; + } +} -- 2.5.0 From programmingkidx at gmail.com Wed Aug 19 13:40:11 2015 From: programmingkidx at gmail.com (Programmingkid) Date: Wed, 19 Aug 2015 09:40:11 -0400 Subject: [OpenBIOS] [PATCH 0/5] Mac OS 9 compatibility improvements In-Reply-To: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> Message-ID: Are these patches already implemented in your binary that is available from your website? On Aug 18, 2015, at 2:17 PM, Cormac O'Brien wrote: > This patchset significantly improves OpenBIOS's ability to boot OS 9, adding > ESCC legacy ports, reworking ADB interaction with QEMU and fixing IDE > controller interaction with the OS. > > Note that the patch to interpreter.fs is a temporary measure pending a fix > that Mark is writing, and that RTAS must be disabled for the OS to boot. > > Signed-off-by: Cormac O'Brien > > Cormac O'Brien (5): > interpreter.fs: allow evaluate to split words on CR as well as LF > ppc: fix up power-mgt properties > ppc: add ESCC legacy support > ppc: fix CUDA ADB packet header format > ppc: fix up IDE device tree and control transfer > > arch/ppc/qemu/methods.c | 2 + > drivers/cuda.c | 17 +++++++-- > drivers/escc.c | 85 +++++++++++++++++++++++++++++++++--------- > drivers/escc.h | 2 + > drivers/ide.c | 33 ++++++++++++++-- > drivers/pci.c | 6 +++ > forth/bootstrap/interpreter.fs | 2 +- > 7 files changed, 121 insertions(+), 26 deletions(-) > > -- > 2.5.0 > > > -- > OpenBIOS http://openbios.org/ > Mailinglist: http://lists.openbios.org/mailman/listinfo > Free your System - May the Forth be with you From laurent at vivier.eu Wed Aug 19 20:57:15 2015 From: laurent at vivier.eu (Laurent Vivier) Date: Wed, 19 Aug 2015 13:57:15 -0700 Subject: [OpenBIOS] [PATCH 0/5] Mac OS 9 compatibility improvements In-Reply-To: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> Message-ID: <55D4EDAB.4090208@vivier.eu> On 18/08/2015 11:17, Cormac O'Brien wrote: > This patchset significantly improves OpenBIOS's ability to boot OS 9, adding > ESCC legacy ports, reworking ADB interaction with QEMU and fixing IDE > controller interaction with the OS. > > Note that the patch to interpreter.fs is a temporary measure pending a fix > that Mark is writing, and that RTAS must be disabled for the OS to boot. > > Signed-off-by: Cormac O'Brien > > Cormac O'Brien (5): > interpreter.fs: allow evaluate to split words on CR as well as LF > ppc: fix up power-mgt properties > ppc: add ESCC legacy support > ppc: fix CUDA ADB packet header format > ppc: fix up IDE device tree and control transfer > > arch/ppc/qemu/methods.c | 2 + > drivers/cuda.c | 17 +++++++-- > drivers/escc.c | 85 +++++++++++++++++++++++++++++++++--------- > drivers/escc.h | 2 + > drivers/ide.c | 33 ++++++++++++++-- > drivers/pci.c | 6 +++ > forth/bootstrap/interpreter.fs | 2 +- > 7 files changed, 121 insertions(+), 26 deletions(-) > Reviewed-by: Laurent Vivier From mark.cave-ayland at ilande.co.uk Wed Aug 19 21:19:46 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Wed, 19 Aug 2015 22:19:46 +0100 Subject: [OpenBIOS] [PATCH 3/5] ppc: add ESCC legacy support In-Reply-To: <1439921853-1029-4-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> <1439921853-1029-4-git-send-email-cormac@c-obrien.org> Message-ID: <55D4F2F2.8000303@ilande.co.uk> On 18/08/15 19:17, Cormac O'Brien wrote: > Mac OS 9 requires that the host provide escc-legacy serial ports, so we add them > here to get further in the boot process. > > Signed-off-by: Cormac O'Brien > --- > drivers/escc.c | 85 +++++++++++++++++++++++++++++++++++++++++++++------------- > drivers/escc.h | 2 ++ > drivers/pci.c | 6 +++++ > 3 files changed, 75 insertions(+), 18 deletions(-) > > diff --git a/drivers/escc.c b/drivers/escc.c > index 240043b..972b06a 100644 > --- a/drivers/escc.c > +++ b/drivers/escc.c > @@ -380,12 +380,22 @@ ob_zs_init(phys_addr_t base, uint64_t offset, int intr, int slave, int keyboard) > > static void > escc_add_channel(const char *path, const char *node, phys_addr_t addr, > - uint32_t offset) > + int esnum) > { > char buf[64], tty[32]; > phandle_t dnode, aliases; > - int len; > - cell props[2]; > + > + cell props[10]; > + int offset; > + int legacy; > + > + switch (esnum) { > + case 2: offset = 1; legacy = 0; break; > + case 3: offset = 0; legacy = 0; break; > + case 4: offset = 1; legacy = 1; break; > + case 5: offset = 0; legacy = 1; break; > + default: return; > + } > > /* add device */ > > @@ -411,16 +421,28 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, > set_property(dnode, "device_type", "serial", > strlen("serial") + 1); > > - snprintf(buf, sizeof(buf), "ch-%s", node); > - len = strlen(buf) + 1; > - snprintf(buf + len, sizeof(buf) - len, "CHRP,es2"); > - set_property(dnode, "compatible", buf, len + 9); > - > - props[0] = IO_ESCC_OFFSET + offset * 0x20; > - props[1] = 0x00000020; > - set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); > + snprintf(buf, sizeof(buf), "chrp,es%d", esnum); > + set_property(dnode, "compatible", buf, 9); > + > + if (legacy) { > + props[0] = IO_ESCC_LEGACY_OFFSET + offset * 0x4; > + props[1] = 0x00000001; > + props[2] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 2; > + props[3] = 0x00000001; > + props[4] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 6; > + props[5] = 0x00000001; > + set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); > + } else { > + props[0] = IO_ESCC_OFFSET + offset * 0x20; > + props[1] = 0x00000020; > + set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); > + } > > - props[0] = addr + IO_ESCC_OFFSET + offset * 0x20; > + if (legacy) { > + props[0] = addr + IO_ESCC_LEGACY_OFFSET + offset * 0x4; > + } else { > + props[0] = addr + IO_ESCC_OFFSET + offset * 0x20; > + } > OLDWORLD(set_property(dnode, "AAPL,address", > (char *)&props, 1 * sizeof(cell))); > > @@ -429,14 +451,17 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, > (char *)&props, 1 * sizeof(cell))); > > props[0] = (0x24) + offset; > - props[1] = 0; > + props[1] = 4 + (offset * 2); > + props[2] = 5 + (offset * 2); I'm slightly curious as to whether things still work with props[1] and props[2] set to 0 here. The reason being that these reference DBDMA serial interrupts which QEMU doesn't (yet) emulate and so it might be better to declare these as zero which should tell the driver to disable the interrupt rather than waiting for something that is non-existent. > NEWWORLD(set_property(dnode, "interrupts", > - (char *)&props, 2 * sizeof(cell))); > + (char *)&props, 3 * sizeof(cell))); > > device_end(); > > - uart_init_line((unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20, > - CONFIG_SERIAL_SPEED); > + if (!legacy) { > + uart_init_line((unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20, > + CONFIG_SERIAL_SPEED); > + } Can we also initialise the legacy ports here at the same time, e.g. if (legacy) { ... ... } else { ... ... } For QEMU it doesn't necessarily matter since the legacy ports are aliased onto the non-legacy ports, but in case this changes at a later date (or someone is interested to run this on real hardware) then we might as well do this at the same time. > } > > void > @@ -467,10 +492,34 @@ escc_init(const char *path, phys_addr_t addr) > > fword("finish-device"); > > - escc_add_channel(buf, "a", addr, 1); > - escc_add_channel(buf, "b", addr, 0); > + escc_add_channel(buf, "a", addr, 2); > + escc_add_channel(buf, "b", addr, 3); > > escc_serial_dev = (unsigned char *)addr + IO_ESCC_OFFSET + > (CONFIG_SERIAL_PORT ? 0 : 0x20); > + > + push_str(path); > + fword("find-device"); > + fword("new-device"); > + > + push_str("escc-legacy"); > + fword("device-name"); > + > + snprintf(buf, sizeof(buf), "%s/escc-legacy", path); > + > + dnode = find_dev(buf); > + > + set_int_property(dnode, "#address-cells", 1); > + props[0] = __cpu_to_be32(IO_ESCC_LEGACY_OFFSET); > + props[1] = __cpu_to_be32(IO_ESCC_LEGACY_SIZE); > + set_property(dnode, "reg", (char *)&props, sizeof(props)); > + set_property(dnode, "device_type", "escc-legacy", > + strlen("escc-legacy") + 1); > + set_property(dnode, "compatible", "chrp,es1", 9); > + > + fword("finish-device"); > + > + escc_add_channel(buf, "a", addr, 4); > + escc_add_channel(buf, "b", addr, 5); > } > #endif > diff --git a/drivers/escc.h b/drivers/escc.h > index caaf00d..e73f267 100644 > --- a/drivers/escc.h > +++ b/drivers/escc.h > @@ -1,6 +1,8 @@ > > #define IO_ESCC_SIZE 0x00001000 > #define IO_ESCC_OFFSET 0x00013000 > +#define IO_ESCC_LEGACY_SIZE 0x00001000 > +#define IO_ESCC_LEGACY_OFFSET 0x00012000 > > #define ZS_REGS 8 > > diff --git a/drivers/pci.c b/drivers/pci.c > index 366f4a1..a68e9dc 100644 > --- a/drivers/pci.c > +++ b/drivers/pci.c > @@ -1420,6 +1420,12 @@ static void ob_pci_host_set_interrupt_map(phandle_t host) > target_node = find_dev("/pci/mac-io/escc/ch-b"); > set_int_property(target_node, "interrupt-parent", dnode); > > + target_node = find_dev("/pci/mac-io/escc-legacy/ch-a"); > + set_int_property(target_node, "interrupt-parent", dnode); > + > + target_node = find_dev("/pci/mac-io/escc-legacy/ch-b"); > + set_int_property(target_node, "interrupt-parent", dnode); > + > /* QEMU only emulates 2 of the 3 ata buses currently */ > /* On a new world Mac these are not numbered but named by the > * ATA version they support. Thus we have: ata-3, ata-3, ata-4 > ATB, Mark. From mark.cave-ayland at ilande.co.uk Wed Aug 19 21:20:01 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Wed, 19 Aug 2015 22:20:01 +0100 Subject: [OpenBIOS] [PATCH 2/5] ppc: fix up power-mgt properties In-Reply-To: <1439921853-1029-3-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> <1439921853-1029-3-git-send-email-cormac@c-obrien.org> Message-ID: <55D4F301.8090706@ilande.co.uk> On 18/08/15 19:17, Cormac O'Brien wrote: > Modify some basic device tree properties to more accurately emulate a real Mac > machine. > > Signed-off-by: Cormac O'Brien > --- > drivers/cuda.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/cuda.c b/drivers/cuda.c > index 9555dea..f117b0b 100644 > --- a/drivers/cuda.c > +++ b/drivers/cuda.c > @@ -380,7 +380,8 @@ powermgt_init(char *path) > > ph = find_dev(buf); > set_property(ph, "device_type", "power-mgt", 10); > - set_property(ph, "compatible", "power-mgt", 10); > + set_property(ph, "mgt-kind", "min-consumption-pwm-led", strlen("min-consumption-pwm-led") + 1); > + set_property(ph, "compatible", "cuda", strlen("cuda") + 1); > } > > cuda_t *cuda_init (const char *path, phys_addr_t base) Reviewed-by: Mark Cave-Ayland ATB, Mark. From mark.cave-ayland at ilande.co.uk Wed Aug 19 21:22:45 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Wed, 19 Aug 2015 22:22:45 +0100 Subject: [OpenBIOS] [PATCH 4/5] ppc: fix CUDA ADB packet header format In-Reply-To: <1439921853-1029-5-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> <1439921853-1029-5-git-send-email-cormac@c-obrien.org> Message-ID: <55D4F3A5.1000801@ilande.co.uk> On 18/08/15 19:17, Cormac O'Brien wrote: > Previous versions of QEMU use a 2-byte header for CUDA ADB packets where it > should have used a 3-byte one, so this commit allows cuda_adb_req() to > differentiate between the two formats and act accordingly. > > Signed-off-by: Cormac O'Brien > --- > drivers/cuda.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/cuda.c b/drivers/cuda.c > index f117b0b..6f5536a 100644 > --- a/drivers/cuda.c > +++ b/drivers/cuda.c > @@ -144,8 +144,18 @@ static int cuda_adb_req (void *host, const uint8_t *snd_buf, int len, > // CUDA_DPRINTF("len: %d %02x\n", len, snd_buf[0]); > len = cuda_request(host, ADB_PACKET, snd_buf, len, buffer); > if (len > 1 && buffer[0] == ADB_PACKET) { > - pos = buffer + 2; > - len -= 2; > + /* QEMU's previous model used a 2-byte header where it should use a > + * 3-byte one, so we check to see what kind of header we ought to use. > + */ > + if (len > 2 && buffer[2] == snd_buf[0]) { > + /* Correct 3-byte header */ > + pos = buffer + 3; > + len -= 3; > + } else { > + /* Old 2-byte header */ > + pos = buffer + 2; > + len -= 2; > + } > } else { > pos = buffer + 1; > len = -1; > I think the patch is good here, but rather than "QEMU's previous model" I'd much prefer giving a specific version e.g. QEMU < 2.5 so it's obvious where the change occurred. In the worst case we can just cherry-pick the ADB change for QEMU for the next release if we can't manage to get all of the patches for QEMU upstream immediately. ATB, Mark. From mark.cave-ayland at ilande.co.uk Wed Aug 19 21:29:53 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Wed, 19 Aug 2015 22:29:53 +0100 Subject: [OpenBIOS] [PATCH 5/5] ppc: fix up IDE device tree and control transfer In-Reply-To: <1439921853-1029-6-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> <1439921853-1029-6-git-send-email-cormac@c-obrien.org> Message-ID: <55D4F551.8030108@ilande.co.uk> On 18/08/15 19:17, Cormac O'Brien wrote: > Mac OS 9 is finicky about devices having the correct properties, so we change > some IDE data to more closely model a real Mac. We also add ide_exit() to Possibly make this "more closely model a real New World Mac" to reflect that this patch also removes the OLDWORLD() guards in a couple of places? > ciface_quiesce() to properly prepare the drives for transferring control to > the operating system. > > Signed-off-by: Cormac O'Brien > --- > arch/ppc/qemu/methods.c | 2 ++ > drivers/ide.c | 33 +++++++++++++++++++++++++++++---- > 2 files changed, 31 insertions(+), 4 deletions(-) > > diff --git a/arch/ppc/qemu/methods.c b/arch/ppc/qemu/methods.c > index cb72bc1..adf3ea2 100644 > --- a/arch/ppc/qemu/methods.c > +++ b/arch/ppc/qemu/methods.c > @@ -109,11 +109,13 @@ NODE_METHODS( tty ) = { > > DECLARE_NODE( ciface, 0, 0, "+/openprom/client-services" ); > > +extern void ide_exit(void); > /* ( -- ) */ > static void > ciface_quiesce( unsigned long args[], unsigned long ret[] ) > { > usb_exit(); > + ide_exit(); > #if 0 > unsigned long msr; > /* This seems to be the correct thing to do - but I'm not sure */ > diff --git a/drivers/ide.c b/drivers/ide.c > index 327c64a..a064bb8 100644 > --- a/drivers/ide.c > +++ b/drivers/ide.c > @@ -1581,6 +1581,11 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) > set_property(dnode, "compatible", (is_oldworld() ? > "heathrow-ata" : "keylargo-ata"), 13); > > + set_property(dnode, "model", ((current_channel == 3) ? > + "ata-3" : "ata-4"), 6); > + > + set_property(dnode, "AAPL,connector", "ata", 4); > + Slight nit here: can we use the same convention as in the earlier patch for specifying the property length, e.g. strlen("ata-3") + 1 and strlen("ata") + 1. I should imagine the overhead should be minimal, and it's a good pattern to use since it helps reduce off-by-one errors, similar to one that we found earlier in the project. > props[0] = 0x00000526; > props[1] = 0x00000085; > props[2] = 0x00000025; > @@ -1589,8 +1594,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) > props[5] = 0x00000000; > props[6] = 0x00000000; > props[7] = 0x00000000; > - OLDWORLD(set_property(dnode, "AAPL,pio-timing", > - (char *)&props, 8*sizeof(props[0]))); > + set_property(dnode, "AAPL,pio-timing", > + (char *)&props, 8*sizeof(props[0])); > > /* The first interrupt entry is the ide interrupt, the second > the dbdma interrupt */ > @@ -1634,8 +1639,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) > (char *)&props, 2*sizeof(props[0]))); > > props[0] = 0; > - OLDWORLD(set_property(dnode, "AAPL,bus-id", (char*)props, > - 1 * sizeof(props[0]))); > + set_property(dnode, "AAPL,bus-id", (char*)props, > + 1 * sizeof(props[0])); > IDE_DPRINTF(DEV_NAME": [io ports 0x%lx]\n", > current_channel, chan->mmio); > > @@ -1683,3 +1688,23 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) > return 0; > } > #endif /* CONFIG_DRIVER_MACIO */ > + > +void ide_exit(void); > +void ide_exit(void) > +{ > + struct ide_channel *current; > + > + current = channels; > + while (current) { > + struct ide_drive *drive; > + int i; > + > + for (i = 0; i < 2; i++) { > + drive = ¤t->drives[i]; > + ob_ide_select_drive(drive); > + ob_ide_software_reset(drive); > + ob_ide_device_type_check(drive); > + } > + current = current->next; > + } > +} ATB, Mark. From mark.cave-ayland at ilande.co.uk Wed Aug 19 21:34:02 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Wed, 19 Aug 2015 22:34:02 +0100 Subject: [OpenBIOS] [PATCH 0/5] Mac OS 9 compatibility improvements In-Reply-To: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> Message-ID: <55D4F64A.7010405@ilande.co.uk> On 18/08/15 19:17, Cormac O'Brien wrote: > This patchset significantly improves OpenBIOS's ability to boot OS 9, adding > ESCC legacy ports, reworking ADB interaction with QEMU and fixing IDE > controller interaction with the OS. > > Note that the patch to interpreter.fs is a temporary measure pending a fix > that Mark is writing, and that RTAS must be disabled for the OS to boot. Just for the archives: I believe in the end that we didn't need to change anything related to RTAS (and it's disabled by default for PPC) so there is actually no change here. > Signed-off-by: Cormac O'Brien > > Cormac O'Brien (5): > interpreter.fs: allow evaluate to split words on CR as well as LF > ppc: fix up power-mgt properties > ppc: add ESCC legacy support > ppc: fix CUDA ADB packet header format > ppc: fix up IDE device tree and control transfer > > arch/ppc/qemu/methods.c | 2 + > drivers/cuda.c | 17 +++++++-- > drivers/escc.c | 85 +++++++++++++++++++++++++++++++++--------- > drivers/escc.h | 2 + > drivers/ide.c | 33 ++++++++++++++-- > drivers/pci.c | 6 +++ > forth/bootstrap/interpreter.fs | 2 +- > 7 files changed, 121 insertions(+), 26 deletions(-) All in all, a good submission. I reckon that we can get this into committable shape without too much difficulty. ATB, Mark. From segher at kernel.crashing.org Wed Aug 19 21:59:51 2015 From: segher at kernel.crashing.org (Segher Boessenkool) Date: Wed, 19 Aug 2015 16:59:51 -0500 Subject: [OpenBIOS] [PATCH 5/5] ppc: fix up IDE device tree and control transfer In-Reply-To: <55D4F551.8030108@ilande.co.uk> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> <1439921853-1029-6-git-send-email-cormac@c-obrien.org> <55D4F551.8030108@ilande.co.uk> Message-ID: <20150819215951.GA26407@gate.crashing.org> On Wed, Aug 19, 2015 at 10:29:53PM +0100, Mark Cave-Ayland wrote: > > + set_property(dnode, "model", ((current_channel == 3) ? > > + "ata-3" : "ata-4"), 6); > > + > > + set_property(dnode, "AAPL,connector", "ata", 4); > > + > > Slight nit here: can we use the same convention as in the earlier patch > for specifying the property length, e.g. strlen("ata-3") + 1 and > strlen("ata") + 1. I should imagine the overhead should be minimal, and Zero overhead to be exact; GCC knows how to do strlen on constant strings. It would be nice if you could do e.g. set_string_property(dnode, "AAPL,connector", "ata"); which handles all common cases. Little helpers are not just for fairy tales :-) Segher From programmingkidx at gmail.com Thu Aug 20 16:17:16 2015 From: programmingkidx at gmail.com (Programmingkid) Date: Thu, 20 Aug 2015 12:17:16 -0400 Subject: [OpenBIOS] [PATCH 5/5] ppc: fix up IDE device tree and control transfer In-Reply-To: <55D4F9B4.8020706@ilande.co.uk> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> <1439921853-1029-6-git-send-email-cormac@c-obrien.org> <55D4F551.8030108@ilande.co.uk> <0118C8AF-9589-4601-A20D-D69D86D6937E@gmail.com> <55D4F777.50001@ilande.co.uk> <006F5C0A-5F52-4BBD-8121-D05C7038D2CB@gmail.com> <55D4F9B4.8020706@ilande.co.uk> Message-ID: <89563B21-DFA6-4B9B-974E-E015B8B9AB45@gmail.com> On Aug 19, 2015, at 5:48 PM, Mark Cave-Ayland wrote: > On 19/08/15 22:45, Programmingkid wrote: > >> On Aug 19, 2015, at 5:39 PM, Mark Cave-Ayland wrote: >> >>> On 19/08/15 22:31, Programmingkid wrote: >>> >>>> Would you know how to disable the RTAS? I want to test out these patches but no directions were given on how to disable the node. >>> >>> Looks like you just missed my latest email - there should be no change >>> required for the RTAS settings. >> >> Ok. If you have tested Cormac's patches, do you see Mac OS 9 booting? I followed all the directions from his testing page and couldn't see anything that belongs to Mac OS 9. Here is the url: http://c-obrien.org/qemu-os9/testing/ >> >> I did my test on Mac OS X, so that could be the problem. > > Yes I did have it working with the github macos9 branch and the Cormac's > github upstream branch earlier in the week. Note that sometimes you can > get a hang before the grey screen appears... > > If you have a specific problem, reply to the thread on the mailing list > and supply a link to a screenshot so other people can test. > I have followed the directions twice from the testing page and have ended up with just this error message: MacOS: unable to find a usable NVRAM partititon - using offset 0x1400. I am building on Mac OS X, so that could be the problem. Cormac, the testing page needs minor changes. The line where configure is set, please change the path from "$HOME/os9/qemu-install" to "$HOME/os9-test/qemu-install". The "-test" part is missing. After the "Run QEMU with the following command:" text, please remove the "cd ..". That would take the user into the home folder rather than in the os9-test folder. The command that runs QEMU should be free of any '>' characters. They cause files to be made called -bios, -boot, -ccdrom, -M, and -m. It would probably be easier to copy and paste the command if it were on one line. At the top of the page it talks about having Python 2 installed. The rest of the directions make no mention of using Python. Are you sure it is needed? Other than the minor issues, the web site looks good. Thank you. From i.am.cormac.obrien at gmail.com Thu Aug 20 19:20:51 2015 From: i.am.cormac.obrien at gmail.com (Cormac O'Brien) Date: Thu, 20 Aug 2015 14:20:51 -0500 Subject: [OpenBIOS] [PATCH 5/5] ppc: fix up IDE device tree and control transfer In-Reply-To: <89563B21-DFA6-4B9B-974E-E015B8B9AB45@gmail.com> References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> <1439921853-1029-6-git-send-email-cormac@c-obrien.org> <55D4F551.8030108@ilande.co.uk> <0118C8AF-9589-4601-A20D-D69D86D6937E@gmail.com> <55D4F777.50001@ilande.co.uk> <006F5C0A-5F52-4BBD-8121-D05C7038D2CB@gmail.com> <55D4F9B4.8020706@ilande.co.uk> <89563B21-DFA6-4B9B-974E-E015B8B9AB45@gmail.com> Message-ID: On Thu, Aug 20, 2015 at 11:17 AM, Programmingkid wrote: > > On Aug 19, 2015, at 5:48 PM, Mark Cave-Ayland wrote: > >> On 19/08/15 22:45, Programmingkid wrote: >> >>> On Aug 19, 2015, at 5:39 PM, Mark Cave-Ayland wrote: >>> >>>> On 19/08/15 22:31, Programmingkid wrote: >>>> >>>>> Would you know how to disable the RTAS? I want to test out these patches but no directions were given on how to disable the node. >>>> >>>> Looks like you just missed my latest email - there should be no change >>>> required for the RTAS settings. >>> >>> Ok. If you have tested Cormac's patches, do you see Mac OS 9 booting? I followed all the directions from his testing page and couldn't see anything that belongs to Mac OS 9. Here is the url: http://c-obrien.org/qemu-os9/testing/ >>> >>> I did my test on Mac OS X, so that could be the problem. >> >> Yes I did have it working with the github macos9 branch and the Cormac's >> github upstream branch earlier in the week. Note that sometimes you can >> get a hang before the grey screen appears... >> >> If you have a specific problem, reply to the thread on the mailing list >> and supply a link to a screenshot so other people can test. >> > > > I have followed the directions twice from the testing page and have ended up with just this error message: > MacOS: unable to find a usable NVRAM partititon - using offset 0x1400. > > I am building on Mac OS X, so that could be the problem. That message is itself not an error, just informational -- OS 9 will reserve some memory to function as the missing NVRAM. It takes a varying amount of time to continue from there but it should be less than 10 seconds. > Cormac, the testing page needs minor changes. > > The line where configure is set, please change the path from "$HOME/os9/qemu-install" to "$HOME/os9-test/qemu-install". The "-test" part is missing. > > After the "Run QEMU with the following command:" text, please remove the "cd ..". That would take the user into the home folder rather than in the os9-test folder. At that point the user should be in qemu-build, so the parent is os9-test. > The command that runs QEMU should be free of any '>' characters. They cause files to be made called -bios, -boot, -ccdrom, -M, and -m. It would probably be easier to copy and paste the command if it were on one line. I'll put another text box in for copy-paste purposes, but I do prefer the current formatting. I just used '>' since that's the default $PS2 in bash. > At the top of the page it talks about having Python 2 installed. The rest of the directions make no mention of using Python. Are you sure it is needed? QEMU uses autoconf for some Python-related stuff, so it definitely is necessary. I included this because Arch users might not be aware of the 'python' -> 'python3' that Arch uses by default. > Other than the minor issues, the web site looks good. Thank you. > -- > OpenBIOS http://openbios.org/ > Mailinglist: http://lists.openbios.org/mailman/listinfo > Free your System - May the Forth be with you From programmingkidx at gmail.com Thu Aug 20 19:51:42 2015 From: programmingkidx at gmail.com (Programmingkid) Date: Thu, 20 Aug 2015 15:51:42 -0400 Subject: [OpenBIOS] [PATCH 5/5] ppc: fix up IDE device tree and control transfer In-Reply-To: References: <1439921853-1029-1-git-send-email-cormac@c-obrien.org> <1439921853-1029-6-git-send-email-cormac@c-obrien.org> <55D4F551.8030108@ilande.co.uk> <0118C8AF-9589-4601-A20D-D69D86D6937E@gmail.com> <55D4F777.50001@ilande.co.uk> <006F5C0A-5F52-4BBD-8121-D05C7038D2CB@gmail.com> <55D4F9B4.8020706@ilande.co.uk> <89563B21-DFA6-4B9B-974E-E015B8B9AB45@gmail.com> Message-ID: <4A09924B-294D-43D7-9F68-8699157E4847@gmail.com> On Aug 20, 2015, at 3:20 PM, Cormac O'Brien wrote: > On Thu, Aug 20, 2015 at 11:17 AM, Programmingkid > wrote: >> >> On Aug 19, 2015, at 5:48 PM, Mark Cave-Ayland wrote: >> >>> On 19/08/15 22:45, Programmingkid wrote: >>> >>>> On Aug 19, 2015, at 5:39 PM, Mark Cave-Ayland wrote: >>>> >>>>> On 19/08/15 22:31, Programmingkid wrote: >>>>> >>>>>> Would you know how to disable the RTAS? I want to test out these patches but no directions were given on how to disable the node. >>>>> >>>>> Looks like you just missed my latest email - there should be no change >>>>> required for the RTAS settings. >>>> >>>> Ok. If you have tested Cormac's patches, do you see Mac OS 9 booting? I followed all the directions from his testing page and couldn't see anything that belongs to Mac OS 9. Here is the url: http://c-obrien.org/qemu-os9/testing/ >>>> >>>> I did my test on Mac OS X, so that could be the problem. >>> >>> Yes I did have it working with the github macos9 branch and the Cormac's >>> github upstream branch earlier in the week. Note that sometimes you can >>> get a hang before the grey screen appears... >>> >>> If you have a specific problem, reply to the thread on the mailing list >>> and supply a link to a screenshot so other people can test. >>> >> >> >> I have followed the directions twice from the testing page and have ended up with just this error message: >> MacOS: unable to find a usable NVRAM partititon - using offset 0x1400. >> >> I am building on Mac OS X, so that could be the problem. > > That message is itself not an error, just informational -- OS 9 will > reserve some memory to function as the missing NVRAM. It takes a > varying amount of time to continue from there but it should be less > than 10 seconds. I let QEMU run for several minutes after the message and never saw anything else. I guess something is different with the Mac OS X build process that prevents Mac OS 9 from working. From cormac at c-obrien.org Thu Aug 20 22:45:12 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Thu, 20 Aug 2015 17:45:12 -0500 Subject: [OpenBIOS] [PATCH v2 0/5] Mac OS 9 compatibility improvements Message-ID: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> This patchset significantly improves OpenBIOS's ability to boot OS 9, adding ESCC legacy ports, reworking ADB interaction with QEMU and fixing IDE controller interaction with the OS. Note that the patch to interpreter.fs is a temporary measure pending a fix that Mark is writing, and that RTAS must be disabled for the OS to boot. Signed-off-by: Cormac O'Brien --- Changes from v1: * Initialize ESCC legacy ports * Don't enable non-implemented DBDMA interrupts * Update some commit messages and comments Cormac O'Brien (5): interpreter.fs: allow evaluate to split words on CR as well as LF ppc: fix up power-mgt properties ppc: add ESCC legacy support ppc: fix CUDA ADB packet header format ppc: fix up IDE device tree and control transfer arch/ppc/qemu/methods.c | 2 + drivers/cuda.c | 17 ++++++-- drivers/escc.c | 88 ++++++++++++++++++++++++++++++++++-------- drivers/escc.h | 2 + drivers/ide.c | 34 ++++++++++++++-- drivers/pci.c | 6 +++ forth/bootstrap/interpreter.fs | 2 +- 7 files changed, 126 insertions(+), 25 deletions(-) -- 2.5.0 From cormac at c-obrien.org Thu Aug 20 22:45:14 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Thu, 20 Aug 2015 17:45:14 -0500 Subject: [OpenBIOS] [PATCH 2/5] ppc: fix up power-mgt properties In-Reply-To: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> References: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> Message-ID: <1440110717-23498-3-git-send-email-cormac@c-obrien.org> Modify some basic device tree properties to more accurately emulate a real Mac machine. Signed-off-by: Cormac O'Brien --- drivers/cuda.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cuda.c b/drivers/cuda.c index 9555dea..f117b0b 100644 --- a/drivers/cuda.c +++ b/drivers/cuda.c @@ -380,7 +380,8 @@ powermgt_init(char *path) ph = find_dev(buf); set_property(ph, "device_type", "power-mgt", 10); - set_property(ph, "compatible", "power-mgt", 10); + set_property(ph, "mgt-kind", "min-consumption-pwm-led", strlen("min-consumption-pwm-led") + 1); + set_property(ph, "compatible", "cuda", strlen("cuda") + 1); } cuda_t *cuda_init (const char *path, phys_addr_t base) -- 2.5.0 From cormac at c-obrien.org Thu Aug 20 22:45:13 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Thu, 20 Aug 2015 17:45:13 -0500 Subject: [OpenBIOS] [PATCH 1/5] interpreter.fs: allow evaluate to split words on CR as well as LF In-Reply-To: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> References: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> Message-ID: <1440110717-23498-2-git-send-email-cormac@c-obrien.org> Otherwise the Forth intepreter fails due to lack of buffer space when trying to execute large boot scripts on platforms that use CR instead of LF for line endings (particularly MacOS 9). Signed-off-by: Mark Cave-Ayland Signed-off-by: Cormac O'Brien --- forth/bootstrap/interpreter.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forth/bootstrap/interpreter.fs b/forth/bootstrap/interpreter.fs index 5187058..5c3e469 100644 --- a/forth/bootstrap/interpreter.fs +++ b/forth/bootstrap/interpreter.fs @@ -163,7 +163,7 @@ defer outer-interpreter : evaluate ( str len -- ?? ) 2dup + -rot over + over do - i c@ 0a = if + i c@ dup 0a = swap 0d = or if i over - (evaluate) i 1+ -- 2.5.0 From cormac at c-obrien.org Thu Aug 20 22:45:15 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Thu, 20 Aug 2015 17:45:15 -0500 Subject: [OpenBIOS] [PATCH 3/5] ppc: add ESCC legacy support In-Reply-To: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> References: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> Message-ID: <1440110717-23498-4-git-send-email-cormac@c-obrien.org> Mac OS 9 requires that the host provide escc-legacy serial ports, so we add them here to get further in the boot process. Signed-off-by: Cormac O'Brien --- drivers/escc.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++------------ drivers/escc.h | 2 ++ drivers/pci.c | 6 ++++ 3 files changed, 79 insertions(+), 17 deletions(-) diff --git a/drivers/escc.c b/drivers/escc.c index 240043b..afb97fa 100644 --- a/drivers/escc.c +++ b/drivers/escc.c @@ -380,12 +380,22 @@ ob_zs_init(phys_addr_t base, uint64_t offset, int intr, int slave, int keyboard) static void escc_add_channel(const char *path, const char *node, phys_addr_t addr, - uint32_t offset) + int esnum) { char buf[64], tty[32]; phandle_t dnode, aliases; - int len; - cell props[2]; + + cell props[10]; + int offset; + int legacy; + + switch (esnum) { + case 2: offset = 1; legacy = 0; break; + case 3: offset = 0; legacy = 0; break; + case 4: offset = 1; legacy = 1; break; + case 5: offset = 0; legacy = 1; break; + default: return; + } /* add device */ @@ -411,16 +421,28 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "device_type", "serial", strlen("serial") + 1); - snprintf(buf, sizeof(buf), "ch-%s", node); - len = strlen(buf) + 1; - snprintf(buf + len, sizeof(buf) - len, "CHRP,es2"); - set_property(dnode, "compatible", buf, len + 9); - - props[0] = IO_ESCC_OFFSET + offset * 0x20; - props[1] = 0x00000020; - set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); + snprintf(buf, sizeof(buf), "chrp,es%d", esnum); + set_property(dnode, "compatible", buf, 9); + + if (legacy) { + props[0] = IO_ESCC_LEGACY_OFFSET + offset * 0x4; + props[1] = 0x00000001; + props[2] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 2; + props[3] = 0x00000001; + props[4] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 6; + props[5] = 0x00000001; + set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); + } else { + props[0] = IO_ESCC_OFFSET + offset * 0x20; + props[1] = 0x00000020; + set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); + } - props[0] = addr + IO_ESCC_OFFSET + offset * 0x20; + if (legacy) { + props[0] = addr + IO_ESCC_LEGACY_OFFSET + offset * 0x4; + } else { + props[0] = addr + IO_ESCC_OFFSET + offset * 0x20; + } OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell))); @@ -430,13 +452,21 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, props[0] = (0x24) + offset; props[1] = 0; + props[2] = 0; NEWWORLD(set_property(dnode, "interrupts", - (char *)&props, 2 * sizeof(cell))); + (char *)&props, 3 * sizeof(cell))); device_end(); - uart_init_line((unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20, - CONFIG_SERIAL_SPEED); + if (legacy) { + uart_init_line( + (unsigned char*)addr + IO_ESCC_LEGACY_OFFSET + offset * 0x4, + CONFIG_SERIAL_SPEED); + } else { + uart_init_line( + (unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20, + CONFIG_SERIAL_SPEED); + } } void @@ -467,10 +497,34 @@ escc_init(const char *path, phys_addr_t addr) fword("finish-device"); - escc_add_channel(buf, "a", addr, 1); - escc_add_channel(buf, "b", addr, 0); + escc_add_channel(buf, "a", addr, 2); + escc_add_channel(buf, "b", addr, 3); escc_serial_dev = (unsigned char *)addr + IO_ESCC_OFFSET + (CONFIG_SERIAL_PORT ? 0 : 0x20); + + push_str(path); + fword("find-device"); + fword("new-device"); + + push_str("escc-legacy"); + fword("device-name"); + + snprintf(buf, sizeof(buf), "%s/escc-legacy", path); + + dnode = find_dev(buf); + + set_int_property(dnode, "#address-cells", 1); + props[0] = __cpu_to_be32(IO_ESCC_LEGACY_OFFSET); + props[1] = __cpu_to_be32(IO_ESCC_LEGACY_SIZE); + set_property(dnode, "reg", (char *)&props, sizeof(props)); + set_property(dnode, "device_type", "escc-legacy", + strlen("escc-legacy") + 1); + set_property(dnode, "compatible", "chrp,es1", 9); + + fword("finish-device"); + + escc_add_channel(buf, "a", addr, 4); + escc_add_channel(buf, "b", addr, 5); } #endif diff --git a/drivers/escc.h b/drivers/escc.h index caaf00d..e73f267 100644 --- a/drivers/escc.h +++ b/drivers/escc.h @@ -1,6 +1,8 @@ #define IO_ESCC_SIZE 0x00001000 #define IO_ESCC_OFFSET 0x00013000 +#define IO_ESCC_LEGACY_SIZE 0x00001000 +#define IO_ESCC_LEGACY_OFFSET 0x00012000 #define ZS_REGS 8 diff --git a/drivers/pci.c b/drivers/pci.c index 366f4a1..a68e9dc 100644 --- a/drivers/pci.c +++ b/drivers/pci.c @@ -1420,6 +1420,12 @@ static void ob_pci_host_set_interrupt_map(phandle_t host) target_node = find_dev("/pci/mac-io/escc/ch-b"); set_int_property(target_node, "interrupt-parent", dnode); + target_node = find_dev("/pci/mac-io/escc-legacy/ch-a"); + set_int_property(target_node, "interrupt-parent", dnode); + + target_node = find_dev("/pci/mac-io/escc-legacy/ch-b"); + set_int_property(target_node, "interrupt-parent", dnode); + /* QEMU only emulates 2 of the 3 ata buses currently */ /* On a new world Mac these are not numbered but named by the * ATA version they support. Thus we have: ata-3, ata-3, ata-4 -- 2.5.0 From cormac at c-obrien.org Thu Aug 20 22:45:16 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Thu, 20 Aug 2015 17:45:16 -0500 Subject: [OpenBIOS] [PATCH 4/5] ppc: fix CUDA ADB packet header format In-Reply-To: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> References: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> Message-ID: <1440110717-23498-5-git-send-email-cormac@c-obrien.org> QEMU < 2.5 uses a 2-byte header for CUDA ADB packets where it should use a 3-byte one, so this commit allows cuda_adb_req() to differentiate between the two formats and act accordingly. Signed-off-by: Cormac O'Brien --- drivers/cuda.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/cuda.c b/drivers/cuda.c index f117b0b..9197729 100644 --- a/drivers/cuda.c +++ b/drivers/cuda.c @@ -144,8 +144,18 @@ static int cuda_adb_req (void *host, const uint8_t *snd_buf, int len, // CUDA_DPRINTF("len: %d %02x\n", len, snd_buf[0]); len = cuda_request(host, ADB_PACKET, snd_buf, len, buffer); if (len > 1 && buffer[0] == ADB_PACKET) { - pos = buffer + 2; - len -= 2; + /* QEMU < 2.5 uses a 2-byte header where it should use a 3-byte one, + * so we check to see what kind of header we ought to use. + */ + if (len > 2 && buffer[2] == snd_buf[0]) { + /* Correct 3-byte header */ + pos = buffer + 3; + len -= 3; + } else { + /* Old 2-byte header */ + pos = buffer + 2; + len -= 2; + } } else { pos = buffer + 1; len = -1; -- 2.5.0 From cormac at c-obrien.org Thu Aug 20 22:45:17 2015 From: cormac at c-obrien.org (Cormac O'Brien) Date: Thu, 20 Aug 2015 17:45:17 -0500 Subject: [OpenBIOS] [PATCH 5/5] ppc: fix up IDE device tree and control transfer In-Reply-To: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> References: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> Message-ID: <1440110717-23498-6-git-send-email-cormac@c-obrien.org> Mac OS 9 is finicky about devices having the correct properties, so we change some IDE data to more closely model a real New World Mac. We also add ide_exit() to ciface_quiesce() to properly prepare the drives for transferring control to the operating system. Signed-off-by: Cormac O'Brien --- arch/ppc/qemu/methods.c | 2 ++ drivers/ide.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/arch/ppc/qemu/methods.c b/arch/ppc/qemu/methods.c index cb72bc1..adf3ea2 100644 --- a/arch/ppc/qemu/methods.c +++ b/arch/ppc/qemu/methods.c @@ -109,11 +109,13 @@ NODE_METHODS( tty ) = { DECLARE_NODE( ciface, 0, 0, "+/openprom/client-services" ); +extern void ide_exit(void); /* ( -- ) */ static void ciface_quiesce( unsigned long args[], unsigned long ret[] ) { usb_exit(); + ide_exit(); #if 0 unsigned long msr; /* This seems to be the correct thing to do - but I'm not sure */ diff --git a/drivers/ide.c b/drivers/ide.c index 327c64a..8ef34cb 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -1581,6 +1581,12 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) set_property(dnode, "compatible", (is_oldworld() ? "heathrow-ata" : "keylargo-ata"), 13); + set_property(dnode, "model", ((current_channel == 3) ? + "ata-3" : "ata-4"), strlen("ata-*") + 1); + + set_property(dnode, "AAPL,connector", "ata", + strlen("ata") + 1); + props[0] = 0x00000526; props[1] = 0x00000085; props[2] = 0x00000025; @@ -1589,8 +1595,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) props[5] = 0x00000000; props[6] = 0x00000000; props[7] = 0x00000000; - OLDWORLD(set_property(dnode, "AAPL,pio-timing", - (char *)&props, 8*sizeof(props[0]))); + set_property(dnode, "AAPL,pio-timing", + (char *)&props, 8*sizeof(props[0])); /* The first interrupt entry is the ide interrupt, the second the dbdma interrupt */ @@ -1634,8 +1640,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) (char *)&props, 2*sizeof(props[0]))); props[0] = 0; - OLDWORLD(set_property(dnode, "AAPL,bus-id", (char*)props, - 1 * sizeof(props[0]))); + set_property(dnode, "AAPL,bus-id", (char*)props, + 1 * sizeof(props[0])); IDE_DPRINTF(DEV_NAME": [io ports 0x%lx]\n", current_channel, chan->mmio); @@ -1683,3 +1689,23 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) return 0; } #endif /* CONFIG_DRIVER_MACIO */ + +void ide_exit(void); +void ide_exit(void) +{ + struct ide_channel *current; + + current = channels; + while (current) { + struct ide_drive *drive; + int i; + + for (i = 0; i < 2; i++) { + drive = ¤t->drives[i]; + ob_ide_select_drive(drive); + ob_ide_software_reset(drive); + ob_ide_device_type_check(drive); + } + current = current->next; + } +} -- 2.5.0 From mark.cave-ayland at ilande.co.uk Sun Aug 23 13:22:41 2015 From: mark.cave-ayland at ilande.co.uk (Mark Cave-Ayland) Date: Sun, 23 Aug 2015 14:22:41 +0100 Subject: [OpenBIOS] [PATCH v2 0/5] Mac OS 9 compatibility improvements In-Reply-To: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> References: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> Message-ID: <55D9C921.3060605@ilande.co.uk> On 20/08/15 23:45, Cormac O'Brien wrote: > This patchset significantly improves OpenBIOS's ability to boot OS 9, adding > ESCC legacy ports, reworking ADB interaction with QEMU and fixing IDE > controller interaction with the OS. > > Note that the patch to interpreter.fs is a temporary measure pending a fix > that Mark is writing, and that RTAS must be disabled for the OS to boot. > > Signed-off-by: Cormac O'Brien > --- > Changes from v1: > * Initialize ESCC legacy ports > * Don't enable non-implemented DBDMA interrupts > * Update some commit messages and comments > > Cormac O'Brien (5): > interpreter.fs: allow evaluate to split words on CR as well as LF > ppc: fix up power-mgt properties > ppc: add ESCC legacy support > ppc: fix CUDA ADB packet header format > ppc: fix up IDE device tree and control transfer > > arch/ppc/qemu/methods.c | 2 + > drivers/cuda.c | 17 ++++++-- > drivers/escc.c | 88 ++++++++++++++++++++++++++++++++++-------- > drivers/escc.h | 2 + > drivers/ide.c | 34 ++++++++++++++-- > drivers/pci.c | 6 +++ > forth/bootstrap/interpreter.fs | 2 +- > 7 files changed, 126 insertions(+), 25 deletions(-) While I need to revisit the interpreter.fs patch, I'm happy with the rest of this patchset and it doesn't appear to introduce any regressions in my tests here so: Reviewed-by: Mark Cave-Ayland ATB, Mark. From agraf at suse.de Wed Aug 26 08:52:10 2015 From: agraf at suse.de (Alexander Graf) Date: Wed, 26 Aug 2015 10:52:10 +0200 Subject: [OpenBIOS] [PATCH 2/5] ppc: fix up power-mgt properties In-Reply-To: <1440110717-23498-3-git-send-email-cormac@c-obrien.org> References: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> <1440110717-23498-3-git-send-email-cormac@c-obrien.org> Message-ID: <55DD7E3A.9060905@suse.de> On 21.08.15 00:45, Cormac O'Brien wrote: > Modify some basic device tree properties to more accurately emulate a real Mac > machine. > > Signed-off-by: Cormac O'Brien > --- > drivers/cuda.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/cuda.c b/drivers/cuda.c > index 9555dea..f117b0b 100644 > --- a/drivers/cuda.c > +++ b/drivers/cuda.c > @@ -380,7 +380,8 @@ powermgt_init(char *path) > > ph = find_dev(buf); > set_property(ph, "device_type", "power-mgt", 10); > - set_property(ph, "compatible", "power-mgt", 10); > + set_property(ph, "mgt-kind", "min-consumption-pwm-led", strlen("min-consumption-pwm-led") + 1); > + set_property(ph, "compatible", "cuda", strlen("cuda") + 1); ... and more candidates for a string helper function Alex From agraf at suse.de Wed Aug 26 08:51:46 2015 From: agraf at suse.de (Alexander Graf) Date: Wed, 26 Aug 2015 10:51:46 +0200 Subject: [OpenBIOS] [PATCH 3/5] ppc: add ESCC legacy support In-Reply-To: <1440110717-23498-4-git-send-email-cormac@c-obrien.org> References: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> <1440110717-23498-4-git-send-email-cormac@c-obrien.org> Message-ID: <55DD7E22.304@suse.de> On 21.08.15 00:45, Cormac O'Brien wrote: > Mac OS 9 requires that the host provide escc-legacy serial ports, so we add > them here to get further in the boot process. > > Signed-off-by: Cormac O'Brien > --- > drivers/escc.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++------------ > drivers/escc.h | 2 ++ > drivers/pci.c | 6 ++++ > 3 files changed, 79 insertions(+), 17 deletions(-) > > diff --git a/drivers/escc.c b/drivers/escc.c > index 240043b..afb97fa 100644 > --- a/drivers/escc.c > +++ b/drivers/escc.c > @@ -380,12 +380,22 @@ ob_zs_init(phys_addr_t base, uint64_t offset, int intr, int slave, int keyboard) > > static void > escc_add_channel(const char *path, const char *node, phys_addr_t addr, > - uint32_t offset) > + int esnum) > { > char buf[64], tty[32]; > phandle_t dnode, aliases; > - int len; > - cell props[2]; > + > + cell props[10]; > + int offset; > + int legacy; > + > + switch (esnum) { > + case 2: offset = 1; legacy = 0; break; > + case 3: offset = 0; legacy = 0; break; > + case 4: offset = 1; legacy = 1; break; > + case 5: offset = 0; legacy = 1; break; > + default: return; > + } > > /* add device */ > > @@ -411,16 +421,28 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, > set_property(dnode, "device_type", "serial", > strlen("serial") + 1); > > - snprintf(buf, sizeof(buf), "ch-%s", node); > - len = strlen(buf) + 1; > - snprintf(buf + len, sizeof(buf) - len, "CHRP,es2"); > - set_property(dnode, "compatible", buf, len + 9); > - > - props[0] = IO_ESCC_OFFSET + offset * 0x20; > - props[1] = 0x00000020; > - set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); > + snprintf(buf, sizeof(buf), "chrp,es%d", esnum); > + set_property(dnode, "compatible", buf, 9); > + > + if (legacy) { > + props[0] = IO_ESCC_LEGACY_OFFSET + offset * 0x4; > + props[1] = 0x00000001; > + props[2] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 2; > + props[3] = 0x00000001; > + props[4] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 6; > + props[5] = 0x00000001; > + set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); > + } else { > + props[0] = IO_ESCC_OFFSET + offset * 0x20; > + props[1] = 0x00000020; > + set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); > + } > > - props[0] = addr + IO_ESCC_OFFSET + offset * 0x20; > + if (legacy) { > + props[0] = addr + IO_ESCC_LEGACY_OFFSET + offset * 0x4; > + } else { > + props[0] = addr + IO_ESCC_OFFSET + offset * 0x20; > + } > OLDWORLD(set_property(dnode, "AAPL,address", > (char *)&props, 1 * sizeof(cell))); > > @@ -430,13 +452,21 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, > > props[0] = (0x24) + offset; > props[1] = 0; > + props[2] = 0; > NEWWORLD(set_property(dnode, "interrupts", > - (char *)&props, 2 * sizeof(cell))); > + (char *)&props, 3 * sizeof(cell))); > > device_end(); > > - uart_init_line((unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20, > - CONFIG_SERIAL_SPEED); > + if (legacy) { > + uart_init_line( > + (unsigned char*)addr + IO_ESCC_LEGACY_OFFSET + offset * 0x4, > + CONFIG_SERIAL_SPEED); > + } else { > + uart_init_line( > + (unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20, > + CONFIG_SERIAL_SPEED); > + } > } > > void > @@ -467,10 +497,34 @@ escc_init(const char *path, phys_addr_t addr) > > fword("finish-device"); > > - escc_add_channel(buf, "a", addr, 1); > - escc_add_channel(buf, "b", addr, 0); > + escc_add_channel(buf, "a", addr, 2); > + escc_add_channel(buf, "b", addr, 3); > > escc_serial_dev = (unsigned char *)addr + IO_ESCC_OFFSET + > (CONFIG_SERIAL_PORT ? 0 : 0x20); > + > + push_str(path); > + fword("find-device"); > + fword("new-device"); > + > + push_str("escc-legacy"); > + fword("device-name"); > + > + snprintf(buf, sizeof(buf), "%s/escc-legacy", path); > + > + dnode = find_dev(buf); > + > + set_int_property(dnode, "#address-cells", 1); > + props[0] = __cpu_to_be32(IO_ESCC_LEGACY_OFFSET); > + props[1] = __cpu_to_be32(IO_ESCC_LEGACY_SIZE); > + set_property(dnode, "reg", (char *)&props, sizeof(props)); > + set_property(dnode, "device_type", "escc-legacy", > + strlen("escc-legacy") + 1); Same comment about the string helper. Otherwise looks good. Alex From agraf at suse.de Wed Aug 26 08:49:08 2015 From: agraf at suse.de (Alexander Graf) Date: Wed, 26 Aug 2015 10:49:08 +0200 Subject: [OpenBIOS] [PATCH 5/5] ppc: fix up IDE device tree and control transfer In-Reply-To: <1440110717-23498-6-git-send-email-cormac@c-obrien.org> References: <1440110717-23498-1-git-send-email-cormac@c-obrien.org> <1440110717-23498-6-git-send-email-cormac@c-obrien.org> Message-ID: <55DD7D84.5060606@suse.de> On 21.08.15 00:45, Cormac O'Brien wrote: > Mac OS 9 is finicky about devices having the correct properties, so we change > some IDE data to more closely model a real New World Mac. Please split this into 2 separate patches. > We also add > ide_exit() to ciface_quiesce() to properly prepare the drives for transferring > control to the operating system. > > Signed-off-by: Cormac O'Brien > --- > arch/ppc/qemu/methods.c | 2 ++ > drivers/ide.c | 34 ++++++++++++++++++++++++++++++---- > 2 files changed, 32 insertions(+), 4 deletions(-) > > diff --git a/arch/ppc/qemu/methods.c b/arch/ppc/qemu/methods.c > index cb72bc1..adf3ea2 100644 > --- a/arch/ppc/qemu/methods.c > +++ b/arch/ppc/qemu/methods.c > @@ -109,11 +109,13 @@ NODE_METHODS( tty ) = { > > DECLARE_NODE( ciface, 0, 0, "+/openprom/client-services" ); > > +extern void ide_exit(void); > /* ( -- ) */ > static void > ciface_quiesce( unsigned long args[], unsigned long ret[] ) > { > usb_exit(); > + ide_exit(); > #if 0 > unsigned long msr; > /* This seems to be the correct thing to do - but I'm not sure */ > diff --git a/drivers/ide.c b/drivers/ide.c > index 327c64a..8ef34cb 100644 > --- a/drivers/ide.c > +++ b/drivers/ide.c > @@ -1581,6 +1581,12 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) > set_property(dnode, "compatible", (is_oldworld() ? > "heathrow-ata" : "keylargo-ata"), 13); > > + set_property(dnode, "model", ((current_channel == 3) ? > + "ata-3" : "ata-4"), strlen("ata-*") + 1); As Segher mentioned somewhere else, please introduce a helper for string properties. > + > + set_property(dnode, "AAPL,connector", "ata", > + strlen("ata") + 1); > + > props[0] = 0x00000526; > props[1] = 0x00000085; > props[2] = 0x00000025; > @@ -1589,8 +1595,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) > props[5] = 0x00000000; > props[6] = 0x00000000; > props[7] = 0x00000000; > - OLDWORLD(set_property(dnode, "AAPL,pio-timing", > - (char *)&props, 8*sizeof(props[0]))); > + set_property(dnode, "AAPL,pio-timing", > + (char *)&props, 8*sizeof(props[0])); > > /* The first interrupt entry is the ide interrupt, the second > the dbdma interrupt */ > @@ -1634,8 +1640,8 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) > (char *)&props, 2*sizeof(props[0]))); > > props[0] = 0; > - OLDWORLD(set_property(dnode, "AAPL,bus-id", (char*)props, > - 1 * sizeof(props[0]))); > + set_property(dnode, "AAPL,bus-id", (char*)props, > + 1 * sizeof(props[0])); > IDE_DPRINTF(DEV_NAME": [io ports 0x%lx]\n", > current_channel, chan->mmio); > > @@ -1683,3 +1689,23 @@ int macio_ide_init(const char *path, uint32_t addr, int nb_channels) > return 0; > } > #endif /* CONFIG_DRIVER_MACIO */ > + > +void ide_exit(void); This should go into a header file. Alex > +void ide_exit(void) > +{ > + struct ide_channel *current; > + > + current = channels; > + while (current) { > + struct ide_drive *drive; > + int i; > + > + for (i = 0; i < 2; i++) { > + drive = ¤t->drives[i]; > + ob_ide_select_drive(drive); > + ob_ide_software_reset(drive); > + ob_ide_device_type_check(drive); > + } > + current = current->next; > + } > +} >