2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-03-15 16:44:15 +00:00
|
|
|
|
LOMEM $A00
|
2015-03-14 21:48:35 +00:00
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
*--------------------------------------
|
2016-09-29 15:30:15 +00:00
|
|
|
|
* TSK.TskMgrRun
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-10-03 15:59:36 +00:00
|
|
|
|
TSK.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
|
2015-06-03 18:30:57 +00:00
|
|
|
|
>STYA pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda TskMgr.Count
|
|
|
|
|
sta TskMgr.Idx
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
.1 dec TskMgr.Idx skip PS 0
|
2016-10-31 21:38:53 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
lda (pPs) get S.PS.F
|
2016-06-24 15:02:13 +00:00
|
|
|
|
bit #S.PS.F.INUSE In use ?
|
2016-08-18 15:26:11 +00:00
|
|
|
|
beq .7
|
2016-06-24 15:02:13 +00:00
|
|
|
|
|
|
|
|
|
bit #S.PS.F.HOLD Waiting for Another Task to Terminate?
|
2015-06-03 18:30:57 +00:00
|
|
|
|
beq .2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-10-29 19:58:21 +00:00
|
|
|
|
ldy #S.PS.CPID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
2016-09-21 15:20:37 +00:00
|
|
|
|
jsr K.GetPSByIDA
|
2016-08-18 15:26:11 +00:00
|
|
|
|
bcc .7 yes, running....
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
lda (pPs) get S.PS.F
|
2015-03-14 21:48:35 +00:00
|
|
|
|
and #$FF^S.PS.F.HOLD unmark as HOLD
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (pPs)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-10-03 06:18:46 +00:00
|
|
|
|
.2 jsr PS.Select
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-06-24 15:02:13 +00:00
|
|
|
|
lda (pPS)
|
2016-08-18 15:26:11 +00:00
|
|
|
|
bit #S.PS.F.INIT
|
2016-10-31 21:38:53 +00:00
|
|
|
|
bne .30
|
2016-08-18 15:26:11 +00:00
|
|
|
|
|
2016-10-31 21:38:53 +00:00
|
|
|
|
bit #S.PS.F.SLEEP Is this PS sleeping?
|
2015-06-03 18:30:57 +00:00
|
|
|
|
beq .3 no, call TSKMGR.RUN
|
|
|
|
|
|
2017-08-21 14:58:48 +00:00
|
|
|
|
jsr TSK.PSWakeUp
|
2015-06-03 18:30:57 +00:00
|
|
|
|
bra .4
|
2016-08-18 15:26:11 +00:00
|
|
|
|
|
2016-10-31 21:38:53 +00:00
|
|
|
|
.30 and #$FF^S.PS.F.INIT unmark as INIT
|
|
|
|
|
sta (pPS)
|
|
|
|
|
|
|
|
|
|
ldx #TSKMGR.INIT
|
|
|
|
|
.HS 2C BIT abs
|
2016-06-24 15:02:13 +00:00
|
|
|
|
.3 ldx #TSKMGR.RUN
|
2016-10-03 06:18:46 +00:00
|
|
|
|
|
2016-08-18 15:26:11 +00:00
|
|
|
|
.31 jsr pCodeJmp Call INIT/RUN function
|
2016-10-03 06:18:46 +00:00
|
|
|
|
|
2016-08-18 15:26:11 +00:00
|
|
|
|
.4 bcc .7 INIT/RUN said CS=QUIT?
|
2016-10-31 21:38:53 +00:00
|
|
|
|
|
|
|
|
|
pha save RC
|
|
|
|
|
ldy #S.PS.PPID Notify Parent Process for exit code...
|
|
|
|
|
lda (pPs),y
|
2017-01-12 17:43:45 +00:00
|
|
|
|
jsr K.GetPSByIDA will set ZPPtr1 if success
|
2016-10-31 21:38:53 +00:00
|
|
|
|
bcs .5 parent is dead.....skipping...
|
|
|
|
|
|
2017-08-21 14:58:48 +00:00
|
|
|
|
lda (ZPPtr1) Parent PS is HOLD?
|
|
|
|
|
bit #S.PS.F.HOLD
|
2016-10-31 21:38:53 +00:00
|
|
|
|
beq .5 no...
|
|
|
|
|
|
2017-08-21 14:58:48 +00:00
|
|
|
|
eor #S.PS.F.HOLD yes, release hold...
|
|
|
|
|
sta (ZPPtr1)
|
|
|
|
|
|
|
|
|
|
pla ...probably waiting for this PS to terminate....
|
|
|
|
|
ldy #S.PS.RC give it RC
|
2017-01-12 17:43:45 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-10-31 21:38:53 +00:00
|
|
|
|
.HS B0 BCS
|
|
|
|
|
.5 pla
|
|
|
|
|
|
|
|
|
|
.6 ldx #TSKMGR.QUIT yes, quit this process
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr pCodeJmp Call QUIT function
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-10-29 19:58:21 +00:00
|
|
|
|
ldy #S.PS.PID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
2016-09-29 15:30:15 +00:00
|
|
|
|
jsr PS.FreeA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-08-18 15:26:11 +00:00
|
|
|
|
.7 lda pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
2016-10-03 15:59:36 +00:00
|
|
|
|
adc #S.PS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta pPs
|
2016-10-31 21:38:53 +00:00
|
|
|
|
bcc .1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
inc pPs+1
|
2016-10-31 21:38:53 +00:00
|
|
|
|
bcs .1 Always
|
2016-08-18 15:26:11 +00:00
|
|
|
|
|
2016-06-24 15:02:13 +00:00
|
|
|
|
.8 clc
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
2015-06-03 18:30:57 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-21 14:58:48 +00:00
|
|
|
|
TSK.PSWakeUp and #$FF^S.PS.F.SLEEP unmark as SLEEP
|
2016-10-31 21:38:53 +00:00
|
|
|
|
sta (pPS)
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.PC
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
sec Advance PC by one as it was saved by a JSR
|
|
|
|
|
adc pCode setup by PS.Select
|
|
|
|
|
sta .1+1
|
|
|
|
|
iny
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
adc pCode+1
|
|
|
|
|
sta .1+2
|
|
|
|
|
|
|
|
|
|
.1 jmp $FFFF
|
|
|
|
|
*--------------------------------------
|
2016-09-29 15:30:15 +00:00
|
|
|
|
* TSK.DispatchEvents
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* IN:
|
|
|
|
|
* OUT:
|
|
|
|
|
* CS: Not Dispatched
|
|
|
|
|
* CC: Event Cleared
|
|
|
|
|
*--------------------------------------
|
2016-09-29 15:30:15 +00:00
|
|
|
|
TSK.DispatchEvents
|
2016-10-03 15:59:36 +00:00
|
|
|
|
>LDYAI TskMgr.Table+S.PS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
>STYA pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
lda TskMgr.Count Number of actual processes...
|
|
|
|
|
sta TskMgr.Idx ...to give event list
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
.1 dec TskMgr.Idx skip PS 0
|
2016-06-24 15:02:13 +00:00
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
lda (pPs) get S.PS.F
|
2016-10-06 15:50:20 +00:00
|
|
|
|
bpl .4
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-10-06 15:50:20 +00:00
|
|
|
|
* bit #S.PS.F.INUSE In use ?
|
|
|
|
|
* beq .4
|
|
|
|
|
|
|
|
|
|
bit #S.PS.F.INIT+S.PS.F.HOLD Init or Waiting for Another Task to Terminate?
|
2016-03-13 21:47:19 +00:00
|
|
|
|
bne .4
|
2016-10-06 15:50:20 +00:00
|
|
|
|
|
2016-06-23 15:56:13 +00:00
|
|
|
|
bit #S.PS.F.EVENT Accept Events ?
|
2016-03-13 21:47:19 +00:00
|
|
|
|
beq .4
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-10-03 06:18:46 +00:00
|
|
|
|
jsr PS.Select
|
2016-03-13 21:47:19 +00:00
|
|
|
|
|
2017-03-15 16:44:15 +00:00
|
|
|
|
lda #EvtMgr.Table
|
|
|
|
|
sta pEvent Select first event in list
|
2016-03-13 21:47:19 +00:00
|
|
|
|
|
2016-10-05 15:57:43 +00:00
|
|
|
|
lda EVTMGR.COUNT
|
2016-03-13 21:47:19 +00:00
|
|
|
|
sta TSKMGR.EVENTCNT
|
|
|
|
|
|
2016-10-05 15:57:43 +00:00
|
|
|
|
.2 lda (pEvent) Empty event, select next
|
2016-03-13 21:47:19 +00:00
|
|
|
|
beq .3
|
|
|
|
|
|
|
|
|
|
lda (pCode)
|
|
|
|
|
cmp #H.BIN.HEADER.BIN65
|
|
|
|
|
bne *
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
ldx #TSKMGR.DOEVENT
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr pCodeJmp Call DOEVENT function
|
2016-10-05 15:57:43 +00:00
|
|
|
|
bcs .3 not for this PS, try next event in list
|
|
|
|
|
|
|
|
|
|
jsr EVT.DestroyEvent this PS handled the EVT, destroy it...
|
2016-03-13 21:47:19 +00:00
|
|
|
|
lda EVTMGR.COUNT
|
2016-10-05 15:57:43 +00:00
|
|
|
|
beq .8 no more event, exit
|
2016-03-13 21:47:19 +00:00
|
|
|
|
|
|
|
|
|
.3 dec TSKMGR.EVENTCNT
|
2016-10-05 15:57:43 +00:00
|
|
|
|
beq .4 all EVT submitted to this PS, try other PS
|
|
|
|
|
|
|
|
|
|
lda pEvent try next EVT to this PS
|
2016-03-13 21:47:19 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.EVT
|
|
|
|
|
sta pEvent
|
|
|
|
|
bra .2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2016-10-05 15:57:43 +00:00
|
|
|
|
.4 lda pPs go to next PS in PS list
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
2016-10-03 15:59:36 +00:00
|
|
|
|
adc #S.PS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta pPs
|
2016-06-24 15:02:13 +00:00
|
|
|
|
bcc .1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
inc pPs+1
|
2016-06-24 15:02:13 +00:00
|
|
|
|
bne .1 always
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2016-03-13 21:47:19 +00:00
|
|
|
|
.8 clc
|
2015-06-03 18:30:57 +00:00
|
|
|
|
rts
|
2016-06-24 15:02:13 +00:00
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2016-09-29 15:30:15 +00:00
|
|
|
|
TSK.TskMgrQuit clc
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-01-12 17:43:45 +00:00
|
|
|
|
TskMgr.Idx .BS 1
|
2016-03-13 21:47:19 +00:00
|
|
|
|
TSKMGR.EVENTCNT .BS 1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/SYS/KERNEL.S.TSK
|
|
|
|
|
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ASM
|