Kernel 0.92

This commit is contained in:
Rémy GIBERT 2018-11-20 16:54:49 +01:00
parent d62a6b1a8e
commit da6265c0cd
12 changed files with 282 additions and 126 deletions

Binary file not shown.

View File

@ -562,6 +562,6 @@ BasePath..1 lda (pData),y
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/BIN/X.FILEENUM.S
LOAD USR/SRC/BIN/BIN/LS.S
SAVE USR/SRC/BIN/X.FILEENUM.S
LOAD USR/SRC/BIN/LS.S
ASM

View File

@ -84,6 +84,8 @@ E.OOM .EQ $FF Out Of Memory Error
E.OOH .EQ $FE Out Of Handle Error
E.INVH .EQ $FD Invalid Handle
E.BUF .EQ $FC Buffer Overflow
E.BADPATH .EQ $FB
E.BADARG .EQ $FA
*--------------------------------------
E.NSP .EQ $DD No Such Process Error
*--------------------------------------
@ -109,21 +111,21 @@ C.ESC .EQ 27
C.SPACE .EQ 32
C.DEL .EQ 127
*--------------------------------------
AF.LOCAL .EQ 0
AF.INET .EQ 2
AF.APPLETALK .EQ 4
AF.LOCAL .EQ 0
AF.INET .EQ 2
AF.APPLETALK .EQ 4
*--------------------------------------
O.RDONLY .EQ %00000001
O.WRONLY .EQ %00000010
O.RDWR .EQ %00000011
O.TRUNC .EQ %00000100
O.APPEND .EQ %00001000
O.TEXT .EQ %01000000
O.CREATE .EQ %10000000
O.RDONLY .EQ %00000001
O.WRONLY .EQ %00000010
O.RDWR .EQ %00000011
O.TRUNC .EQ %00000100
O.APPEND .EQ %00001000
O.TEXT .EQ %01000000
O.CREATE .EQ %10000000
*--------------------------------------
SEEK.SET .EQ $00
SEEK.CUR .EQ $02
SEEK.END .EQ $04
SEEK.SET .EQ $00
SEEK.CUR .EQ $02
SEEK.END .EQ $04
*--------------------------------------
* A2osX.SYSCALL Functions Indexes
*--------------------------------------
@ -204,7 +206,7 @@ SYS.StrMatch .EQ $7E
SYS.StrLen .EQ $80
SYS.StrCpy .EQ $82
SYS.StrCat .EQ $84
* .EQ $86
* .EQ $86
SYS.StrUpr .EQ $88
SYS.StrLwr .EQ $8A
SYS.StrCmp .EQ $8C

View File

@ -248,14 +248,14 @@ OApple+1,OApple+2,OApple+3 to switch between screens : Kernel Log, text, DHGR.
| Name | Status | Comment | K.Ver |
| ---- | ------ | ------- | ------|
| INSDRV | Working | | 0.92 |
| GETTY | Working | | 0.92 |
| GETTY | Working | -E : Exit on remote close | 0.92 |
| LOGIN | In Progress | no auth using /etc/passwd yet | 0.92 |
| SHELL | Working | (See Internal Shell commands) | 0.92 |
| KCONFIG | Working | Kernel Configuration Utility | 0.92 |
| ---- | ------ | ------- | ----- |
| TCPIPD | Working | Socket API.ARP,IP,ICMP,UDP & TCP ok | 0.92 |
| TCPIPD | Working | ARP,IP,ICMP,UDP & TCP ok | 0.92 |
| DHCPCLNT| Working | rewritten to use new Socket API | 0.92 |
| TELNETD | In Progress | | 0.92 |
| TELNETD | Working | | 0.92 |
| HTTPD | In Progress | | 0.9 |
## Internal Shell commands:
@ -288,7 +288,8 @@ OApple+1,OApple+2,OApple+3 to switch between screens : Kernel Log, text, DHGR.
| | | [ int32 -le int32 ] |
| | | [ int32 -gt int32 ] |
| | | [ int32 -ge int32 ] |
| SHIFT | Working | Remove $1 from cmd line |
| WHILE BREAK LOOP | Working | [ same as IF ] |
## Shell variables:

View File

