Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-09-03 08:01:07 +02:00
parent aad9f9912f
commit 5c3d2a0ae2
10 changed files with 65 additions and 40 deletions

Binary file not shown.

Binary file not shown.

View File

@ -16,6 +16,7 @@ BUFSIZE .EQ 256
*-------------------------------------- *--------------------------------------
ZPIPCfgPtr .EQ ZPBIN ZPIPCfgPtr .EQ ZPBIN
ZPBufPtr .EQ ZPBIN+2 ZPBufPtr .EQ ZPBIN+2
ZPBufLen .EQ ZPBIN+4
*-------------------------------------- *--------------------------------------
* File Header (16 Bytes) * File Header (16 Bytes)
*-------------------------------------- *--------------------------------------
@ -27,7 +28,7 @@ CS.START cld
.DA CS.END-CS.START Code Length To Relocate .DA CS.END-CS.START Code Length To Relocate
.DA DS.END-DS.START Data Segment to Allocate .DA DS.END-DS.START Data Segment to Allocate
.DA #16 SS .DA #16 SS
.DA #2 ZP .DA #6 ZP
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
.1 .DA CS.INIT .1 .DA CS.INIT
@ -42,6 +43,7 @@ L.MSG.UNKNOWN .DA MSG.UNKNOWN
L.MSG.HOSTOK .DA MSG.HOSTOK L.MSG.HOSTOK .DA MSG.HOSTOK
L.MSG.SKTKO .DA MSG.SKTKO L.MSG.SKTKO .DA MSG.SKTKO
L.MSG.SKTOK .DA MSG.SKTOK L.MSG.SKTOK .DA MSG.SKTOK
L.MSG.SKTERR .DA MSG.SKTERR
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
CS.INIT >LDYA L.LIBTCPIP CS.INIT >LDYA L.LIBTCPIP
@ -82,7 +84,6 @@ CS.RUN.IPOK ldy #S.PS.ARGC
>PUSHYA >PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME >LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME
bcc CS.RUN.HOSTOK bcc CS.RUN.HOSTOK
>SLEEP
jsr Wait.Timeout jsr Wait.Timeout
bcc .2 bcc .2
@ -150,14 +151,14 @@ CS.RUN.OPENSKT ldx #3
txa txa
>STA.G hBuf >STA.G hBuf
>DEBUG CS.RUN.LOOP >SLEEP
CS.RUN.LOOP >PUSHB.G hSocket >PUSHB.G hSocket
>PUSHW ZPBufPtr >PUSHW ZPBufPtr
>PUSHWI BUFSIZE >PUSHWI BUFSIZE
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Read >LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Read
bcc .1 bcc .1
tay tay
beq .2 no char beq .2 no char
rts rts
@ -177,16 +178,22 @@ CS.RUN.LOOP >PUSHB.G hSocket
bcc .3 bcc .3
tay tay
beq CS.RUN.LOOP beq CS.RUN.LOOP
>PUSHA
>PUSHBI 1
>LDYA L.MSG.SKTERR
>SYSCALL printf
rts rts
.3 phy .3 >STYA ZPBufLen
pha
lda (ZPBufPtr)
cmp #3 Ctrl-C
beq .9
>PUSHB.G hSocket >PUSHB.G hSocket
>PUSHW ZPBufPtr >PUSHW ZPBufPtr
pla >PUSHW ZPBufLen
>PUSHA
pla
>PUSHA
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Write >LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Write
bcs CS.RUN.ERR bcs CS.RUN.ERR
@ -209,11 +216,10 @@ CS.DOEVENT lda (pEvent)
.9 sec do not discard TIMER event .9 sec do not discard TIMER event
rts rts
*-------------------------------------- *--------------------------------------
CS.QUIT ldy #hSocket CS.QUIT >LDA.G hSocket
lda (pData),y
beq .1 beq .1
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Close * >LIBCALL hLIBTCPIP,LIBTCPIP.SKT.Close
.1 >LDA.G hBuf .1 >LDA.G hBuf
beq .2 beq .2
@ -247,6 +253,7 @@ MSG.UNKNOWN .AZ "%s: Unknown host\r\n"
MSG.HOSTOK .AZ "Connecting to %d.%d.%d.%d (%s) ...\r\n" MSG.HOSTOK .AZ "Connecting to %d.%d.%d.%d (%s) ...\r\n"
MSG.SKTKO .AZ "Failed to Open Socket." MSG.SKTKO .AZ "Failed to Open Socket."
MSG.SKTOK .AZ "Connected." MSG.SKTOK .AZ "Connected."
MSG.SKTERR .AZ "Socket Error : $%h\r\n"
*-------------------------------------- *--------------------------------------
Socket .DA #S.SOCKET.SOCK.STREAM Socket .DA #S.SOCKET.SOCK.STREAM
.BS 1 .BS 1

