mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 07:54:37 +00:00
367 lines
6.6 KiB
Plaintext
367 lines
6.6 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
*/--------------------------------------
|
||
* # Sleep
|
||
* Make current process suspend until next RUN
|
||
* ## In :
|
||
* (none)
|
||
* ## Out :
|
||
* (none)
|
||
*\--------------------------------------
|
||
K.Sleep pla get PC LO
|
||
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
|
||
*/--------------------------------------
|
||
* # ExecProcessNewEnv.YA
|
||
* # ExecProcess.YA (Blocking Parent PID)
|
||
* # CreateProcessNewEnv.YA
|
||
* # CreateProcess.YA (Non Blocking)
|
||
* ## In:
|
||
* Y,A = PTR To Cmd Line
|
||
* ## Out:
|
||
* A = Child PSID
|
||
*\--------------------------------------
|
||
K.ExecProcessNewEnv.YA
|
||
ldx #S.PS.F.ENV+S.PS.F.HOLD
|
||
.HS 2C bit abs
|
||
K.ExecProcess.YA
|
||
ldx #S.PS.F.HOLD
|
||
.HS 2C bit abs
|
||
K.CreateProcessNewEnv.YA
|
||
ldx #S.PS.F.ENV
|
||
.HS 2C bit abs
|
||
K.CreateProcess.YA
|
||
ldx #0
|
||
stx K.CreateProcess.Flags
|
||
>STYA K.CreateProcess.CmdLine
|
||
|
||
jsr PS.CreateChild Child S.PS at ZPPtr3
|
||
bcs .9
|
||
|
||
sta .8+1
|
||
|
||
>LDYA K.CreateProcess.CmdLine
|
||
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
|
||
*--------------------------------------
|
||
K.CreateProcess.Flags .BS 1
|
||
K.CreateProcess.CmdLine .BS 2
|
||
*--------------------------------------
|
||
* PS.CreateChild
|
||
* in :
|
||
* out :
|
||
* A = PSID
|
||
* we cannot use ZPPtrs1 & 2
|
||
* because of calling K.NewStrY.A & S.DupEnv.A
|
||
*--------------------------------------
|
||
PS.CreateChild >LDYAI TskMgr.Table+S.PS
|
||
>STYA ZPPtr3
|
||
|
||
ldx #0
|
||
|
||
.1 inx
|
||
cpx TskMgr.Count
|
||
beq .2
|
||
|
||
lda (ZPPtr3) Found an empty slot
|
||
bpl .3
|
||
lda ZPPtr3
|
||
clc
|
||
adc #S.PS
|
||
sta ZPPtr3
|
||
bcc .1
|
||
inc ZPPtr3+1
|
||
|
||
bra .1
|
||
|
||
.2 cpx #K.PS.MAX
|
||
bne .3
|
||
|
||
lda #TSKMGR.ERROOH
|
||
sec
|
||
rts
|
||
|
||
.3 inc TskMgr.Count
|
||
|
||
.4 inc TSKMGR.LASTID Get a PSID not alredy running
|
||
beq .4 not = 0
|
||
lda TSKMGR.LASTID
|
||
jsr CORE.GetPSByID.A
|
||
bcc .4
|
||
|
||
ldy #S.PS.PID
|
||
lda TSKMGR.LASTID
|
||
sta (ZPPtr3),y
|
||
|
||
lda #0
|
||
ldy #S.PS.hCS
|
||
|
||
.5 sta (ZPPtr3),y Blank Everything in this S.PS
|
||
iny
|
||
cpy #S.PS
|
||
bne .5
|
||
|
||
lda #S.PS.F.ENV
|
||
bit K.CreateProcess.Flags need to create ENV & Prefix ?
|
||
beq .6 no...
|
||
|
||
sta (ZPPtr3) Mark this PS with ENV flag
|
||
|
||
ldy #S.PS.hPREFIX copy hPREFIX...
|
||
lda (pPs),y
|
||
jsr K.GetMemPtr.A
|
||
jsr K.NewStr.YA
|
||
bcs .9
|
||
|
||
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 K.CreateProcess.Flags
|
||
beq .82
|
||
|
||
ora (pPs)
|
||
sta (pPs) HOLD parent PS if ExecProcess
|
||
|
||
.82 lda #S.PS.F.INUSE+S.PS.F.INIT
|
||
ora (ZPPtr3)
|
||
sta (ZPPtr3) Make this PS Init....
|
||
|
||
ldy #S.PS.CPID
|
||
lda TSKMGR.LASTID
|
||
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
|
||
|
||
stz PS.CmdLine2Args.bInQuote
|
||
|
||
ldy #0
|
||
ldx #0 Arg Count
|
||
|
||
.4 lda (ZPPtr1),y
|
||
beq .8
|
||
|
||
cmp #'"' found a quote ?
|
||
bne .5
|
||
lda PS.CmdLine2Args.bInQuote
|
||
eor #$ff
|
||
sta PS.CmdLine2Args.bInQuote
|
||
bra .71
|
||
|
||
.5 cmp #' '
|
||
bne .70
|
||
|
||
bit PS.CmdLine2Args.bInQuote
|
||
bmi .70
|
||
|
||
inx Found one arg !!!
|
||
lda #0
|
||
|
||
.70 sta (ZPPtr2) yes, set this token len
|
||
.71 inc ZPPtr2
|
||
bne .72
|
||
inc ZPPtr2+1
|
||
.72 iny
|
||
bne .4
|
||
|
||
.8 lda #0
|
||
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.CmdLine2Args.bInQuote
|
||
.BS 1
|
||
*--------------------------------------
|
||
PS.Init jsr BIN.Load.YA Y,A=filename full path
|
||
bcs .9
|
||
|
||
>STYA ZPPtr4 save PTR to Code Segment
|
||
txa
|
||
ldy #S.PS.hCS
|
||
sta (ZPPtr3),y save CS hMem in TSKSLOT
|
||
|
||
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
|
||
|
||
txa
|
||
ldy #S.PS.hDS
|
||
sta (ZPPtr3),y save DS hMem in TSKSLOT
|
||
|
||
.2 ldy #H.BIN.EXE.SS.SIZE
|
||
lda (ZPPtr4),y Load SS.SIZE.LO
|
||
|
||
ldy #S.PS.SP
|
||
sta (ZPPtr3),y Init SP to top of hSS
|
||
|
||
lda #0
|
||
tay
|
||
bne .3 SS.SIZE.LO=0, set as default $100
|
||
inc SS.SIZE.HI
|
||
|
||
.3 >PUSHYA
|
||
>PUSHBI S.MEM.F.ALIGN
|
||
jsr K.GetMem
|
||
bcs .9
|
||
|
||
txa
|
||
ldy #S.PS.hSS
|
||
sta (ZPPtr3),y save SS hMem in TSKSLOT
|
||
|
||
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
|
||
|
||
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
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/SYS/KERNEL.S.PS
|
||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||
ASM
|