Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-10-24 16:47:28 +02:00
parent cacba39dd6
commit 44ef0642d3
4 changed files with 174 additions and 118 deletions

Binary file not shown.

View File

@ -236,7 +236,7 @@ SKT.listen >SYSCALL2 GetMemPtr
ldy #S.SOCKET.T ldy #S.SOCKET.T
lda (ZPPtrSKT),y lda (ZPPtrSKT),y
cmp #S.SOCKET.T.SEQPACKET+1 cmp #S.SOCKET.T.SEQPACKET
bcc .9 bcc .9
ldy #S.SOCKET.TCP.S ldy #S.SOCKET.TCP.S
@ -970,7 +970,6 @@ SKT.Send.STREAM lda #ERR.SKT.BAD
SKT.Send.9 rts SKT.Send.9 rts
*-------------------------------------- *--------------------------------------
SKT.Send.SEQPACKET SKT.Send.SEQPACKET
bra *
>LDYA ZPDataInLen >LDYA ZPDataInLen
jsr TCP.NewFrame jsr TCP.NewFrame
bcs SKT.Send.9 bcs SKT.Send.9

View File

@ -20,6 +20,21 @@ ZS.START
ZPIPCfgPtr .BS 2 ZPIPCfgPtr .BS 2
ZPSktPtr .BS 2 ZPSktPtr .BS 2
ZPMsgPtr .BS 2 ZPMsgPtr .BS 2
ZPMsgDataPtr .BS 2
ZPMsgDataLen .BS 2
ZPMsgDataCnt .BS 2
ArgIndex .BS 1
hRootdir .BS 1
ZPRootDirPtr .BS 2
ZPStrPtr .BS 2
hSrvSocket .BS 1
hClntSocket .BS 1
hMsg .BS 1
hStr .BS 1
TimeOut .BS 1
ZS.END .ED ZS.END .ED
*-------------------------------------- *--------------------------------------
* File Header (16 Bytes) * File Header (16 Bytes)
@ -45,10 +60,9 @@ CS.START cld
L.LIBTCPIP .DA LIBTCPIP L.LIBTCPIP .DA LIBTCPIP
L.SA.Local .DA SA.Local L.SA.Local .DA SA.Local
L.MSG.TCPWAIT .DA MSG.TCPWAIT L.MSG.TCPWAIT .DA MSG.TCPWAIT
L.MSG.INITOK .DA MSG.INITOK
L.MSG.TCPIPERR .DA MSG.TCPIPERR L.MSG.TCPIPERR .DA MSG.TCPIPERR
L.MSG.INITOK .DA MSG.INITOK
L.MSG.SKTERR .DA MSG.SKTERR L.MSG.SKTERR .DA MSG.SKTERR
L.MSG.ABORT .DA MSG.ABORT
L.MSG.INCOMING .DA MSG.INCOMING L.MSG.INCOMING .DA MSG.INCOMING
L.HTTP.200OK .DA HTTP.200OK L.HTTP.200OK .DA HTTP.200OK
.DA 0 .DA 0
@ -62,8 +76,9 @@ CS.INIT >LDYA L.LIBTCPIP
*-------------------------------------- *--------------------------------------
CS.RUN >LDYA L.MSG.TCPWAIT CS.RUN >LDYA L.MSG.TCPWAIT
>SYSCALL puts >SYSCALL puts
>DEBUG
jsr Init.Timeout lda #TIMEOUT.MAX
sta TimeOut
.1 >SLEEP .1 >SLEEP
>LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ? >LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ?
@ -73,7 +88,7 @@ CS.RUN >LDYA L.MSG.TCPWAIT
lda (ZPIPCfgPtr) Configured ? lda (ZPIPCfgPtr) Configured ?
bmi CS.RUN.INIT bmi CS.RUN.INIT
jsr Wait.Timeout lda Timeout
bcs .99 bcs .99
ldy #S.PS.hStdIn ldy #S.PS.hStdIn
@ -89,14 +104,12 @@ CS.RUN >LDYA L.MSG.TCPWAIT
cmp #$03 cmp #$03
bne .1 bne .1
>LDYA L.MSG.ABORT
>SYSCALL puts
lda #3
sec sec
rts rts
.99 >LDYA L.MSG.TCPIPERR .99 >LDYA L.MSG.TCPIPERR
>SYSCALL puts >SYSCALL puts
CS.RUN.SYN
lda #E.SYN lda #E.SYN
sec sec
CS.RUN.RTS rts CS.RUN.RTS rts
@ -109,24 +122,56 @@ CS.RUN.INIT ldx #3
dey dey
dex dex
bpl .1 bpl .1
>DEBUG
>PUSHBI 0 no protocol lda #1
sta ArgIndex
>SYSCALL ArgV
bcs CS.RUN.SYN
>SYSCALL atoi
bcs .2
>STYA SA.LOCAL+S.SOCKADDR.PORT
inc ArgIndex
.2 lda ArgIndex
>SYSCALL ArgV
bcs CS.RUN.SYN
>SYSCALL realpath
bcs CS.RUN.RTS
>STYA ZPRootDirPtr
CS.RUN.ARGSOK >PUSHBI 0 no protocol
lda #S.SOCKET.T.SEQPACKET lda #S.SOCKET.T.SEQPACKET
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket >LIBCALL hLIBTCPIP,LIBTCPIP.Socket
bcs CS.RUN.ERR bcs CS.RUN.ERR
>STA.G hSrvSocket sta hSrvSocket
pha
>PUSHW L.SA.LOCAL >PUSHW L.SA.LOCAL
pla lda hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind >LIBCALL hLIBTCPIP,LIBTCPIP.Bind
bcs CS.RUN.ERR bcs CS.RUN.ERR
>LDA.G hSrvSocket
lda hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Listen >LIBCALL hLIBTCPIP,LIBTCPIP.Listen
bcs CS.RUN.ERR bcs CS.RUN.ERR
>LDYAI 256
>SYSCALL getmem
bcs CS.RUN.ERR
>STYA ZPStrPtr
stx hStr
>PUSHW ZPRootDirPtr
>PUSHW SA.LOCAL+S.SOCKADDR.PORT
>PUSHBI 4
>LDYA L.MSG.INITOK >LDYA L.MSG.INITOK
>SYSCALL puts >SYSCALL printf
CS.RUN.LOOP >SLEEP CS.RUN.LOOP >SLEEP
jsr CS.RUN.SERVER jsr CS.RUN.SERVER
@ -139,10 +184,11 @@ CS.RUN.LOOP >SLEEP
sec sec
CS.RUN.ERR rts CS.RUN.ERR rts
*-------------------------------------- *--------------------------------------
CS.RUN.SERVER >LDA.G hSrvSocket CS.RUN.SERVER lda hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.accept >LIBCALL hLIBTCPIP,LIBTCPIP.accept
bcs .8 bcs .8
>STA.G hClntSocket
sta hClntSocket
>SYSCALL GetMemPtr >SYSCALL GetMemPtr
>STYA ZPSktPtr >STYA ZPSktPtr
@ -154,7 +200,7 @@ CS.RUN.SERVER >LDA.G hSrvSocket
dex dex
bpl .3 bpl .3
>PUSHB.G hClntSocket >PUSHB hClntSocket
>PUSHBI 5 >PUSHBI 5
>LDYA L.MSG.INCOMING >LDYA L.MSG.INCOMING
@ -174,41 +220,112 @@ CS.RUN.CLIENT
beq .1 beq .1
bra .8 bra .8
.2 pha .2 jsr CS.RUN.MSG.INIT
>SYSCALL getmemptr
>STYA ZPMsgPtr
>PUSHW ZPMsgPtr .3 jsr CS.RUN.MSG.GetStr
bcs .7
>PUSHW ZPStrPtr
ldy #S.PS.hStdOut ldy #S.PS.hStdOut
lda (pPS),y lda (pPS),y
>SYSCALL fwrite >SYSCALL fwrite
bra .3
pla lda hMsg
>SYSCALL freemem >SYSCALL freemem
.7 >PUSHWI HTTP.200OK.len .7 >PUSHWI HTTP.200OK.len
>PUSHW L.HTTP.200OK >PUSHW L.HTTP.200OK
>LDA.G hClntSocket lda hClntSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Send >LIBCALL hLIBTCPIP,LIBTCPIP.Send
.8 >LDA.G hClntSocket .8 lda hClntSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown >LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
clc clc
rts rts
*-------------------------------------- *--------------------------------------
CS.RUN.MSG.INIT sta hMsg
>SYSCALL getmemptr
>STYA ZPMsgPtr
pha
tya
* clc
adc #S.TCP
sta ZPMsgDataPtr
pla
adc /S.TCP
sta ZPMsgDataPtr+1
ldy #S.IP.TOTAL.LENGTH+1
lda (ZPMsgPtr),y
sec
sbc #S.IP
sta ZPMsgDataLen
eor #$ff
sta ZPMsgDataCnt
dey
lda (ZPMsgPtr),y
sbc /S.IP
sta ZPMsgDataLen+1
eor #$ff
sta ZPMsgDataCnt+1
rts
*--------------------------------------
CS.RUN.MSG.GetStr
ldy #0
.1 inc ZPMsgDataCnt
bne .2
inc ZPMsgDataCnt+1
beq .9
.2 lda (ZPMsgDataPtr)
inc ZPMsgDataPtr
bne .21
inc ZPMsgDataPtr+1
.21 cmp #C.CR
bne .4
inc ZPMsgDataCnt
bne .3
inc ZPMsgDataCnt+1
beq .9
.3 lda (ZPMsgDataPtr)
inc ZPMsgDataPtr
bne .31
inc ZPMsgDataPtr+1
.31 eor #C.LF
bne .9
sta (ZPStrPtr),y
clc
rts
.4 sta (ZPStrPtr),y
iny
bra .1
.9 sec
rts
*--------------------------------------
CS.DOEVENT lda (pEvent) CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event? bpl .9 is it a TIMER event?
>LDA.G TimeOut lda TimeOut
beq .9 beq .9
dec dec TimeOut
sta (pData),y
.9 sec do not discard TIMER event .9 sec do not discard TIMER event
rts rts
*-------------------------------------- *--------------------------------------
CS.QUIT ldy #hSrvSocket CS.QUIT lda hSrvSocket
lda (pData),y
beq .3 beq .3
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown >LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
@ -221,32 +338,19 @@ CS.QUIT ldy #hSrvSocket
.8 clc .8 clc
rts rts
*-------------------------------------- *--------------------------------------
Init.Timeout ldy #TimeOut
lda #TIMEOUT.MAX
sta (pData),y
rts
*--------------------------------------
Wait.TimeOut sec
ldy #TimeOut
lda (pData),y
beq .9
clc
.9 rts
*--------------------------------------
CS.END CS.END
*-------------------------------------- *--------------------------------------
hLIBTCPIP .BS 1 hLIBTCPIP .BS 1
LIBTCPIP .AZ "libtcpip" LIBTCPIP .AZ "libtcpip"
MSG.TCPWAIT .AZ "HTTPD:Waiting for TCP/IP initializing..." MSG.TCPWAIT .AZ "HTTPD:Waiting for TCP/IP initializing..."
MSG.INITOK .AZ "HTTPD:Init Ok, Listening."
MSG.TCPIPERR .AZ "HTTPD:TCP/IP Not initialized properly." MSG.TCPIPERR .AZ "HTTPD:TCP/IP Not initialized properly."
MSG.INITOK .AZ "HTTPD:Listening on port %D, root dir: %s.\r\n"
MSG.SKTERR .AZ "HTTPD:Listen Error." MSG.SKTERR .AZ "HTTPD:Listen Error."
MSG.ABORT .AZ "HTTPD:User Aborted."
MSG.INCOMING .AZ "HTTPD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n" MSG.INCOMING .AZ "HTTPD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n"
*-------------------------------------- *--------------------------------------
HTTP.200OK .AS "HTTP/1.1 200 OK" HTTP.200OK .AS "HTTP/1.1 200 OK"
.DA #C.CR,#C.LF .DA #C.CR,#C.LF
.AS "Server: A2osX-HTTPD 0.92" .AS "Server: A2osX-HTTPD 0.93"
.DA #C.CR,#C.LF .DA #C.CR,#C.LF
.AS "Content-Type: text/html" .AS "Content-Type: text/html"
.DA #C.CR,#C.LF .DA #C.CR,#C.LF
@ -267,9 +371,6 @@ SA.LOCAL .DA #AF.INET S.SOCKADDR.AF
.DUMMY .DUMMY
.OR 0 .OR 0
DS.START DS.START
hSrvSocket .BS 1
hClntSocket .BS 1
TimeOut .BS 1
DS.END DS.END
.ED .ED
*-------------------------------------- *--------------------------------------

