Kernel version 0.9 : TCP & Sockets, bugfix session #4

This commit is contained in:
Rémy GIBERT 2017-02-17 17:39:38 +01:00
parent b5f7300385
commit 6775ed4e56
5 changed files with 172 additions and 77 deletions

Binary file not shown.

Binary file not shown.

View File

@ -576,29 +576,73 @@ SKT.AddToQueueA sta .2+1
rts rts
*-------------------------------------- *--------------------------------------
* From TCP.IN * From TCP.IN
* Src : A,X
* Dst : hOutMem/OUTTAIL
*--------------------------------------
SKT.FreeDataFromSktOutAX
pha
ldy #S.SOCKET.SQ.OUTTAIL
clc
adc (ZPPtrSKT),y
sta (ZPPtrSKT),y
iny
txa
adc (ZPPtrSKT),y
and /K.TCP.WSIZE-1
sta (ZPPtrSKT),y
pla
sta .1+1
stx .2+1
ldy #S.SOCKET.SQ.OUTFREE
clc
adc (ZPPtrSKT),y
sta (ZPPtrSKT),y
iny
txa
adc (ZPPtrSKT),y
sta (ZPPtrSKT),y
ldy #S.SOCKET.SQ.OUTUSED
sec
lda (ZPPtrSKT),y
.1 sbc #$ff
sta (ZPPtrSKT),y
iny
adc (ZPPtrSKT),y
.2 sbc #$ff
sta (ZPPtrSKT),y
rts
*--------------------------------------
* From TCP.IN
* Src : ZPDataInPtr/ZPDataInLen * Src : ZPDataInPtr/ZPDataInLen
* Dst : hInMem/INHEAD * Dst : hInMem/INHEAD
*-------------------------------------- *--------------------------------------
SKT.AddDataToSktIn SKT.AddDataToSktIn
jsr SKT.GetCopy jsr SKT.GetTCB
ldx ZPDataInLen ldx ZPDataInLen
cpx SKT.TmpCache+S.SOCKET.SQ.INFREE cpx SKT.TCBCache+S.SOCKET.SQ.INFREE
lda ZPDataInLen+1 lda ZPDataInLen+1
sbc SKT.TmpCache+S.SOCKET.SQ.INFREE+1 sbc SKT.TCBCache+S.SOCKET.SQ.INFREE+1
bcc .9 Not enough room in Q bcc .9 Not enough room in Q
lda SKT.TmpCache+S.SOCKET.STREAM.hInMem lda SKT.TCBCache+S.SOCKET.STREAM.hInMem
>SYSCALL GetMemPtrA >SYSCALL GetMemPtrA
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base >STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
lda ZPTmpPtr1 lda ZPTmpPtr1
clc clc
adc SKT.TmpCache+S.SOCKET.SQ.INHEAD adc SKT.TCBCache+S.SOCKET.SQ.INHEAD
sta ZPTmpPtr2 sta ZPTmpPtr2
lda ZPTmpPtr1+1 lda ZPTmpPtr1+1
adc SKT.TmpCache+S.SOCKET.SQ.INHEAD+1 adc SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
sta ZPTmpPtr2+1 Make ZPTmpPtr2=base+Tail sta ZPTmpPtr2+1 Make ZPTmpPtr2=base+Tail
lda ZPDataInLen lda ZPDataInLen
@ -627,13 +671,13 @@ SKT.AddDataToSktIn
bne .4 bne .4
inc ZPTmpPtr2+1 inc ZPTmpPtr2+1
.4 inc SKT.TmpCache+S.SOCKET.SQ.INHEAD .4 inc SKT.TCBCache+S.SOCKET.SQ.INHEAD
bne .1 bne .1
inc SKT.TmpCache+S.SOCKET.SQ.INHEAD+1 inc SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
lda SKT.TmpCache+S.SOCKET.SQ.INHEAD+1 lda SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
cmp /K.TCP.WSIZE cmp /K.TCP.WSIZE
bne .1 bne .1
stz SKT.TmpCache+S.SOCKET.SQ.INHEAD+1 stz SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
lda ZPTmpPtr1 Dst Ptr=Buffer Base lda ZPTmpPtr1 Dst Ptr=Buffer Base
sta ZPTmpPtr2 sta ZPTmpPtr2
@ -644,23 +688,23 @@ SKT.AddDataToSktIn
.9 sec .9 sec
rts rts
.8 lda SKT.TmpCache+S.SOCKET.SQ.INFREE .8 lda SKT.TCBCache+S.SOCKET.SQ.INFREE
sec sec
sbc ZPDataInLen sbc ZPDataInLen
sta SKT.TmpCache+S.SOCKET.SQ.INFREE sta SKT.TCBCache+S.SOCKET.SQ.INFREE
lda SKT.TmpCache+S.SOCKET.SQ.INFREE+1 lda SKT.TCBCache+S.SOCKET.SQ.INFREE+1
sbc ZPDataInLen+1 sbc ZPDataInLen+1
sta SKT.TmpCache+S.SOCKET.SQ.INFREE+1 sta SKT.TCBCache+S.SOCKET.SQ.INFREE+1
lda SKT.TmpCache+S.SOCKET.SQ.INUSED lda SKT.TCBCache+S.SOCKET.SQ.INUSED
clc clc
adc ZPDataInLen adc ZPDataInLen
sta SKT.TmpCache+S.SOCKET.SQ.INUSED sta SKT.TCBCache+S.SOCKET.SQ.INUSED
lda SKT.TmpCache+S.SOCKET.SQ.INUSED+1 lda SKT.TCBCache+S.SOCKET.SQ.INUSED+1
adc ZPDataInLen+1 adc ZPDataInLen+1
sta SKT.TmpCache+S.SOCKET.SQ.INUSED+1 sta SKT.TCBCache+S.SOCKET.SQ.INUSED+1
jsr SKT.PutCopy jsr SKT.StoreTCB
clc clc
rts rts
*-------------------------------------- *--------------------------------------
@ -669,25 +713,25 @@ SKT.AddDataToSktIn
* Dst : hOutMem/OUTHEAD * Dst : hOutMem/OUTHEAD
*-------------------------------------- *--------------------------------------
SKT.AddDataToSktOut SKT.AddDataToSktOut
jsr SKT.GetCopy jsr SKT.GetTCB
ldx ZPDataInLen ldx ZPDataInLen
cpx SKT.TmpCache+S.SOCKET.SQ.OUTFREE cpx SKT.TCBCache+S.SOCKET.SQ.OUTFREE
lda ZPDataInLen+1 lda ZPDataInLen+1
sbc SKT.TmpCache+S.SOCKET.SQ.OUTFREE+1 sbc SKT.TCBCache+S.SOCKET.SQ.OUTFREE+1
bcc .9 Not enough room in Q bcc .9 Not enough room in Q
lda SKT.TmpCache+S.SOCKET.STREAM.hOutMem lda SKT.TCBCache+S.SOCKET.STREAM.hOutMem
>SYSCALL GetMemPtrA >SYSCALL GetMemPtrA
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base >STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
lda ZPTmpPtr1 lda ZPTmpPtr1
clc clc
adc SKT.TmpCache+S.SOCKET.SQ.OUTHEAD adc SKT.TCBCache+S.SOCKET.SQ.OUTHEAD
sta ZPTmpPtr2 sta ZPTmpPtr2
lda ZPTmpPtr1+1 lda ZPTmpPtr1+1
adc SKT.TmpCache+S.SOCKET.SQ.OUTHEAD+1 adc SKT.TCBCache+S.SOCKET.SQ.OUTHEAD+1
sta ZPTmpPtr2+1 Make ZPTmpPtr2=base+Tail sta ZPTmpPtr2+1 Make ZPTmpPtr2=base+Tail
lda ZPDataInLen lda ZPDataInLen
@ -716,13 +760,13 @@ SKT.AddDataToSktOut
bne .4 bne .4
inc ZPTmpPtr2+1 inc ZPTmpPtr2+1
.4 inc SKT.TmpCache+S.SOCKET.SQ.OUTHEAD .4 inc SKT.TCBCache+S.SOCKET.SQ.OUTHEAD
bne .1 bne .1
inc SKT.TmpCache+S.SOCKET.SQ.OUTHEAD+1 inc SKT.TCBCache+S.SOCKET.SQ.OUTHEAD+1
lda SKT.TmpCache+S.SOCKET.SQ.OUTHEAD+1 lda SKT.TCBCache+S.SOCKET.SQ.OUTHEAD+1
cmp /K.TCP.WSIZE cmp /K.TCP.WSIZE
bne .1 bne .1
stz SKT.TmpCache+S.SOCKET.SQ.OUTHEAD+1 stz SKT.TCBCache+S.SOCKET.SQ.OUTHEAD+1
lda ZPTmpPtr1 Dst Ptr=Buffer Base lda ZPTmpPtr1 Dst Ptr=Buffer Base
sta ZPTmpPtr2 sta ZPTmpPtr2
@ -733,23 +777,23 @@ SKT.AddDataToSktOut
.9 sec .9 sec
rts rts
.8 lda SKT.TmpCache+S.SOCKET.SQ.OUTFREE .8 lda SKT.TCBCache+S.SOCKET.SQ.OUTFREE
sec sec
sbc ZPDataInLen sbc ZPDataInLen
sta SKT.TmpCache+S.SOCKET.SQ.OUTFREE sta SKT.TCBCache+S.SOCKET.SQ.OUTFREE
lda SKT.TmpCache+S.SOCKET.SQ.OUTFREE+1 lda SKT.TCBCache+S.SOCKET.SQ.OUTFREE+1
sbc ZPDataInLen+1 sbc ZPDataInLen+1
sta SKT.TmpCache+S.SOCKET.SQ.OUTFREE+1 sta SKT.TCBCache+S.SOCKET.SQ.OUTFREE+1
lda SKT.TmpCache+S.SOCKET.SQ.OUTUSED lda SKT.TCBCache+S.SOCKET.SQ.OUTUSED
clc clc
adc ZPDataInLen adc ZPDataInLen
sta SKT.TmpCache+S.SOCKET.SQ.OUTUSED sta SKT.TCBCache+S.SOCKET.SQ.OUTUSED
lda SKT.TmpCache+S.SOCKET.SQ.OUTUSED+1 lda SKT.TCBCache+S.SOCKET.SQ.OUTUSED+1
adc ZPDataInLen+1 adc ZPDataInLen+1
sta SKT.TmpCache+S.SOCKET.SQ.OUTUSED+1 sta SKT.TCBCache+S.SOCKET.SQ.OUTUSED+1
jsr SKT.PutCopy jsr SKT.StoreTCB
clc clc
rts rts
*-------------------------------------- *--------------------------------------
@ -758,19 +802,19 @@ SKT.AddDataToSktOut
* Dst : ZPDataOutPtr/ZPDataOutLen * Dst : ZPDataOutPtr/ZPDataOutLen
*-------------------------------------- *--------------------------------------
SKT.GetDataFromSktOut SKT.GetDataFromSktOut
jsr SKT.GetCopy jsr SKT.GetTCB
lda SKT.TmpCache+S.SOCKET.STREAM.hOutMem lda SKT.TCBCache+S.SOCKET.STREAM.hOutMem
>SYSCALL GetMemPtrA >SYSCALL GetMemPtrA
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base >STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
lda ZPTmpPtr1 lda ZPTmpPtr1
clc clc
adc SKT.TmpCache+S.SOCKET.SQ.OUTTAIL adc SKT.TCBCache+S.SOCKET.SQ.OUTTAIL
sta ZPTmpPtr2 sta ZPTmpPtr2
lda ZPTmpPtr1+1 lda ZPTmpPtr1+1
adc SKT.TmpCache+S.SOCKET.SQ.OUTTAIL+1 adc SKT.TCBCache+S.SOCKET.SQ.OUTTAIL+1
sta ZPTmpPtr2+1 sta ZPTmpPtr2+1
lda ZPDataOutLen lda ZPDataOutLen
@ -799,13 +843,13 @@ SKT.GetDataFromSktOut
bne .4 bne .4
inc ZPTmpPtr2+1 inc ZPTmpPtr2+1
.4 inc SKT.TmpCache+S.SOCKET.SQ.OUTTAIL .4 inc SKT.TCBCache+S.SOCKET.SQ.OUTTAIL
bne .1 bne .1
inc SKT.TmpCache+S.SOCKET.SQ.OUTTAIL+1 inc SKT.TCBCache+S.SOCKET.SQ.OUTTAIL+1
lda SKT.TmpCache+S.SOCKET.SQ.OUTTAIL+1 lda SKT.TCBCache+S.SOCKET.SQ.OUTTAIL+1
cmp /K.TCP.WSIZE cmp /K.TCP.WSIZE
bne .1 bne .1
stz SKT.TmpCache+S.SOCKET.SQ.OUTTAIL+1 stz SKT.TCBCache+S.SOCKET.SQ.OUTTAIL+1
lda ZPTmpPtr1 Dst Ptr=Buffer Base lda ZPTmpPtr1 Dst Ptr=Buffer Base
sta ZPTmpPtr2 sta ZPTmpPtr2
@ -816,7 +860,7 @@ SKT.GetDataFromSktOut
.8 clc .8 clc
rts rts
*-------------------------------------- *--------------------------------------
* From SKT.Write * From SKT.Read
* In: * In:
* Src : hInMem/INTAIL * Src : hInMem/INTAIL
* Dst : ZPDataOutPtr/ZPDataOutLen * Dst : ZPDataOutPtr/ZPDataOutLen
@ -831,15 +875,15 @@ SKT.GetDataFromSktIn
>SYSCALL GetMemPtrA >SYSCALL GetMemPtrA
>STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base >STYA ZPTmpPtr1 Make ZPTmpPtr1=buffer base
jsr SKT.GetCopy jsr SKT.GetTCB
lda ZPTmpPtr1 lda ZPTmpPtr1
clc clc
adc SKT.TmpCache+S.SOCKET.SQ.INTAIL adc SKT.TCBCache+S.SOCKET.SQ.INTAIL
sta ZPTmpPtr2 sta ZPTmpPtr2
lda ZPTmpPtr1+1 lda ZPTmpPtr1+1
adc SKT.TmpCache+S.SOCKET.SQ.INTAIL+1 adc SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
sta ZPTmpPtr2+1 sta ZPTmpPtr2+1
lda ZPDataOutLen lda ZPDataOutLen
@ -862,25 +906,25 @@ SKT.GetDataFromSktIn
beq .7 beq .7
pha pha
.2 lda SKT.TmpCache+S.SOCKET.SQ.INTAIL .2 lda SKT.TCBCache+S.SOCKET.SQ.INTAIL
eor SKT.TmpCache+S.SOCKET.SQ.INHEAD eor SKT.TCBCache+S.SOCKET.SQ.INHEAD
bne .3 bne .3
lda SKT.TmpCache+S.SOCKET.SQ.INTAIL+1 lda SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
eor SKT.TmpCache+S.SOCKET.SQ.INHEAD+1 eor SKT.TCBCache+S.SOCKET.SQ.INHEAD+1
beq .8 no more data.... beq .8 no more data....
.3 lda (ZPTmpPtr2) .3 lda (ZPTmpPtr2)
pha pha
inc SKT.TmpCache+S.SOCKET.SQ.INTAIL inc SKT.TCBCache+S.SOCKET.SQ.INTAIL
bne .5 bne .5
inc SKT.TmpCache+S.SOCKET.SQ.INTAIL+1 inc SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
lda SKT.TmpCache+S.SOCKET.SQ.INTAIL+1 lda SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
cmp /K.TCP.WSIZE cmp /K.TCP.WSIZE
bne .4 bne .4
stz SKT.TmpCache+S.SOCKET.SQ.INTAIL+1 stz SKT.TCBCache+S.SOCKET.SQ.INTAIL+1
lda ZPTmpPtr1 lda ZPTmpPtr1
sta ZPTmpPtr2 sta ZPTmpPtr2
lda ZPTmpPtr1+1 lda ZPTmpPtr1+1
@ -919,25 +963,25 @@ SKT.GetDataFromSktIn
eor ZPTmpPtr3+1 eor ZPTmpPtr3+1
beq .9 beq .9
lda SKT.TmpCache+S.SOCKET.SQ.INFREE lda SKT.TCBCache+S.SOCKET.SQ.INFREE
clc clc
adc ZPTmpPtr3 adc ZPTmpPtr3
sta SKT.TmpCache+S.SOCKET.SQ.INFREE sta SKT.TCBCache+S.SOCKET.SQ.INFREE
lda SKT.TmpCache+S.SOCKET.SQ.INFREE+1 lda SKT.TCBCache+S.SOCKET.SQ.INFREE+1
adc ZPTmpPtr3+1 adc ZPTmpPtr3+1
sta SKT.TmpCache+S.SOCKET.SQ.INFREE+1 sta SKT.TCBCache+S.SOCKET.SQ.INFREE+1
lda SKT.TmpCache+S.SOCKET.SQ.INUSED lda SKT.TCBCache+S.SOCKET.SQ.INUSED
sec sec
sbc ZPTmpPtr3 sbc ZPTmpPtr3
sta SKT.TmpCache+S.SOCKET.SQ.INUSED sta SKT.TCBCache+S.SOCKET.SQ.INUSED
lda SKT.TmpCache+S.SOCKET.SQ.INUSED+1 lda SKT.TCBCache+S.SOCKET.SQ.INUSED+1
sbc ZPTmpPtr3+1 sbc ZPTmpPtr3+1
sta SKT.TmpCache+S.SOCKET.SQ.INUSED+1 sta SKT.TCBCache+S.SOCKET.SQ.INUSED+1
jsr SKT.PutCopy jsr SKT.StoreTCB
>LDYA ZPTmpPtr3 >LDYA ZPTmpPtr3
clc clc
rts rts
@ -946,15 +990,15 @@ SKT.GetDataFromSktIn
sec sec
rts rts
*-------------------------------------- *--------------------------------------
SKT.GetCopy ldy #S.SOCKET-1 SKT.GetTCB ldy #S.SOCKET-1
.1 lda (ZPPtrSKT),y .1 lda (ZPPtrSKT),y
sta SKT.TmpCache sta SKT.TCBCache,y
dey dey
bpl .1 bpl .1
rts rts
*-------------------------------------- *--------------------------------------
SKT.PutCopy ldy #S.SOCKET-1 SKT.StoreTCB ldy #S.SOCKET-1
.1 lda SKT.TmpCache .1 lda SKT.TCBCache,y
sta (ZPPtrSKT),y sta (ZPPtrSKT),y
dey dey
bpl .1 bpl .1