View File

@ -293,8 +293,13 @@ S.MSTAT .EQ 24
* IOCTL device API * IOCTL device API
*-------------------------------------- *--------------------------------------
C.EOF .EQ 4 C.EOF .EQ 4
C.ENQ .EQ 5
C.BS .EQ 8
C.LF .EQ 10 C.LF .EQ 10
C.FF .EQ 12
C.CR .EQ 13 C.CR .EQ 13
C.FS .EQ 21
C.ESC .EQ 27
C.DEL .EQ 127 C.DEL .EQ 127
*-------------------------------------- *--------------------------------------
DEVID.NULL .EQ 0 DEVID.NULL .EQ 0

View File

@ -59,12 +59,7 @@ ERR.SKT.BAD .EQ $BD
ERR.DNS.PENDING .EQ $B9 ERR.DNS.PENDING .EQ $B9
ERR.DNS.ERROR .EQ $B8 ERR.DNS.ERROR .EQ $B8
ERR.ARP .EQ $B7
ERR.ARP.PENDING .EQ $B5 ERR.ARP.PENDING .EQ $B5
ERR.ARP.ERROR .EQ $B4
ERR.DEV .EQ $B3
*-------------------------------------- *--------------------------------------
UDP.PORT.DNS .EQ 53 UDP.PORT.DNS .EQ 53
UDP.PORT.PMAP .EQ 111 UDP.PORT.PMAP .EQ 111

View File

@ -215,6 +215,7 @@ ARP.QUERY.I jsr ARP.FIND.BY.IP
iny iny
cpy #S.ARPCACHE.MAC+6 cpy #S.ARPCACHE.MAC+6
bne .2 bne .2
clc clc
rts rts

View File

@ -228,7 +228,9 @@ FRM.Queue ldy hFrameOut no hFrame, cannot queue for retry
inx inx
cpx #K.FRMQUEUE.SIZE cpx #K.FRMQUEUE.SIZE
bne .1 bne .1
ldx #0 ldx #0
.1 cpx FRM.QUEUE.Tail .1 cpx FRM.QUEUE.Tail
beq .9 beq .9
ldy FRM.QUEUE.Head ldy FRM.QUEUE.Head
@ -240,9 +242,9 @@ FRM.Queue ldy hFrameOut no hFrame, cannot queue for retry
lda hFrameOut lda hFrameOut
sta FRM.QUEUE.hMem,y sta FRM.QUEUE.hMem,y
lda ZPFrameOutLen lda ZPFrameOutLen
sta FRM.QUEUE.LenL,x sta FRM.QUEUE.LenL,y
lda ZPFrameOutLen+1 lda ZPFrameOutLen+1
sta FRM.QUEUE.LenH,x sta FRM.QUEUE.LenH,y
clc clc
rts rts
@ -266,8 +268,9 @@ FRM.Retry ldx FRM.QUEUE.Tail
sta ZPFrameOutLen+1 sta ZPFrameOutLen+1
lda FRM.QUEUE.State,x lda FRM.QUEUE.State,x
cmp #ERR.DEV+1 Device error ? cmp #ERR.ARP.PENDING
bcc .1 yes, retry sending... bne .1
jsr IP.SetDestMAC Err is ARP or higher, retry getting MAC jsr IP.SetDestMAC Err is ARP or higher, retry getting MAC
bcs .2 still error getting dest MAC bcs .2 still error getting dest MAC
@ -283,11 +286,13 @@ FRM.Retry ldx FRM.QUEUE.Tail
lda FRM.QUEUE.hMem,x lda FRM.QUEUE.hMem,x
>SYSCALL FreeMem >SYSCALL FreeMem
.4 ldx FRM.QUEUE.Tail ldx FRM.QUEUE.Tail
inx inx
cpx #K.FRMQUEUE.SIZE cpx #K.FRMQUEUE.SIZE
bne .5 bne .5
ldx #0 ldx #0
.5 stx FRM.QUEUE.Tail .5 stx FRM.QUEUE.Tail
bra .10 bra .10

