Kernel version 0.9 : TCPIP, TCP code reorg

This commit is contained in:
Rémy GIBERT 2017-02-01 17:49:44 +01:00
parent ec385bd23f
commit 303d1d692c
5 changed files with 126 additions and 44 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -174,9 +174,9 @@ S.SOCKET.HQ.MAX .EQ 14 14 hMem (frames)
* Stream type Queue
S.SOCKET.SQ.hInMem .EQ 16
S.SOCKET.SQ.hOutMem .EQ 17
S.SOCKET.SQ.SIZE .EQ 18
S.SOCKET.SQ.HEAD .EQ 20
S.SOCKET.SQ.TAIL .EQ 22
*S.SOCKET.SQ.SIZE .EQ 18
S.SOCKET.SQ.INHEAD .EQ 20
S.SOCKET.SQ.INTAIL .EQ 22
S.SOCKET.SQ.SEQNUM .EQ 24
S.SOCKET.SQ.ACKNUM .EQ 28
*

View File

@ -219,37 +219,27 @@ TCP.IN.JMP.ESTBLSH
ldy #S.TCP.OPTIONS
lda (ZPFrameInPtr),y
cmp #S.TCP.OPTIONS.ACK
bne .3
bne .1
jsr TCP.UpdateSktAckNum
.1 jsr TCP.SetDataInPtrAndLen
jsr TCP.AddDataToSkt
jsr TCP.UpdateAck
.3 lda ZPFrameInPtr
clc
adc #S.TCP
sta ZPDataInPtr
lda ZPFrameInPtr+1
adc /S.TCP
sta ZPDataInPtr+1
ldy #S.TCP.DATAOFFSET
lda (ZPFrameInPtr),y
lsr
lsr
rts
*--------------------------------------
TCP.IN.JMP.CLWAIT
TCP.IN.JMP.LASTACK
TCP.IN.JMP.FINWT1
TCP.IN.JMP.FINWT2
TCP.IN.JMP.CLOSING
TCP.IN.JMP.TIMEWT
clc
adc ZPDataInPtr
sta ZPDataInPtr
lda ZPDataInPtr+1
adc ZPDataInPtr+1
sta ZPDataInPtr+1
lda ZPDataInPtr
sec
sbc ZPFrameInPtr
sta ZPDataInLen
lda ZPDataInPtr+1
sbc ZPFrameInPtr+1
sta ZPDataInLen+1
rts
*--------------------------------------
TCP.UpdateSktAckNum
ldy #S.SOCKET.SQ.ACKNUM+3
lda (ZPPtrSKT),y
clc
@ -267,22 +257,9 @@ TCP.IN.JMP.ESTBLSH
lda (ZPPtrSKT),y
adc #0
sta (ZPPtrSKT),y
jsr TCP.SendACK
clc
rts
*--------------------------------------
TCP.IN.JMP.CLWAIT
TCP.IN.JMP.LASTACK
TCP.IN.JMP.FINWT1
TCP.IN.JMP.FINWT2
TCP.IN.JMP.CLOSING
TCP.IN.JMP.TIMEWT
clc
rts
*--------------------------------------
TCP.UpdateAck ldy #S.TCP.ACK.NUMBER
ldy #S.TCP.ACK.NUMBER
ldx #4
.1 lda (ZPFrameInPtr),y
@ -301,6 +278,111 @@ TCP.UpdateAck ldy #S.TCP.ACK.NUMBER
bne .2
rts
*--------------------------------------
TCP.SetDataInPtrAndLen
ldy #S.TCP.DATAOFFSET
lda (ZPFrameInPtr),y
and #$F0
lsr
lsr
adc #S.TCP
sta TmpOffset
lda #0
* clc
adc /S.TCP
sta TmpOffset+1 TmpOffset=Data Offset in Frame
lda ZPFrameInPtr
* clc
adc TmpOffset
sta ZPDataInPtr
lda ZPFrameInPtr+1
adc #0
sta ZPDataInPtr+1
lda ZPFrameInLen
sec
sbc TmpOffset
sta ZPDataInLen
lda ZPFrameInLen+1
sbc TmpOffset+1
sta ZPDataInLen+1
rts
*--------------------------------------
TCP.AddDataToSkt
ldy #S.SOCKET.SQ.hInMem
lda (ZPPtrSKT),y
>SYSCALL GetMemPtrA
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
ldy #S.SOCKET.SQ.INHEAD
lda (ZPPtrSKT),y
tax save LO for compare later
clc
adc ZPTmpPtr1
sta ZPTmpPtr2 Make ZPTmpPtr2=actual head
iny
lda (ZPPtrSKT),y
pha save HI for compare later
adc ZPTmpPtr1+1
sta ZPTmpPtr2+1
lda ZPDataInLen
eor #$ff
sta ZPTmpPtr3 Make ZPTmpPtr3=!count
lda ZPDataInLen+1
eor #$ff
sta ZPTmpPtr3+1
ldy #0
.1 inc ZPTmpPtr3
bne .2
inc ZPTmpPtr3+1
beq .9
.2 lda (ZPDataInPtr),y
sta (ZPTmpPtr2)
iny
bne .3
inc ZPDataInPtr+1
.3 inc ZPTmpPtr2
bne .4
inc ZPTmpPtr2+1
.4 pla
inx
bne .5
inc
.5 pha
cpx #K.TCP.WSIZE
sbc /K.TCP.WSIZE
bcc .1
.6 inc ZPTmpPtr3
bne .7
inc ZPTmpPtr3+1
beq .9
.7 lda (ZPDataInPtr),y
sta (ZPTmpPtr1)
iny
bne .8
inc ZPDataInPtr+1
.8 inc ZPTmpPtr1
bne .6
inc ZPTmpPtr1+1
bra .6
.9 pla
rts
*--------------------------------------
TCP.SendACK lda #S.TCP.OPTIONS.ACK
bra TCP.SendMSG
TCP.SendSYNACK lda #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK