Kernel 0.9.1 : Code reorganization & move to CSTR (GETTY,LOGIN)

This commit is contained in:
Rémy GIBERT 2017-09-14 17:21:06 +02:00
parent c55cfbbf0e
commit 4eb13cc475
17 changed files with 213 additions and 188 deletions

Binary file not shown.

Binary file not shown.

View File

@ -51,7 +51,7 @@ DEV.HEADER cld
jmp (DRV.CS.START,x)
.DA #S.DEV.S.WRITE+S.DEV.S.READ
.BS 6
>PSTR "CON" NAME
>CSTR "CON" NAME
.HS 00 NAME must Be 5 bytes long
*--------------------------------------
* Driver Code

View File

@ -214,7 +214,7 @@ SYS.SPrintF.YA .EQ $5A
SYS.FPrintF.YA .EQ $5C
* .EQ $5E
SYS.FileSearch .EQ $60
* .EQ $60
SYS.GetFullPath.YA .EQ $62
SYS.LoadFile .EQ $64
SYS.SaveFile .EQ $66
@ -246,7 +246,7 @@ SYS.PTime2Time .EQ $94
SYS.LoadLib.YA .EQ $98
SYS.UnloadLib.A .EQ $9A
SYS.LoadDrv.YA .EQ $9C
* .EQ $9E
SYS.FileSearch .EQ $9E
SYS.ExecProcessNewEnvYA .EQ $A0
SYS.ExecProcessYA .EQ $A2

View File

@ -40,17 +40,13 @@ L.MSG.GREETINGS .DA MSG.GREETINGS
L.TERM .DA TERM
.DA 0 End Of Reloc Table
*--------------------------------------
CS.INIT >SYSCALL GetArgC
cmp #1
bne .1
CS.INIT ldy #S.PS.ARGC
lda (pPs),y
cmp #2
bne .9
>LDYA L.MSG.USAGE
>SYSCALL PrintF.YA
lda #0
sec
rts
.1 lda #1
>DEBUG
lda #1
>SYSCALL GetArg.A
>SYSCALL MkNod.YA
@ -80,6 +76,12 @@ CS.INIT >SYSCALL GetArgC
sta (pPs)
clc
rts
>LDYA L.MSG.USAGE
>SYSCALL PrintF.YA
lda #0
sec
.9 rts
*--------------------------------------
CS.RUN jsr Init.Timeout
@ -293,7 +295,7 @@ Wait.TimeOut sec
*--------------------------------------
CS.END
PRINT.DEBUG.CHAR .AS "0123456789ABCDEF"
MSG.USAGE >CSTR "GETTY <DEV> <PROGRAM>\r\n"
MSG.USAGE >CSTR "Usage : GETTY <DEV> <PROGRAM>\r\n"
MSG.TELNET.OPT
* .DA #IAC,#WILL,#TELOPT.BINARY
* .DA #IAC,#DO,#TELOPT.LINEMODE

View File

@ -37,8 +37,7 @@ L.MSG.HELP .DA MSG.HELP
L.MSG.LOAD .DA MSG.LOAD
.DA 0
*--------------------------------------
CS.INIT >DEBUG
ldy #S.PS.ARGC
CS.INIT ldy #S.PS.ARGC
lda (pPs),y
bne .1

View File

@ -38,7 +38,8 @@ L.MSG.PASSWORD .DA MSG.PASSWORD
L.SHELL .DA SHELL
.DA 0
*--------------------------------------
CS.INIT lda (pPs)
CS.INIT >DEBUG
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc Tell TskMgr To stay in memory

View File

