mirror of
https://github.com/elliotnunn/mac-rom.git
synced 2024-05-31 16:41:28 +00:00
366 lines
13 KiB
Plaintext
366 lines
13 KiB
Plaintext
;
|
|
; File: Boot1.a (formerly BootBlocks.a)
|
|
;
|
|
; Contains: Macintosh disk-based boot code
|
|
;
|
|
; This code goes into the two disk boot blocks and is loaded into RAM
|
|
; after ROM initialization is complete and a boot diskette is in place.
|
|
;
|
|
; In the System file, this code lives in the 'boot' 1 resource.
|
|
;
|
|
; When this code is entered, the interrupt system, Memory Manager, and
|
|
; ROM-based I/O drivers have been initialized. This code finds the
|
|
; System file and loads the contents of its data fork, and turns over
|
|
; the rest of the booting process to the code that it finds there.
|
|
;
|
|
; Original written by: Larry Kenyon
|
|
; Written by: Darin Adler
|
|
;
|
|
; Copyright: © 1983-1992 by Apple Computer, Inc., all rights reserved.
|
|
;
|
|
; Change History (most recent first):
|
|
;
|
|
; <10> 4/20/92 JSM Moved this file from {TidBits}BootBlocks.a to {StartMgr}Boot1.a,
|
|
; keeping all revisions.
|
|
; <9> 1/15/91 stb & dba; reduce size to fit in one DDP packet
|
|
; <8> 12/11/90 dba & bbm; make the check for new ROMs check the whole version word,
|
|
; instead of doing a compare on the low byte of the version
|
|
; <7> 4/14/90 dba fix bug with register not set to ROMBase
|
|
; <6> 4/11/90 dba size the system heap in the old way for Plus and SE ROMs; this
|
|
; makes 6.X systems work properly; also unmount volume if
|
|
; HGetVInfo or OpenWD fails; respect the maximum size from network
|
|
; booting (small)
|
|
; <5> 4/10/90 dba boot from a resource instead of the system file data fork; this
|
|
; new version will handle systems with or without the new 'boot'
|
|
; (2) resources; systems without the resource will be booted in
|
|
; the old-fashioned way
|
|
; <4> 3/21/90 dba all new boot blocks (the old ones were hardly used); these leave
|
|
; most of the booting to code in the system file
|
|
; <3> 1/4/90 dba get rid of warnings by deleting extraneous equates
|
|
; <2> 12/28/89 dba use MAIN instead of PROC for dead code stripping; redo the
|
|
; padding at the end of the boot blocks
|
|
; <1.2> 6/1/89 GGD Fixed assembly errors in previous change
|
|
; <1.1> 5/31/89 PAT Conditionalized the StartUp ("Hello") program to be
|
|
; "Multifinder" for System 7.0 and later, and remain "Finder" for
|
|
; all earlier Systems.
|
|
; 5/31/89 PAT Conditionalized the StartUp (Hello) program in boot resource
|
|
; System 7.0 and later: StartUp application = "Multifinder"
|
|
; Earlier than System 7.0: StartUp application = "Finder"
|
|
; <1.0> 11/16/88 CCH Added to EASE.
|
|
; 5/24/88 EKH Update the boot blocks: bumped the version to 0x17, and set the
|
|
; system heap size to 0x2000 (128K).
|
|
; 3/9/87 LAK Rebuilt for inclusion in system resource file as resource of
|
|
; type 'boot'.
|
|
; 5/7/84 LAK reverted to early rev num to placate MacWorks.
|
|
; 4/20/84 SC drop the font fix... (f--k IÕm brilliant)
|
|
; 4/16/84 SC soften event number and do appl font fix
|
|
; 2/23/84 SC Max event and file # maximums
|
|
; 2/23/84 AJH fixed system heap size for systems > 512K
|
|
; 2/13/84 SC thereÕs a 512 version tacked on end. Copy entire .PROC, chg to
|
|
; boot512 and uncomment code @ H512 label
|
|
; 1/13/84 AJH donÕt SetAppBase until after InitResources
|
|
; 1/12/84 AJH load in INIT routines in resID order
|
|
; 1/12/84 AJH check to see the file to launch exists
|
|
; 1/10/84 AJH/LAK read-only permissions for Macsbug, clear less FS globals
|
|
; 1/6/84 AJH set up applZone after file system init, set up version #
|
|
; 1/5/84 AJH changed default names, more FCBs for bigger system heaps
|
|
; 1/2/84 AJH added system heap CompactMem, increased size in sysHeap, new
|
|
; version
|
|
; 12/20/83 LAK updated version number to $0081.
|
|
; 12/18/83 AJH fixed up mouse scaling cause the ROM uses the wrong bit...
|
|
; 12/13/83 AJH got rid of start-up, use "INIT" resources instead
|
|
; 12/2/83 AJH final overhaul -- 256K support, startUp file detach, etc
|
|
; 11/13/83 AJH get rid of bootBlock deepShit alert; put in Sys.rsrc set up
|
|
; screenRow
|
|
; 10/13/83 LAK movescreen now uses CopyBits for Lisa compatibility; scrounged
|
|
; bytes from various places.
|
|
; 9/7/83 LAK added call to _ZeroScrap. optimized IO to make it fit.
|
|
; 9/5/83 SC scrap vars point to name
|
|
; 9/4/83 LAK added CLR.L ResErrProc for resources,
|
|
; 8/28/83 AJH added whichAlerts option for DS alerts
|
|
; 8/20/83 LAK Added event queue count in header. Added scrap name in header.
|
|
; Changed param. memory for key stuff. Added param. mem. for click
|
|
; and caret. Added DoDetach for saving code.
|
|
; 8/17/83 LAK added init of EvtBufLen; FinderName var moved in lomem.
|
|
; 8/9/83 AJH fixed bug releasing bootAlerts; misc cleanup
|
|
; 7/13/83 LAK changed CLR.L Keylast to CLR.W Keylast.
|
|
; 6/10/83 AJH added "Hello" fileName for initial launch
|
|
; 6/8/83 AJH finderName is 12 long, not 16...
|
|
; 6/7/83 AJH set up master block start address, ext file system fields
|
|
; 6/5/83 AJH set up key repeat parms from parameter RAM
|
|
; 6/4/83 AJH implemented system heap sizing and page 2 reservation
|
|
; 6/3/83 AJH KEYM -> KEYC; detached keyProcs and deep shit alerts
|
|
; 6/2/83 AJH cleared theScrap, set up vidPage launch param set up sysResName
|
|
; and put MacSys there
|
|
; 5/31/83 AJH MacSys.Code no longer necessary to boot
|
|
; 5/27/83 AJH New Loader!
|
|
; 4/7/83 AJH Complete rewrite of mainline; installed deep shit alerts
|
|
; 4/1/83 AJH Made it work on 512K system
|
|
; 2/8/83 LAK New Today.
|
|
;
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
; equates
|
|
|
|
load 'StandardEqu.d'
|
|
|
|
maxBootCodeSize equ 404 ; only this many bytes across the network (net booting)
|
|
bootBlocksSize equ 1024 ; two 512-byte disk blocks
|
|
|
|
macro
|
|
str16 &string
|
|
string pascal
|
|
@label: dc.b &string
|
|
org @label+16
|
|
endm
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
BootBlocks proc export
|
|
|
|
; Here is the boot block header.
|
|
|
|
dc.w ('LK') ; boot code identifier
|
|
bra.w Boot ; kick off the boot code
|
|
|
|
Version
|
|
dc.b ('D') ; executable on all machines
|
|
dc.b $18 ; version number
|
|
|
|
Page2Flags dc.w 0
|
|
SystemFileName str16 'System'
|
|
FinderFileName str16 'Finder'
|
|
DebuggerFileName str16 'MacsBug'
|
|
DisassemblerFileName str16 'Disassembler'
|
|
StartupScreenFileName str16 'StartUpScreen'
|
|
HelloFileName str16 'Finder'
|
|
ClipboardFileName str16 'Clipboard'
|
|
ClassicFileName str16 'Classic'
|
|
|
|
NumFCBs dc.w 40 ; number of FCBs to allocate at boot
|
|
NumEvents dc.w 48 ; number of event queue elements
|
|
|
|
SystemHeapSize128K dc.l $4300 ; size of system heap for 128K system (never used)
|
|
SystemHeapSize256K dc.l $8000 ; size of system heap for 256K system (never used)
|
|
SystemHeapSize dc.l $20000 ; size of system heap (used for pre-7.0)
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
Boot
|
|
|
|
; This code will either boot the machine, and not return or return with an error in d0.
|
|
; If the error returned is noErr (0), then it means that this is an old-style System file,
|
|
; and the older ROM booting code should be used.
|
|
;
|
|
; D7 must contain a pointer to a place for a parameter block on entry to this routine.
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
GetFileNames
|
|
|
|
; Put names of system files in low memory.
|
|
|
|
lea SystemFileName,a0
|
|
lea SysResName,a1
|
|
moveq #16,d0
|
|
_BlockMoveData
|
|
lea FinderFileName,a0
|
|
lea FinderName,a1
|
|
moveq #16,d0
|
|
_BlockMoveData
|
|
lea ClipboardFileName,a0
|
|
LEA ScrapTag,A1
|
|
MOVE.L A1,ScrapName ; point ScrapName to ScrapTag
|
|
moveq #16,d0
|
|
_BlockMoveData
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
InitializeEventManager
|
|
|
|
move.w NumEvents,d0
|
|
_InitEvents
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
MountStartupDisk
|
|
|
|
move.l d7,a0 ; point to parameter block
|
|
move.w BootDrive,ioDrvNum(a0) ; set up drive number
|
|
_MountVol ; mount startup disk
|
|
bz @noErr ; reboot if thereÕs an error, with one exception:
|
|
cmp.w #volOnLinErr,d0 ; "drive volume already on-line at MountVol"
|
|
bne Return
|
|
@noErr
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
FindBlessedFolder
|
|
|
|
moveq #0,d0
|
|
move.w ioVRefNum(a0),d0
|
|
|
|
move.l d0,-(sp)
|
|
clr.l -(sp)
|
|
move.l #-1,-(sp)
|
|
move.l #$0001011C,d0
|
|
dc.w $FE22
|
|
|
|
cmp.w #-1,d0
|
|
bne.s @refnumNotFirst
|
|
move.l #$00000C04, d0
|
|
dc.w $FE22
|
|
addq #4,sp
|
|
@refnumNotFirst
|
|
|
|
move.l d0,ioWDDirID(a0)
|
|
clr.l ioFileName(a0) ; ? we donÕt want the diskÕs name
|
|
clr.w ioVolIndex(a0) ; ? use the vRefNum left over from MountVol
|
|
bra.s @straightToOpenWD
|
|
|
|
clr.l ioFileName(a0) ; we donÕt want the diskÕs name
|
|
clr.w ioVolIndex(a0) ; use the vRefNum left over from MountVol
|
|
_HGetVInfo ; see if there is a system folder
|
|
bnz UnmountAndReturn ; if we fail, tell our caller
|
|
move.l ioVFndrInfo+4(a0),a4 ; save dirID of startup app. in a4 for pre-7.0 systems
|
|
move.l ioVFndrInfo(a0),ioWDDirID(a0) ; get the dirID of system folder
|
|
bz.s @noFolder ; if it is 0, boot the root
|
|
move.l #'ERIK',ioWDProcID(a0) ; magic incantation from hell
|
|
|
|
@straightToOpenWD
|
|
_OpenWD ; use the vRefNum left over from MountVol
|
|
bnz UnmountAndReturn ; canÕt open, tell our caller
|
|
_SetVol ; make blessed folder the default volume
|
|
@noFolder
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
InitializeResourceManager
|
|
|
|
subq #2,sp ; make room for function result
|
|
_InitResources ; open that system file
|
|
tst.w (sp)+ ; did we get it?
|
|
bmi InitResourcesFailed ; yes, weÕre OK
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
subq #4,sp
|
|
move.l #'vers',-(sp)
|
|
move.w #1,-(sp)
|
|
_GetResource
|
|
move.l (sp)+,d5
|
|
beq.s @noVersResource
|
|
|
|
move.l d5,a0
|
|
move.l (a0),a0
|
|
moveq #0,d5
|
|
move.w (a0),d5
|
|
|
|
clr.l -(sp)
|
|
move.l d5,-(sp)
|
|
move.l #$00020C03,d0
|
|
dc.w $FE22
|
|
addq #8,sp
|
|
@noVersResource
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
clr.b ResLoad
|
|
subq #2,sp
|
|
pea ClassicFileName
|
|
_OpenResFile
|
|
st ResLoad
|
|
move.w (sp)+,d5
|
|
bmi @noClassicFile
|
|
|
|
subq #4,sp
|
|
move.l #'gvrs',-(sp) ; no docs on this resource
|
|
move.w #1,-(sp)
|
|
_Get1Resource
|
|
move.l (sp)+,d6
|
|
bz.s @noGvrsResource
|
|
|
|
move.l d6,a0
|
|
move.l (a0),a0
|
|
move.l (a0),(sp) ; really does not look right
|
|
@noGvrsResource
|
|
|
|
move.w d5,-(sp)
|
|
_CloseResFile
|
|
@noClassicFile
|
|
|
|
move.l #$0002020A,d0 ; does the above set an argument for this?
|
|
dc.w $FE22
|
|
addq #8,sp
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
move.l d7,a0 ; get back our ParamBlock ptr
|
|
move.w ioVRefNum(a0),-(sp) ; save ioVRefNum for _SetVol (not BootDrive!)
|
|
move.w BootDrive,ioVRefNum(a0) ; call _MountVol on BootDrive
|
|
_MountVol
|
|
move.w (sp)+,ioVRefNum(a0) ; restore ioVRefNum for _SetVol
|
|
_SetVol
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
ContinueBooting
|
|
|
|
; Check for a secondary boot resource; 'boot' (2).
|
|
; If it is there, call it.
|
|
;
|
|
; Registers passed in:
|
|
; A3 = handle to 'boot' (2) resource
|
|
; A4 = dirID of the startup application (for pre-7.0 systems)
|
|
; A5 = pointer to globals (SP + 400)
|
|
|
|
; If there is none, do the old style standard boot using the code in ROM.
|
|
|
|
subq #4,sp ; make room for the handle
|
|
move.l #'boot',-(sp)
|
|
move.w #2,-(sp) ; 'boot' 2 resource contains secondary boot code
|
|
_GetResource
|
|
move.l (sp)+,d0 ; is there a 'boot' 2 resource?
|
|
bz.s Return ; no, return with 0 in d0 (noErr) to continue booting
|
|
|
|
addq #4,sp ; get rid of the return address, we are not returning
|
|
|
|
move.l d0,a3 ; get ready to start the Macintosh
|
|
move.l (a3),a0 ; get the address of secondary boot code
|
|
jmp (a0) ; call the secondary boot code
|
|
|
|
; ÑÑÑ THE END ÑÑÑ
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
InitResourcesFailed
|
|
|
|
moveq #dsSystemFileErr,d0 ; return just the right error code
|
|
|
|
UnmountAndReturn
|
|
|
|
addq #8,sp ; oops! been leaking stack have we?
|
|
move.w d0,-(sp) ; save the result code
|
|
move.l d7,a0 ; point to parameter block
|
|
_UnmountVol ; already set up (for HGetVInfo)
|
|
move.w (sp)+,d0 ; get error code to return to caller
|
|
|
|
Return
|
|
|
|
rts
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
bootBlocksSoFar: equ *-BootBlocks
|
|
; if bootBlocksSoFar > maxBootCodeSize then
|
|
; aerror &concat('boot blocks donÕt fit: ', \
|
|
; &i2s(bootBlocksSoFar),' bytes; ', \
|
|
; 'maximum ',&i2s(maxBootCodeSize),' bytes')
|
|
; else
|
|
; dcb.b bootBlocksSize-bootBlocksSoFar,$DA
|
|
; endif
|
|
|
|
; ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
|
|
|
|
end
|