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
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* 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-11-22 22:30:06 +00:00
|
|
|
|
>LDYAI TskMgr.Table Clear whole process table
|
|
|
|
|
>STYA ZPQuickPtr1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
ldx #K.PS.MAX
|
|
|
|
|
|
|
|
|
|
.1 lda #0
|
|
|
|
|
ldy #S.PS.SIZE-1
|
|
|
|
|
|
2015-11-22 22:30:06 +00:00
|
|
|
|
.2 sta (ZPQuickPtr1),y
|
2015-03-14 21:48:35 +00:00
|
|
|
|
dey
|
|
|
|
|
bpl .2
|
|
|
|
|
|
2015-11-22 22:30:06 +00:00
|
|
|
|
lda ZPQuickPtr1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #S.PS.SIZE
|
2015-11-22 22:30:06 +00:00
|
|
|
|
sta ZPQuickPtr1
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bcc .3
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-11-22 22:30:06 +00:00
|
|
|
|
inc ZPQuickPtr1+1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
.3 dex
|
2015-03-14 21:48:35 +00:00
|
|
|
|
bne .1
|
2015-11-22 22:30:06 +00:00
|
|
|
|
|
|
|
|
|
lda #1
|
2015-11-10 21:47:57 +00:00
|
|
|
|
ldy #S.PS.hINDEV
|
2015-11-22 22:30:06 +00:00
|
|
|
|
sta TskMgr.Table,y Make In DEV = SYS
|
2015-11-10 21:47:57 +00:00
|
|
|
|
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-11-23 14:54:30 +00:00
|
|
|
|
S.TskMgrInit.Env
|
|
|
|
|
|
|
|
|
|
jsr S.SelectProcess0
|
|
|
|
|
|
|
|
|
|
ldx #DEVMGR.OPEN
|
|
|
|
|
jsr pDevJmp
|
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
>PUSHWI TmpBuffer256 push ENV value
|
|
|
|
|
>PUSHWI ENV.A2osX push ENV name
|
|
|
|
|
jsr S.SetEnvVarP
|
2015-11-22 22:30:06 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>PUSHWI ENV.PATH.VALUE
|
|
|
|
|
>PUSHWI ENV.PATH
|
|
|
|
|
jsr S.SetEnvVarP
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>PUSHWI ENV.LIB.VALUE
|
|
|
|
|
>PUSHWI ENV.LIB
|
|
|
|
|
jsr S.SetEnvVarP
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>PUSHWI ENV.DRV.VALUE
|
|
|
|
|
>PUSHWI ENV.DRV
|
|
|
|
|
jsr S.SetEnvVarP
|
|
|
|
|
bcs .9
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-11-22 22:30:06 +00:00
|
|
|
|
.9 rts
|
2015-03-14 21:48:35 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* 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
|
|
|
|
|
*--------------------------------------
|
2015-11-22 22:30:06 +00:00
|
|
|
|
* S.ExecProcessNewEnvYA
|
|
|
|
|
* S.ExecProcessYA (Blocking Parent PID)
|
|
|
|
|
* S.CreateProcessNewEnvYA
|
|
|
|
|
* S.CreateProcessYA (Non Blocking)
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* in :
|
2015-06-03 18:30:57 +00:00
|
|
|
|
* A = hMem To Cmd Line
|
2015-11-22 22:30:06 +00:00
|
|
|
|
* Y = hMem To Args
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* out :
|
|
|
|
|
* A = Child PSID
|
|
|
|
|
*--------------------------------------
|
2015-11-22 22:30:06 +00:00
|
|
|
|
S.ExecProcessNewEnvYA
|
|
|
|
|
ldx #S.PS.F.ENV
|
|
|
|
|
.HS 2C bit abs
|
|
|
|
|
S.ExecProcessYA ldx #0
|
2015-10-19 20:35:00 +00:00
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
2015-11-22 22:30:06 +00:00
|
|
|
|
S.CreateProcessNewEnvYA
|
|
|
|
|
ldx #S.PS.F.ENV
|
|
|
|
|
.HS 2C bit abs
|
|
|
|
|
S.CreateProcessYA
|
|
|
|
|
ldx #0
|
|
|
|
|
S.CreateProcess stx S.CreateChildProcess.Flags
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta S.CreateProcessA.Cmd
|
2015-11-22 22:30:06 +00:00
|
|
|
|
sty S.CreateProcessA.Args
|
|
|
|
|
|
|
|
|
|
* lda #'|'
|
|
|
|
|
* jsr S.CoutA
|
|
|
|
|
* lda S.CreateProcessA.Cmd
|
|
|
|
|
* jsr S.PSTROutA
|
|
|
|
|
* lda #'|'
|
|
|
|
|
* jsr S.CoutA
|
|
|
|
|
* lda S.CreateProcessA.Args
|
|
|
|
|
* beq .1
|
|
|
|
|
* jsr S.PSTROutA
|
|
|
|
|
*.1 lda #'|'
|
|
|
|
|
* jsr S.CoutA
|
|
|
|
|
* lda #13
|
|
|
|
|
* jsr S.CoutA
|
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-11-22 22:30:06 +00:00
|
|
|
|
jsr S.InitProcess
|
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
|
2015-11-22 22:30:06 +00:00
|
|
|
|
S.CreateProcessA.Args .BS 1
|
2015-06-03 18:30:57 +00:00
|
|
|
|
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-11-22 22:30:06 +00:00
|
|
|
|
* S.InitProcess
|
2015-03-14 21:48:35 +00:00
|
|
|
|
* In :
|
|
|
|
|
* A = hMem To Full Cmd Line
|
|
|
|
|
*--------------------------------------
|
2015-11-22 22:30:06 +00:00
|
|
|
|
S.InitProcess lda S.CreateProcessA.Args
|
|
|
|
|
beq .1
|
|
|
|
|
jsr S.ExpandPStrA
|
|
|
|
|
.1 ldy #S.PS.hARGS
|
2015-06-03 18:30:57 +00:00
|
|
|
|
sta (pPs),y set ARGS hMem (0 if none)
|
2015-11-22 22:30:06 +00:00
|
|
|
|
|
|
|
|
|
lda S.CreateProcessA.Cmd
|
|
|
|
|
jsr S.ExpandPStrA
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
ldy #S.PS.hCMD
|
|
|
|
|
sta (pPs),y
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
2015-03-14 21:48:35 +00:00
|
|
|
|
jsr S.LoadBinA A = BinPath hMem
|
2015-11-22 22:30:06 +00:00
|
|
|
|
bcs .99
|
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
|
|
|
|
|
|
2015-11-22 22:30:06 +00:00
|
|
|
|
beq .2 DS.SIZE=0...
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
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-11-22 22:30:06 +00:00
|
|
|
|
bcs .99
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
>STYA pData
|
|
|
|
|
txa
|
|
|
|
|
ldy #S.PS.hDS
|
|
|
|
|
sta (pPs),y save DS hMem in TSKSLOT
|
|
|
|
|
|
2015-11-22 22:30:06 +00:00
|
|
|
|
.2 ldx #TSKMGR.INIT
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr pCodeJmp Call INIT function
|
|
|
|
|
|
2015-11-22 22:30:06 +00:00
|
|
|
|
.99 rts
|
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
|
2015-11-22 22:30:06 +00:00
|
|
|
|
tay
|
|
|
|
|
bne S.SelectProcessN
|
|
|
|
|
S.SelectProcess0
|
|
|
|
|
>LDYAI TskMgr.Table Make PS #0 as current process
|
|
|
|
|
>STYA pPs
|
|
|
|
|
bra S.SelectProcessDev
|
|
|
|
|
S.SelectProcessN
|
2015-06-03 18:30:57 +00:00
|
|
|
|
jsr S.GetPSByIDA
|
|
|
|
|
bcs *
|
2015-11-22 22:30:06 +00:00
|
|
|
|
>STYA pPs
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
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
|
2015-11-22 22:30:06 +00:00
|
|
|
|
beq S.SelectProcessDev
|
2015-06-03 18:30:57 +00:00
|
|
|
|
|
|
|
|
|
jsr S.GetMemPtrA
|
|
|
|
|
>STYA pData
|
|
|
|
|
|
2015-11-22 22:30:06 +00:00
|
|
|
|
S.SelectProcessDev
|
|
|
|
|
ldy #S.PS.hOUTDEV
|
2015-06-03 18:30:57 +00:00
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE SYS/KERNEL.S.TSK
|
|
|
|
|
LOAD SYS/KERNEL.S
|
|
|
|
|
ASM
|