View File

@ -11,7 +11,6 @@ NEW
.INB INC/LIBTCPIP.I .INB INC/LIBTCPIP.I
.INB INC/NET.TELNET.I .INB INC/NET.TELNET.I
*-------------------------------------- *--------------------------------------
CONN.MAX .EQ 16
TIMEOUT.MAX .EQ 200 20 sec. TIMEOUT.MAX .EQ 200 20 sec.
*-------------------------------------- *--------------------------------------
.DUMMY .DUMMY
@ -20,8 +19,9 @@ ZS.START
ZPIPCfgPtr .BS 2 ZPIPCfgPtr .BS 2
ZPSktPtr .BS 2 ZPSktPtr .BS 2
TimeOut .BS 1 TimeOut .BS 1
ZS.END hSrvSocket .BS 1
.ED hClientSocket .BS 1
ZS.END .ED
*-------------------------------------- *--------------------------------------
* File Header (16 Bytes) * File Header (16 Bytes)
*-------------------------------------- *--------------------------------------
@ -33,7 +33,7 @@ CS.START cld
.DA #0 .DA #0
.DA CS.END-CS.START CS .DA CS.END-CS.START CS
.DA DS.END-DS.START DS .DA DS.END-DS.START DS
.DA #64 SS .DA #32 SS
.DA #ZS.END-ZS.START Zero Page Size .DA #ZS.END-ZS.START Zero Page Size
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
@ -49,7 +49,6 @@ L.MSG.TCPWAIT .DA MSG.TCPWAIT
L.MSG.INITOK .DA MSG.INITOK L.MSG.INITOK .DA MSG.INITOK
L.MSG.TCPIPERR .DA MSG.TCPIPERR L.MSG.TCPIPERR .DA MSG.TCPIPERR
L.MSG.SKTERR .DA MSG.SKTERR L.MSG.SKTERR .DA MSG.SKTERR
L.MSG.ABORT .DA MSG.ABORT
L.MSG.INCOMING .DA MSG.INCOMING L.MSG.INCOMING .DA MSG.INCOMING
L.MSG.EXECERR .DA MSG.EXECERR L.MSG.EXECERR .DA MSG.EXECERR
L.NOD.Template .DA NOD.Template L.NOD.Template .DA NOD.Template
@ -94,8 +93,8 @@ CS.RUN lda #TIMEOUT.MAX
cmp #$03 cmp #$03
bne .1 bne .1
* sec
jmp CS.RUN.ABORT rts
.99 pha .99 pha
>LDYA L.MSG.TCPIPERR >LDYA L.MSG.TCPIPERR
@ -124,14 +123,14 @@ CS.RUN.PORTOK >PUSHBI 0 no protocol
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket >LIBCALL hLIBTCPIP,LIBTCPIP.Socket
bcs .9 bcs .9
>STA.G hSrvSocket sta hSrvSocket
pha
>PUSHW L.SA.LOCAL >PUSHW L.SA.LOCAL
pla lda hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind >LIBCALL hLIBTCPIP,LIBTCPIP.Bind
bcs .9 bcs .9
>LDA.G hSrvSocket lda hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Listen >LIBCALL hLIBTCPIP,LIBTCPIP.Listen
bcs .9 bcs .9
@ -140,12 +139,17 @@ CS.RUN.PORTOK >PUSHBI 0 no protocol
.2 >SLEEP .2 >SLEEP
>LDA.G hSrvSocket lda hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Accept >LIBCALL hLIBTCPIP,LIBTCPIP.Accept
bcs .2 bcs .2
jsr CS.RUN.SERVER
pha
jsr CS.RUN.CLIENT
pla
bcc .2 bcc .2
rts >LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
bra .2
.9 pha .9 pha
>LDYA L.MSG.SKTERR >LDYA L.MSG.SKTERR
@ -153,36 +157,10 @@ CS.RUN.PORTOK >PUSHBI 0 no protocol
pla pla
sec sec
rts rts
CS.RUN.ABORT >LDYA L.MSG.ABORT
>SYSCALL puts
lda #3
sec
rts
*--------------------------------------
CS.RUN.SERVER pha
ldy #hSockets
ldx #CONN.MAX
.1 lda (pData),y
bne .2
pla
sta (pData),y
bra CS.RUN.CLIENT
.2 iny
dex
bne .1
pla
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
.8 clc
rts
*-------------------------------------- *--------------------------------------
CS.RUN.CLIENT >SLEEP give some time for TCPIP SYN/ACK CS.RUN.CLIENT >SLEEP give some time for TCPIP SYN/ACK
>STA.G hClientSocket sta hClientSocket
>SYSCALL GetMemPtr >SYSCALL GetMemPtr
>STYA ZPSktPtr >STYA ZPSktPtr
@ -194,25 +172,25 @@ CS.RUN.CLIENT >SLEEP give some time for TCPIP SYN/ACK
dex dex
bpl .3 bpl .3
>PUSHB.G hClientSocket >PUSHB hClientSocket
>PUSHBI 5 >PUSHBI 5
>LDYA L.MSG.INCOMING >LDYA L.MSG.INCOMING
>SYSCALL printf >SYSCALL printf
>PUSHB.G hClientSocket >PUSHB hClientSocket
>PUSHBI 1 >PUSHBI 1
>PUSHW L.NOD.Template >PUSHW L.NOD.Template
>LEA.G NodBuf >LEA.G NodBuf
>SYSCALL sprintf >SYSCALL sprintf
>PUSHB.G hClientSocket >PUSHB hClientSocket
>PUSHW 0 >PUSHW 0
>LEA.G NodBuf >LEA.G NodBuf
>SYSCALL mknod >SYSCALL mknod
bcs .9 bcs .9
>STA.G hClientFile * sta hClientFile
>PUSHEA.G NodBuf >PUSHEA.G NodBuf
>PUSHBI 2 >PUSHBI 2
>PUSHW L.CMD.Template >PUSHW L.CMD.Template
@ -240,23 +218,7 @@ CS.DOEVENT lda (pEvent)
.9 sec do not discard TIMER event .9 sec do not discard TIMER event
rts rts
*-------------------------------------- *--------------------------------------
CS.QUIT ldx #CONN.MAX CS.QUIT lda hSrvSocket
ldy #hSockets
.1 lda (pData),y
beq .2
phx
phy
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
ply
plx
.2 iny
dex
bne .1
>LDA.G hSrvSocket
beq .3 beq .3
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown >LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
@ -277,7 +239,6 @@ MSG.TCPWAIT .AZ "TELNETD:Waiting for TCP/IP initializing..."
MSG.INITOK .AZ "TELNETD:Init Ok, Listening." MSG.INITOK .AZ "TELNETD:Init Ok, Listening."
MSG.TCPIPERR .AZ "TELNETD:TCP/IP Not initialized properly." MSG.TCPIPERR .AZ "TELNETD:TCP/IP Not initialized properly."
MSG.SKTERR .AZ "TELNETD:Listen Error." MSG.SKTERR .AZ "TELNETD:Listen Error."
MSG.ABORT .AZ "TELNETD:User Aborted."
MSG.INCOMING .AZ "TELNETD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n" MSG.INCOMING .AZ "TELNETD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n"
MSG.EXECERR .AZ "TELNETD:ExecL failed $%h." MSG.EXECERR .AZ "TELNETD:ExecL failed $%h."
*-------------------------------------- *--------------------------------------
@ -292,11 +253,6 @@ SA.LOCAL .DA #AF.INET S.SOCKADDR.AF
.DUMMY .DUMMY
.OR 0 .OR 0
DS.START DS.START
hSockets .BS CONN.MAX pData
SktIndex .BS 1
hSrvSocket .BS 1
hClientSocket .BS 1
hClientFile .BS 1
NodBuf .BS 11 NodBuf .BS 11
CmdBuf .BS 65 CmdBuf .BS 65
DS.END .ED DS.END .ED