@ -12,6 +12,8 @@ AUTO 4,1
*--------------------------------------
TIMEOUT.MAX .EQ 100 10 sec.
*--------------------------------------
ZPPtr1 .EQ ZPBIN
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
@ -23,7 +25,7 @@ CS.START cld
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
.DA #0 ZP
.DA #2 ZP
.DA 0
*--------------------------------------
* Relocation Table
@ -38,7 +40,6 @@ L.TELNETOPTS .DA TELNETOPTS
L.TELNETOPT.TTYPE .DA TELNETOPT.TTYPE
L.TELNETOPT.LMODE .DA TELNETOPT.LMODE
L.ENV.TERM .DA ENV.TERM
L.MSG.DEBUG .DA MSG.DEBUG
.DA 0 End Of Reloc Table
*--------------------------------------
CS.INIT clc
@ -48,16 +49,52 @@ CS.RUN ldy #S.PS.ARGC
lda (pPs),y
cmp #3
bcc .90
bcc .9
.1 >INC.G ArgIndex
>SYSCALL ArgV
bcs .8
>STYA ZPPtr1
jsr CkeckOption
bcs .9
beq .1 valid option, check next arg
>LDA.G ArgDev
bne .2
>LDA.G ArgIndex
>STA.G ArgDev
bra .1
.2 >LDA.G ArgProg
bne .9
>LDA.G ArgIndex
>STA.G ArgProg
bra .1
.9 >PUSHBI 0
>LDYA L.MSG.USAGE
>SYSCALL printf
lda #E.SYN
sec
.99 rts
.8 >LDA.G ArgDev
beq .9
>LDA.G ArgProg
beq .9
>PUSHWI 0 auxtype
>PUSHBI 0 type
>PUSHBI O.RDWR
lda #1
>SYSCALL ArgV get /dev/xxx
>LDA.G ArgDev
>SYSCALL ArgV
>SYSCALL fopen
bcs .9
bcs .99
ldy #S.PS.hStdIn
sta (pPs),y
@ -66,15 +103,7 @@ CS.RUN ldy #S.PS.ARGC
iny #S.PS.hStdErr
sta (pPs),y
>STA.G hDEV
bra CS.RUN.LOOP0
.90 >PUSHBI 0
>LDYA L.MSG.USAGE
>SYSCALL printf
lda #E.SYN
sec
.9 rts
>STA.G hFILE
CS.RUN.LOOP0 >LDYA L.ENV.TERM
>SYSCALL UnSetEnv
@ -119,16 +148,20 @@ CS.RUN.LOOP1 >SLEEP
.2 >PUSHBI S.PS.F.DUPENV+S.PS.F.HOLD
lda #2
>LDA.G ArgProg
>SYSCALL ArgV
>SYSCALL ExecV
bcs CS.RUN.9
>SLEEP
>LDA.G bExitOnClose
bmi .8
jmp CS.RUN.LOOP0
clc
.8 lda #0
sec
CS.RUN.9 rts
*--------------------------------------
CS.RUN.IACMODE >SLEEP Wait for IAC CMD (or SB)
@ -222,7 +255,7 @@ CS.RUN.IAC.SB
>SYSCALL SetEnv
.8 jmp CS.RUN.LOOP1
*--------------------------------------
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
@ -235,7 +268,7 @@ CS.DOEVENT lda (pEvent)
.9 sec do not discard TIMER event
rts
*--------------------------------------
CS.QUIT >LDA.G hDEV
CS.QUIT >LDA.G hFILE
beq .8
>SYSCALL fclose
@ -253,13 +286,41 @@ Wait.TimeOut sec
clc
.9 rts
*--------------------------------------
CkeckOption lda (ZPPtr1)
cmp #'-'
bne .8
ldy #2
lda (ZPPtr1),y
bne .8
dey
lda (ZPPtr1),y
ldx OptionList
.2 cmp OptionList,x
beq .3
dex
bne .2
sec invalid option
rts
.3 ldy OptionVars-1,x
eor #$80 toggle option
sta (pData),y
lda #0 exit with 0
.8 clc !0 if bot an option
rts
*--------------------------------------
CS.END
OptionList >PSTR "Ee"
OptionVars .DA #bCloseOnExit,#bCloseOnExit
MSG.USAGE .AZ "Usage : GETTY <DEV> <PROGRAM>\r\n"
.AZ " -E : Close DEV on exit\r\n"
OptionVars .DA #bExitOnClose,#bExitOnClose
MSG.USAGE .AS "Usage : GETTY <DEV> <PROGRAM>\r\n"
.AZ " -E : Exit on disconnect\r\n"
MSG.GREETINGS .AZ "\r\nA2osX-GeTTY %d.%d\r\n"
MSG.DEBUG .AZ "{%h}"
*--------------------------------------
TELNETOPTS .DA #IAC,#WILL,#TELOPT.BINARY
.DA #IAC,#WILL,#TELOPT.ECHO
@ -280,8 +341,11 @@ ENV.TERM .AZ "TERM"
.DUMMY
.OR 0
DS.START
hDEV .BS 1
bCloseOnExit .BS 1
ArgIndex .BS 1
ArgDev .BS 1
ArgProg .BS 1
hFILE .BS 1
bExitOnClose .BS 1
TimeOut .BS 1
IAC.CMD .BS 1
IAC.SUBCMD .BS 1

