2015-03-14 21:48:35 +00:00
|
|
|
|
PR#3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
PREFIX /A2OSX.SRC
|
2015-03-14 21:48:35 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* S.TskMgrInit
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
S.TskMgrInit stz TSKMGR.LASTID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda #1
|
|
|
|
|
sta TSKMGR.SIZE One Slot Busy (Kernel PS=0)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
>LDYAI TskMgr.Table Make PS #0 as current process
|
|
|
|
|
>STYA pPs
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldx #K.PS.MAX
|
|
|
|
|
|
|
|
|
|
.1 lda #0
|
|
|
|
|
ldy #S.PS.SIZE-1
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.2 sta (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
dey
|
|
|
|
|
bpl .2
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.PS.SIZE
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcc .3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
inc pPs+1
|
|
|
|
|
.3 dex
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
>LDYAI TskMgr.Table Make PS #0 as current process
|
|
|
|
|
>STYA pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-11-10 21:47:57 +00:00
|
|
|
|
lda #0
|
|
|
|
|
ldy #S.PS.hINDEV
|
|
|
|
|
sta TskMgr.Table,y Make In DEV = NUL
|
|
|
|
|
inc
|
|
|
|
|
ldy #S.PS.hOUTDEV
|
|
|
|
|
sta TskMgr.Table,y Make OUT DEV = SYS
|
|
|
|
|
ldy #S.PS.hERRDEV
|
|
|
|
|
sta TskMgr.Table,y Make ERR DEV = SYS
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.CreateEnv
|
2015-06-03 18:30:57 +00:00
|
|
|
|
bcs *
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.PS.hENV
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta TskMgr.Table,y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
>LDYAI TmpBuffer256
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr S.MLIGetPrefixYA
|
|
|
|
|
bcs *
|
|
|
|
|
|
|
|
|
|
>LDYAI TmpBuffer256
|
|
|
|
|
jsr S.NewPStrYA
|
|
|
|
|
bcs *
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.PS.hPREFIX
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta TskMgr.Table,y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>PUSHWI TmpBuffer256 push ENV value
|
|
|
|
|
>PUSHWI ENV.A2osX push ENV name
|
|
|
|
|
ldy #S.PS.hENV
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda TskMgr.Table,y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>PUSHA
|
|
|
|
|
jsr S.SetEnvVarP
|
|
|
|
|
rts
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* S.TskMgrRun
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
S.TskMgrRun >LDYAI TskMgr.Table+S.PS.SIZE
|
|
|
|
|
>STYA pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda #1 Skip PS #0
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sta TSKMGR.COUNT
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.1 lda (pPs) get S.PS.F
|
2015-03-14 21:48:35 +00:00
|
|
|
|
and #S.PS.F.INUSE In use ?
|
|
|
|
|
beq .5
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs) get S.PS.F
|
2015-03-14 21:48:35 +00:00
|
|
|
|
and #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
|
|
|
|
|
|
|
|
|
ldy #S.PS.CID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
|
|
|
|
jsr S.GetPSByIDA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcc .5 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
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.2 jsr S.SelectProcess
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.PC+1 Is this PS sleeping?
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
tax
|
|
|
|
|
dey
|
|
|
|
|
ora (pPs),y
|
|
|
|
|
beq .3 no, call TSKMGR.RUN
|
|
|
|
|
|
|
|
|
|
lda (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
2015-06-03 18:30:57 +00:00
|
|
|
|
adc pCode
|
|
|
|
|
sta S.TskMgrRunJmp+1
|
|
|
|
|
txa
|
|
|
|
|
adc pCode+1
|
|
|
|
|
sta S.TskMgrRunJmp+2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
lda #0 Don't forget to reset S.PC
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ldy #S.PS.PC
|
|
|
|
|
sta (pPs),y
|
|
|
|
|
iny
|
|
|
|
|
sta (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr S.TskMgrRunJmp
|
|
|
|
|
bra .4
|
|
|
|
|
|
|
|
|
|
.3 ldx #TSKMGR.RUN
|
|
|
|
|
jsr pCodeJmp Call RUN function
|
|
|
|
|
.4 bcc .5 RUN said CS=QUIT?
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
ldy #S.PS.ID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeProcessA
|
|
|
|
|
bcs .99
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.5 lda pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.PS.SIZE
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcc .6
|
2015-06-03 18:30:57 +00:00
|
|
|
|
inc pPs+1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.6 lda TSKMGR.COUNT
|
|
|
|
|
inc TSKMGR.COUNT
|
|
|
|
|
cmp TSKMGR.SIZE
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .1
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.99 bra *
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
S.TskMgrRunJmp jmp $FFFF
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* S.DispatchEvent
|
|
|
|
|
* IN:
|
|
|
|
|
* OUT:
|
|
|
|
|
* CS: Not Dispatched
|
|
|
|
|
* CC: Event Cleared
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
S.DispatchEvent >LDYAI TskMgr.Table+S.PS.SIZE
|
|
|
|
|
>STYA pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda #1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sta TSKMGR.COUNT
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.1 lda (pPs) get S.PS.F
|
2015-03-14 21:48:35 +00:00
|
|
|
|
and #S.PS.F.INUSE In use ?
|
|
|
|
|
beq .3
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs) get S.PS.F
|
2015-03-14 21:48:35 +00:00
|
|
|
|
and #S.PS.F.HOLD Waiting for Another Task to Terminate?
|
|
|
|
|
bne .3
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs) get S.PS.F
|
2015-03-14 21:48:35 +00:00
|
|
|
|
and #S.PS.F.EVENT Accept Events ?
|
|
|
|
|
beq .3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
jsr S.SelectProcess
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
ldx #TSKMGR.DOEVENT
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr pCodeJmp Call DOEVENT function
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcc .8
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.3 lda pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.PS.SIZE
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta pPs
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcc .4
|
2015-06-03 18:30:57 +00:00
|
|
|
|
inc pPs+1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.4 lda TSKMGR.COUNT
|
|
|
|
|
inc TSKMGR.COUNT
|
|
|
|
|
cmp TSKMGR.SIZE
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .1
|
|
|
|
|
sec
|
2015-06-03 18:30:57 +00:00
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.8 jsr S.DestroyEvent
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* S.TskMgrQuit
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
S.TskMgrQuit clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* PUBLIC
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* S.ExecProcessA (Blocking Parent PID)
|
|
|
|
|
* in :
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* A = hMem To Cmd Line
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* out :
|
|
|
|
|
* A = Child PSID
|
|
|
|
|
*--------------------------------------
|
2015-10-19 20:35:00 +00:00
|
|
|
|
S.ExecProcessNewEnvA
|
|
|
|
|
ldy #S.PS.F.ENV
|
|
|
|
|
bra S.ExecProcess
|
|
|
|
|
S.ExecProcessA ldy #0
|
|
|
|
|
S.ExecProcess jsr S.CreateProcess
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .9 terminated, do not set PID as HOLD
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.PS.CID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (pPs),y
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
pha Save Child PID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ora #S.PS.F.HOLD
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (pPs)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
pla Get Back PID
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* S.CreateProcessA (Non Blocking)
|
|
|
|
|
* in :
|
|
|
|
|
* A = hMem To Full Cmd Line
|
|
|
|
|
* out :
|
|
|
|
|
* A = Child PSID
|
|
|
|
|
*--------------------------------------
|
2015-10-19 20:35:00 +00:00
|
|
|
|
S.CreateProcessNewEnvA
|
|
|
|
|
ldy #S.PS.F.ENV
|
|
|
|
|
bra S.CreateProcess
|
2015-03-14 21:48:35 +00:00
|
|
|
|
S.CreateProcessA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
ldy #0
|
|
|
|
|
S.CreateProcess sty S.CreateChildProcess.Flags
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta S.CreateProcessA.Cmd
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>LDYAI MSG.NEWPS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr S.SysScrPPSTRYA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr S.CreateChildProcess
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcs .99
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
sta S.CreateProcessA.CPSID
|
|
|
|
|
|
|
|
|
|
jsr S.SelectProcessA
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda S.CreateProcessA.Cmd
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.InitProcessA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
bcs .98 Init Failed or exit?
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.PID switch back to Parent Process
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
|
|
|
|
|
jsr S.SelectProcessA
|
|
|
|
|
|
|
|
|
|
lda S.CreateProcessA.CPSID
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.98 pha save error code
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.PID switch back to Parent Process
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
jsr S.SelectProcessA
|
|
|
|
|
|
|
|
|
|
lda S.CreateProcessA.CPSID
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeProcessA
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
pla get back error code
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.99 sec
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
S.CreateProcessA.Cmd .BS 1
|
|
|
|
|
S.CreateProcessA.CPSID .BS 1
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* S.GetPSByIDA
|
|
|
|
|
* In :
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* A = PID
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* Out :
|
|
|
|
|
* Y,A = PTR to TSKSLOT
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
S.GetPSByIDA sta S.GetPSByIDA.PS
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
>LDYAI TskMgr.Table
|
|
|
|
|
>STYA ZPQuickPtr1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda S.GetPSByIDA.PS
|
2015-03-14 21:48:35 +00:00
|
|
|
|
beq .8
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 inx
|
|
|
|
|
lda ZPQuickPtr1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.PS.SIZE
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta ZPQuickPtr1
|
|
|
|
|
bcc .2
|
|
|
|
|
inc ZPQuickPtr1+1
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPQuickPtr1)
|
|
|
|
|
bpl .3
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.ID
|
|
|
|
|
lda (ZPQuickPtr1),y
|
|
|
|
|
cmp S.GetPSByIDA.PS
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
.3 cpx TSKMGR.SIZE
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.9 lda #TSKMGR.ERRNSP
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.8 >LDYA ZPQuickPtr1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2015-06-03 18:30:57 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
S.GetPSByIDA.PS .BS 1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-11-10 21:47:57 +00:00
|
|
|
|
S.Sleep ldy #S.PS.hCS
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
>SYSCALL SYS.GetMemPtrA
|
|
|
|
|
>STYA S.Sleep.SaveCS
|
|
|
|
|
ldy #S.PS.PC
|
|
|
|
|
pla get PC LO
|
|
|
|
|
plx get PC HI
|
|
|
|
|
inc Advance PC one Byte
|
|
|
|
|
bne .1
|
|
|
|
|
inx
|
|
|
|
|
|
|
|
|
|
.1 sec
|
|
|
|
|
sbc S.Sleep.SaveCS
|
|
|
|
|
sta (pPs),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sbc S.Sleep.SaveCS+1
|
|
|
|
|
sta (pPs),y
|
|
|
|
|
clc No error,
|
|
|
|
|
rts back to Kernel
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
S.Sleep.SaveCS .BS 2
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* PRIVATE
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* S.CreateChildProcess
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* in :
|
|
|
|
|
* out :
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* A = PSID
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* we cannot use ZPQuickPtrs
|
|
|
|
|
* because of calling S.PStrCpyA & S.DupEnvA
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
S.CreateChildProcess
|
|
|
|
|
>LDYAI TskMgr.Table+S.PS.SIZE
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>STYA R.AX
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 inx
|
|
|
|
|
cpx TSKMGR.SIZE
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
lda (R.AX) Found an empty slot
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bpl .3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda R.AL
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.PS.SIZE
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta R.AL
|
|
|
|
|
bcc .1
|
|
|
|
|
inc R.AH
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.2 cpx #K.PS.MAX
|
|
|
|
|
bne .30
|
|
|
|
|
|
|
|
|
|
lda #TSKMGR.ERROOH
|
2015-03-14 21:48:35 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.30 inc TSKMGR.SIZE
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.3 lda #S.PS.F.INUSE
|
2015-10-19 20:35:00 +00:00
|
|
|
|
ora S.CreateChildProcess.Flags
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (R.AX)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.4 inc TSKMGR.LASTID Get a PSID not alredy running
|
|
|
|
|
beq .4 not = 0
|
|
|
|
|
lda TSKMGR.LASTID
|
|
|
|
|
jsr S.GetPSByIDA
|
|
|
|
|
bcc .4
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.ID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda TSKMGR.LASTID
|
|
|
|
|
sta (R.AX),y
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
lda #0
|
|
|
|
|
ldy #S.PS.hCS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.5 sta (R.AX),y Blank Everything in this S.PS
|
2015-03-14 21:48:35 +00:00
|
|
|
|
iny
|
|
|
|
|
cpy #S.PS.SIZE
|
|
|
|
|
bne .5
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
|
|
|
|
lda S.CreateChildProcess.Flags
|
|
|
|
|
and #S.PS.F.ENV need to create ENV & Prefix ?
|
|
|
|
|
beq .6
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.hPREFIX copy hPREFIX...
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.PStrCpyA
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hPREFIX
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (R.AX),y
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.PS.hENV ...and hENV from parent PS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.DupEnvA
|
|
|
|
|
bcs .99
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.PS.hENV
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (R.AX),y
|
2015-10-19 20:35:00 +00:00
|
|
|
|
bra .8
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.6 ldy #S.PS.hPREFIX reuse same hPREFIX...
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
sta (R.AX),y
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hENV ...and hENV from parent PS
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
sta (R.AX),y
|
|
|
|
|
|
|
|
|
|
.8 ldy #S.PS.hINDEV
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
|
|
|
|
sta (R.AX),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.PS.hOUTDEV
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
|
|
|
|
sta (R.AX),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.PS.hERRDEV
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
|
|
|
|
sta (R.AX),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.PS.ID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.PID
|
|
|
|
|
sta (R.AX),y
|
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda TSKMGR.LASTID
|
2015-06-03 18:30:57 +00:00
|
|
|
|
clc Exit with A=PSID
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.99 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2015-10-19 20:35:00 +00:00
|
|
|
|
S.CreateChildProcess.Flags
|
|
|
|
|
.BS 1
|
|
|
|
|
*--------------------------------------
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* S.InitProcessA
|
|
|
|
|
* In :
|
|
|
|
|
* A = hMem To Full Cmd Line
|
|
|
|
|
*--------------------------------------
|
2015-10-19 20:35:00 +00:00
|
|
|
|
S.InitProcessA stz S.InitProcessA.hPath
|
|
|
|
|
stz S.InitProcessA.hFullPath
|
|
|
|
|
>PUSHA Push Cmd Line
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>PUSHBI $20 Push SEP=' '
|
|
|
|
|
>PUSHBI 0 Push 0 for getting CMD And ARGS
|
|
|
|
|
jsr S.PStrGetTkn
|
2015-06-03 18:30:57 +00:00
|
|
|
|
bcc .10
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.99 rts OOM error
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.10 sta S.InitProcessA.hCmd
|
|
|
|
|
pha
|
2015-03-14 21:48:35 +00:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hARGS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (pPs),y set ARGS hMem (0 if none)
|
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
pla
|
|
|
|
|
jsr S.GetMemPtrA
|
|
|
|
|
>STYA ZPQuickPtr1
|
|
|
|
|
lda (ZPQuickPtr1)
|
|
|
|
|
cmp #'/'
|
|
|
|
|
bne .20
|
|
|
|
|
|
|
|
|
|
lda S.InitProcessA.hCmd
|
|
|
|
|
bra .30
|
|
|
|
|
|
|
|
|
|
.20 >PUSHWI ENV.PATH push ENVNAME=PATH
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldy #S.PS.hENV
|
2015-06-03 18:30:57 +00:00
|
|
|
|
lda (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>PUSHA
|
|
|
|
|
jsr S.GetEnvVarP get value for ENV=PATH
|
|
|
|
|
bcs .99
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sta S.InitProcessA.hPath save VALUE hMem for discard
|
|
|
|
|
pha
|
|
|
|
|
lda S.InitProcessA.hCmd
|
|
|
|
|
>PUSHA push CMD for S.FileSearch
|
|
|
|
|
pla
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>PUSHA A=PStr to ENV Value
|
|
|
|
|
jsr S.FileSearch find File in %PATH%
|
2015-10-19 20:35:00 +00:00
|
|
|
|
bcs S.InitProcessA.ClnUp
|
|
|
|
|
|
|
|
|
|
sta S.InitProcessA.hFullPath save FULLPATH hMem for discard
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.30 jsr S.PStrCpyA
|
|
|
|
|
ldy #S.PS.hCMD
|
|
|
|
|
sta (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
pha
|
|
|
|
|
jsr S.SysScrPPSTRA
|
|
|
|
|
pla
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.LoadBinA A = BinPath hMem
|
2015-10-19 20:35:00 +00:00
|
|
|
|
bcs S.InitProcessA.ClnUp
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
>STYA pCode save PTR to Code Segment
|
2015-03-14 21:48:35 +00:00
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hCS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (pPs),y save CS hMem in TSKSLOT
|
|
|
|
|
|
|
|
|
|
ldy #H.BIN.BIN.DS.SIZE+1
|
|
|
|
|
lda (pCode),y Load DS.SIZE HI
|
|
|
|
|
tax
|
|
|
|
|
dey
|
|
|
|
|
ora (pCode),y
|
|
|
|
|
|
|
|
|
|
beq .1 DS.SIZE=0...
|
|
|
|
|
|
|
|
|
|
lda (pCode),y
|
|
|
|
|
>PUSHAX Push DS.SIZE
|
2015-09-13 20:35:07 +00:00
|
|
|
|
>PUSHBI S.MEM.F.INIT0 Clear DS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr S.GetMem
|
2015-10-19 20:35:00 +00:00
|
|
|
|
bcs S.InitProcessA.ClnUp
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
>STYA pData
|
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hDS
|
|
|
|
|
sta (pPs),y save DS hMem in TSKSLOT
|
|
|
|
|
|
|
|
|
|
.1 ldx #TSKMGR.INIT
|
|
|
|
|
jsr pCodeJmp Call INIT function
|
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
S.InitProcessA.ClnUp
|
|
|
|
|
php save Carry
|
|
|
|
|
pha save ERR
|
|
|
|
|
lda S.InitProcessA.hFullPath
|
|
|
|
|
beq .1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeMemA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.1 lda S.InitProcessA.hPath
|
|
|
|
|
beq .2
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeMemA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
|
|
|
|
.2 pla
|
|
|
|
|
plp
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
S.InitProcessA.hCmd .BS 1
|
|
|
|
|
S.InitProcessA.hPath .BS 1
|
|
|
|
|
S.InitProcessA.hFullPath .BS 1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* S.SelectProcessA
|
|
|
|
|
* In : A=PSID
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
S.SelectProcessA
|
|
|
|
|
jsr S.GetPSByIDA
|
|
|
|
|
bcs *
|
|
|
|
|
>STYA pPS
|
|
|
|
|
|
|
|
|
|
S.SelectProcess ldy #S.PS.hCS
|
|
|
|
|
lda (pPs),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.GetMemPtrA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
>STYA pCode
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hDS
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
jsr S.GetMemPtrA
|
|
|
|
|
>STYA pData
|
|
|
|
|
|
|
|
|
|
.1 ldy #S.PS.hOUTDEV
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
jsr S.GetDevByIDA
|
|
|
|
|
>STYA pDev
|
|
|
|
|
|
|
|
|
|
.8 clc
|
2015-03-14 21:48:35 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* S.FreeProcessA
|
|
|
|
|
* In : A = PID to free
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
S.FreeProcessA jsr S.GetPSByIDA
|
|
|
|
|
bcs .9
|
|
|
|
|
>STYA ZPQuickPtr1
|
|
|
|
|
ldy #S.PS.hARGS
|
|
|
|
|
lda (ZPQuickPtr1),y
|
|
|
|
|
beq .1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeMemA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.1 ldy #S.PS.hCMD
|
|
|
|
|
lda (ZPQuickPtr1),y
|
|
|
|
|
beq .2
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeMemA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
|
|
|
|
lda (ZPQuickPtr1) get S.PS.F
|
2015-11-10 21:47:57 +00:00
|
|
|
|
and #S.PS.F.ENV do we have to discard duplicated env & prefix ?
|
2015-10-19 20:35:00 +00:00
|
|
|
|
beq .4
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.2 ldy #S.PS.hENV
|
|
|
|
|
lda (ZPQuickPtr1),y
|
|
|
|
|
beq .3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeMemA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.3 ldy #S.PS.hPREFIX
|
|
|
|
|
lda (ZPQuickPtr1),y
|
|
|
|
|
beq .4
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeMemA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.4 ldy #S.PS.hDS
|
|
|
|
|
lda (ZPQuickPtr1),y
|
|
|
|
|
beq .5
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeMemA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.5 ldy #S.PS.hCS
|
|
|
|
|
lda (ZPQuickPtr1),y
|
|
|
|
|
beq .8
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.FreeMemA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
.8 lda #0
|
|
|
|
|
sta (ZPQuickPtr1) Mark TSKSLOT as free
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
.9 bra *
|
|
|
|
|
*--------------------------------------
|
2015-06-03 18:30:57 +00:00
|
|
|
|
TSKMGR.SIZE .BS 1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
TSKMGR.COUNT .BS 1
|
|
|
|
|
TSKMGR.LASTID .BS 1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MSG.NEWPS >PSTRING "\nTskMgr:"
|
|
|
|
|
MAN
|
|
|
|
|
SAVE SYS/KERNEL.S.TSK
|
|
|
|
|
LOAD SYS/KERNEL.S
|
|
|
|
|
ASM
|