View File

@ -8,7 +8,7 @@ AUTO 4,1
* **In:** * **In:**
* PUSHW = PTR to S.SOCKET template * PUSHW = PTR to S.SOCKET template
* **Out:** * **Out:**
* YA = PTR to new S.SOCKET * Y,A = PTR to new S.SOCKET
* X = hSocket * X = hSocket
*\-------------------------------------- *\--------------------------------------
SKT.New >PULLW ZPTmpPtr1 SKT.New >PULLW ZPTmpPtr1
@ -29,7 +29,7 @@ SKT.New >PULLW ZPTmpPtr1
>STYA ZPTmpPtr2 >STYA ZPTmpPtr2
lda #$ff lda #$ff
sta TmpOffset to keep track of any free slot sta TmpByte to keep track of any free slot
ldx #0 ldx #0
@ -52,12 +52,12 @@ SKT.New >PULLW ZPTmpPtr1
sec sec
rts rts
.4 lda TmpOffset .4 lda TmpByte
bpl .5 already found an empty slot.... bpl .5 already found an empty slot....
>LDYA ZPTmpPtr2 found one... >LDYA ZPTmpPtr2 found one...
>STYA ZPPtrSKT save it! >STYA ZPPtrSKT save it!
stx TmpOffset stx TmpByte
.5 lda ZPTmpPtr2 .5 lda ZPTmpPtr2
clc clc
@ -69,7 +69,7 @@ SKT.New >PULLW ZPTmpPtr1
cpx #K.SKTTABLE.SIZE cpx #K.SKTTABLE.SIZE
bne .2 bne .2
lda TmpOffset Did we found an empty slot ? lda TmpByte Did we found an empty slot ?
bmi .9 bmi .9
ldy #S.SOCKET.HDR-1 ldy #S.SOCKET.HDR-1
@ -90,19 +90,19 @@ SKT.New >PULLW ZPTmpPtr1
jsr SKT.NewTCB jsr SKT.NewTCB
bcs .99 bcs .99
lda #S.TCP.OPTIONS.SYN lda #S.TCP.OPTIONS.SYN
jsr TCP.OUT.SendOptA Send SYN,Only for CLIENT conn!!!! jsr TCP.OUT.SendOptA Send SYN,Only for CLIENT conn!!!!
bcs .99 bcs .99
ldy #S.SOCKET.TCP.STATUS ldy #S.SOCKET.TCP.STATUS
lda #S.SOCKET.TCP.STATUS.SYNSENT lda #S.SOCKET.TCP.STATUS.SYNSENT
sta (ZPPtrSKT),y sta (ZPPtrSKT),y
.8 lda TmpOffset .8 lda TmpByte
ora #$80 ora #$80
tax tax
>LDYA ZPTmpPtr3 >LDYA ZPPtrSKT
clc clc
rts rts
@ -339,7 +339,7 @@ SKT.MkNod sta .1+1
SKT.Read >PULLW ZPDataOutLen SKT.Read >PULLW ZPDataOutLen
>PULLW ZPDataOutPtr >PULLW ZPDataOutPtr
>PULLA >PULLA
SKT.Read.I jsr SKT.Get.I SKT.Read.I jsr SKT.Get.I
bcs .99 bcs .99
cmp #S.SOCKET.SOCK.STREAM cmp #S.SOCKET.SOCK.STREAM