View File

@ -184,7 +184,7 @@ INPUT.LINEIN ldy #INPUT.Status
CS.END
MSG.LOGIN .AZ "\r\nlogin:"
MSG.PASSWORD .AZ "\r\npassword:"
SHELL .AZ "${A2OSX}SBIN/SHELL"
SHELL .AZ "${ROOT}SBIN/SHELL"
.HS 00
*--------------------------------------
.DUMMY

View File

@ -39,17 +39,13 @@ Cmd.Exec >LDA.G CMD.IntCmd
cpx #C.ELSE always execute ELSE,FI
bcs .1
jsr CMD.StkGet
jsr CMD.StkGet IF,WHILE,FOR ?
bcs .1 no particular context
bpl .8 context is FALSE, skip line
.1 jmp (J.CMD.INT,x)
.99 lda #E.SYN
sec
rts
.2 >PUSHB.G CMD.PSFlags
>LDYA ZPArgVBuf
>SYSCALL execv
@ -59,7 +55,7 @@ Cmd.Exec >LDA.G CMD.IntCmd
>LDA.G CMD.PSFlags
and #S.PS.F.HOLD
bne .3
bne .4
txa
>PUSHA
@ -68,45 +64,53 @@ Cmd.Exec >LDA.G CMD.IntCmd
>SYSCALL printf
rts
.3 >SLEEP Suspend this PID
.4 >SLEEP Suspend this PID
ldy #S.PS.RC
lda (pPs),y
bne .9
bne .99
.8 clc
.9 rts
.99 sec
rts
*--------------------------------------
* STARTPROC : intcmd = 0
*--------------------------------------
Cmd.INT.STARTPROC
clc
rts
*--------------------------------------
*--------------------------------------
Cmd.INT.SHIFT lda #1
jmp ShiftA
*--------------------------------------
Cmd.INT.PWD ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL GetMemPtr
>SYSCALL puts
Cmd.INT.PWD.RTS rts
rts
*--------------------------------------
Cmd.INT.CD ldx #1
jsr Cmd.GetArgX
bcc Cmd.INT.CD.ARG
bcs Cmd.INT.CD.HOME
>SYSCALL RealPath
bcc Cmd.INT.CD.1
Cmd.INT.CD.RTS rts
Cmd.INT.CD.HOME >LDYA L.ENV.HOME
>SYSCALL GetEnv
bcc .1
>LDYA L.ENV.ROOT
>SYSCALL GetEnv
bcs Cmd.INT.PWD.RTS
bcs Cmd.INT.PWD
.1 >SYSCALL ExpandStr
bcs Cmd.INT.PWD.RTS
bra Cmd.INT.CD.1
Cmd.INT.CD.ARG >SYSCALL RealPath
bcs Cmd.INT.PWD.RTS
bcs Cmd.INT.CD.RTS
Cmd.INT.CD.1 >STYA ZPPtr1
txa
>STA.G CMD.hCmdLine
@ -170,7 +174,7 @@ Cmd.Exec.ERRSYN lda #E.SYN
*--------------------------------------
Cmd.INT.SET ldx #1
jsr Cmd.GetArgX
bcc Cmd.INT.SETVAR
bcc Cmd.INT.SET.1
* No arg, print all ENV
@ -220,8 +224,19 @@ Cmd.INT.SET ldx #1
.8 clc
.9 rts
*--------------------------------------
Cmd.INT.SETVAR jsr CMD.IsSwitch
bcs .10
* SET +X VAR = VALUE1 op VALUE2 op VALUE3 ...
*--------------------------------------
Cmd.INT.SET.1 >STZ.G CMD.Varname
lda #1
>STA.G CMD.ArgIndex
.1 tax
jsr Cmd.GetArgX
bcs .8
jsr CMD.IsSwitch
bcs .2
cmp #'X'
bne .99
@ -229,49 +244,67 @@ Cmd.INT.SETVAR jsr CMD.IsSwitch
lda #$ff
>EOR.G bSET.X
sta (pData),y
>INC.G CMD.ArgIndex
tax
bra .1
.2 >LDA.G CMD.ArgIndex
>STA.G CMD.Varname
>INC.G CMD.ArgIndex
tax
jsr Cmd.GetArgX
bcs Cmd.INT.SET.GET
>STYA ZPPTR1
lda (ZPPTR1)
cmp #'='
bne .99
ldy #1
lda (ZPPTR1),y
bne .99
>INC.G CMD.ArgIndex
tax
jsr Cmd.GetArgX
bcs Cmd.INT.SET.UNSET
>PUSHYA
>LDA.G CMD.Varname
tax
jsr Cmd.GetArgX
>SYSCALL SetEnv
rts
.8 clc
rts
.10 lda (ZPPTR1) set by CMD.IsSwitch
cmp #'=' string is '=value' ?
beq .99 syntax error
ldy #0
.1 iny
lda (ZPPTR1),y
beq .3 no =, GetEnv
cmp #'=' ARGS contains =, PutEnv
bne .1
iny
lda (ZPPTR1),y
beq .2 "VAR=" go UnsetEnv
>LDYA ZPPTR1 String is VAR=VALUE...
>SYSCALL PutEnv
rts
.2 dey String is "VAR=", Remove ending '='
lda #0
sta (ZPPTR1),y
>LDYA ZPPTR1 String is "VAR"...
>SYSCALL UnsetEnv
rts
.99 lda #E.SYN
sec
rts
* Print requested VAR
.3 >LDYA ZPPTR1
Cmd.INT.SET.UNSET
>LDA.G CMD.Varname
tax
jsr Cmd.GetArgX
>SYSCALL UnsetEnv
rts
Cmd.INT.SET.GET
>LDA.G CMD.Varname
tax
jsr Cmd.GetArgX
>SYSCALL GetEnv
bcs .8
rts
>PUSHYA push value
>PUSHW ZPPTR1 push name
>LDA.G CMD.Varname
tax
jsr Cmd.GetArgX
>PUSHYA push name
*--------------------------------------
Cmd.INT.SET.PRINT
>PUSHBI 4
@ -753,6 +786,9 @@ Cmd.INT.FI jsr CMD.StkPull
Cmd.INT.NEXT
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.BREAK
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.INT.LOOP jsr CMD.StkPull
bcs .9
tax

