mac-rom/OS/NKEventGroupWrapper.a

91 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

; Straightforward 68k wrappers for three NanoKernel MPCalls related to EventGroups
; How the FE1F trap makes MP calls:
;
; 68 reg | input | output
; -----------------------------------------------
; D0 | r0/MPCall selector | r3/return value 1
; A0 | r3/argument 1 | r4/return value 2
; D1 | r4/argument 2 | r5/return value 3
; A1 | r5/argument 3 | r6/return value 4
; pascal OSStatus NKCreateEvent(long return_space, MPEventID *event);
NKCreateEvent PROC EXPORT
LINK A6, #0
MOVEQ.L #49, D0
DC.W $FE1F ; CALL
MOVE.L D0, $C(A6) ; return r3;
MOVE.L $8(A6), D0 ; if(event) *event = r4;
BEQ.S @NOPTR
MOVE.L D0, A1
MOVE.L A0, (A1)
@NOPTR
UNLK A6
MOVE.L (SP)+, A0
ADDQ #4, SP
JMP (A0)
; pascal OSStatus NKSetSWIEvent(long return_space, MPEventID event, long swi);
NKSetSWIEvent PROC EXPORT
LINK A6, #0
MOVE.L $C(A6), A0 ; r3 = event;
MOVE.L $8(A6), D1 ; r4 = swi;
MOVEQ.L #54, D0
DC.W $FE1F ; CALL
MOVE.L D0, $10(A6) ; return r3;
UNLK A6
MOVE.L (SP)+, A0
ADDQ.L #8, SP
JMP (A0)
; pascal OSStatus NKWaitForEvent(MPEventID event, MPEventFlags *flags, Duration duration)
NKWaitForEvent PROC EXPORT
LINK A6, #$0
MOVE.L $8(A6), A1 ; r5 = duration;
MOVE.L $10(A6), A0 ; r3 = event;
MOVEQ.L #52, D0
DC.W $FE1F ; CALL
MOVE.L D0, $14(A6) ; return r3;
MOVE.L $C(A6), D0 ; if(flags) *flags = r4;
BEQ.B @NOPTR
MOVE.L D0, A1
MOVE.L A0, (A1)
@NOPTR
UNLK A6
MOVE.L (SP)+, A0
; DC.W $DEFC, $000C
OPT NONE ; not sure how this instruction got here!
ADDA.W #$C, SP
JMP (A0)
END