View File

@ -169,13 +169,28 @@ TCP.IN.JMP.SYNSENT
dex dex
bpl .1 bpl .1
ldx #3
ldy #S.TCP.SEQNUM+3
sec ACK=SEC+1
.2 lda (ZPFrameInPtr),y
adc #0
sta SKT.TCBCache+S.TCB.INLASTSEQNUM,x
sta SKT.TCBCache+S.TCB.OUTACKNUM,x
dey
dex
bpl .2
lda #S.TCP.OPTIONS.ACK lda #S.TCP.OPTIONS.ACK
jsr TCP.OUT.SendOptA SYN.ACK recieved, Send, ACK jsr TCP.OUT.SendOptA SYN.ACK recieved, Send, ACK
bcs .9 bcs .9
ldy #S.SOCKET.TCP.STATUS ldy #S.SOCKET.TCP.STATUS
lda #S.SOCKET.TCP.STATUS.ESTBLSH lda #S.SOCKET.TCP.STATUS.ESTBLSH
sta (ZPPtrSKT),y sta (ZPPtrSKT),y
jsr SKT.StoreTCB
.8 clc .8 clc
.9 rts .9 rts
@ -450,7 +465,6 @@ TCP.OUT.SendOptA
TCP.OUT.SendOptA.1 TCP.OUT.SendOptA.1
ldy #S.TCP.OPTIONS ldy #S.TCP.OPTIONS
ora #S.TCP.OPTIONS.ACK
sta (ZPFrameOutPtr),y sta (ZPFrameOutPtr),y
ldx #3 ldx #3

View File

@ -114,7 +114,6 @@ L.ARP.CACHE .DA ARP.CACHE
L.DNS.CACHE .DA DNS.CACHE L.DNS.CACHE .DA DNS.CACHE
L.SKT.Template .DA SKT.Template L.SKT.Template .DA SKT.Template
L.HST.SScanF .DA HST.SScanF L.HST.SScanF .DA HST.SScanF
L.TmpByte .DA TmpByte
L.IOCTL .DA IOCTL L.IOCTL .DA IOCTL
L.DCB.NIC .DA DCB.NIC L.DCB.NIC .DA DCB.NIC
L.TCP.IN.JMP .DA TCP.IN.JMP.CLOSED L.TCP.IN.JMP .DA TCP.IN.JMP.CLOSED
@ -218,7 +217,7 @@ POLL >PUSHW L.IOCTL
PULSE and #S.EVT.F.T1SEC PULSE and #S.EVT.F.T1SEC
beq .1 beq .1
jsr ARP.EXPIRE * jsr ARP.EXPIRE
jsr DNS.EXPIRE jsr DNS.EXPIRE
.1 jsr DNS.POLL .1 jsr DNS.POLL
@ -367,7 +366,6 @@ TmpDWord .BS 4
TmpOffset .BS 2 TmpOffset .BS 2
hFrameIn .BS 1 hFrameIn .BS 1
hFrameOut .BS 1 hFrameOut .BS 1
bTextMode .BS 1
HST.SScanF .AZ "%d.%d.%d.%d" HST.SScanF .AZ "%d.%d.%d.%d"
IP.ID .BS 2 IP.ID .BS 2
IP.CHECKSUM .BS 4 IP.CHECKSUM .BS 4