View File

@ -13,27 +13,29 @@ History.MAX .EQ 256
CMD.STACK.MAX .EQ 64
*--------------------------------------
C.STARTPROC .EQ 0
C.CD .EQ 2
C.DATE .EQ 4
C.ECHO .EQ 6
C.EXIT .EQ 8
C.FOR .EQ 10
C.IF .EQ 12
C.MD .EQ 14
C.PAUSE .EQ 16
C.PWD .EQ 18
C.RD .EQ 20
C.READ .EQ 22
C.REN .EQ 24
C.SET .EQ 26
C.SLEEP .EQ 28
C.TIME .EQ 30
C.WHILE .EQ 32
C.NEXT .EQ 34
C.LOOP .EQ 36
C.BREAK .EQ 2
C.CD .EQ 4
C.DATE .EQ 6
C.ECHO .EQ 8
C.EXIT .EQ 10
C.FOR .EQ 12
C.IF .EQ 14
C.MD .EQ 16
C.PAUSE .EQ 18
C.PWD .EQ 20
C.RD .EQ 22
C.READ .EQ 24
C.REN .EQ 26
C.SET .EQ 28
C.SLEEP .EQ 30
C.SHIFT .EQ 32
C.TIME .EQ 34
C.WHILE .EQ 36
C.NEXT .EQ 38
C.LOOP .EQ 40
*--------------------------------------
C.ELSE .EQ 38
C.FI .EQ 40
C.ELSE .EQ 42
C.FI .EQ 44
*--------------------------------------
E.SYNTAX .EQ $C0
E.STKOVERFLOW .EQ $C1
@ -116,6 +118,7 @@ J.CL.IO .DA CL.IO.AMP
.DA CL.IO.2OUT
L.CMD.INT .DA CMD.INT
J.CMD.INT .DA Cmd.INT.STARTPROC
.DA Cmd.INT.BREAK
.DA Cmd.INT.CD
.DA Cmd.INT.DATE
.DA Cmd.INT.ECHO
@ -130,6 +133,7 @@ J.CMD.INT .DA Cmd.INT.STARTPROC
.DA Cmd.INT.REN
.DA Cmd.INT.SET
.DA Cmd.INT.SLEEP
.DA Cmd.INT.SHIFT
.DA Cmd.INT.TIME
.DA Cmd.INT.WHILE
.DA Cmd.INT.NEXT
@ -168,6 +172,9 @@ CS.RUN jsr Cmd.INT.CD.HOME
>SYSCALL GetMemPtr
>STYA ZPFileBufPtr
lda #0
jsr ShiftA Remove $0=/bin/shell
.DO CSH=1
jsr CSH.Init
.FIN
@ -435,6 +442,49 @@ SetPWD.I >SYSCALL GetMemPtr
>SYSCALL SetEnv
rts
*--------------------------------------
ShiftA >SYSCALL ArgV
bcs .8
>STYA ZPPtr1
>STYA ZPPtr2
.10 ldy #$ff
.1 iny Compute ArgX len
lda (ZPPtr1),y
bne .1
.2 tya
sec
adc ZPPtr1
sta ZPPtr1
bcc .3
inc ZPPtr1+1
.3 ldy #$ff
.4 iny
lda (ZPPtr1),y
sta (ZPPtr2),y
bne .4
tya
beq .7
sec
adc ZPPtr2
sta ZPPtr2
bcc .2
inc ZPPtr2+1
bra .2
.7 ldy #S.PS.ARGC
lda (pPS),y
dec
sta (pPS),y
.8 clc
rts
*--------------------------------------
Lookup >STYA ZPPtr2
>PULLW ZPPtr1
@ -489,7 +539,7 @@ MSG.TRACE .AS ">%s"
MSG.ECHOCRLF .AZ "\r\n"
MSG.BATCHERR .AZ "^\r\nLine #%D:"
MSG.ERROR .AZ "[$%h]:%S.\r\n"
MSG.PRINTENV .AZ "%s=%s\r\n"
MSG.PRINTENV .AZ "%s = %s\r\n"
MSG.PID .AZ "PID=%d\r\n"
FMT.DATE .AZ "%A (%w), %B %d %Y"
FMT.TIME .AZ "%H:%M:%S (%I:%M:%S%p)"
@ -514,6 +564,7 @@ CL.IO .AZ "&"
.HS 00
*--------------------------------------
CMD.INT .AZ "STARTPROC"
.AZ "BREAK"
.AZ "CD"
.AZ "DATE"
.AZ "ECHO"
@ -528,6 +579,7 @@ CMD.INT .AZ "STARTPROC"
.AZ "REN"
.AZ "SET"
.AZ "SLEEP"
.AZ "SHIFT"
.AZ "TIME"
.AZ "WHILE"
.AZ "NEXT"
@ -605,6 +657,7 @@ CMD.hCmdLine .BS 1
CMD.hArgVBuf .BS 1
CMD.ArgIndex .BS 1
CMD.Varname .BS 1
CMD.Test .BS 1
CMD.Operator .BS 1
CMD.NumArg1 .BS 4

