A2osX/SYS/KERNEL.S.ENVX.txt

418 lines
6.7 KiB
Plaintext
Raw Normal View History

2020-01-22 16:31:48 +00:00
NEW
AUTO 3,1
*--------------------------------------
2020-02-02 14:58:01 +00:00
ENVX.hEnv .BS 1
2020-03-12 16:44:11 +00:00
ENVX.hSID .BS 1
2020-02-02 14:58:01 +00:00
*--------------------------------------
2020-02-06 16:23:59 +00:00
ENVX.PutEnv.9 lda #E.SYN
sec
rts
*--------------------------------------
2020-08-12 19:31:36 +00:00
ENVX.PutEnv sta ENVX.hEnv
2020-03-12 16:44:11 +00:00
sty ENVX.hSID
2020-08-12 19:31:36 +00:00
2020-02-06 16:23:59 +00:00
ldy #$ff
2020-01-22 16:31:48 +00:00
.1 iny
2021-05-04 17:31:21 +00:00
jsr SHARED.TXTPTRgY NAME=
2020-02-06 16:23:59 +00:00
beq ENVX.PutEnv.9
2020-01-22 16:31:48 +00:00
cmp #'='
bne .1
tya
sec skip =
adc TXTPTR
sta FORPNT
2020-08-12 19:31:36 +00:00
2020-01-22 16:31:48 +00:00
lda #0
adc TXTPTR+1
sta FORPNT+1
2020-08-12 19:31:36 +00:00
jsr ENVX.UnsetEnv.I
bra ENVX.SetEnv.I
2020-01-22 16:31:48 +00:00
*--------------------------------------
ENVX.SetEnv jsr ENVX.UnsetEnv
2020-08-12 19:31:36 +00:00
ENVX.SetEnv.I
2020-02-03 19:41:04 +00:00
.1 jsr ENVX.InitEnvP3
2020-01-22 16:31:48 +00:00
2020-08-12 19:31:36 +00:00
lda #1 \0
2020-01-22 16:31:48 +00:00
sta ZPPtr4
2020-08-12 19:31:36 +00:00
stz ZPPtr4+1
2020-01-22 16:31:48 +00:00
.10 lda (ZPPtr3) End of ENV
beq .15
2020-01-29 16:46:51 +00:00
jsr ENVX.GetP3LenY
jsr ENVX.NextEnvP3Y
jsr ENVX.NextEnvP4Y
2020-01-22 16:31:48 +00:00
bra .10
2020-01-29 16:46:51 +00:00
.15 ldy #$ff
2020-01-22 16:31:48 +00:00
.16 iny
2021-05-04 17:31:21 +00:00
jsr SHARED.TXTPTRgY
2020-01-22 16:31:48 +00:00
beq .17
jsr SHARED.IsIDValid
bcc .16
2020-01-29 16:46:51 +00:00
.17 jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VAR
2020-01-22 16:31:48 +00:00
ldy #$ff
.19 iny
2021-05-04 17:31:21 +00:00
jsr SHARED.FORPNTgY
2020-01-22 16:31:48 +00:00
bne .19
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VALUE
2020-01-22 16:31:48 +00:00
2020-08-12 19:31:36 +00:00
* lda ENVX.hEnv done by ENVX.InitEnvP3
* jsr MEM.GetMemByID
2020-01-22 16:31:48 +00:00
2020-08-12 19:31:36 +00:00
ldy #S.MEM.LEN
lda (ZPMemMgrSPtr),y
cmp ZPPtr4
iny
lda (ZPMemMgrSPtr),y
sbc ZPPtr4+1
2020-02-03 15:17:34 +00:00
bcs .22 env is large enough
2020-08-12 19:31:36 +00:00
ldy #S.MEM.PTR
lda (ZPMemMgrSPtr),y
sta A1L
iny
lda (ZPMemMgrSPtr),y
sta A1L+1
iny #S.MEM.LEN
lda (ZPMemMgrSPtr),y
eor #$ff
sta A4L
iny
lda (ZPMemMgrSPtr),y
eor #$ff
sta A4L+1
>LDYA ZPPtr4
jsr MEM.DupA1LnA4L
2020-01-22 16:31:48 +00:00
bcs .9
2020-08-12 19:31:36 +00:00
pha
lda ENVX.hEnv
jsr K.FreeMem
pla
sta ENVX.hEnv
2020-02-03 15:17:34 +00:00
sta CLRWRITEAUX
2020-01-22 16:31:48 +00:00
ldy #S.PS.hENV
2020-08-12 19:31:36 +00:00
sta (pPS),y
2020-02-03 15:17:34 +00:00
sta SETWRITEAUX
2020-01-22 16:31:48 +00:00
bra .1 Start over
.22 ldy #$ff
2020-08-12 19:31:36 +00:00
2020-01-22 16:31:48 +00:00
.23 iny
2021-05-04 17:31:21 +00:00
jsr SHARED.TXTPTRgY
2020-01-22 16:31:48 +00:00
sta (ZPPtr3),y
beq .24
jsr SHARED.IsIDValid
bcc .23
.24 lda #'='
sta (ZPPtr3),y
2020-08-12 19:31:36 +00:00
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3Y
2020-01-22 16:31:48 +00:00
ldy #$ff
.25 iny
2021-05-04 17:31:21 +00:00
jsr SHARED.FORPNTgY
2020-01-22 16:31:48 +00:00
sta (ZPPtr3),y
bne .25
iny
sta (ZPPtr3),y don't forget array ending 0
clc
2020-01-29 16:46:51 +00:00
.9 rts
2020-01-22 16:31:48 +00:00
*--------------------------------------
2020-03-13 16:10:36 +00:00
ENVX.GetEnv sta ENVX.hEnv
sty ENVX.hSID
2020-08-12 19:31:36 +00:00
2020-03-12 16:44:11 +00:00
ldy TXTPTR+1
2020-02-04 20:04:33 +00:00
bne .10
tax hMem for CopyToMain
2020-08-12 19:31:36 +00:00
2020-02-04 20:04:33 +00:00
jsr MEM.GetMemByID
2020-08-12 19:31:36 +00:00
2020-02-04 20:04:33 +00:00
ldy #S.MEM.LEN
lda (ZPMemMgrSPtr),y
pha
iny
lda (ZPMemMgrSPtr),y
ply YA = Len
jmp MEM.CopyToMain
2020-03-13 07:15:58 +00:00
*--------------------------------------
.10 jsr ENVX.FindEnvVar
2020-03-12 16:44:11 +00:00
bcc .11
jsr ENVX.FindSIDVar
2020-01-22 16:31:48 +00:00
bcs .9
2020-08-12 19:31:36 +00:00
2020-03-12 16:44:11 +00:00
>STYA ZPPtr3
bra .12
2020-01-22 16:31:48 +00:00
2020-03-12 16:44:11 +00:00
.11 jsr ENVX.NextEnvP3Y Skip NAME=
2020-01-22 16:31:48 +00:00
2020-03-12 16:44:11 +00:00
.12 lda FORPNT+1
2020-01-22 16:31:48 +00:00
bne .3
ldy #$ff
2020-08-12 19:31:36 +00:00
2020-01-22 16:31:48 +00:00
.1 iny
lda (ZPPtr3),y
bne .1
2020-08-12 19:31:36 +00:00
2020-01-22 16:31:48 +00:00
iny
bne .2
inc
2020-02-03 15:17:34 +00:00
.2 ldx #SYS.GetMem
jsr K.SYSCALL2.MAIN !!! Get a buffer In MAIN Mem !!!
2020-08-12 19:31:36 +00:00
2020-01-22 16:31:48 +00:00
bcs .99
2020-08-12 19:31:36 +00:00
2020-01-22 16:31:48 +00:00
>STYA FORPNT
2020-01-29 16:46:51 +00:00
.3 ldy #$ff
2020-01-22 16:31:48 +00:00
.4 iny
lda (ZPPtr3),y
2021-05-04 17:31:21 +00:00
jsr SHARED.FORPNTpY
2020-01-22 16:31:48 +00:00
bne .4
2020-08-12 19:31:36 +00:00
2020-01-22 16:31:48 +00:00
>LDYA FORPNT
clc
rts
2020-08-12 19:31:36 +00:00
2020-07-09 11:34:07 +00:00
.9 lda #E.NOKEY
2020-02-03 15:17:34 +00:00
2020-01-22 16:31:48 +00:00
* sec
.99 rts
2020-01-29 16:46:51 +00:00
*--------------------------------------
2020-02-03 15:17:34 +00:00
ENVX.UnsetEnv sta ENVX.hEnv
2020-03-12 16:44:11 +00:00
sty ENVX.hSID
2020-08-12 19:31:36 +00:00
ENVX.UnsetEnv.I jsr ENVX.FindEnvVar
2020-02-02 14:58:01 +00:00
bcs .8 not found, quit
2020-01-22 16:31:48 +00:00
2020-01-29 16:46:51 +00:00
jsr ENVX.DelVarP3 Ptr3 -> NAME=VALUE
2020-02-02 14:58:01 +00:00
.8 clc
2020-08-12 19:31:36 +00:00
2020-01-22 16:31:48 +00:00
rts
*--------------------------------------
2020-03-12 16:44:11 +00:00
* ENV.FindEnvVar
2020-01-22 16:31:48 +00:00
* In:
* TXTPTR -> NAME
* Out:
* CC: Found
* Y = NAME len
* TXTPTR -> NAME
* ZPPtr3 -> NAME=VALUE
* CS: Not Found
* TXTPTR -> NAME
* ZPPtr3 -> PTR to Ending 0
*--------------------------------------
2020-03-12 16:44:11 +00:00
ENVX.FindEnvVar jsr ENVX.InitEnvP3 Store ENV
2020-01-22 16:31:48 +00:00
.1 lda (ZPPtr3)
beq .9 end of ENV
ldy #$ff
.2 iny
2021-05-04 17:31:21 +00:00
jsr SHARED.TXTPTRgY
2020-01-22 16:31:48 +00:00
beq .3
jsr SHARED.IsIDValid
bcs .3
cmp (ZPPtr3),y
beq .2
bra .4
.3 lda (ZPPtr3),y
cmp #'='
bne .4
clc
rts
2020-01-29 16:46:51 +00:00
.4 jsr ENVX.NextEnvP3 Skip NAME=VALUE
2020-01-22 16:31:48 +00:00
bra .1
2020-01-29 16:46:51 +00:00
.9 sec
2020-08-12 19:31:36 +00:00
rts
2020-01-22 16:31:48 +00:00
*--------------------------------------
2020-03-12 16:44:11 +00:00
ENVX.FindSIDVar >LDYAI ENVX.SIDVars
>STYA ZPPtr3
ldx #0
.1 lda (ZPPtr3)
beq .9
ldy #$ff
2020-08-12 19:31:36 +00:00
2020-03-12 16:44:11 +00:00
.2 iny
2021-05-04 17:31:21 +00:00
jsr SHARED.TXTPTRgY
2020-03-12 16:44:11 +00:00
beq .3
jsr SHARED.IsIDValid
bcs .3
cmp (ZPPtr3),y
beq .2
bra .4
.3 lda (ZPPtr3),y
bne .4
jmp (ENVX.SIDVarsJmp,x)
.4 inx
inx
jsr ENVX.NextEnvP3
bra .1
.9 sec
rts
*--------------------------------------
ENVX.SIDVars .AZ "LOGNAME"
.AZ "GECOS"
.AZ "HOME"
.AZ "SHELL"
.AZ "UID"
.AZ "GID"
.DA #0
*--------------------------------------
ENVX.SIDVarsJmp .DA ENVX.SIDVarsSTR
.DA ENVX.SIDVarsSTR
.DA ENVX.SIDVarsSTR
.DA ENVX.SIDVarsSTR
.DA ENVX.SIDVarsUID
.DA ENVX.SIDVarsGID
*--------------------------------------
ENVX.SIDVarsSTR jsr ENVX.InitSIDP3
2020-08-12 19:31:36 +00:00
2020-03-12 16:44:11 +00:00
lda ZPPtr3
clc
adc #S.SESSION.NAME
sta ZPPtr3
lda ZPPtr3+1
adc /S.SESSION.NAME
sta ZPPtr3+1
.1 dex
dex
bmi .8
ldy #$ff
2020-08-12 19:31:36 +00:00
2020-03-12 16:44:11 +00:00
.2 iny
lda (ZPPtr3),y
bne .2
jsr ENVX.NextEnvP3Y
bra .1
2020-08-12 19:31:36 +00:00
2020-03-12 16:44:11 +00:00
.8 >LDYA ZPPtr3
clc
rts
*--------------------------------------
ENVX.SIDVarsUID ldx #S.SESSION.UID
.HS 2C
ENVX.SIDVarsGID ldx #S.SESSION.GID
2020-08-12 19:31:36 +00:00
2020-03-12 16:44:11 +00:00
jsr ENVX.InitSIDP3
txa
tay
lda (ZPPtr3),y
2020-08-12 19:31:36 +00:00
2021-04-29 11:56:34 +00:00
jsr MATH.A2STR10NP
2020-08-12 19:31:36 +00:00
2021-05-04 17:31:21 +00:00
>LDYAI FOUTBuf
2020-03-12 16:44:11 +00:00
clc
rts
*--------------------------------------
2020-01-22 16:31:48 +00:00
* ENV.DelVarP3
* In:
* ZPPtr3 -> ENV.NAME to Discard
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.DelVarP3 >LDYA ZPPtr3 save actual Ptr
2020-01-22 16:31:48 +00:00
>STYA ZPPtr4
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3 Skip NAME=VALUE
2020-01-22 16:31:48 +00:00
.1 ldy #$ff
.2 iny
lda (ZPPtr3),y Move back CSTRs...
sta (ZPPtr4),y
bne .2
tya
2020-08-12 19:31:36 +00:00
2020-01-22 16:31:48 +00:00
beq .8 we moved back ending \0
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3Y
jsr ENVX.NextEnvP4Y
2020-01-22 16:31:48 +00:00
bra .1
2020-08-12 19:31:36 +00:00
2020-01-29 16:46:51 +00:00
.8 rts
2020-01-22 16:31:48 +00:00
*--------------------------------------
2020-02-02 14:58:01 +00:00
ENVX.InitEnvP3 lda ENVX.hEnv
2020-03-12 16:44:11 +00:00
bra ENVX.InitP3
*--------------------------------------
ENVX.InitSIDP3 lda ENVX.hSID
2020-03-13 16:10:36 +00:00
2020-03-12 16:44:11 +00:00
ENVX.InitP3 jsr K.GetMemPtr
>STYA ZPPtr3
2020-01-22 16:31:48 +00:00
rts
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.NextEnvP3 jsr ENVX.GetP3LenY
2020-01-22 16:31:48 +00:00
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.NextEnvP3Y tya
ENVX.NextEnvP3A sec
2020-01-22 16:31:48 +00:00
adc ZPPtr3
sta ZPPtr3
bcc .8
inc ZPPtr3+1
.8 rts
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.GetP3LenY ldy #$ff
2020-01-22 16:31:48 +00:00
.1 iny
lda (ZPPtr3),y
bne .1
rts
2020-08-12 19:31:36 +00:00
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.NextEnvP4Y tya
2020-01-22 16:31:48 +00:00
sec
adc ZPPtr4
sta ZPPtr4
bcc .8
inc ZPPtr4+1
.8 rts
*--------------------------------------
MAN
2020-12-15 13:23:22 +00:00
SAVE usr/src/sys/kernel.s.envx
LOAD usr/src/sys/kernel.s
2020-01-22 16:31:48 +00:00
ASM