A2osX/SYS/KERNEL.S.PS.txt

411 lines
7.6 KiB
Plaintext
Raw Normal View History

2016-08-17 06:25:58 +00:00
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.SelectProcessA
* In : A=PSID
2016-08-17 06:25:58 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.SelectProcessA
tay
2016-09-21 15:20:37 +00:00
bne K.SelectProcessN
K.SelectProcess0
>LDYAI TskMgr.Table Make PS #0 as current process
>STYA pPs
2016-09-21 15:20:37 +00:00
bra K.SelectProcessDev
K.SelectProcessN
jsr K.GetPSByIDA
bcs *
>STYA pPs
2016-08-17 06:25:58 +00:00
2016-09-21 15:20:37 +00:00
K.SelectProcess ldy #S.PS.hCS
lda (pPs),y
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
>STYA pCode
2016-08-17 06:25:58 +00:00
ldy #S.PS.hDS
lda (pPs),y
2016-09-21 15:20:37 +00:00
beq K.SelectProcessDev
2016-08-17 06:25:58 +00:00
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
>STYA pData
2016-08-17 06:25:58 +00:00
2016-09-21 15:20:37 +00:00
K.SelectProcessDev
ldy #S.PS.hOUTDEV
lda (pPs),y
beq .8
2016-08-17 06:25:58 +00:00
2016-09-21 15:20:37 +00:00
jsr K.GetDevByIDA
>STYA pDev
2016-08-17 06:25:58 +00:00
.8 clc
2016-08-17 06:25:58 +00:00
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.GetPSByIDA
2016-08-17 06:25:58 +00:00
* In :
* A = PID
* Out :
* Y,A = PTR to TSKSLOT
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.GetPSByIDA sta K.GetPSByIDA.PS
2016-08-17 06:25:58 +00:00
>LDYAI TskMgr.Table
>STYA ZPQuickPtr1
2016-09-21 15:20:37 +00:00
lda K.GetPSByIDA.PS
2016-08-17 06:25:58 +00:00
beq .8
ldx #0
.1 inx
lda ZPQuickPtr1
clc
adc #S.PS.SIZE
sta ZPQuickPtr1
bcc .2
inc ZPQuickPtr1+1
.2 lda (ZPQuickPtr1)
bpl .3
ldy #S.PS.ID
lda (ZPQuickPtr1),y
2016-09-21 15:20:37 +00:00
cmp K.GetPSByIDA.PS
2016-08-17 06:25:58 +00:00
beq .8
.3 cpx TSKMGR.SIZE
bne .1
.9 lda #TSKMGR.ERRNSP
sec
rts
.8 >LDYA ZPQuickPtr1
clc
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.GetPSByIDA.PS .BS 1
2016-08-17 06:25:58 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.Sleep pla get PC LO
2016-08-17 06:25:58 +00:00
sec
sbc pCode
ldy #S.PS.PC
sta (pPs),y
pla get PC HI
sbc pCode+1
iny
sta (pPs),y
lda (pPs)
ora #S.PS.F.SLEEP
sta (pPs)
clc No error,
rts back to Kernel
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.ExecProcessNewEnvYA
* K.ExecProcessYA (Blocking Parent PID)
* K.CreateProcessNewEnvYA
* K.CreateProcessYA (Non Blocking)
* in :
* Y,A = PTR To Cmd Line
* out :
* A = Child PSID
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.ExecProcessNewEnvYA
ldx #S.PS.F.ENV+S.PS.F.HOLD
.HS 2C bit abs
2016-09-21 15:20:37 +00:00
K.ExecProcessYA ldx #S.PS.F.HOLD
.HS 2C bit abs
2016-09-21 15:20:37 +00:00
K.CreateProcessNewEnvYA
ldx #S.PS.F.ENV
.HS 2C bit abs
2016-09-21 15:20:37 +00:00
K.CreateProcessYA
ldx #0
2016-09-21 15:20:37 +00:00
stx K.CreateProcess.Flags
2016-09-21 15:20:37 +00:00
jsr K.ExpandPStrYA
bcs .99
2016-09-21 15:20:37 +00:00
stx K.CreateProcess.hCmdLine
>STYA K.CreateProcess.CmdLine
2016-09-21 15:20:37 +00:00
jsr K.CreateProcess.Child
bcs .98
2016-09-21 15:20:37 +00:00
sta K.CreateProcess.CPSID
2016-09-21 15:20:37 +00:00
jsr K.CreateProcess.Init
bcs .97
2016-09-21 15:20:37 +00:00
lda K.CreateProcess.CPSID
clc
rts
.97 pha save error code
2016-09-21 15:20:37 +00:00
lda K.CreateProcess.CPSID
jsr K.FreeProcessA
pla get back error code
.98 pha
2016-09-21 15:20:37 +00:00
lda K.CreateProcess.hCmdLine
jsr K.FreeMemA
pla
.99 sec
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.CreateProcess.Flags .BS 1
K.CreateProcess.hCmdLine .BS 1
K.CreateProcess.CmdLine .BS 2
K.CreateProcess.CPSID .BS 1
2016-08-17 06:25:58 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.CreateProcess.Child
2016-08-17 06:25:58 +00:00
* in :
* out :
* A = PSID
* we cannot use ZPQuickPtrs1 & 2
2016-09-21 15:20:37 +00:00
* because of calling K.NewPStrYA & S.DupEnvA
2016-08-17 06:25:58 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.CreateProcess.Child
2016-08-17 06:25:58 +00:00
>LDYAI TskMgr.Table+S.PS.SIZE
>STYA ZPQuickPtr3
ldx #0
.1 inx
cpx TSKMGR.SIZE
beq .2
lda (ZPQuickPtr3) Found an empty slot
bpl .3
lda ZPQuickPtr3
clc
adc #S.PS.SIZE
sta ZPQuickPtr3
bcc .1
inc ZPQuickPtr3+1
bra .1
.2 cpx #K.PS.MAX
bne .3
2016-08-17 06:25:58 +00:00
lda #TSKMGR.ERROOH
sec
rts
.3 inc TSKMGR.SIZE
2016-08-17 06:25:58 +00:00
.4 inc TSKMGR.LASTID Get a PSID not alredy running
beq .4 not = 0
lda TSKMGR.LASTID
2016-09-21 15:20:37 +00:00
jsr K.GetPSByIDA
2016-08-17 06:25:58 +00:00
bcc .4
ldy #S.PS.ID
lda TSKMGR.LASTID
sta (ZPQuickPtr3),y
lda #0
ldy #S.PS.hCS
2016-08-17 06:25:58 +00:00
.5 sta (ZPQuickPtr3),y Blank Everything in this S.PS
iny
cpy #S.PS.SIZE
bne .5
lda #S.PS.F.ENV
2016-09-21 15:20:37 +00:00
bit K.CreateProcess.Flags need to create ENV & Prefix ?
beq .6 no...
sta (ZPQuickPtr3) Mark this PS with ENV flag
2016-08-17 06:25:58 +00:00
ldy #S.PS.hPREFIX copy hPREFIX...
lda (pPs),y
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
jsr K.NewPStrYA
bcs .9
2016-08-17 06:25:58 +00:00
txa
ldy #S.PS.hPREFIX
sta (ZPQuickPtr3),y
ldy #S.PS.hENV ...and hENV from parent PS
lda (pPs),y
jsr S.DupEnvA
bcs .9
2016-08-17 06:25:58 +00:00
ldy #S.PS.hENV
sta (ZPQuickPtr3),y
bra .8
.6 ldy #S.PS.hPREFIX reuse same hPREFIX...
lda (pPs),y
sta (ZPQuickPtr3),y
ldy #S.PS.hENV ...and hENV from parent PS
lda (pPs),y
sta (ZPQuickPtr3),y
.8 ldy #S.PS.hINDEV
2016-08-17 06:25:58 +00:00
.81 lda (pPs),y
sta (ZPQuickPtr3),y
iny
cpy #S.PS.hERRDEV+1
bne .81
ldy #S.PS.ID
lda (pPs),y
ldy #S.PS.PID
sta (ZPQuickPtr3),y
ldy #S.PS.CID
2016-08-17 06:25:58 +00:00
lda TSKMGR.LASTID
sta (pPs),y
lda #S.PS.F.HOLD
2016-09-21 15:20:37 +00:00
bit K.CreateProcess.Flags
beq .82
2016-08-17 06:25:58 +00:00
ora (pPs)
sta (pPs) HOLD parent PS if ExecProcess
.82 lda #S.PS.F.INUSE+S.PS.F.INIT
ora (ZPQuickPtr3)
sta (ZPQuickPtr3) Make this PS Init....
lda TSKMGR.LASTID
clc Exit with A=PSID
.9 rts
2016-08-17 06:25:58 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.CreateProcess.Init
>LDYA K.CreateProcess.CmdLine
jsr K.PStr2StrArrayYA
2016-08-17 06:25:58 +00:00
bcs .9
phy save PTR to StrArray...
pha
txa
ldy #S.PS.hCMDLINE
sta (ZPQuickPtr3),y
2016-08-17 06:25:58 +00:00
pla Restore PTR...
ply
2016-09-21 15:20:37 +00:00
jsr K.LoadBinYA A = BinPath hMem
2016-08-17 06:25:58 +00:00
bcs .9
>STYA ZPQuickPtr4 save PTR to Code Segment
2016-08-17 06:25:58 +00:00
txa
ldy #S.PS.hCS
sta (ZPQuickPtr3),y save CS hMem in TSKSLOT
2016-08-17 06:25:58 +00:00
ldy #H.BIN.BIN.DS.SIZE+1
lda (ZPQuickPtr4),y Load DS.SIZE HI
2016-08-17 06:25:58 +00:00
tax
dey
ora (ZPQuickPtr4),y
2016-08-17 06:25:58 +00:00
beq .2 DS.SIZE=0...
lda (ZPQuickPtr4),y
2016-08-17 06:25:58 +00:00
>PUSHAX Push DS.SIZE
>PUSHBI S.MEM.F.INIT0 Clear DS
2016-09-21 15:20:37 +00:00
jsr K.GetMem
2016-08-17 06:25:58 +00:00
bcs .9
txa
ldy #S.PS.hDS
sta (ZPQuickPtr3),y save DS hMem in TSKSLOT
2016-08-17 06:25:58 +00:00
.2
2016-08-17 06:25:58 +00:00
clc
.9 rts
2016-08-17 06:25:58 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.FreeProcessA
2016-08-17 06:25:58 +00:00
* In : A = PID to free
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.FreeProcessA jsr K.GetPSByIDA
2016-08-17 06:25:58 +00:00
bcs *
>STYA ZPQuickPtr1
ldy #S.PS.hCMDLINE
lda (ZPQuickPtr1),y
beq .2
2016-09-21 15:20:37 +00:00
jsr K.FreeMemA
2016-08-17 06:25:58 +00:00
lda (ZPQuickPtr1) get S.PS.F
and #S.PS.F.ENV do we have to discard duplicated env & prefix ?
beq .4
.2 ldy #S.PS.hENV
lda (ZPQuickPtr1),y
beq .3
2016-09-21 15:20:37 +00:00
jsr K.FreeMemA
2016-08-17 06:25:58 +00:00
.3 ldy #S.PS.hPREFIX
lda (ZPQuickPtr1),y
beq .4
2016-09-21 15:20:37 +00:00
jsr K.FreeMemA
2016-08-17 06:25:58 +00:00
.4 ldy #S.PS.hDS
lda (ZPQuickPtr1),y
beq .5
2016-09-21 15:20:37 +00:00
jsr K.FreeMemA
2016-08-17 06:25:58 +00:00
.5 ldy #S.PS.hCS
lda (ZPQuickPtr1),y
beq .8
2016-09-21 15:20:37 +00:00
jsr K.FreeMemA
2016-08-17 06:25:58 +00:00
.8 lda #0
sta (ZPQuickPtr1) Mark TSKSLOT as free
clc
rts
*--------------------------------------
* S.DupEnvA
* In:
* A = ENV hMem To Duplicate
* Out:
* A = hMem to new ENV
*--------------------------------------
2016-09-21 15:20:37 +00:00
S.DupEnvA jsr K.GetMemPtrA
2016-08-17 06:25:58 +00:00
>STYA ZPQuickPtr1
>PUSHWI K.ENV.SIZE
>PUSHBI 0
2016-09-21 15:20:37 +00:00
jsr K.GetMem
2016-08-17 06:25:58 +00:00
bcs .9
>STYA ZPQuickPtr2
ldy #0
.1 lda (ZPQuickPtr1),y
sta (ZPQuickPtr2),y
beq .8
iny
bne .1
inc ZPQuickPtr1+1
inc ZPQuickPtr2+1
bra .1
.8 txa
clc
.9 rts
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.PS
LOAD SYS/KERNEL.S
ASM