View File

@ -280,7 +280,7 @@ MSG.INCOMING .AZ "TELNETD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n"
MSG.EXECERR .AZ "TELNETD:ExecL failed $%h."
*--------------------------------------
NOD.Template .AZ "/DEV/TTY%h"
CMD.Template .AZ "${ROOT}SBIN/GETTY %s ${ROOT}SBIN/LOGIN"
CMD.Template .AZ "${ROOT}SBIN/GETTY -E %s ${ROOT}SBIN/LOGIN"
*--------------------------------------
SA.LOCAL .DA #AF.INET S.SOCKADDR.AF
.BS 1

View File

@ -29,7 +29,7 @@ K.OpenDir jsr PFT.CheckPathYA
sta (pFD),y
ldy #1
lda (ZPPtr2),y One char ?
lda K.Buf256,y One char ("/") ?
beq .8 No, Go open dir....
>MLICALL MLIGETFILEINFO
@ -50,7 +50,7 @@ K.OpenDir jsr PFT.CheckPathYA
sta (pFD),y
.8 ldx #$ff Self Modified
>LDYA ZPPtr2
>LDYAI K.Buf256
jsr STDIO.NewHFileYAX
bcc .99

View File

@ -1148,7 +1148,7 @@ K.FSeek jsr PFT.CheckNodeA
.9 rts
.98 lda #E.SYN
.98 lda #E.BADARG
.HS 2C bit abs
.99 lda #E.FTB
sec

View File

@ -398,7 +398,7 @@ K.realpath.I clc
>LDYAI K.Buf256
jmp K.NewStr
.90 lda #E.SYN
.90 lda #E.BADPATH
sec
rts