honeylisp/ssc/iigs/bootstub.fnl

62 lines
1.8 KiB
Plaintext
Raw Normal View History

(import-macros {:sss ! : compile} :ssc.macros)
(local link (require :link))
#(compile $1
(start-symbol boot)
2021-10-05 01:22:48 +00:00
(predef-fn boot () void far)
(predef-fn [(or $2 :main)] () void far)
[(when (not= link.name :udpdebug) (! (do ;udpdebug boots into 16-bit mode
(start-symbol boot-8)
(org 0x1000)
(fn boot-8 ()
2021-10-05 01:22:48 +00:00
(asm (clc) (xce) (rep 0x30)) ; disable emulation mode, 16-bit index registers
(boot)
(asm (sec) (xce))) ; re-enter emulation mode
)))]
(org 0x060000)
(require ssc.iigs.toolbox)
2021-08-20 03:51:12 +00:00
(require ssc.task)
(global word BootUserID)
(global long BootHandle-00)
(global long BootHandle-01)
(global long BootHandle-e0)
(global long BootHandle-e1)
(global long BootHandle-06)
(far-fn boot ()
(save-dp-sp 0x0800)
2021-08-20 03:51:12 +00:00
(set-task-base 0x0800) ; space for 8 tasks
(save-6502-stack)
; http://www.1000bit.it/support/manuali/apple/technotes/pdos/tn.pdos.27.html
; When bootstrapping with no OS, we must reserve
(TLStartUp)
(LoadOneTool ToolsetMisc 0x0100)
(MTStartUp)
(set! BootUserID (GetNewID 0x1f00))
(LoadOneTool ToolsetMemoryManager 0x0100)
(set! BootHandle-06 (NewHandle 0xffff BootUserID 0xb017 0x060000))
(set! BootHandle-00 (NewHandle 0xb800 BootUserID 0xb017 0x000800))
(set! BootHandle-01 (NewHandle 0xb800 BootUserID 0xb017 0x010800))
(set! BootHandle-e0 (NewHandle 0x4000 BootUserID 0xb017 0xe02000))
(set! BootHandle-e1 (NewHandle 0x8000 BootUserID 0xb017 0xe12000))
2021-10-05 01:22:48 +00:00
( [(or $2 :main)] )
(DisposeHandle BootHandle-e1)
(DisposeHandle BootHandle-e0)
(DisposeHandle BootHandle-01)
(DisposeHandle BootHandle-00)
(DisposeHandle BootHandle-06)
(DeleteID BootUserID)
(MTShutDown)
2021-08-20 03:51:12 +00:00
(restore-6502-stack)
(restore-dp-sp)))