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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -169,13 +169,28 @@ TCP.IN.JMP.SYNSENT
dex
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
jsr TCP.OUT.SendOptA SYN.ACK recieved, Send, ACK
bcs .9
ldy #S.SOCKET.TCP.STATUS
lda #S.SOCKET.TCP.STATUS.ESTBLSH
sta (ZPPtrSKT),y
sta (ZPPtrSKT),y
jsr SKT.StoreTCB
.8 clc
.9 rts
@ -450,7 +465,6 @@ TCP.OUT.SendOptA
TCP.OUT.SendOptA.1
ldy #S.TCP.OPTIONS
ora #S.TCP.OPTIONS.ACK
sta (ZPFrameOutPtr),y
ldx #3

View File

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