@ -65,7 +65,10 @@ Cmd.Parse.NextC lda (ZPPtr1)
*--------------------------------------
* ZPCMDBuf-> Command line (formatted & not empty)
*--------------------------------------
Cmd.Exec stz bStartProc
Cmd.Exec lda #0
>STA.G CMD.bStartProc
>STA.G CMD.hFullpath
>STA.G CMD.hExtCmdLine
>LDYA ZPCMDBuf
>SYSCALL ExpandStr.YA
@ -74,26 +77,7 @@ Cmd.Exec stz bStartProc
txa
>STA.G CMD.hCmdLine
Cmd.Exec.2 ldy #$ff CMD Len
.1 iny
lda (ZPPtr1),y Get CMD char...
beq .2
cmp #' ' we reached blank between CMD ARGS
bne .1
lda #0
sta (ZPPtr1),y Cut CMD with the ending 0
iny
.2 tya Y=CMD len+0, if ARGS="" Y=
clc
adc ZPPtr1
sta ZPPtr2
lda ZPPtr1+1
adc #0
sta ZPPtr2+1 ZPPtr2->ARGS or CMD ending 0 if empty
jsr Cmd.Exec.Split
>LDYA L.INTCMDS
>STYA ZPCMDBuf we use ZPCMDBuf as a temp Ptr
@ -139,16 +123,47 @@ Cmd.Exec.2 ldy #$ff CMD Len
inc ZPCMDBuf+1
bra .3
.8 jsr Cmd.Exec.INT Found an internal Cmd...
.8 jmp (J.INTCMDS,x) Found an internal Cmd...
*--------------------------------------
Cmd.Exec.Done php
pha
>LDA.G CMD.hCmdLine
>SYSCALL FreeMem.A
pla
>LDA.G CMD.hExtCmdLine
beq .1
>SYSCALL FreeMem.A
.1 >LDA.G CMD.hFullpath
beq .2
>SYSCALL FreeMem.A
.2 pla
plp
rts
*--------------------------------------
Cmd.Exec.Split ldy #$ff CMD Len
.1 iny
lda (ZPPtr1),y Get CMD char...
beq .2
cmp #' ' we reached blank between CMD ARGS
bne .1
lda #0
sta (ZPPtr1),y Cut CMD with the ending 0
iny
.2 tya Y=CMD len+0, if ARGS="" Y=
clc
adc ZPPtr1
sta ZPPtr2
lda ZPPtr1+1
adc #0
sta ZPPtr2+1 ZPPtr2->ARGS or CMD ending 0 if empty
rts
*--------------------------------------
* ZPPtr1->CMD
* ZPPtr2->ARGS
*--------------------------------------
@ -157,12 +172,12 @@ Cmd.Exec.EXT >LDYAI 256
bcs .99
>STYA ZPCMDBuf
lda #0
sta (ZPCMDBuf)
txa
>STA.G CMD.hExtCmdLine
lda #0
sta (ZPCMDBuf)
lda (ZPPtr1)
cmp #'/' Command line is already full path, no search
bne .1
@ -234,9 +249,10 @@ Cmd.Exec.EXT.BIN
>PUSHW ZPCMDBuf
>SYSCALL StrCat
.1 >LDYA ZPCMDBuf
bit bStartProc
bmi .2 startproc
.1 >LDA.G CMD.bStartProc
asl
>LDYA ZPCMDBuf
bcs .2 startproc
>SYSCALL ExecProcessNewEnvYA
jmp Cmd.Exec.Done
@ -267,8 +283,6 @@ Cmd.Exec.EXT.SEP
*--------------------------------------
* Internal Commands
*--------------------------------------
Cmd.Exec.INT jmp (J.INTCMDS,x)
*--------------------------------------
Cmd.Exec.CD lda (ZPPTR2)
bne Cmd.Exec.CD1
@ -276,7 +290,7 @@ Cmd.Exec.PWD ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL GetMemPtr.A
>SYSCALL PrintF.YA
rts
jmp Cmd.Exec.Done
Cmd.Exec.CD1 stz UsrBuf256
@ -380,21 +394,24 @@ Cmd.Exec.CD1 stz UsrBuf256
sta (pPs),y
jsr SetPWD
clc
.9 rts
.9 jmp Cmd.Exec.Done
*--------------------------------------
Cmd.Exec.ERRSYN lda #SYSMGR.ERRSYN
sec
rts
jmp Cmd.Exec.Done
*--------------------------------------
Cmd.Exec.STARTPROC
lda (ZPPTR2)
beq Cmd.Exec.ERRSYN
sec
ror bStartProc
lda #$ff
>STA.G CMD.bStartProc
>LDYA ZPPTR2
>STYA ZPPTR1
jmp Cmd.Exec.2
jsr Cmd.Exec.Split
jmp Cmd.Exec.EXT
*--------------------------------------
Cmd.Exec.SET lda (ZPPTR2)
bne Cmd.Exec.SETVAR
@ -446,7 +463,8 @@ Cmd.Exec.SET lda (ZPPTR2)
bra .1
.8 clc
.9 rts
.9 jmp Cmd.Exec.Done
Cmd.Exec.SETVAR ldy #0
@ -467,13 +485,13 @@ Cmd.Exec.SETVAR ldy #0
>LDYA ZPPTR2 String is VAR=VALUE...
>SYSCALL PutEnv.YA
rts
jmp Cmd.Exec.Done
.2 dey String is "VAR=", Remove endig '='
sta (ZPPTR2),y
>LDYA ZPPTR2 String is "VAR"...
>SYSCALL UnsetEnv.YA
rts
jmp Cmd.Exec.Done
* Print requested VAR
@ -487,7 +505,7 @@ Cmd.Exec.SETVAR ldy #0
>SYSCALL PrintF.YA
.8 clc
.9 rts
.9 jmp Cmd.Exec.Done
.99 jmp Cmd.Exec.ERRSYN
*--------------------------------------
@ -511,7 +529,7 @@ Cmd.Exec.TIME clc
>LDYAI UsrBuf256
>SYSCALL PrintF.YA
bcs Cmd.Exec.ECHO.RTS
bcs Cmd.Exec.ECHO.END
bra Cmd.Exec.ECHO.CR
*--------------------------------------
Cmd.Exec.ECHO lda (ZPPtr2)
@ -523,13 +541,13 @@ Cmd.Exec.ECHO lda (ZPPtr2)
Cmd.Exec.ECHO.CR
lda #13
>SYSCALL PutChar.A
bcs Cmd.Exec.ECHO.RTS
bcs Cmd.Exec.ECHO.END
lda #10
>SYSCALL PutChar.A
Cmd.Exec.ECHO.RTS
rts
Cmd.Exec.ECHO.END
jmp Cmd.Exec.Done
*--------------------------------------
Cmd.Exec.READ lda (ZPPtr2)
beq .9
@ -613,7 +631,7 @@ Cmd.Exec.READ lda (ZPPtr2)
beq .9
clc
.99 rts
.99 jmp Cmd.Exec.Done
*--------------------------------------
Cmd.Exec.SLEEP lda (ZPPtr2)
beq .9
@ -630,18 +648,18 @@ Cmd.Exec.SLEEP lda (ZPPtr2)
bcs .9
rts
jmp Cmd.Exec.Done
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.Exec.PAUSE lda #$FF
>STA.G bPause
clc
rts
jmp Cmd.Exec.Done
*--------------------------------------
Cmd.Exec.EXIT lda #$FF
>STA.G bExit
clc
rts
jmp Cmd.Exec.Done
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SBIN/SHELL.S.CMD

