home *** CD-ROM | disk | FTP | other *** search
-
- ; LWP.A
- ;
- ; Light Weight Process Support
-
- section text,code
-
- ; start a new LWP process. D0.W = bytes of args
- ; D1.W = bytes of local vars
- ;
- ; push args. Return address (start pc) already pushed
- ; by calling process.
- __LWPStart
- ext.l D0
- ext.l D1
- move.l D1,-(sp)
- move.l D0,-(sp)
- jsr __CLWPStart(pc) ; sets up independant context
- lea 8+4(sp),sp ; args, skip local ret addr
- moveq.l #0,D0
- rts ; return from calling procedure
-
- ; JMP'd to at end of LWP subroutine.
-
- __LWPReturn:
- move.l D0,-(sp) ; return code
- move.l (A5),-(sp) ; LWP descriptor
- jsr __CLWPReturn(pc); sets up new context and
- addq.l #8,sp
- move.l D0,A0 ; returns it
-
- ; D0,D2-D7,PC,A2,A3,A5,A6
- ; (D0 usually holds a return address)
-
- movem.l (A0),D0/D2-D7/A1/A2/A3/A5/A6
- jmp (A1)
-
- ; Called by user. LWPGetEvent(). First do a context
- ; switch if feasible.
-
- _LWPGetEvent:
- move.l (A5),A0 ; LWP descriptor (circular doubly
- tst.l 8(A0) ; event ready ?
- bne lge10
- ; no, unlink from rdy
- move.l 4(A0),A1 ; A1 = prev
- move.l (A0),(A1) ; this->next -> prev->next
- move.l (A0),A1 ; A1 = next
- move.l 4(A0),4(A1) ; this->prev -> next->prev
- move.l A1,D1 ; next ready context
-
- lgeout lea lge50(pc),A1 ; restore pc (when event ready)
- move.l (sp)+,D0 ; return address
- movem.l D0/D2-D7/A1/A2/A3/A5/A6,12(A0) ; save ctx
- move.l D1,A1
- movem.l 12(A1),D0/D2-D7/A1/A2/A3/A5/A6 ; restore ctx
- jmp (A1) ; go
-
- ; lge50, restore from wait state, check event,
- ; relink if event found, else go back to wait state.
-
- lge50 move.l (A5),A0 ; get A0 back
- move.l D0,-(sp) ; push ret addr again
-
- move.l __LWPRdyBase(A4),D1
- move.l 8(A0),D0
- beq lgeout
-
- ; event in D0. first relink
-
- move.l __LWPRdyBase(A4),A1 ; insert after item
-
- move.l (A1),(A0) ; item->next -> this->next
- move.l A1,4(A0) ; item -> this->prev
- move.l A0,(A1) ; this -> item->next
- move.l (A0),A1 ; (A1 = nextitem)
- move.l A0,4(A1) ; nextitem->prev = this
-
- ; unlink event
-
- move.l D0,A1
- move.l (A1),8(A0)
-
- ; return event
-
- rts
-
- END
-
-