This patchset is really a roll-up/rework of ESCC patches posted by Hervé and John along with a general tidy-up of the ESCC channel code and addition of DBDMA properties.
The most interesting change with this patchset is that a basic OS 9.2 image with just OT extensions enabled now hangs in QEMU in a loop constantly polling ESCC registers rather than crashing into MacsBug.
NOTE: for OS 9 testers, QEMU's default G4 CPU for mac99 seems buggy and always crashes into MacsBug. Make sure that you have the interpreter.fs patch applied and run QEMU with -cpu G3.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
v2: - Switch channel offsets over to match http://nandra.segv.jp/NetBSD/G4.dump-device-tree.txt (fixes serial port on Linux)
- Fix DBDMA region size to 0x100
Mark Cave-Ayland (6): escc.c: rename offset to index ppc: fix ESCC reg properties escc.c: tidy-up legacy and non-legacy codepaths escc.c: add empty slot-names property to serial ports escc.c: add DBDMA addresses to reg property escc.c: add DBDMA interrupt properties
openbios-devel/drivers/escc.c | 92 +++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 36 deletions(-)
This better describes the variable since it contains a reference to the channel rather than an offset.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/drivers/escc.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index afb97fa..9b87083 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -386,15 +386,15 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, phandle_t dnode, aliases;
cell props[10]; - int offset; + int index; 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; + case 2: index = 1; legacy = 0; break; + case 3: index = 0; legacy = 0; break; + case 4: index = 1; legacy = 1; break; + case 5: index = 0; legacy = 1; break; + default: return; }
/* add device */ @@ -425,32 +425,32 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "compatible", buf, 9);
if (legacy) { - props[0] = IO_ESCC_LEGACY_OFFSET + offset * 0x4; + props[0] = IO_ESCC_LEGACY_OFFSET + index * 0x4; props[1] = 0x00000001; - props[2] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 2; + props[2] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 2; props[3] = 0x00000001; - props[4] = IO_ESCC_LEGACY_OFFSET + offset * 0x4 + 6; + props[4] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 6; props[5] = 0x00000001; set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); } else { - props[0] = IO_ESCC_OFFSET + offset * 0x20; + props[0] = IO_ESCC_OFFSET + index * 0x20; props[1] = 0x00000020; set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); }
if (legacy) { - props[0] = addr + IO_ESCC_LEGACY_OFFSET + offset * 0x4; + props[0] = addr + IO_ESCC_LEGACY_OFFSET + index * 0x4; } else { - props[0] = addr + IO_ESCC_OFFSET + offset * 0x20; + props[0] = addr + IO_ESCC_OFFSET + index * 0x20; } OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell)));
- props[0] = 0x00000010 - offset; + props[0] = 0x00000010 - index; OLDWORLD(set_property(dnode, "AAPL,interrupts", (char *)&props, 1 * sizeof(cell)));
- props[0] = (0x24) + offset; + props[0] = (0x24) + index; props[1] = 0; props[2] = 0; NEWWORLD(set_property(dnode, "interrupts", @@ -460,11 +460,11 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr,
if (legacy) { uart_init_line( - (unsigned char*)addr + IO_ESCC_LEGACY_OFFSET + offset * 0x4, + (unsigned char*)addr + IO_ESCC_LEGACY_OFFSET + index * 0x4, CONFIG_SERIAL_SPEED); } else { uart_init_line( - (unsigned char*)addr + IO_ESCC_OFFSET + offset * 0x20, + (unsigned char*)addr + IO_ESCC_OFFSET + index * 0x20, CONFIG_SERIAL_SPEED); } }
I/O offsets were wrong in legacy mode and some were missing in non-legacy mode. This fixes serial port detection in NetBSD, which was ignoring it. This also partly fixes MacOS 9.2, which relies on them to initialize OpenTransport.
Based upon an original patch from Hervé Poussineau hpoussin@reactos.org.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/drivers/escc.c | 43 ++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index 9b87083..44b73f0 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -388,7 +388,20 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, cell props[10]; int index; int legacy; - + int reg_offsets[2][2][3] = { + { + /* ch-b */ + { 0x00, 0x10, 0x40 }, + /* ch-a */ + { 0x20, 0x30, 0x50 } + },{ + /* legacy ch-b */ + { 0x0, 0x2, 0x8 }, + /* legacy ch-a */ + { 0x4, 0x6, 0xa } + } + }; + switch (esnum) { case 2: index = 1; legacy = 0; break; case 3: index = 0; legacy = 0; break; @@ -425,17 +438,21 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "compatible", buf, 9);
if (legacy) { - props[0] = IO_ESCC_LEGACY_OFFSET + index * 0x4; - props[1] = 0x00000001; - props[2] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 2; - props[3] = 0x00000001; - props[4] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 6; - props[5] = 0x00000001; + props[0] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][0]; + props[1] = 0x1; + props[2] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][1]; + props[3] = 0x1; + props[4] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][2]; + props[5] = 0x1; set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); } else { - props[0] = IO_ESCC_OFFSET + index * 0x20; - props[1] = 0x00000020; - set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell)); + props[0] = IO_ESCC_OFFSET + reg_offsets[legacy][index][0]; + props[1] = 0x1; + props[2] = IO_ESCC_OFFSET + reg_offsets[legacy][index][1]; + props[3] = 0x1; + props[4] = IO_ESCC_OFFSET + reg_offsets[legacy][index][2]; + props[5] = 0x1; + set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); }
if (legacy) { @@ -446,13 +463,13 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell)));
- props[0] = 0x00000010 - index; + props[0] = 0x10 - index; OLDWORLD(set_property(dnode, "AAPL,interrupts", (char *)&props, 1 * sizeof(cell)));
props[0] = (0x24) + index; - props[1] = 0; - props[2] = 0; + props[1] = 0x0; + props[2] = 0x0; NEWWORLD(set_property(dnode, "interrupts", (char *)&props, 3 * sizeof(cell)));
On Feb 20, 2016, at 12:18 PM, Mark Cave-Ayland wrote:
I/O offsets were wrong in legacy mode and some were missing in non-legacy mode. This fixes serial port detection in NetBSD, which was ignoring it. This also partly fixes MacOS 9.2, which relies on them to initialize OpenTransport.
Based upon an original patch from Hervé Poussineau hpoussin@reactos.org.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
openbios-devel/drivers/escc.c | 43 ++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index 9b87083..44b73f0 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -388,7 +388,20 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, cell props[10]; int index; int legacy;
- int reg_offsets[2][2][3] = {
{
/* ch-b */
{ 0x00, 0x10, 0x40 },
/* ch-a */
{ 0x20, 0x30, 0x50 }
},{
/* legacy ch-b */
{ 0x0, 0x2, 0x8 },
/* legacy ch-a */
{ 0x4, 0x6, 0xa }
}
- };
- switch (esnum) { case 2: index = 1; legacy = 0; break; case 3: index = 0; legacy = 0; break;
@@ -425,17 +438,21 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "compatible", buf, 9);
if (legacy) {
props[0] = IO_ESCC_LEGACY_OFFSET + index * 0x4;
props[1] = 0x00000001;
props[2] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 2;
props[3] = 0x00000001;
props[4] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 6;
props[5] = 0x00000001;
props[0] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][2];
} else {props[5] = 0x1; set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + index * 0x20;
props[1] = 0x00000020;
set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_OFFSET + reg_offsets[legacy][index][2];
props[5] = 0x1;
set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
}
if (legacy) {
@@ -446,13 +463,13 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell)));
- props[0] = 0x00000010 - index;
props[0] = 0x10 - index; OLDWORLD(set_property(dnode, "AAPL,interrupts", (char *)&props, 1 * sizeof(cell)));
props[0] = (0x24) + index;
- props[1] = 0;
- props[2] = 0;
- props[1] = 0x0;
- props[2] = 0x0; NEWWORLD(set_property(dnode, "interrupts", (char *)&props, 3 * sizeof(cell)));
-- 1.7.10.4
I had a lot of problems applying this patch. Eventually I just applied it by hand. Testing your v2 patch set with Mac OS 9.2 ends with an Illegal Instruction error for me. When I tested Mac OS 9.0, the OS just stops booting and does nothing. It doesn't crash. I just sits there doing nothing. The mouse cursor still can move. I tried this OS again and it crashed on the second time. The third time it just sat there doing nothing like the first time.
On 23/02/16 03:58, Programmingkid wrote:
On Feb 20, 2016, at 12:18 PM, Mark Cave-Ayland wrote:
I/O offsets were wrong in legacy mode and some were missing in non-legacy mode. This fixes serial port detection in NetBSD, which was ignoring it. This also partly fixes MacOS 9.2, which relies on them to initialize OpenTransport.
Based upon an original patch from Hervé Poussineau hpoussin@reactos.org.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
openbios-devel/drivers/escc.c | 43 ++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index 9b87083..44b73f0 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -388,7 +388,20 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, cell props[10]; int index; int legacy;
- int reg_offsets[2][2][3] = {
{
/* ch-b */
{ 0x00, 0x10, 0x40 },
/* ch-a */
{ 0x20, 0x30, 0x50 }
},{
/* legacy ch-b */
{ 0x0, 0x2, 0x8 },
/* legacy ch-a */
{ 0x4, 0x6, 0xa }
}
- };
- switch (esnum) { case 2: index = 1; legacy = 0; break; case 3: index = 0; legacy = 0; break;
@@ -425,17 +438,21 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "compatible", buf, 9);
if (legacy) {
props[0] = IO_ESCC_LEGACY_OFFSET + index * 0x4;
props[1] = 0x00000001;
props[2] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 2;
props[3] = 0x00000001;
props[4] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 6;
props[5] = 0x00000001;
props[0] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][2];
} else {props[5] = 0x1; set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + index * 0x20;
props[1] = 0x00000020;
set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_OFFSET + reg_offsets[legacy][index][2];
props[5] = 0x1;
set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
}
if (legacy) {
@@ -446,13 +463,13 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell)));
- props[0] = 0x00000010 - index;
props[0] = 0x10 - index; OLDWORLD(set_property(dnode, "AAPL,interrupts", (char *)&props, 1 * sizeof(cell)));
props[0] = (0x24) + index;
- props[1] = 0;
- props[2] = 0;
- props[1] = 0x0;
- props[2] = 0x0; NEWWORLD(set_property(dnode, "interrupts", (char *)&props, 3 * sizeof(cell)));
-- 1.7.10.4
I had a lot of problems applying this patch. Eventually I just applied it by hand. Testing your v2 patch set with Mac OS 9.2 ends with an Illegal Instruction error for me. When I tested Mac OS 9.0, the OS just stops booting and does nothing. It doesn't crash. I just sits there doing nothing. The mouse cursor still can move. I tried this OS again and it crashed on the second time. The third time it just sat there doing nothing like the first time.
Just this one patch, or the entire patchset? Pretty much everything just works with "git am" these days?
I think there are two issues here: firstly something does cause memory corruption which can cause random crashes under OS 9, and secondly the changes to the serial ports. We know that OT probe causes OS 9 to crash/hang when booting from a vanilla image, but the probe doesn't take place on pre-installed images. In these cases the hang is almost better than the crash in that at least the OS gets to the point where it can probe the serial ports, it is just that the QEMU emulation is lacking.
If the change in behaviour occurs when booting from a fresh ISO then I'm not too worried because everyone testing at the moment will have removed these extensions from their images. However if existing installed images start to fail then perhaps the patch needs more work.
Howard, is this something that you can test? I believe this is a good candidate to be applied to trunk this week in time for QEMU freeze since it definitely fixes the properties in terms of the reference device tree and indeed it works to the point where NetBSD/Linux can now see the serial ports and use them.
ATB,
Mark.
On 23 Feb 2016, at 20:33, Mark Cave-Ayland mark.cave-ayland@ilande.co.uk wrote:
On 23/02/16 03:58, Programmingkid wrote:
On Feb 20, 2016, at 12:18 PM, Mark Cave-Ayland wrote:
I/O offsets were wrong in legacy mode and some were missing in non-legacy mode. This fixes serial port detection in NetBSD, which was ignoring it. This also partly fixes MacOS 9.2, which relies on them to initialize OpenTransport.
Based upon an original patch from Hervé Poussineau hpoussin@reactos.org.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
openbios-devel/drivers/escc.c | 43 ++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index 9b87083..44b73f0 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -388,7 +388,20 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, cell props[10]; int index; int legacy;
- int reg_offsets[2][2][3] = {
{
/* ch-b */
{ 0x00, 0x10, 0x40 },
/* ch-a */
{ 0x20, 0x30, 0x50 }
},{
/* legacy ch-b */
{ 0x0, 0x2, 0x8 },
/* legacy ch-a */
{ 0x4, 0x6, 0xa }
}
- };
- switch (esnum) { case 2: index = 1; legacy = 0; break; case 3: index = 0; legacy = 0; break;
@@ -425,17 +438,21 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "compatible", buf, 9);
if (legacy) {
props[0] = IO_ESCC_LEGACY_OFFSET + index * 0x4;
props[1] = 0x00000001;
props[2] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 2;
props[3] = 0x00000001;
props[4] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 6;
props[5] = 0x00000001;
props[0] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][2];
} else {props[5] = 0x1; set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + index * 0x20;
props[1] = 0x00000020;
set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_OFFSET + reg_offsets[legacy][index][2];
props[5] = 0x1;
set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
}
if (legacy) {
@@ -446,13 +463,13 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell)));
- props[0] = 0x00000010 - index;
props[0] = 0x10 - index; OLDWORLD(set_property(dnode, "AAPL,interrupts", (char *)&props, 1 * sizeof(cell)));
props[0] = (0x24) + index;
- props[1] = 0;
- props[2] = 0;
- props[1] = 0x0;
- props[2] = 0x0; NEWWORLD(set_property(dnode, "interrupts", (char *)&props, 3 * sizeof(cell)));
-- 1.7.10.4
I had a lot of problems applying this patch. Eventually I just applied it by hand. Testing your v2 patch set with Mac OS 9.2 ends with an Illegal Instruction error for me. When I tested Mac OS 9.0, the OS just stops booting and does nothing. It doesn't crash. I just sits there doing nothing. The mouse cursor still can move. I tried this OS again and it crashed on the second time. The third time it just sat there doing nothing like the first time.
Just this one patch, or the entire patchset? Pretty much everything just works with "git am" these days?
I think there are two issues here: firstly something does cause memory corruption which can cause random crashes under OS 9, and secondly the changes to the serial ports. We know that OT probe causes OS 9 to crash/hang when booting from a vanilla image, but the probe doesn't take place on pre-installed images. In these cases the hang is almost better than the crash in that at least the OS gets to the point where it can probe the serial ports, it is just that the QEMU emulation is lacking.
If the change in behaviour occurs when booting from a fresh ISO then I'm not too worried because everyone testing at the moment will have removed these extensions from their images. However if existing installed images start to fail then perhaps the patch needs more work.
Howard, is this something that you can test? I believe this is a good candidate to be applied to trunk this week in time for QEMU freeze since it definitely fixes the properties in terms of the reference device tree and indeed it works to the point where NetBSD/Linux can now see the serial ports and use them.
ATB,
Mark.
Hi, yes, I can test. Can you provide a build? I tried building, but the resulting binary doesn’t boot my OS 9 images, only the OSX images ;-)
Best, Howard
On Feb 23, 2016, at 2:38 PM, Howard Spoelstra wrote:
On 23 Feb 2016, at 20:33, Mark Cave-Ayland mark.cave-ayland@ilande.co.uk wrote:
On 23/02/16 03:58, Programmingkid wrote:
On Feb 20, 2016, at 12:18 PM, Mark Cave-Ayland wrote:
I/O offsets were wrong in legacy mode and some were missing in non-legacy mode. This fixes serial port detection in NetBSD, which was ignoring it. This also partly fixes MacOS 9.2, which relies on them to initialize OpenTransport.
Based upon an original patch from Hervé Poussineau hpoussin@reactos.org.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
openbios-devel/drivers/escc.c | 43 ++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index 9b87083..44b73f0 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -388,7 +388,20 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, cell props[10]; int index; int legacy;
- int reg_offsets[2][2][3] = {
{
/* ch-b */
{ 0x00, 0x10, 0x40 },
/* ch-a */
{ 0x20, 0x30, 0x50 }
},{
/* legacy ch-b */
{ 0x0, 0x2, 0x8 },
/* legacy ch-a */
{ 0x4, 0x6, 0xa }
}
- };
- switch (esnum) { case 2: index = 1; legacy = 0; break; case 3: index = 0; legacy = 0; break;
@@ -425,17 +438,21 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "compatible", buf, 9);
if (legacy) {
props[0] = IO_ESCC_LEGACY_OFFSET + index * 0x4;
props[1] = 0x00000001;
props[2] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 2;
props[3] = 0x00000001;
props[4] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 6;
props[5] = 0x00000001;
props[0] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][2];
} else {props[5] = 0x1; set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + index * 0x20;
props[1] = 0x00000020;
set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_OFFSET + reg_offsets[legacy][index][2];
props[5] = 0x1;
set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
}
if (legacy) {
@@ -446,13 +463,13 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell)));
- props[0] = 0x00000010 - index;
props[0] = 0x10 - index; OLDWORLD(set_property(dnode, "AAPL,interrupts", (char *)&props, 1 * sizeof(cell)));
props[0] = (0x24) + index;
- props[1] = 0;
- props[2] = 0;
- props[1] = 0x0;
- props[2] = 0x0; NEWWORLD(set_property(dnode, "interrupts", (char *)&props, 3 * sizeof(cell)));
-- 1.7.10.4
I had a lot of problems applying this patch. Eventually I just applied it by hand. Testing your v2 patch set with Mac OS 9.2 ends with an Illegal Instruction error for me. When I tested Mac OS 9.0, the OS just stops booting and does nothing. It doesn't crash. I just sits there doing nothing. The mouse cursor still can move. I tried this OS again and it crashed on the second time. The third time it just sat there doing nothing like the first time.
Just this one patch, or the entire patchset? Pretty much everything just works with "git am" these days?
I think there are two issues here: firstly something does cause memory corruption which can cause random crashes under OS 9, and secondly the changes to the serial ports. We know that OT probe causes OS 9 to crash/hang when booting from a vanilla image, but the probe doesn't take place on pre-installed images. In these cases the hang is almost better than the crash in that at least the OS gets to the point where it can probe the serial ports, it is just that the QEMU emulation is lacking.
If the change in behaviour occurs when booting from a fresh ISO then I'm not too worried because everyone testing at the moment will have removed these extensions from their images. However if existing installed images start to fail then perhaps the patch needs more work.
Howard, is this something that you can test? I believe this is a good candidate to be applied to trunk this week in time for QEMU freeze since it definitely fixes the properties in terms of the reference device tree and indeed it works to the point where NetBSD/Linux can now see the serial ports and use them.
ATB,
Mark.
Hi, yes, I can test. Can you provide a build? I tried building, but the resulting binary doesn’t boot my OS 9 images, only the OSX images ;-)
I know what is wrong. There is a patch needed that filters out linefeed and carriage return characters that needs to be applied. Here is the patch.
--- openbios-devel/forth/bootstrap/interpreter.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openbios-devel/forth/bootstrap/interpreter.fs b/openbios-devel/forth/bootstrap/interpreter.fs index 5187058..74a109f 100644 --- a/openbios-devel/forth/bootstrap/interpreter.fs +++ b/openbios-devel/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+
On Feb 23, 2016, at 2:33 PM, Mark Cave-Ayland wrote:
On 23/02/16 03:58, Programmingkid wrote:
On Feb 20, 2016, at 12:18 PM, Mark Cave-Ayland wrote:
I/O offsets were wrong in legacy mode and some were missing in non-legacy mode. This fixes serial port detection in NetBSD, which was ignoring it. This also partly fixes MacOS 9.2, which relies on them to initialize OpenTransport.
Based upon an original patch from Hervé Poussineau hpoussin@reactos.org.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
openbios-devel/drivers/escc.c | 43 ++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index 9b87083..44b73f0 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -388,7 +388,20 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, cell props[10]; int index; int legacy;
- int reg_offsets[2][2][3] = {
{
/* ch-b */
{ 0x00, 0x10, 0x40 },
/* ch-a */
{ 0x20, 0x30, 0x50 }
},{
/* legacy ch-b */
{ 0x0, 0x2, 0x8 },
/* legacy ch-a */
{ 0x4, 0x6, 0xa }
}
- };
- switch (esnum) { case 2: index = 1; legacy = 0; break; case 3: index = 0; legacy = 0; break;
@@ -425,17 +438,21 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "compatible", buf, 9);
if (legacy) {
props[0] = IO_ESCC_LEGACY_OFFSET + index * 0x4;
props[1] = 0x00000001;
props[2] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 2;
props[3] = 0x00000001;
props[4] = IO_ESCC_LEGACY_OFFSET + index * 0x4 + 6;
props[5] = 0x00000001;
props[0] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][2];
} else {props[5] = 0x1; set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + index * 0x20;
props[1] = 0x00000020;
set_property(dnode, "reg", (char *)&props, 2 * sizeof(cell));
props[0] = IO_ESCC_OFFSET + reg_offsets[legacy][index][0];
props[1] = 0x1;
props[2] = IO_ESCC_OFFSET + reg_offsets[legacy][index][1];
props[3] = 0x1;
props[4] = IO_ESCC_OFFSET + reg_offsets[legacy][index][2];
props[5] = 0x1;
set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell));
}
if (legacy) {
@@ -446,13 +463,13 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell)));
- props[0] = 0x00000010 - index;
props[0] = 0x10 - index; OLDWORLD(set_property(dnode, "AAPL,interrupts", (char *)&props, 1 * sizeof(cell)));
props[0] = (0x24) + index;
- props[1] = 0;
- props[2] = 0;
- props[1] = 0x0;
- props[2] = 0x0; NEWWORLD(set_property(dnode, "interrupts", (char *)&props, 3 * sizeof(cell)));
-- 1.7.10.4
I had a lot of problems applying this patch. Eventually I just applied it by hand. Testing your v2 patch set with Mac OS 9.2 ends with an Illegal Instruction error for me. When I tested Mac OS 9.0, the OS just stops booting and does nothing. It doesn't crash. I just sits there doing nothing. The mouse cursor still can move. I tried this OS again and it crashed on the second time. The third time it just sat there doing nothing like the first time.
Just this one patch, or the entire patchset? Pretty much everything just works with "git am" these days?
It was with this patch only. This patch would not show up when I went to view it as raw text.
I think there are two issues here: firstly something does cause memory corruption which can cause random crashes under OS 9, and secondly the changes to the serial ports. We know that OT probe causes OS 9 to crash/hang when booting from a vanilla image, but the probe doesn't take place on pre-installed images. In these cases the hang is almost better than the crash in that at least the OS gets to the point where it can probe the serial ports, it is just that the QEMU emulation is lacking.
Agreed.
If the change in behaviour occurs when booting from a fresh ISO then I'm not too worried because everyone testing at the moment will have removed these extensions from their images. However if existing installed images start to fail then perhaps the patch needs more work.
It was fresh ISO's that I used for testing.
On 23/02/16 20:19, Programmingkid wrote:
Just this one patch, or the entire patchset? Pretty much everything just works with "git am" these days?
It was with this patch only. This patch would not show up when I went to view it as raw text.
How strange. The entire patchset was a straightforward invocation of git format-patch.
I think there are two issues here: firstly something does cause memory corruption which can cause random crashes under OS 9, and secondly the changes to the serial ports. We know that OT probe causes OS 9 to crash/hang when booting from a vanilla image, but the probe doesn't take place on pre-installed images. In these cases the hang is almost better than the crash in that at least the OS gets to the point where it can probe the serial ports, it is just that the QEMU emulation is lacking.
Agreed.
If the change in behaviour occurs when booting from a fresh ISO then I'm not too worried because everyone testing at the moment will have removed these extensions from their images. However if existing installed images start to fail then perhaps the patch needs more work.
It was fresh ISO's that I used for testing.
Well that's definitely not a regression, just not an improvement :) As long as yourself/Howard are happy that the pre-installed OS 9 images work then I think we're good.
ATB,
Mark.
On 23 Feb 2016, at 22:07, Mark Cave-Ayland mark.cave-ayland@ilande.co.uk wrote:
On 23/02/16 20:19, Programmingkid wrote:
Just this one patch, or the entire patchset? Pretty much everything just works with "git am" these days?
It was with this patch only. This patch would not show up when I went to view it as raw text.
How strange. The entire patchset was a straightforward invocation of git format-patch.
I think there are two issues here: firstly something does cause memory corruption which can cause random crashes under OS 9, and secondly the changes to the serial ports. We know that OT probe causes OS 9 to crash/hang when booting from a vanilla image, but the probe doesn't take place on pre-installed images. In these cases the hang is almost better than the crash in that at least the OS gets to the point where it can probe the serial ports, it is just that the QEMU emulation is lacking.
Agreed.
If the change in behaviour occurs when booting from a fresh ISO then I'm not too worried because everyone testing at the moment will have removed these extensions from their images. However if existing installed images start to fail then perhaps the patch needs more work.
It was fresh ISO's that I used for testing.
Well that's definitely not a regression, just not an improvement :) As long as yourself/Howard are happy that the pre-installed OS 9 images work then I think we're good.
ATB,
Mark.
-- OpenBIOS http://openbios.org/ http://openbios.org/ Mailinglist: http://lists.openbios.org/mailman/listinfo http://lists.openbios.org/mailman/listinfo Free your System - May the Forth be with you
I see no regressions with openbios with these patches:
For completeness, I tested all images I have. All test results against a recent build of David Gibson's ppc-for 2.6 tree, mac99/G3/256.
Disk images: Various 9.2 disk images boot or seem to crash as before ;-) 10.3/9.1 installation image: boots and runs, classic runs. 10.4/9.2 installation image: boots and runs, classic runs.
Clean isos: 8.5 starts boot, but complains about /rtas missing 9.0 crashes qemu 9.1 boots to progress bar, then hangs 9.2 boots to progress bar, then display system error 10.0 boots to happy mac, verbose boot, then kernel panic in com.apple.driver.AppleSCCSerial kmod_create: com.apple.iokit.IOSerialFamily (id 36), 11 pages loaded at 0x9d80000, header size 0x1000 kmod_create: com.apple.driver.AppleSCCSerial (id 37) 9 pages loaded at 0x9be4000. header size 0x1000 panic(cpu 0): mapping_remove: attempt to unmap a permanent mapping - pmap = 002FCC00, va = 00013000, mapping 01492060 10.1 boots to happy mac, verbose boot, then hangs during creation of records in/out 10.2 boots and runs installer 10.3 boots and runs installer 10.4 boots and runs installer 10.5 hangs during verbose mode, but boots to graphics display and shows error log with mac99/G4/256. No mouse/keyboard working.
Best regards, Howard
On Tue, 23 Feb 2016, Howard Spoelstra wrote:
On 23 Feb 2016, at 22:07, Mark Cave-Ayland mark.cave-ayland@ilande.co.uk wrote: How strange. The entire patchset was a straightforward invocation of git format-patch.
git am did apply them for me but complained about some white space errors. Could it be that some strange chars in this patch made it encode in some other way than plain text?
9.0 crashes qemu
That should not happen. Do you have more info on this or can you get a backtrace?
10.0 boots to happy mac, verbose boot, then kernel panic in com.apple.driver.AppleSCCSerial kmod_create: com.apple.iokit.IOSerialFamily (id 36), 11 pages loaded at 0x9d80000, header size 0x1000 kmod_create: com.apple.driver.AppleSCCSerial (id 37) 9 pages loaded at 0x9be4000. header size 0x1000 panic(cpu 0): mapping_remove: attempt to unmap a permanent mapping - pmap = 002FCC00, va = 00013000, mapping 01492060
Could this be related to missing DMA? At least this might have source one could look at to find out more.
Regards, BALATON Zoltan
On 23/02/16 22:14, Howard Spoelstra wrote:
I see no regressions with openbios with these patches:
For completeness, I tested all images I have. All test results against a recent build of David Gibson's ppc-for 2.6 tree, mac99/G3/256.
Disk images: Various 9.2 disk images boot or seem to crash as before ;-) 10.3/9.1 installation image: boots and runs, classic runs. 10.4/9.2 installation image: boots and runs, classic runs.
Clean isos: 8.5 starts boot, but complains about /rtas missing 9.0 crashes qemu 9.1 boots to progress bar, then hangs 9.2 boots to progress bar, then display system error 10.0 boots to happy mac, verbose boot, then kernel panic in com.apple.driver.AppleSCCSerial kmod_create: com.apple.iokit.IOSerialFamily (id 36), 11 pages loaded at 0x9d80000, header size 0x1000 kmod_create: com.apple.driver.AppleSCCSerial (id 37) 9 pages loaded at 0x9be4000. header size 0x1000 panic(cpu 0): mapping_remove: attempt to unmap a permanent mapping - pmap = 002FCC00, va = 00013000, mapping 01492060 10.1 boots to happy mac, verbose boot, then hangs during creation of records in/out 10.2 boots and runs installer 10.3 boots and runs installer 10.4 boots and runs installer 10.5 hangs during verbose mode, but boots to graphics display and shows error log with mac99/G4/256. No mouse/keyboard working.
Wow that's a much more comprehensive test suite than I have available :)
Thanks for making sure there are no regressions - I'll commit the ESCC changes to SVN trunk later so they can be included in the up-and-coming upstream QEMU pull.
ATB,
Mark.
Now that the reg addresses are all table-driven, it is possible to simplify and almost remove the legacy and non-legacy codepaths.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/drivers/escc.c | 42 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 28 deletions(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index 44b73f0..c770e23 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -386,6 +386,7 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, phandle_t dnode, aliases;
cell props[10]; + ucell offset; int index; int legacy; int reg_offsets[2][2][3] = { @@ -438,28 +439,20 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, set_property(dnode, "compatible", buf, 9);
if (legacy) { - props[0] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][0]; - props[1] = 0x1; - props[2] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][1]; - props[3] = 0x1; - props[4] = IO_ESCC_LEGACY_OFFSET + reg_offsets[legacy][index][2]; - props[5] = 0x1; - set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); + offset = IO_ESCC_LEGACY_OFFSET; } else { - props[0] = IO_ESCC_OFFSET + reg_offsets[legacy][index][0]; - props[1] = 0x1; - props[2] = IO_ESCC_OFFSET + reg_offsets[legacy][index][1]; - props[3] = 0x1; - props[4] = IO_ESCC_OFFSET + reg_offsets[legacy][index][2]; - props[5] = 0x1; - set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); + offset = IO_ESCC_OFFSET; }
- if (legacy) { - props[0] = addr + IO_ESCC_LEGACY_OFFSET + index * 0x4; - } else { - props[0] = addr + IO_ESCC_OFFSET + index * 0x20; - } + props[0] = offset + reg_offsets[legacy][index][0]; + props[1] = 0x1; + props[2] = offset + reg_offsets[legacy][index][1]; + props[3] = 0x1; + props[4] = offset + reg_offsets[legacy][index][2]; + props[5] = 0x1; + set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); + + props[0] = addr + offset + reg_offsets[legacy][index][0]; OLDWORLD(set_property(dnode, "AAPL,address", (char *)&props, 1 * sizeof(cell)));
@@ -475,15 +468,8 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr,
device_end();
- if (legacy) { - uart_init_line( - (unsigned char*)addr + IO_ESCC_LEGACY_OFFSET + index * 0x4, - CONFIG_SERIAL_SPEED); - } else { - uart_init_line( - (unsigned char*)addr + IO_ESCC_OFFSET + index * 0x20, - CONFIG_SERIAL_SPEED); - } + uart_init_line((unsigned char*)addr + offset + reg_offsets[legacy][index][0], + CONFIG_SERIAL_SPEED); }
void
This is required to enable the ports to be detected by OS X.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/drivers/escc.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index c770e23..ebfe242 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -466,6 +466,8 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, NEWWORLD(set_property(dnode, "interrupts", (char *)&props, 3 * sizeof(cell)));
+ set_int_property(dnode, "slot-names", 0); + device_end();
uart_init_line((unsigned char*)addr + offset + reg_offsets[legacy][index][0],
These are required for MacOS to locate the serial port.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland> --- openbios-devel/drivers/escc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index ebfe242..3dd5174 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -389,6 +389,14 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, ucell offset; int index; int legacy; + + int dbdma_offsets[2][2] = { + /* ch-b */ + { 0x6, 0x7 }, + /* ch-a */ + { 0x4, 0x5 } + }; + int reg_offsets[2][2][3] = { { /* ch-b */ @@ -450,7 +458,11 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, props[3] = 0x1; props[4] = offset + reg_offsets[legacy][index][2]; props[5] = 0x1; - set_property(dnode, "reg", (char *)&props, 6 * sizeof(cell)); + props[6] = 0x8000 + dbdma_offsets[index][0] * 0x100; + props[7] = 0x100; + props[8] = 0x8000 + dbdma_offsets[index][1] * 0x100; + props[9] = 0x100; + set_property(dnode, "reg", (char *)&props, 10 * sizeof(cell));
props[0] = addr + offset + reg_offsets[legacy][index][0]; OLDWORLD(set_property(dnode, "AAPL,address",
These are required for MacOS to locate the serial port. Also make sure we add the 2nd integer to each interrupt in order to indicate level/edge triggering.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/drivers/escc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/openbios-devel/drivers/escc.c b/openbios-devel/drivers/escc.c index 3dd5174..5fa3139 100644 --- a/openbios-devel/drivers/escc.c +++ b/openbios-devel/drivers/escc.c @@ -473,10 +473,13 @@ escc_add_channel(const char *path, const char *node, phys_addr_t addr, (char *)&props, 1 * sizeof(cell)));
props[0] = (0x24) + index; - props[1] = 0x0; - props[2] = 0x0; + props[1] = 0x1; + props[2] = dbdma_offsets[index][0]; + props[3] = 0x0; + props[4] = dbdma_offsets[index][1]; + props[5] = 0x0; NEWWORLD(set_property(dnode, "interrupts", - (char *)&props, 3 * sizeof(cell))); + (char *)&props, 6 * sizeof(cell)));
set_int_property(dnode, "slot-names", 0);
Le 20/02/2016 18:18, Mark Cave-Ayland a écrit :
This patchset is really a roll-up/rework of ESCC patches posted by Hervé and John along with a general tidy-up of the ESCC channel code and addition of DBDMA properties.
The most interesting change with this patchset is that a basic OS 9.2 image with just OT extensions enabled now hangs in QEMU in a loop constantly polling ESCC registers rather than crashing into MacsBug.
NOTE: for OS 9 testers, QEMU's default G4 CPU for mac99 seems buggy and always crashes into MacsBug. Make sure that you have the interpreter.fs patch applied and run QEMU with -cpu G3.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
v2:
Switch channel offsets over to match http://nandra.segv.jp/NetBSD/G4.dump-device-tree.txt (fixes serial port on Linux)
Fix DBDMA region size to 0x100
Mark Cave-Ayland (6): escc.c: rename offset to index ppc: fix ESCC reg properties escc.c: tidy-up legacy and non-legacy codepaths escc.c: add empty slot-names property to serial ports escc.c: add DBDMA addresses to reg property escc.c: add DBDMA interrupt properties
openbios-devel/drivers/escc.c | 92 +++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 36 deletions(-)
Tested-by: Hervé Poussineau hpoussin@reactos.org
On Feb 20, 2016, at 12:18 PM, Mark Cave-Ayland wrote:
This patchset is really a roll-up/rework of ESCC patches posted by Hervé and John along with a general tidy-up of the ESCC channel code and addition of DBDMA properties.
The most interesting change with this patchset is that a basic OS 9.2 image with just OT extensions enabled now hangs in QEMU in a loop constantly polling ESCC registers rather than crashing into MacsBug.
Do you know which ESCC register that Mac OS 9 is polling? If you do then making a patch that changes the value of this register to something Mac OS 9 expects can be done.