View File

@ -211,15 +211,66 @@ TCP.IN.JMP.ESTBLSH
ldy #S.TCP.OPTIONS ldy #S.TCP.OPTIONS
lda (ZPFrameInPtr),y lda (ZPFrameInPtr),y
bit #S.TCP.OPTIONS.ACK bit #S.TCP.OPTIONS.ACK
beq .1 beq .2
jsr TCP.UpdateSktAckNum ldy #S.TCP.ACK.NUMBER+3 Get new ACK number from FrameIn...
ldx #3
.1 jsr TCP.SetDataInPtrAndLen .1 lda (ZPFrameInPtr),y
sta TmpDWord,x
dey
dex
bpl .1
ldy #S.SOCKET.SQ.ACKNUM Substract old Ack from socket
sec
lda (ZPPtrSKT),y
sbc TmpDWord
pha save result LO for FreeData
lda TmpDWord
sta (ZPPtrSKT),y and store new ACK in skt
iny
lda (ZPPtrSKT),y
sbc TmpDWord+1
tax save result HI for FreeData
lda TmpDWord+1 we stop here, will never be more than K.TCP.WSIZE
sta (ZPPtrSKT),y
iny
lda TmpDWord+2
sta (ZPPtrSKT),y
iny
lda TmpDWord+3
sta (ZPPtrSKT),y
pla
jsr SKT.FreeDataFromSktOutAX
*----------
.2 lda ZPDataInLen
ora ZPDataInLen+1
beq .8 No data in this incoming frame...
ldy #S.TCP.SEQ.NUMBER+3
ldx #3
.3 lda (ZPFrameInPtr),y
sta TmpDWord,x
dey
dex
bpl .3
jsr TCP.SetDataInPtrAndLen
jsr SKT.AddDataToSktIn jsr SKT.AddDataToSktIn
clc .8 clc
rts rts
*-------------------------------------- *--------------------------------------
TCP.IN.JMP.CLWAIT TCP.IN.JMP.CLWAIT

View File

@ -293,13 +293,13 @@ DNS.HostName .BS K.DNS.MAXLEN+1
DNS.TmpCache .BS S.DNSCACHE DNS.TmpCache .BS S.DNSCACHE
ARP.TmpCache .BS S.ARP ARP.TmpCache .BS S.ARP
SKT.Template .BS S.SOCKET.TEMPLATE SKT.Template .BS S.SOCKET.TEMPLATE
SKT.TmpCache .BS S.SOCKET SKT.TCBCache .BS S.SOCKET
TmpDWord .BS 4 TmpDWord .BS 4
TmpOffset .BS 2
hFrameIn .BS 1 hFrameIn .BS 1
hFrameOut .BS 1 hFrameOut .BS 1
hSocket .BS 1 hSocket .BS 1
bTextMode .BS 1 bTextMode .BS 1
TmpOffset .BS 2
HST.DecStr .BS 4 HST.DecStr .BS 4
HST.IP .BS 5 HST.IP .BS 5
IP.ID .BS 2 IP.ID .BS 2