From c087445dd08741902cce667475b8fe6b96c2c7a5 Mon Sep 17 00:00:00 2001 From: Elliot Nunn Date: Sat, 18 Nov 2017 16:53:08 +0800 Subject: [PATCH] Correct names of NK Event Group wrapper code The names of the NanoKernel MP calls made by this 68k ROM library were found by inspecting the PowerPC MPLibrary, which makes these and many other MP calls. The document "Adding Multitasking Capability to Applications Using Multiprocessing Services" gave some background information. It also helped to determine the function signatures of the MP calls and of these ROM wrappers. --- BuildResults/RISC/Obj/NKEventGroupRelated.a.o | Bin 2276 -> 2362 bytes OS/NKEventGroupWrapper.a | 119 +++++++++++------- 2 files changed, 77 insertions(+), 42 deletions(-) diff --git a/BuildResults/RISC/Obj/NKEventGroupRelated.a.o b/BuildResults/RISC/Obj/NKEventGroupRelated.a.o index b931de9e1ff88bfbb6327e77d4a179d8bf8e7f76..932ac4b280c971f1bc49b197f79ce65f9f497399 100644 GIT binary patch delta 434 zcmaDNxJzimPew+r$&5^X6ARcU`!f|yj%87u{DO&($IsiI-o`ohI2q!B(uS?=O*j0c{7$EoF;(chsiJ5 z^pzA+GK*4^OESw+brgWsx`(<32P1a^z)OSuvar)n4G{NYkGm<~rodAp diff --git a/OS/NKEventGroupWrapper.a b/OS/NKEventGroupWrapper.a index 8114f69..16691b4 100644 --- a/OS/NKEventGroupWrapper.a +++ b/OS/NKEventGroupWrapper.a @@ -1,55 +1,90 @@ ; Straightforward 68k wrappers for three NanoKernel MPCalls related to EventGroups -MPCall49 PROC EXPORT ; create an EventGroup (will be for blue), return its ID - - Link A6, #$0 - MoveQ.L #49, D0 - dc.w $fe1f - Move.L D0, $C(A6) - Move.L $8(A6), D0 - BEQ.B (* + $6) - MoveA.L D0, A1 - Move.L A0, (A1) - Unlk A6 - MoveA.L (SP)+, A0 - AddQ #$4, SP - Jmp (A0) +; 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 -MPCall54 PROC EXPORT +; pascal OSStatus NKCreateEvent(long return_space, MPEventID *event); - Link A6, #$0 - MoveA.L $C(A6), A0 - Move.L $8(A6), D1 - MoveQ.L #54, D0 - dc.w $fe1f - Move.L D0, $10(A6) - Unlk A6 - MoveA.L (SP)+, A0 - AddQ.L #$8, SP - Jmp (A0) +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) -MPCall52 PROC EXPORT +; pascal OSStatus NKSetSWIEvent(long return_space, MPEventID event, long swi); - Link A6, #$0 - MoveA.L $8(A6), A1 - MoveA.L $10(A6), A0 - MoveQ.L #52, D0 - dc.w $fe1f - Move.L D0, $14(A6) - Move.L $C(A6), D0 - BEQ.B (* + $6) - MoveA.L D0, A1 - Move.L A0, (A1) - Unlk A6 - MoveA.L (SP)+, A0 - DC.W $defc, $000c -; AddA.W #$C, SP - Jmp (A0) +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) - END \ No newline at end of file +; 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