These patches fix a number of issues that hindered the Mac OS 9 boot process.
Signed-off-by: Cormac O'Brien <i.am.cormac.obrien(a)gmail.com>
Cormac O'Brien (6):
bootinfo_load: recognize ASCII EOT as end of bootinfo
ppc: add Adler-32 checksum capability
ppc: add ROM node to device tree
ppc: fix stack usage in mmu_claim, mem_claim
ppc: add CPU reservation-granule-size property
ppc: add Apple copyright injection to adler32
arch/ppc/qemu/init.c | 62 +++++++++++++++++++++++++++++++++++++++++++++
arch/ppc/qemu/methods.c | 34 ++++++++++++-------------
arch/ppc/qemu/qemu.fs | 28 ++++++++++++++++++++
arch/ppc/qemu/tree.fs | 8 ++++++
libopenbios/bootinfo_load.c | 10 ++++++++
5 files changed, 125 insertions(+), 17 deletions(-)
--
2.4.4
Author: mcayland
Date: Sun Jun 21 20:52:51 2015
New Revision: 1346
URL: http://tracker.coreboot.org/trac/openbios/changeset/1346
Log:
ppc: add Apple copyright injection to adler32
Since Mac OS 9 and BootX are the only known users of the adler32 word, we use
the word to add an Apple copyright message to the device tree in order to
allow OS 9 to boot.
Signed-off-by: Cormac O'Brien <i.am.cormac.obrien(a)gmail.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/ppc/qemu/init.c
trunk/openbios-devel/arch/ppc/qemu/qemu.fs
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/init.c Sun Jun 21 20:52:47 2015 (r1345)
+++ trunk/openbios-devel/arch/ppc/qemu/init.c Sun Jun 21 20:52:51 2015 (r1346)
@@ -1006,7 +1006,7 @@
bind_func("filll", ffilll);
/* Implementation of adler32 word (required by OS 9, BootX) */
- bind_func("adler32", adler32);
+ bind_func("(adler32)", adler32);
bind_func("platform-boot", boot);
bind_func("(go)", go);
Modified: trunk/openbios-devel/arch/ppc/qemu/qemu.fs
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/qemu.fs Sun Jun 21 20:52:47 2015 (r1345)
+++ trunk/openbios-devel/arch/ppc/qemu/qemu.fs Sun Jun 21 20:52:51 2015 (r1346)
@@ -93,3 +93,31 @@
:noname
set-defaults
; PREPOST-initializer
+
+\ -------------------------------------------------------------------------
+\ Adler-32 wrapper
+\ -------------------------------------------------------------------------
+
+: adler32 ( adler buf len -- checksum )
+ \ Since Mac OS 9 is the only system using this word, we take this
+ \ opportunity to inject a copyright message that is necessary for the
+ \ system to boot.
+ " Copyright 1983-2001 Apple Computer, Inc. THIS MESSAGE FOR COMPATIBILITY ONLY"
+ encode-string " copyright"
+ " /" find-package if
+ " set-property" $find if
+ execute
+ else
+ 3drop drop
+ then
+ then
+
+ ( adler buf len )
+
+ " (adler32)" $find if
+ execute
+ else
+ ." Can't find " ( adler32-name ) type cr
+ 3drop 0
+ then
+;
Author: mcayland
Date: Sun Jun 21 20:52:47 2015
New Revision: 1345
URL: http://tracker.coreboot.org/trac/openbios/changeset/1345
Log:
ppc: add CPU reservation-granule-size property
This patch adds the 'reservation-granule-size' property to the CPU node, as is
required by Mac OS 9.
Signed-off-by: Cormac O'Brien <i.am.cormac.obrien(a)gmail.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/ppc/qemu/init.c
Modified: trunk/openbios-devel/arch/ppc/qemu/init.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/init.c Sun Jun 21 20:52:44 2015 (r1344)
+++ trunk/openbios-devel/arch/ppc/qemu/init.c Sun Jun 21 20:52:47 2015 (r1345)
@@ -302,6 +302,11 @@
fword("encode-string");
push_str("state");
fword("property");
+
+ PUSH(0x20);
+ fword("encode-int");
+ push_str("reservation-granule-size");
+ fword("property");
}
static void
Author: mcayland
Date: Sun Jun 21 20:52:42 2015
New Revision: 1343
URL: http://tracker.coreboot.org/trac/openbios/changeset/1343
Log:
ppc: add ROM node to device tree
This patch adds a ROM node to the PPC device tree as is required by Mac OS 9.
Based on a patch by John Arbuckle <programmingkidx(a)gmail.com>
Signed-off-by: Cormac O'Brien <i.am.cormac.obrien(a)gmail.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/arch/ppc/qemu/tree.fs
Modified: trunk/openbios-devel/arch/ppc/qemu/tree.fs
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/tree.fs Sun Jun 21 20:52:38 2015 (r1342)
+++ trunk/openbios-devel/arch/ppc/qemu/tree.fs Sun Jun 21 20:52:42 2015 (r1343)
@@ -42,6 +42,14 @@
: close ;
finish-device
+new-device
+ " rom" device-name
+ h# ff800000 encode-int 0 encode-int encode+ " reg" property
+ 1 encode-int " #address-cells" property
+ h# ff800000 encode-int h# 800000 encode-int encode+
+ h# ff800000 encode-int encode+ " ranges" property
+finish-device
+
\ -------------------------------------------------------------
\ /packages
\ -------------------------------------------------------------
Author: mcayland
Date: Sun Jun 21 20:52:35 2015
New Revision: 1341
URL: http://tracker.coreboot.org/trac/openbios/changeset/1341
Log:
bootinfo_load.c: stop parsing CHRP boot script when NULL is reached
The Mac OS 9 CHRP boot script consists of a null-terminated Forth string
followed by a large binary payload. Make sure we correctly determine the size
of the bootscript at this point instead of trying to allocate memory for the
entire binary blob which fails due to insufficient memory.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/libopenbios/bootinfo_load.c
Modified: trunk/openbios-devel/libopenbios/bootinfo_load.c
==============================================================================
--- trunk/openbios-devel/libopenbios/bootinfo_load.c Wed May 13 01:11:05 2015 (r1340)
+++ trunk/openbios-devel/libopenbios/bootinfo_load.c Sun Jun 21 20:52:35 2015 (r1341)
@@ -161,6 +161,12 @@
feval("load-size");
size = POP();
+ /* Some bootinfo scripts contain a binary payload after the
+ NULL-terminated Forth string such as OS 9. Restrict our
+ size to just the Forth section, otherwise we end up trying
+ to allocate memory for the entire binary which might fail. */
+ size = strnlen(base, size);
+
bootscript = malloc(size);
if (bootscript == NULL) {
DPRINTF("Can't malloc %d bytes\n", size);
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 <mark.cave-ayland(a)ilande.co.uk>
---
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+
--
1.7.10.4
The Mac OS 9 CHRP boot script consists of a null-terminated Forth string
followed by a large binary payload. Make sure we correctly determine the size
of the bootscript at this point instead of trying to allocate memory for the
entire binary blob which fails due to insufficient memory.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
---
openbios-devel/libopenbios/bootinfo_load.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/openbios-devel/libopenbios/bootinfo_load.c b/openbios-devel/libopenbios/bootinfo_load.c
index fa9e36b..e9b0739 100644
--- a/openbios-devel/libopenbios/bootinfo_load.c
+++ b/openbios-devel/libopenbios/bootinfo_load.c
@@ -161,6 +161,12 @@ bootinfo_init_program(void)
feval("load-size");
size = POP();
+ /* Some bootinfo scripts contain a binary payload after the
+ NULL-terminated Forth string such as OS 9. Restrict our
+ size to just the Forth section, otherwise we end up trying
+ to allocate memory for the entire binary which will fail. */
+ size = strnlen(base, size);
+
bootscript = malloc(size);
if (bootscript == NULL) {
DPRINTF("Can't malloc %d bytes\n", size);
--
1.7.10.4
The Mac OS 9 CHRP boot script consists of a null-terminated Forth string
followed by a large binary payload. Make sure we correctly determine the size
of the bootscript at this point instead of trying to allocate memory for the
entire binary blob which fails due to insufficient memory.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
---
openbios-devel/libopenbios/bootinfo_load.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/openbios-devel/libopenbios/bootinfo_load.c b/openbios-devel/libopenbios/bootinfo_load.c
index fa9e36b..c70203e 100644
--- a/openbios-devel/libopenbios/bootinfo_load.c
+++ b/openbios-devel/libopenbios/bootinfo_load.c
@@ -161,6 +161,12 @@ bootinfo_init_program(void)
feval("load-size");
size = POP();
+ /* Some bootinfo scripts contain a binary payload after the
+ NULL-terminated Forth string such as OS 9. Restrict our
+ size to just the Forth section, otherwise we end up trying
+ to allocate memory for the entire binary which will fail. */
+ size = MIN(strlen(base), size);
+
bootscript = malloc(size);
if (bootscript == NULL) {
DPRINTF("Can't malloc %d bytes\n", size);
--
1.7.10.4