View File

@ -163,7 +163,7 @@ CSH.Run jsr CSH.GetBuf
>STA.G bCmdBufexec
>LDA.G bEcho
* beq .80
beq .80
>PUSHW ZPCMDBuf
>LDYA L.MSG.ECHO

View File

@ -556,7 +556,6 @@ EscChars >PSTR "DBAC"
EscAscii .HS 04080A0B15
TIME .BS S.TIME
STAT .BS S.STAT
bStartProc .BS 1
CSH.TSIZE .HS 0001020405 00,CHAR,INT,LONG,FLOAT....
CSH.ACCT .BS 1
CSH.ACC .BS 5
@ -584,6 +583,7 @@ Sleep .BS 4
CMD.hCmdLine .BS 1
CMD.hFullpath .BS 1
CMD.hExtCmdLine .BS 1
CMD.bStartProc .BS 1
CMD.VarName .BS VarLen.MAX+1
CMD.Stat .BS S.STAT

View File

@ -113,6 +113,95 @@ K.LoadDrv.YA jsr BIN.FindDRV
jsr K.FreeMem.A
pla
rts
*/--------------------------------------
* # FileSearch
* Search a file in the provided PATH list
* And return, if found, the full path to it.
* ## In:
* PUSHW = Ptr to Search Path (CSTR) %LIB%;/SYS/SLIB
* PUSHW = Ptr to File Name (CSTR)
* PUSHW = Ptr to DstBuf
* PUSHW = Ptr to DstStat
* ## Out:
* CC : success
* DstBuf = FilePath
* DstStat = S.STAT
* CS : not found
*\--------------------------------------
K.FileSearch >PULLW .4+1 DstStat
>PULLW .2+1 DstBuf
jsr K.FileSearch.I
bcs .9
ldx #$ff
.1 inx
lda K.Buf256,x
.2 sta $ffff,x Self Modified
bne .1
ldx #S.STAT-1
.3 lda K.S.STAT,x
.4 sta $ffff,x Self Modified
dex
bpl .3
.9 rts
K.FileSearch.I >PULLW .4+1 Filename
>PULLYA Get Search list
jsr K.ExpandStr.YA Expand it
bcs .99
stx .98+1
>STYA .2+1 expanded search list ;
stz .1+1
.1 ldy #$ff Self Modified Index in Search list string
ldx #$0
.2 lda $ffff,y Self Modified, Search list string
beq .3 end of string, try it....
iny
cmp #';'
beq .3
sta K.Buf256,x
inx
bra .2
.3 txa
beq .98 String is empty....nothing to try
sty .1+1 save current index
ldy #$0
.4 lda $ffff,y Self Modified, Append Fiename...
sta K.Buf256,x
beq .5
iny
inx
bra .4
.5 stz K.Buf256+1,x set string ending 0
>PUSHWI K.S.STAT
>PUSHWI K.Buf256
>SYSCALL STAT -> BNK1
bcs .1 Failed...retry next path...
jsr .98 Discard Expanded hSrch list
clc
rts
.98 lda #$ff SELF MODIFIED : Discard Expanded hSrch list
jsr K.FreeMem.A
lda #MLI.ERR.FNOTFND
sec
.99 rts
*--------------------------------------
BIN.FindLIB clc
.HS B0 bcs
@ -123,14 +212,11 @@ BIN.FindDRV sec
bcc .1
>LDYAI BIN.Find.ENV.DRV
.1 >SYSCALL GetEnv.YA get value for Search Path
.1 jsr K.GetEnv.YA get value for Search Path
bcs .9
>PUSHYA Push Search path
>LDYA BIN.CmdLine
jsr K.FileSearch.I find libname in Search
>PUSHYA
>PUSHW BIN.CmdLine
jsr K.FileSearch.I find LIB/DRV in Search
bcs .9
>LDYAI K.Buf256

