This series changes the injection of the copyright property on PPC such that it is included just before control is handed to the client. The motivation behind this is that older versions of the MacOS bootloader don't call the adler32 word which means the injection is omitted and boot fails.
The property is only inserted if a MacOS boot loader is detected and is removed if the bootloader terminates, thereby only making it visible to MacOS clients.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
v2: - Updated Forth suggested by Segher - Update messages/comments as suggested by Alyssa - Only insert copyright property if MacOS bootloader detected
Mark Cave-Ayland (6): string.fs: add functions to support ROT13 string encoding/decoding ppc: move copyright property generation into a separate word ppc: use ROT13 encoding for copyright property ciface.fs: implement optional (exit) hook when returning control back to the interpreter ppc: add complementary delete-copyright-property word ppc: move copyright property hooks from adler32 word
openbios-devel/arch/ppc/qemu/init.c | 5 +++++ openbios-devel/arch/ppc/qemu/qemu.fs | 33 +++++++++++++++++++++++++-------- openbios-devel/forth/lib/string.fs | 19 +++++++++++++++++++ openbios-devel/forth/system/ciface.fs | 8 ++++++++ 4 files changed, 57 insertions(+), 8 deletions(-)
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/forth/lib/string.fs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/openbios-devel/forth/lib/string.fs b/openbios-devel/forth/lib/string.fs index eb64749..43eca1c 100644 --- a/openbios-devel/forth/lib/string.fs +++ b/openbios-devel/forth/lib/string.fs @@ -125,3 +125,22 @@ : parse-hex ( str len -- value ) base @ hex -rot $number if 0 then swap base ! ; + + +\ ----------------------------------------------------- +\ miscellaneous functions +\ ----------------------------------------------------- + +: rot13 ( c - c ) + dup upc [char] A [char] M between if d# 13 + exit then + dup upc [char] N [char] Z between if d# 13 - then +; + +: $rot13 ( str len -- ) + bounds ?do i c@ rot13 i c! loop +; + +: rot13-str ( str len -- newstr len ) + \ Encode copy of input string + strdup 2dup $rot13 +;
On Sat, Feb 13, 2016 at 04:10:57PM +0000, Mark Cave-Ayland wrote:
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Signed-off-by: Segher Boessenkool segher@kernel.crashing.org
Have you tested this? I just typed it in :-)
+: rot13-str ( str len -- newstr len )
- \ Encode copy of input string
- strdup 2dup $rot13
+;
I would do without this one btw, just put the strdup in the caller.
Segher
On 13/02/16 22:47, Segher Boessenkool wrote:
On Sat, Feb 13, 2016 at 04:10:57PM +0000, Mark Cave-Ayland wrote:
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Signed-off-by: Segher Boessenkool segher@kernel.crashing.org
Have you tested this? I just typed it in :-)
Indeed, and it actually works!
+: rot13-str ( str len -- newstr len )
- \ Encode copy of input string
- strdup 2dup $rot13
+;
I would do without this one btw, just put the strdup in the caller.
Yeah I'm happy to fold $rot13/rot13-str together but thought there may be another reason for doing it as you suggested. I'll update this for the next revision and add your S-o-B above.
ATB,
Mark.
On Sun, Feb 14, 2016 at 11:08:10AM +0000, Mark Cave-Ayland wrote:
On 13/02/16 22:47, Segher Boessenkool wrote:
On Sat, Feb 13, 2016 at 04:10:57PM +0000, Mark Cave-Ayland wrote:
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Signed-off-by: Segher Boessenkool segher@kernel.crashing.org
Have you tested this? I just typed it in :-)
Indeed, and it actually works!
+: rot13-str ( str len -- newstr len )
- \ Encode copy of input string
- strdup 2dup $rot13
+;
I would do without this one btw, just put the strdup in the caller.
Yeah I'm happy to fold $rot13/rot13-str together but thought there may be another reason for doing it as you suggested. I'll update this for the next revision and add your S-o-B above.
I only did rot13-str with those semantics because you had it before as well :-) With $rot13 (or call it differently, whatever name fits existing practice best) rot13-str is just stringing together two unrelated things (well, three: allocation, strdup, rot13), and it's not an oft-used phrase, so things are easier to read if you just keep it separate. Very minor, of course.
Segher
On 14/02/16 15:36, Segher Boessenkool wrote:
On Sun, Feb 14, 2016 at 11:08:10AM +0000, Mark Cave-Ayland wrote:
On 13/02/16 22:47, Segher Boessenkool wrote:
On Sat, Feb 13, 2016 at 04:10:57PM +0000, Mark Cave-Ayland wrote:
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Signed-off-by: Segher Boessenkool segher@kernel.crashing.org
Have you tested this? I just typed it in :-)
Indeed, and it actually works!
+: rot13-str ( str len -- newstr len )
- \ Encode copy of input string
- strdup 2dup $rot13
+;
I would do without this one btw, just put the strdup in the caller.
Yeah I'm happy to fold $rot13/rot13-str together but thought there may be another reason for doing it as you suggested. I'll update this for the next revision and add your S-o-B above.
I only did rot13-str with those semantics because you had it before as well :-) With $rot13 (or call it differently, whatever name fits existing practice best) rot13-str is just stringing together two unrelated things (well, three: allocation, strdup, rot13), and it's not an oft-used phrase, so things are easier to read if you just keep it separate. Very minor, of course.
From my experience with OpenBIOS, the expectation is that words which
change strings return a copy so I'd be okay to fold these two words together. Thanks once again :)
ATB,
Mark.
Separate this out rather than keeping it as part of adler32.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/ppc/qemu/qemu.fs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/openbios-devel/arch/ppc/qemu/qemu.fs b/openbios-devel/arch/ppc/qemu/qemu.fs index 11e344a..e9f1282 100644 --- a/openbios-devel/arch/ppc/qemu/qemu.fs +++ b/openbios-devel/arch/ppc/qemu/qemu.fs @@ -95,13 +95,11 @@ variable keyboard-phandle 0 keyboard-phandle ! ; PREPOST-initializer
\ ------------------------------------------------------------------------- -\ Adler-32 wrapper +\ copyright property handling \ -------------------------------------------------------------------------
-: 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. +: insert-copyright-property + \ As required for MacOS 9 and below " Copyright 1983-2001 Apple Computer, Inc. THIS MESSAGE FOR COMPATIBILITY ONLY" encode-string " copyright" " /" find-package if @@ -111,6 +109,17 @@ variable keyboard-phandle 0 keyboard-phandle ! 3drop drop then then +; + +\ ------------------------------------------------------------------------- +\ 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. + insert-copyright-property
( adler buf len )
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/ppc/qemu/qemu.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/openbios-devel/arch/ppc/qemu/qemu.fs b/openbios-devel/arch/ppc/qemu/qemu.fs index e9f1282..f0ab340 100644 --- a/openbios-devel/arch/ppc/qemu/qemu.fs +++ b/openbios-devel/arch/ppc/qemu/qemu.fs @@ -100,8 +100,8 @@ variable keyboard-phandle 0 keyboard-phandle !
: insert-copyright-property \ As required for MacOS 9 and below - " Copyright 1983-2001 Apple Computer, Inc. THIS MESSAGE FOR COMPATIBILITY ONLY" - encode-string " copyright" + " Pbclevtug 1983-2001 Nccyr Pbzchgre, Vap. GUVF ZRFFNTR SBE PBZCNGVOVYVGL BAYL" + rot13-str encode-string " copyright" " /" find-package if " set-property" $find if execute
This allows us to optionally intercept and execute code before returning back to the Forth interactive console.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/forth/system/ciface.fs | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/openbios-devel/forth/system/ciface.fs b/openbios-devel/forth/system/ciface.fs index fd6c54e..85a6076 100644 --- a/openbios-devel/forth/system/ciface.fs +++ b/openbios-devel/forth/system/ciface.fs @@ -326,6 +326,14 @@ external
: exit ( -- ) ." EXIT" + + \ Execute (exit) hook if one exists + s" (exit)" $find if + execute + else + 2drop + then + outer-interpreter ;
This simply removes the copyright property generated by insert-copyright-property.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/ppc/qemu/qemu.fs | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/openbios-devel/arch/ppc/qemu/qemu.fs b/openbios-devel/arch/ppc/qemu/qemu.fs index f0ab340..a34a31e 100644 --- a/openbios-devel/arch/ppc/qemu/qemu.fs +++ b/openbios-devel/arch/ppc/qemu/qemu.fs @@ -111,6 +111,16 @@ variable keyboard-phandle 0 keyboard-phandle ! then ;
+: delete-copyright-property + \ Remove copyright property created above + active-package + " /" find-package if + active-package! + " copyright" delete-property + then + active-package! +; + \ ------------------------------------------------------------------------- \ Adler-32 wrapper \ -------------------------------------------------------------------------
Instead insert the copyright property if we detect the /rom/macos device generated by the MacOS boot loader just before we call the client with go and remove it before control is returned back to the interpreter.
This effectively hides the property from everyone except for MacOS bootloaders.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/ppc/qemu/init.c | 5 +++++ openbios-devel/arch/ppc/qemu/qemu.fs | 12 +++++------- 2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/openbios-devel/arch/ppc/qemu/init.c b/openbios-devel/arch/ppc/qemu/init.c index 2b5b8e1..b76c570 100644 --- a/openbios-devel/arch/ppc/qemu/init.c +++ b/openbios-devel/arch/ppc/qemu/init.c @@ -601,6 +601,11 @@ go(void) { ucell addr;
+ /* Insert copyright property for MacOS 9 and below */ + if (find_dev("/rom/macos")) { + fword("insert-copyright-property"); + } + feval("saved-program-state >sps.entry @"); addr = POP();
diff --git a/openbios-devel/arch/ppc/qemu/qemu.fs b/openbios-devel/arch/ppc/qemu/qemu.fs index a34a31e..3d99a34 100644 --- a/openbios-devel/arch/ppc/qemu/qemu.fs +++ b/openbios-devel/arch/ppc/qemu/qemu.fs @@ -121,18 +121,16 @@ variable keyboard-phandle 0 keyboard-phandle ! active-package! ;
+: (exit) + \ Clean up before returning to the interpreter + delete-copyright-property +; + \ ------------------------------------------------------------------------- \ 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. - insert-copyright-property - - ( adler buf len ) - " (adler32)" $find if execute else
On Sat, Feb 13, 2016 at 04:11:02PM +0000, Mark Cave-Ayland wrote:
Instead insert the copyright property if we detect the /rom/macos device generated by the MacOS boot loader just before we call the client with go and remove it before control is returned back to the interpreter.
Does this work for "OldWorld" systems (do we support those at all)?
Segher
On Feb 13, 2016, at 5:53 PM, Segher Boessenkool wrote:
On Sat, Feb 13, 2016 at 04:11:02PM +0000, Mark Cave-Ayland wrote:
Instead insert the copyright property if we detect the /rom/macos device generated by the MacOS boot loader just before we call the client with go and remove it before control is returned back to the interpreter.
Does this work for "OldWorld" systems (do we support those at all)?
Someone on the list said the copyright message isn't there on a real Beige G3 computer.
Mac OS 9 would not be able to boot on an old world "g3beige" emulator because we would need the real Apple ROM code from an actual Beige G3 system. Just to note this is what emulators like vMac expect. They are crippled without this file.
On 13/02/16 22:53, Segher Boessenkool wrote:
On Sat, Feb 13, 2016 at 04:11:02PM +0000, Mark Cave-Ayland wrote:
Instead insert the copyright property if we detect the /rom/macos device generated by the MacOS boot loader just before we call the client with go and remove it before control is returned back to the interpreter.
Does this work for "OldWorld" systems (do we support those at all)?
The /rom/macos node is present in the MacOS 8.5 bootloader which I believe is one of the earliest versions QEMU can support. Sadly I don't have the ability to actually test this though :(
ATB,
Mark.
On 14 Feb 2016, at 12:22, Mark Cave-Ayland mark.cave-ayland@ilande.co.uk wrote:
On 13/02/16 22:53, Segher Boessenkool wrote:
On Sat, Feb 13, 2016 at 04:11:02PM +0000, Mark Cave-Ayland wrote:
Instead insert the copyright property if we detect the /rom/macos device generated by the MacOS boot loader just before we call the client with go and remove it before control is returned back to the interpreter.
Does this work for "OldWorld" systems (do we support those at all)?
The /rom/macos node is present in the MacOS 8.5 bootloader which I believe is one of the earliest versions QEMU can support. Sadly I don't have the ability to actually test this though :(
Openbios with this patch can boot 8.5 with no copyright warning, but complains about missing rtas. It never displays graphics. I seem to remember Alyssa mentioning that everything below 9.x do not use the framebuffer and hence cannot display graphics.
On 14/02/16 12:28, Howard Spoelstra wrote:
On 14 Feb 2016, at 12:22, Mark Cave-Ayland mark.cave-ayland@ilande.co.uk wrote:
On 13/02/16 22:53, Segher Boessenkool wrote:
On Sat, Feb 13, 2016 at 04:11:02PM +0000, Mark Cave-Ayland wrote:
Instead insert the copyright property if we detect the /rom/macos device generated by the MacOS boot loader just before we call the client with go and remove it before control is returned back to the interpreter.
Does this work for "OldWorld" systems (do we support those at all)?
The /rom/macos node is present in the MacOS 8.5 bootloader which I believe is one of the earliest versions QEMU can support. Sadly I don't have the ability to actually test this though :(
Openbios with this patch can boot 8.5 with no copyright warning, but complains about missing rtas. It never displays graphics. I seem to remember Alyssa mentioning that everything below 9.x do not use the framebuffer and hence cannot display graphics.
Thanks for testing - sounds like it works fine. Missing the /rtas package is a separate issue but if boot doesn't abort due to the missing copyright property then we're good :)
ATB,
Mark.
On Feb 14, 2016, at 6:22 AM, Mark Cave-Ayland wrote:
On 13/02/16 22:53, Segher Boessenkool wrote:
On Sat, Feb 13, 2016 at 04:11:02PM +0000, Mark Cave-Ayland wrote:
Instead insert the copyright property if we detect the /rom/macos device generated by the MacOS boot loader just before we call the client with go and remove it before control is returned back to the interpreter.
Does this work for "OldWorld" systems (do we support those at all)?
The /rom/macos node is present in the MacOS 8.5 bootloader which I believe is one of the earliest versions QEMU can support. Sadly I don't have the ability to actually test this though :(
A Mac OS 8.5 iso file has been posted on the Emaculation list.
MacOS 8.5 (Install, extensions and control panels disabled)
http://bebop.gtxent.com/OS_8.5.iso.zip
MacOS 8.6 (Installation CD System Folder, extensions and control panels disabled)
http://bebop.gtxent.com/OS_8.6.iso.zip
MacOS 9.0 (Installation CD System Folder, extensions and control panels disabled)
http://bebop.gtxent.com/OS_9.0.iso.zip
MacOS 9.1 (Installation CD System Folder, extensions and control panels disabled)
On Sun, Feb 14, 2016 at 11:22:35AM +0000, Mark Cave-Ayland wrote:
On 13/02/16 22:53, Segher Boessenkool wrote:
Does this work for "OldWorld" systems (do we support those at all)?
The /rom/macos node is present in the MacOS 8.5 bootloader which I believe is one of the earliest versions QEMU can support. Sadly I don't have the ability to actually test this though :(
If no one can test it, it is obviously not supported ;-)
Segher