sys7.1-doc-wip/OS/SCSIMgr4pt3/SIMmachine.a

225 lines
6.7 KiB
Plaintext
Raw Normal View History

2019-07-27 14:37:48 +00:00
;==========================================================================
;
; File: SIMMachine.a
;
; Contains: Misc. routines for SIM SCSI State Machine
;
; Written by: Paul Wolf
;
; Copyright: © 1990-1993 by Apple Computer, Inc., all rights reserved.
;
; Change History (most recent first):
;
; <SM12> 11/16/93 SAM Include HardwarePrivateEqu.a
; <SM11> 10/14/93 pdw <MC> roll-in.
; <MC2> 10/12/93 pdw Added support for Synchronous data transfers, rewrote State
; Machine, message handling etc.
; <SM10> 9/9/93 pdw Lots of little changes. Name changes, temporary cache_bug
; stuff.
; <SM9> 7/8/93 pdw Changed recording data for stack switching events to help Kurt
; with StkLowPt problem.
; <SM8> 6/29/93 pdw Massive checkins: Change asynchronicity mechanism to CallMachine
; stack switching mechanism. Adding support for Cold Fusion.
; Rearranging HW/SW Init code. Some code optimizations.
; <SM7> 5/5/93 PW Converted names to meanies-friendly names. Updated with latest
; from Ludwig stuff.
; <LW3> 5/1/93 PW Got rid of RECORD_ON and RECORD_rCMD definitions (should only be
; in Debug.a now.
; <SM6> 2/9/93 PW Removed some PDM debug stuff that's not needed.
; <SM5> 1/31/93 PW Update from the latest of Ludwig. Also changes required for PDM
; (will update Ludwig with these as needed myself).
; <SM4> 11/20/92 DCB Removed VM Stuff and put it into SCSIGlue.a
; <SM3> 10/30/92 DCB Stopped recording VM calls
; <SM2> 10/8/92 PW Removed lots of unused code.
;
;==========================================================================
MACHINE MC68020 ; '020-level
BLANKS ON ; assembler accepts spaces & tabs in operand field
PRINT OFF ; do not send subsequent lines to the listing file
; don't print includes
INCLUDE 'SysEqu.a' ; for StkLowPt
INCLUDE 'HardwarePrivateEqu.a'
INCLUDE 'Traps.a' ; for _DebugStr
INCLUDE 'Debug.a' ; for NAME
INCLUDE 'ACAM.a'
INCLUDE 'HALc96equ.a'
PRINT ON ; do send subsequent lines to the listing files
CASE OBJECT
IMPORT RecordEvent
;==========================================================================
;**************************************************************************
;
; CallMachine -
;
;==========================================================================
CallMachine PROC EXPORT
IMPORT TheMachine
IMPORT FreeMachine
WITH HALc96GlobalRecord
;………………………………………………………………………………………………………………………………………………………………………………………………………………………
; Switch to SCSI stack, suspending the main "thread".
; then call the selected routine
; then switch back to the previous "thread" which may be the main thread or
; it may be the interrupt thread (i.e. we're finally completing a request)
;………………………………………………………………………………………………………………………………………………………………………………………………………………………
move.l A5, -(sp) ; save caller's A5
move.l 8(sp), A0 ; get SIMg parameter
move.l (A0), A5 ; get HALg
DisableSCSIIRQ ; disable ints before we go down into Machine
IF STACK_RECORD_ON THEN
pea '>> '
move.l StkLowPt, -(sp)
bsr RecordEvent
addq.l #8, sp
ENDIF
movem.l D3-D7/A2-A6, -(sp)
bsr.s PrivateCallMachine ; MAGIC stack change here!!
movem.l (sp)+, D3-D7/A2-A6
IF STACK_RECORD_ON THEN
pea '<< '
move.l StkLowPt, -(sp)
bsr RecordEvent
addq.l #8, sp
ENDIF
EnableSCSIIRQ ; enable ints after we come back out
move.l (sp)+, A5 ; restore caller's A5
rts
NAME 'CallMachine'
;……………………………………………………………………………………………………………………………………………………
PrivateCallMachine
; Switch to SCSI stack ……………………………………
IF STACK_RECORD_ON THEN
pea ' >>'
move.l StkLowPt, -(sp)
bsr RecordEvent
addq.l #8, sp
ENDIF
move.l StkLowPt, publicStkLowPt(A5) ; remember old StkLowPt
clr.l StkLowPt ; and disable stack sniffer
move.l sp, publicSP(A5) ; suspend main thread
IF DEBUGGING THEN
move.b #1, privStackState(A5)
ENDIF
move.l privStackTop(A5), sp ; create SCSI thread
IF STACK_RECORD_ON THEN
pea '>Mch'
move.l StkLowPt, -(sp)
bsr RecordEvent
addq.l #8, sp
ENDIF
; Call the State Machine ……………………………………
; TheMachine( OSErr * finalStatus, SIM_IO ** completedIO, SIMglobals * SIMg)
subq.l #6, sp ; allocate room for completedIO & finalStatus
move.l A0, -(sp) ; pass SIMg into Machine
pea 4(sp) ; sp=SIMg,completedIO
pea 12(sp) ; sp=*completedIO,SIMg,completedIO,finalStatus
bsr TheMachine
lea 8(sp), sp ; get rid of parameters except for...
move.l (sp)+, A0 ; ...SIMg
move.l (sp)+, A1 ; get completedIO
moveq.l #0, D1
move.w (sp)+, D1 ; get finalStatus
; Return to previous stack ……………………………………
IF STACK_RECORD_ON THEN
pea '<Mch'
move.l StkLowPt, -(sp)
bsr RecordEvent
addq.l #8, sp
ENDIF
IF DEBUGGING THEN
move.b #4, privStackState(A5)
ENDIF
move.l publicSP(A5), sp ; resume previous thread
move.l publicStkLowPt(A5), StkLowPt ; resume stack sniffing
IF STACK_RECORD_ON THEN
pea ' <<'
move.l StkLowPt, -(sp)
bsr RecordEvent
addq.l #8, sp
ENDIF
tst.w D0 ; what did TheMachine return?
beq.s @exit ; freeTheMachine? no -> rts (old API)
move.l A0, -(sp) ; SIMg
move.l A1, -(sp) ; ioPtr
move.l D1, -(sp) ; finalStatus
bsr FreeMachine
lea 12(sp), sp ; get rid of parameters
@exit
rts
NAME 'PrivateCallMachine'
ENDWITH
;**************************************************************************
;
; BlockInterrupts, UnblockInterrupts -
;
;==========================================================================
BlockInterrupts PROC EXPORT
move.w SR, D0
ori.w #$0700,SR ; disable all ints
rts
NAME 'BlockInterrupts'
ENDP
;……………………………………………………………………………………………………………………………………………………
UnblockInterrupts PROC EXPORT
move.w 6(sp), SR
rts
NAME 'UnblockInterrupts'
ENDP
END