View File

@ -31,7 +31,7 @@ K.GetDevByID.A cmp DevMgr.Count
*/--------------------------------------
* # GetDevByName.YA
* ## IN:
* Y,A = Ptr to device name (PStr)
* Y,A = Ptr to device name (C-String)
* ## OUT:
* CC = OK, CS = ERROR
* X = DEVID
@ -44,18 +44,12 @@ K.GetDevByName.YA
ldx #0
.1 lda (ZPPtr2)
cmp (ZPPtr1)
bne .3
.1 ldy #$ff
tay
.2 lda (ZPPtr1),y
cmp (ZPPtr2),y
bne .3
dey
bne .2
.2 iny
lda (ZPPtr1),y
ora (ZPPtr2),y
bne .3 Both char are 0, match!
lda ZPPtr2
sec
@ -66,7 +60,11 @@ K.GetDevByName.YA
clc
rts
.3 lda ZPPtr2
.3 lda (ZPPtr1),y
cmp (ZPPtr2),y
beq .2
lda ZPPtr2
clc
adc #S.DEV
sta ZPPtr2

View File

@ -484,7 +484,6 @@ ENV.SysVarsExit2
* ZPPtr3 -> PTR to Ending 0
*--------------------------------------
ENV.FindVarPtr1 jsr ENV.InitEnvPtr3 Store ENV
bcs .99
.1 lda (ZPPtr3)
beq .9 end of ENV
@ -509,7 +508,7 @@ ENV.FindVarPtr1 jsr ENV.InitEnvPtr3 Store ENV
bra .1
.9 sec
.99 rts
rts
*--------------------------------------
* ENV.DiscardVarPtr3
* In:
@ -548,7 +547,7 @@ ENV.DiscardVarPtr3
ENV.InitEnvPtr3 ldy #S.PS.hENV
lda (pPs),y
jsr K.GetMemPtr.A
>STYA ZPPtr3 Store ENV
>STYA ZPPtr3 Store ENV
rts
*--------------------------------------
ENV.NextEnvPtr3 ldy #0

View File

