mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
419 lines
7.4 KiB
Plaintext
419 lines
7.4 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
*/--------------------------------------
|
||
* # ExecPSNewEnv.YA
|
||
* # ExecPS.YA (Blocking Parent PID)
|
||
* # CreatePSNewEnv.YA
|
||
* # CreatePS.YA (Non Blocking)
|
||
* ## In:
|
||
* Y,A = PTR To Cmd Line
|
||
* ## Out:
|
||
* A = Child PSID
|
||
*\--------------------------------------
|
||
K.ExecPSNewEnv.YA
|
||
ldx #S.PS.F.DUPENV+S.PS.F.HOLD
|
||
.HS 2C bit abs
|
||
K.ExecPS.YA
|
||
ldx #S.PS.F.HOLD
|
||
.HS 2C bit abs
|
||
K.CreatePSNewEnv.YA
|
||
ldx #S.PS.F.DUPENV
|
||
.HS 2C bit abs
|
||
K.CreatePS.YA
|
||
ldx #0
|
||
stx PS.Flags
|
||
>STYA PS.CL
|
||
|
||
jsr PS.CreateChild Child S.PS at ZPPtr3
|
||
bcs .9
|
||
|
||
sta .8+1
|
||
|
||
>LDYA PS.CL
|
||
jsr PS.CmdLine2Args Y,A = Args[0]
|
||
bcs .9
|
||
|
||
jsr PS.Init
|
||
bcc .8
|
||
|
||
pha save error code
|
||
lda .8+1
|
||
jsr CORE.PSFree.A
|
||
pla get back error code
|
||
sec
|
||
rts
|
||
|
||
.8 lda #$ff self modified
|
||
.9 rts
|
||
*--------------------------------------
|
||
PS.Flags .BS 1
|
||
PS.CL .BS 2
|
||
*--------------------------------------
|
||
* PS.CreateChild
|
||
* in :
|
||
* out :
|
||
* A = PSID
|
||
* we cannot use ZPPtrs1 & 2
|
||
* because of calling K.NewStr.YA & S.DupEnv.A
|
||
*--------------------------------------
|
||
PS.CreateChild ldx #0
|
||
|
||
.1 cpx CORE.PSCount
|
||
beq .2
|
||
|
||
lda PS.Table.PID,x
|
||
beq .31 Found an empty slot
|
||
inx
|
||
bra .1
|
||
|
||
.2 cpx #K.PS.MAX
|
||
bne .3
|
||
|
||
lda #K.E.OOH
|
||
sec
|
||
rts
|
||
|
||
.99 plx
|
||
rts
|
||
|
||
.3 inc CORE.PSCount
|
||
|
||
.31 phx save PS inex
|
||
|
||
.4 inc CORE.LastPSID Get a PSID not alredy running
|
||
beq .4 not = 0
|
||
lda CORE.LastPSID
|
||
jsr CORE.GetPSByID.A
|
||
bcc .4
|
||
|
||
plx
|
||
lda CORE.LastPSID
|
||
sta PS.Table.PID,x
|
||
phx
|
||
|
||
>LDYAI S.PS
|
||
jsr K.GetMem0.YA Blank Everything in this S.PS
|
||
bcs .99
|
||
|
||
>STYA ZPPtr3
|
||
txa
|
||
plx
|
||
sta PS.Table.hMem,x
|
||
|
||
jsr PS.SetMemOwner Set Ownership
|
||
|
||
ldy #S.PS.PID
|
||
lda CORE.LastPSID
|
||
sta (ZPPtr3),y
|
||
|
||
lda #S.PS.F.DUPENV
|
||
bit PS.Flags need to create ENV & Prefix ?
|
||
beq .6 no...
|
||
|
||
sta (ZPPtr3) Mark this PS with DUPENV flag
|
||
|
||
ldy #S.PS.hPREFIX copy hPREFIX...
|
||
lda (pPs),y
|
||
jsr K.GetMemPtr.A
|
||
jsr K.NewStr.YA
|
||
bcs .9
|
||
|
||
jsr PS.SetMemOwner Set Ownership
|
||
|
||
txa
|
||
ldy #S.PS.hPREFIX
|
||
sta (ZPPtr3),y
|
||
|
||
ldy #S.PS.hENV ...and hENV from parent PS
|
||
lda (pPs),y
|
||
jsr PS.DupEnv.A
|
||
bcs .9
|
||
|
||
ldy #S.PS.hENV
|
||
sta (ZPPtr3),y
|
||
bra .8
|
||
|
||
.6 ldy #S.PS.hPREFIX reuse same hPREFIX...
|
||
lda (pPs),y
|
||
sta (ZPPtr3),y
|
||
|
||
ldy #S.PS.hENV ...and hENV from parent PS
|
||
lda (pPs),y
|
||
sta (ZPPtr3),y
|
||
|
||
.8 ldy #S.PS.hStdIn
|
||
|
||
.81 lda (pPs),y
|
||
sta (ZPPtr3),y
|
||
iny
|
||
cpy #S.PS.hStdErr+1
|
||
bne .81
|
||
|
||
ldy #S.PS.PID
|
||
lda (pPs),y
|
||
|
||
ldy #S.PS.PPID
|
||
sta (ZPPtr3),y
|
||
|
||
lda #S.PS.F.HOLD
|
||
bit PS.Flags
|
||
beq .82
|
||
|
||
ora (pPs)
|
||
sta (pPs) HOLD parent PS if ExecPS
|
||
|
||
.82 lda #S.PS.F.INIT
|
||
ora (ZPPtr3)
|
||
sta (ZPPtr3) Make this PS Init....
|
||
|
||
ldy #S.PS.CPID
|
||
lda CORE.LastPSID
|
||
sta (pPs),y
|
||
|
||
clc Exit with A=PSID
|
||
.9 rts
|
||
*--------------------------------------
|
||
PS.CmdLine2Args >STYA ZPPtr1
|
||
|
||
ldy #0
|
||
|
||
.1 lda (ZPPtr1),y compute strlen in Y,X
|
||
beq .2
|
||
cmp #'"' skip " in computation....
|
||
beq .1
|
||
iny
|
||
bne .1 max 255
|
||
|
||
.2 tya +2 for ending 0 for last string, and endig 0 for array
|
||
clc
|
||
adc #2
|
||
tay
|
||
lda #0
|
||
bcc .3
|
||
inc
|
||
|
||
.3 jsr K.GetMem.YA
|
||
bcs .9
|
||
|
||
phy save PTR.LO
|
||
pha save PTR.HI
|
||
>STYA ZPPtr2
|
||
|
||
txa
|
||
ldy #S.PS.hARGS
|
||
sta (ZPPtr3),y
|
||
|
||
jsr PS.SetMemOwner Set Ownership
|
||
|
||
stz PS.bInQuote
|
||
|
||
ldy #$ff
|
||
ldx #0 Arg Count
|
||
|
||
.4 iny
|
||
lda (ZPPtr1),y
|
||
beq .7
|
||
|
||
cmp #'"' found a quote ?
|
||
bne .5
|
||
lda PS.bInQuote
|
||
eor #$ff
|
||
sta PS.bInQuote
|
||
bra .4
|
||
|
||
.5 cmp #' '
|
||
bne .6
|
||
|
||
bit PS.bInQuote
|
||
bmi .6
|
||
|
||
inx Found one arg !!!
|
||
lda #0 set this token End
|
||
|
||
.6 sta (ZPPtr2)
|
||
|
||
inc ZPPtr2
|
||
bne .4
|
||
inc ZPPtr2+1
|
||
bra .4
|
||
|
||
.7 sta (ZPPtr2) set Arg Ending 0
|
||
|
||
inc ZPPtr2
|
||
bne .8
|
||
inc ZPPtr2+1
|
||
|
||
.8 sta (ZPPtr2) set Array Ending 0
|
||
|
||
txa
|
||
ldy #S.PS.ARGC
|
||
sta (ZPPtr3),y
|
||
|
||
pla get back PTR.HI
|
||
ply get back PTR.LO
|
||
|
||
clc
|
||
.9 rts
|
||
|
||
PS.bInQuote .BS 1
|
||
*--------------------------------------
|
||
PS.Init jsr BIN.Load.YA Y,A=filename full path
|
||
bcs .9
|
||
>STYA ZPPtr4 save PTR to Code Segment
|
||
|
||
phy
|
||
ldy #S.PS.ZP.CODE+1
|
||
sta (ZPPtr3),y save pCode HI...
|
||
dey
|
||
pla
|
||
sta (ZPPtr3),y save pCode LO...
|
||
|
||
txa
|
||
ldy #S.PS.hCS
|
||
sta (ZPPtr3),y save CS hMem in S.PS
|
||
|
||
jsr K.GetMemByID.A
|
||
jsr PS.SetMemOwner Set Ownership
|
||
|
||
ldy #H.BIN.EXE.DS.SIZE+1
|
||
lda (ZPPtr4),y Load DS.SIZE HI
|
||
tax
|
||
dey
|
||
ora (ZPPtr4),y
|
||
|
||
beq .2 DS.SIZE=0...
|
||
|
||
lda (ZPPtr4),y
|
||
tay
|
||
txa Y,A = DS.SIZE
|
||
jsr K.GetMem0.YA
|
||
bcs .9
|
||
|
||
phy
|
||
ldy #S.PS.ZP.DATA+1
|
||
sta (ZPPtr3),y save pData HI...
|
||
dey
|
||
pla
|
||
sta (ZPPtr3),y save pData LO...
|
||
|
||
txa
|
||
ldy #S.PS.hDS
|
||
sta (ZPPtr3),y save DS hMem in S.PS
|
||
|
||
jsr PS.SetMemOwner Set Ownership
|
||
|
||
.2 ldy #H.BIN.EXE.SS.SIZE
|
||
lda (ZPPtr4),y Load SS.SIZE
|
||
ldy #S.PS.ZP.STACK
|
||
sta (ZPPtr3),y save pStack LO...
|
||
|
||
tay
|
||
|
||
bne .3 SS.SIZE.LO=0, set as default $100
|
||
lda #1 SS.SIZE.HI
|
||
.HS 2C bit abs
|
||
.3 lda #0
|
||
|
||
ldx #S.MEM.F.ALIGN
|
||
jsr MEM.GetMem.YAX
|
||
bcs .9
|
||
|
||
ldy #S.PS.ZP.STACK+1
|
||
sta (ZPPtr3),y save pStack HI...(LO alredy set to Stack TOP)
|
||
|
||
txa
|
||
ldy #S.PS.hSS
|
||
sta (ZPPtr3),y save SS hMem in S.PS
|
||
|
||
jsr PS.SetMemOwner Set Ownership
|
||
|
||
ldy #H.BIN.EXE.ZP.SIZE
|
||
lda (ZPPtr4),y
|
||
clc
|
||
adc #8 Add room for 4 saved PTR
|
||
ldy #S.PS.ZP.SIZE
|
||
sta (ZPPtr3),y
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* PS.DupEnv.A
|
||
* In:
|
||
* A = ENV hMem To Duplicate
|
||
* Out:
|
||
* A = hMem to new ENV
|
||
*--------------------------------------
|
||
PS.DupEnv.A jsr K.GetMemPtr.A
|
||
>STYA ZPPtr1
|
||
|
||
>LDYAI K.ENV.SIZE
|
||
jsr K.GetMem.YA
|
||
bcs .9
|
||
|
||
>STYA ZPPtr2
|
||
|
||
jsr PS.SetMemOwner Set Ownership
|
||
|
||
ldy #0
|
||
|
||
.1 lda (ZPPtr1),y
|
||
sta (ZPPtr2),y
|
||
beq .8
|
||
|
||
.2 iny
|
||
bne .3
|
||
inc ZPPtr1+1
|
||
inc ZPPtr2+1
|
||
|
||
.3 lda (ZPPtr1),y
|
||
sta (ZPPtr2),y
|
||
bne .2
|
||
|
||
iny
|
||
bne .1
|
||
inc ZPPtr1+1
|
||
inc ZPPtr2+1
|
||
bra .1
|
||
|
||
.8 txa hMem
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
PS.SetMemOwner lda CORE.LastPSID
|
||
ldy #S.MEM.OWNERPID
|
||
sta (ZPMEMMGR),y
|
||
rts
|
||
*--------------------------------------
|
||
K.GetPSStatus.A jsr CORE.GetPSByID.A
|
||
bcs .9
|
||
>STYA ZPPtr1
|
||
lda (ZPPtr1)
|
||
.9 rts
|
||
*--------------------------------------
|
||
K.GetPSList.YA >STYA ZPPtr1
|
||
|
||
ldx #0
|
||
ldy #0
|
||
|
||
.1 lda PS.Table.PID,x
|
||
beq .2
|
||
|
||
lda PS.Table.hMem,x
|
||
iny
|
||
sta (ZPPtr1),y
|
||
|
||
.2 inx
|
||
cpx CORE.PSCount
|
||
bne .1
|
||
|
||
.9 tya
|
||
sta (ZPPtr1)
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/SYS/KERNEL.S.PS
|
||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||
ASM
|