@ -4,95 +4,6 @@ LOMEM $A00
INC 1
AUTO 6
*/--------------------------------------
* # FileSearch
* Search a file in the provided PATH list
* And return, if found, the full path to it.
* ## In:
* PUSHW = Ptr to Search Path (CSTR) %LIB%;/SYS/SLIB
* PUSHW = Ptr to File Name (CSTR)
* PUSHW = Ptr to DstBuf
* PUSHW = Ptr to DstStat
* ## Out:
* CC : success
* DstBuf = FilePath
* DstStat = S.STAT
* CS : not found
*\--------------------------------------
K.FileSearch >PULLW .4+1 DstStat
>PULLW .2+1 DstBuf
jsr K.FileSearch.I
bcs .9
ldx #$ff
.1 inx
lda K.Buf256,x
.2 sta $ffff,x Self Modified
bne .1
ldx #S.STAT-1
.3 lda K.S.STAT,x
.4 sta $ffff,x Self Modified
dex
bpl .3
.9 rts
K.FileSearch.I >PULLW .4+1
>PULLYA Get Search list
>SYSCALL ExpandStr.YA Expand it (SYSCALL to BNK2)
bcs .99
stx .98+1
>STYA .2+1 expanded search list ;
stz .1+1
.1 ldy #$ff Self Modified Index in Search list string
ldx #$0
.2 lda $ffff,y Self Modified, Search list string
beq .3 end of string, try it....
iny
cmp #';'
beq .3
sta K.Buf256,x
inx
bra .2
.3 txa
beq .98 String is empty....nothing to try
sty .1+1 save current index
ldy #$0
.4 lda $ffff,y Self Modified, Append Fiename...
sta K.Buf256,x
beq .5
iny
inx
bra .4
.5 stz K.Buf256+1,x set string ending 0
>PUSHWI K.S.STAT
>PUSHWI K.Buf256
jsr K.STAT
bcs .1 Failed...retry next path...
jsr .98 Discard Expanded hSrch list
clc
rts
.98 lda #$ff SELF MODIFIED : Discard Expanded hSrch list
jsr K.FreeMem.A
lda #MLI.ERR.FNOTFND
sec
.99 rts
*/--------------------------------------
* # GetFullPath.YA
* ## In :
* Y,A = Filename (C-String)

View File

@ -434,14 +434,14 @@ DevMgr.NUL cld
jmp (DevMgr.NUL.Code,x)
.DA #S.DEV.S.WRITE+S.DEV.S.READ+S.DEV.S.OPENED
.BS 6
>PSTR "NUL" NAME
>CSTR "NUL" NAME
.HS 00 NAME must Be 4 bytes long
*--------------------------------------
DevMgr.SYS cld
jmp (DevMgr.SYS.Code,x)
.DA #S.DEV.S.WRITE+S.DEV.S.READ
.BS 6
>PSTR "SYS" NAME
>CSTR "SYS" NAME
.HS 00 NAME must Be 4 bytes long
*--------------------------------------
* Setup AuxLC $FFFE->Kernel IRQ Handler
@ -856,7 +856,7 @@ MSG.KCREAD >CSTR "Reading Kernel Config File..."
MSG.KCREAD.OK >CSTR "OK\n"
MSG.KCREAD.KO >CSTR "\nError While Reading Kernel Config File, Using Default.\n"
*--------------------------------------
DEV.SYS >PSTR "SYS"
DEV.SYS >CSTR "SYS"
I.ENV.A2osX >CSTR "A2OSX"
I.ENV.PATH >CSTR "PATH=${A2OSX}SBIN/;${A2OSX}BIN/"
I.ENV.LIB >CSTR "LIB=${A2OSX}LIB/"

View File

@ -62,7 +62,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.FPrintF.YA
.DA 0
.DA K.FileSearch $60
.DA 0 $60
.DA K.GetFullPath.YA
.DA K.LoadFile
.DA K.SaveFile
@ -98,7 +98,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.LoadLib.YA
.DA K.UnloadLib.A
.DA K.LoadDrv.YA
.DA 0
.DA K.FileSearch
.DA K.ExecProcessNewEnv.YA $A0
.DA K.ExecProcess.YA

View File

@ -328,18 +328,29 @@ PS.Init jsr BIN.Load.YA Y,A=filename full path
*--------------------------------------
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
iny
.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