Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-09-21 17:28:46 +02:00
parent e040a2a11e
commit 556c800444
10 changed files with 190 additions and 358 deletions

Binary file not shown.

Binary file not shown.

View File

@ -171,7 +171,8 @@ S.TCB.OUTFREE .EQ 14
S.TCB.OUTTOSEND .EQ 16 S.TCB.OUTTOSEND .EQ 16
S.TCB.OUTUSED .EQ 18 S.TCB.OUTUSED .EQ 18
* *
S.TCB.INLASTSEQNUM .EQ 20 Rcvd:Last SEQ recieved from remote S.TCB.INLASTSEQNUM .EQ 20 Rcvd:Last SEQ received from remote
S.TCB.OUTSEQNUM .EQ 24 Send:SEQ sent not yet ACKed (retransmit) S.TCB.OUTSEQNUM .EQ 24 Send:SEQ sent not yet ACKed (retransmit)
S.TCB.OUTNEXTSEQ .EQ 28 Send:Next SEQ to send S.TCB.OUTNEXTSEQ .EQ 28 Send:Next SEQ to send
S.TCB.OUTACKNUM .EQ 32 Send:ACK to send to remote S.TCB.OUTACKNUM .EQ 32 Send:ACK to send to remote

View File

@ -56,12 +56,14 @@ ARP.Add >PULLW ZPPtrIP IP
stz ARP.TmpCache+S.ARPCACHE.TTL+1 stz ARP.TmpCache+S.ARPCACHE.TTL+1
ldy #3 ldy #3
.1 lda (ZPPtrIP),y .1 lda (ZPPtrIP),y
sta ARP.TmpCache+S.ARPCACHE.IP,y sta ARP.TmpCache+S.ARPCACHE.IP,y
dey dey
bpl .1 bpl .1
ldy #5 ldy #5
.2 lda (ZPPtrMAC),y .2 lda (ZPPtrMAC),y
sta ARP.TmpCache+S.ARPCACHE.MAC,y sta ARP.TmpCache+S.ARPCACHE.MAC,y
dey dey
@ -76,6 +78,7 @@ ARP.ADD.I sta ARP.TmpCache
jsr ARP.FIND.FREE jsr ARP.FIND.FREE
.1 ldy #S.ARPCACHE-1 .1 ldy #S.ARPCACHE-1
.2 lda ARP.TmpCache,y .2 lda ARP.TmpCache,y
sta (ZPCachePtr),y sta (ZPCachePtr),y
dey dey
@ -84,13 +87,13 @@ ARP.ADD.I sta ARP.TmpCache
clc clc
rts rts
*/-------------------------------------- */--------------------------------------
* # ARP.GetCAche * # ARP.GetCache
* Return a Ptr to ARP Cache Table * Return a Ptr to ARP Cache Table
* **In:** * **In:**
* **Out:** * **Out:**
* Y,A = PTR to ARP.CACHE * Y,A = PTR to ARP.CACHE
*\-------------------------------------- *\--------------------------------------
ARP.GetCAche >LDYA L.ARP.CACHE ARP.GetCache >LDYA L.ARP.CACHE
clc clc
rts rts
*-------------------------------------- *--------------------------------------

View File

@ -3,7 +3,7 @@ PREFIX /A2OSX.BUILD
AUTO 4,1 AUTO 4,1
.LIST OFF .LIST OFF
*-------------------------------------- *--------------------------------------
* FRM.New * FRM.NewIP
* In: * In:
* Y,A = DataLen * Y,A = DataLen
* X = S.IP.PROTOCOL.xxx * X = S.IP.PROTOCOL.xxx
@ -177,7 +177,7 @@ FRM.SendIP ldx #3 Copy SRC.IP even if IP offload
lda (ZPFrameOutPtr),y lda (ZPFrameOutPtr),y
cmp #S.IP.PROTOCOL.TCP cmp #S.IP.PROTOCOL.TCP
bne .3 bne .3
jsr TCP.ComputeChecksum jsr IP.ComputeTCPChecksum
bra .5 bra .5
.3 cmp #S.IP.PROTOCOL.UDP .3 cmp #S.IP.PROTOCOL.UDP
@ -196,12 +196,12 @@ FRM.SendIP ldx #3 Copy SRC.IP even if IP offload
dey dey
sta (ZPFrameOutPtr),y sta (ZPFrameOutPtr),y
jsr UDP.ComputeChecksum jsr IP.ComputeUDPChecksum
bra .5 bra .5
.4 cmp #S.IP.PROTOCOL.ICMP .4 cmp #S.IP.PROTOCOL.ICMP
bne .5 bne .5
jsr ICMP.ComputeChecksum jsr IP.ComputeICMPChecksum
.5 lda DCB.NIC+S.DCB.NIC.FLAGS .5 lda DCB.NIC+S.DCB.NIC.FLAGS
and #S.DCB.NIC.FLAGS.ARPOFFLOAD and #S.DCB.NIC.FLAGS.ARPOFFLOAD
@ -217,7 +217,7 @@ FRM.SendIP ldx #3 Copy SRC.IP even if IP offload
lda hFrameOut lda hFrameOut
beq .9 beq .9
>SYSCALL FreeMem >SYSCALL FreeMem
stz hFrameOut
clc clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------

View File

@ -6,29 +6,18 @@ AUTO 4,1
HST.GetByName >PULLW ZPPtrDNS HST.GetByName >PULLW ZPPtrDNS
>PULLW ZPPtrIP >PULLW ZPPtrIP
lda ZPPtrIP ldx #3
.1 txa
clc clc
adc #3 adc ZPPtrIP
tay tay
lda ZPPtrIP+1 lda ZPPtrIP+1
adc #0 adc #0
>PUSHYA @IP[3] >PUSHYA @IP[3][2][1][0]
lda ZPPtrIP dex
clc bpl .1
adc #2
tay
lda ZPPtrIP+1
adc #0
>PUSHYA @IP[2]
>LDYA ZPPtrIP
iny
bne .1
inc
.1 >PUSHYA @IP[1]
>PUSHW ZPPtrIP @IP[0]
>PUSHBI 8 4 PTRs on stack >PUSHBI 8 4 PTRs on stack
>PUSHW L.HST.SScanF >PUSHW L.HST.SScanF

View File

@ -25,47 +25,24 @@ ICMP.IN.ECHOREQ ldy #S.IP.DST+3
lda #S.ICMP.TYPE.ECHOREP lda #S.ICMP.TYPE.ECHOREP
sta (ZPFrameInPtr),y sta (ZPFrameInPtr),y
ldy #S.IP.SRC+3 jsr ARP.AddFromFrameInPtr
lda hFrameIn
stz hFrameIn DO NOT DISCARD this frame,it is SOURCE frame!!!
sta hFrameOut
>LDYA ZPFrameInPtr
>STYA ZPFrameOutPtr
ldx #3 ldx #3
.2 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.IP,x
dey
dex
bpl .2
ldy #S.IP.DST+3 ldy #S.IP.DST+3
ldx #3
.3 lda ARP.TmpCache+S.ARPCACHE.IP,x .3 lda ARP.TmpCache+S.ARPCACHE.IP,x
sta (ZPFrameInPtr),y sta (ZPFrameOutPtr),y
dey dey
dex dex
bpl .3 bpl .3
ldy #S.ETH.SRCMAC+5
ldx #5
.4 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.MAC,x
dey
dex
bpl .4
lda #K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL
lda /K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL+1
lda #S.ARPCACHE.STATUS.RESOLVED
jsr ARP.ADD.I
lda hFrameIn
stz hFrameIn
sta hFrameOut DO NOT DISCARD this frame,it is SOURCE frame!!!
>LDYA ZPFrameInPtr
>STYA ZPFrameOutPtr
jmp FRM.SendIP jmp FRM.SendIP
ICMP.IN.EXIT lda hFrameIn ICMP.IN.EXIT lda hFrameIn
@ -114,7 +91,7 @@ ICMP.IN.ECHOREP jsr IP.FillSKT.TemplateSrcDstIP
lda hFrameIn lda hFrameIn
jsr SKT.AddToQueueA jsr SKT.AddToQueueA
bcs .9 Q full, discard... bcs ICMP.IN.EXIT Q full, discard...
rts DO NOT Discard this queued frame rts DO NOT Discard this queued frame
@ -129,31 +106,7 @@ ICMP.IN.ECHOREP jsr IP.FillSKT.TemplateSrcDstIP
cpx #K.SKTTABLE.SIZE cpx #K.SKTTABLE.SIZE
bne .3 bne .3
.9 lda hFrameIn bra ICMP.IN.EXIT
beq .99
>SYSCALL FreeMem
.99 clc
rts
*--------------------------------------
ICMP.ComputeChecksum
>PUSHW ZPFrameOutLen
>PUSHWI S.ICMP.TYPE
ldy #S.ICMP.CHECKSUM
lda #0
sta (ZPFrameOutPtr),y
iny
sta (ZPFrameOutPtr),y
jsr IP.ComputeChecksum
phy
ldy #S.ICMP.CHECKSUM
sta (ZPFrameOutPtr),y
iny
pla
sta (ZPFrameOutPtr),y
rts
*-------------------------------------- *--------------------------------------
MAN MAN
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.ICMP SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.ICMP

View File

@ -22,73 +22,162 @@ IP.IN ldy #S.IP.PROTOCOL
>SYSCALL FreeMem >SYSCALL FreeMem
rts rts
*-------------------------------------- *--------------------------------------
* In: IP.ComputeICMPChecksum
* PULLW = Start Offset
* PULLW = End Offset
* Out:
* Y,A = CheckSum
*--------------------------------------
IP.ComputeChecksum
>PULLA
clc
adc ZPFrameOutPtr
sta ZPTmpPtr1
>PULLA
adc ZPFrameOutPtr+1
sta ZPTmpPtr1+1
>PULLA
clc
adc ZPFrameOutPtr
sta TmpOffset
>PULLA
adc ZPFrameOutPtr+1
sta TmpOffset+1
stz IP.CHECKSUM stz IP.CHECKSUM
stz IP.CHECKSUM+1 stz IP.CHECKSUM+1
stz IP.CHECKSUM+2
stz IP.CHECKSUM+3
ldy #0 lda ZPFrameOutLen
sec
sbc #S.ICMP.TYPE
eor #$ff
tax
.1 clc lda ZPFrameOutLen+1
sbc /S.ICMP.TYPE
eor #$ff
ldy #S.ICMP.CHECKSUM
jmp IP.ComputeChecksum
*--------------------------------------
IP.ComputeUDPChecksum
ldy #S.UDP.LENGTH
lda (ZPFrameOutPtr),y
clc
* adc /S.IP.PROTOCOL.UDP (all zero)
sta IP.CHECKSUM
iny iny
lda (ZPTmpPtr1),y lda (ZPFrameOutPtr),y
adc #S.IP.PROTOCOL.UDP
sta IP.CHECKSUM+1
jsr IP.AddSrcDstIPToChecksum
lda ZPFrameOutLen
sec
sbc #S.IP
eor #$ff
tax
lda ZPFrameOutLen+1
sbc /S.IP
eor #$ff
ldy #S.UDP.CHECKSUM
bra IP.ComputeChecksum
*--------------------------------------
IP.ComputeTCPChecksum
lda ZPFrameOutLen
sec
sbc #S.IP
sta ZPDataInLen
lda ZPFrameOutLen+1
sbc /S.IP
sta ZPDataInLen+1
clc
* lda ZPDataInLen+1
* adc /S.IP.PROTOCOL.TCP (all zero)
sta IP.CHECKSUM
lda ZPDataInLen
adc #S.IP.PROTOCOL.TCP
sta IP.CHECKSUM+1
jsr IP.AddSrcDstIPToChecksum
lda ZPDataInLen
eor #$ff
tax
lda ZPDataInLen+1
eor #$ff
ldy #S.TCP.CHECKSUM
*--------------------------------------
* X,A = !ByteCount, Y = Offset in Frame
*--------------------------------------
IP.ComputeChecksum
phy Save Offset
pha Save !ByteCount.HI
lda #0 Reset Checksum
sta (ZPFrameOutPtr),y
iny
sta (ZPFrameOutPtr),y
>LDYA ZPFrameOutPtr
>STYA ZPTmpPtr1
ldy #S.IP
.1 inx
bne .11
pla
inc
beq .8
pha
.11 lda (ZPTmpPtr1),y
adc IP.CHECKSUM adc IP.CHECKSUM
sta IP.CHECKSUM sta IP.CHECKSUM
dey iny
lda (ZPTmpPtr1),y bne .20
inc ZPTmpPtr1+1
.20 inx
bne .2
pla
inc
beq .7
pha
.2 lda (ZPTmpPtr1),y
adc IP.CHECKSUM+1 adc IP.CHECKSUM+1
sta IP.CHECKSUM+1 sta IP.CHECKSUM+1
bcc .3 iny
inc IP.CHECKSUM+2
bne .3
inc IP.CHECKSUM+3
.3 lda ZPTmpPtr1
clc
adc #2
sta ZPTmpPtr1
bcc .4
inc ZPTmpPtr1+1
.4 cmp TmpOffset
bne .1
lda ZPTmpPtr1+1
cmp TmpOffset+1
bne .1 bne .1
inc ZPTmpPtr1+1
bra .1
.7 adc IP.CHECKSUM+1 A=0 from beq .7
sta IP.CHECKSUM+1
.8 ply
lda IP.CHECKSUM lda IP.CHECKSUM
clc adc #0 Don't forget to add last carry!!!
adc IP.CHECKSUM+2
eor #$FF eor #$FF
tay sta (ZPFrameOutPtr),y
iny
lda IP.CHECKSUM+1 lda IP.CHECKSUM+1
adc IP.CHECKSUM+3 adc #0 Don't forget to add last carry!!!
eor #$FF eor #$FF
sta (ZPFrameOutPtr),y
rts
*--------------------------------------
IP.AddSrcDstIPToChecksum
ldy #S.IP.SRC
ldx #4 4 words for SRC & DST IP
.1 lda (ZPFrameOutPtr),y
adc IP.CHECKSUM
sta IP.CHECKSUM
iny
lda (ZPFrameOutPtr),y
adc IP.CHECKSUM+1
sta IP.CHECKSUM+1
iny
dex
bne .1
rts rts
*-------------------------------------- *--------------------------------------
IP.FillSKT.TemplateSrcDstIPP IP.FillSKT.TemplateSrcDstIPP
@ -179,11 +268,13 @@ IP.SetDestMAC ldy #S.IP.DST
ldx #5 ldx #5
ldy #S.ETH.DSTMAC+5 ldy #S.ETH.DSTMAC+5
.11 lda ARP.TmpCache+S.ARPCACHE.MAC,x .11 lda ARP.TmpCache+S.ARPCACHE.MAC,x
sta (ZPFrameOutPtr),y sta (ZPFrameOutPtr),y
dey dey
dex dex
bpl .11 bpl .11
clc clc
.99 rts .99 rts
*-------------------------------------- *--------------------------------------

View File

@ -100,25 +100,14 @@ TCP.IN.JMP.LISTEN
.2 lda #$ff .2 lda #$ff
sta ZPPtrSKT+1 sta ZPPtrSKT+1
ldy #S.TCP.SEQNUM+3 Get Remote SEQ jsr TCP.IN.ACKTheSYN
ldx #3
sec
.3 lda (ZPFrameInPtr),y Set OUTACK=SEQ+1 for new socket...
adc #0
sta SKT.TCBCache+S.TCB.INLASTSEQNUM,x
sta SKT.TCBCache+S.TCB.OUTACKNUM,x
dey
dex
bpl .3
jsr SKT.StoreTCB jsr SKT.StoreTCB
jsr ARP.AddFromFrameInPtr jsr ARP.AddFromFrameInPtr
lda #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK lda #S.TCP.OPTIONS.SYN+S.TCP.OPTIONS.ACK
jsr TCP.OUT.SendOptA SYN recieved, Send SYN.ACK jsr TCP.OUT.SendOptA SYN received, Send SYN.ACK
bcs .9 bcs .9
ldy #S.SOCKET.TCP.STATUS ldy #S.SOCKET.TCP.STATUS
@ -156,18 +145,7 @@ TCP.IN.JMP.SYNSENT
dex dex
bpl .1 bpl .1
ldx #3 jsr TCP.IN.ACKTheSYN
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
@ -185,7 +163,7 @@ TCP.IN.JMP.SYNSENT
jmp SKT.Destroy jmp SKT.Destroy
*-------------------------------------- *--------------------------------------
TCP.IN.JMP.SYNRCVD TCP.IN.JMP.SYNRCVD
ldy #S.TCP.OPTIONS SYN Recieved, SYN.ACK Sent, only accept ACK packet ldy #S.TCP.OPTIONS SYN Received, SYN.ACK Sent, only accept ACK packet
lda (ZPFrameInPtr),y lda (ZPFrameInPtr),y
cmp #S.TCP.OPTIONS.ACK cmp #S.TCP.OPTIONS.ACK
bne .8 bne .8
@ -313,6 +291,21 @@ TCP.IN.JMP.TIMEWT
TCP.IN.JMP.CLOSED TCP.IN.JMP.CLOSED
jmp SKT.Destroy jmp SKT.Destroy
*-------------------------------------- *--------------------------------------
TCP.IN.ACKTheSYN
ldy #S.TCP.SEQNUM+3 Get Remote SEQ
ldx #3
sec
.3 lda (ZPFrameInPtr),y Set OUTACK=SEQ+1 for new socket...
adc #0
sta SKT.TCBCache+S.TCB.INLASTSEQNUM,x
sta SKT.TCBCache+S.TCB.OUTACKNUM,x
dey
dex
bpl .3
rts
*--------------------------------------
TCP.IN.ACKTheFIN TCP.IN.ACKTheFIN
ldy #S.SOCKET.TCP.OPTIONS ldy #S.SOCKET.TCP.OPTIONS
lda (ZPPtrSKT),y lda (ZPPtrSKT),y
@ -507,109 +500,6 @@ TCP.NewFrame ldx #S.IP.PROTOCOL.TCP
clc clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
TCP.ComputeChecksum
lda #0 RESET.TCP.CHECKSUM
ldy #S.TCP.CHECKSUM
sta (ZPFrameOutPtr),y
iny
sta (ZPFrameOutPtr),y
>LDYA ZPFrameOutPtr
>STYA ZPTmpPtr1
lda ZPFrameOutLen
sec
sbc #S.IP
sta ZPDataInLen
lda ZPFrameOutLen+1
sbc /S.IP
sta ZPDataInLen+1
clc
* lda ZPDataInLen+1
* adc #0 RESERVED (all zero)
sta IP.CHECKSUM
lda ZPDataInLen
adc #S.IP.PROTOCOL.TCP
sta IP.CHECKSUM+1
ldy #S.IP.SRC
ldx #4 4 words for SRC & DST IP
.10 lda (ZPFrameOutPtr),y
adc IP.CHECKSUM
sta IP.CHECKSUM
iny
lda (ZPFrameOutPtr),y
adc IP.CHECKSUM+1
sta IP.CHECKSUM+1
iny
dex
bne .10
ldy #S.IP
lda ZPDataInLen
eor #$ff
tax
lda ZPDataInLen+1
eor #$ff
pha
.1 inx
bne .11
pla
inc
beq .8
pha
.11 lda (ZPTmpPtr1),y
adc IP.CHECKSUM
sta IP.CHECKSUM
iny
bne .20
inc ZPTmpPtr1+1
.20 inx
bne .2
pla
inc
beq .7
pha
.2 lda (ZPTmpPtr1),y
adc IP.CHECKSUM+1
sta IP.CHECKSUM+1
iny
bne .1
inc ZPTmpPtr1+1
bra .1
.7 adc IP.CHECKSUM+1 A=0 from beq .7
sta IP.CHECKSUM+1
.8 ldy #S.TCP.CHECKSUM
lda IP.CHECKSUM
adc #0 Don't forget to add last carry!!!
eor #$FF
sta (ZPFrameOutPtr),y
iny
lda IP.CHECKSUM+1
adc #0 Don't forget to add last carry!!!
eor #$FF
sta (ZPFrameOutPtr),y
rts
*--------------------------------------
MAN MAN
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.TCP SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.TCP
LOAD /A2OSX.SRC/LIB/LIBTCPIP.S LOAD /A2OSX.SRC/LIB/LIBTCPIP.S

View File

@ -61,101 +61,6 @@ UDP.IN jsr IP.FillSKT.TemplateSrcDstIPP
>SYSCALL FreeMem >SYSCALL FreeMem
rts rts
*-------------------------------------- *--------------------------------------
UDP.ComputeChecksum
lda #0 RESET.TCP.CHECKSUM
ldy #S.UDP.CHECKSUM
sta (ZPFrameOutPtr),y
iny
sta (ZPFrameOutPtr),y
>LDYA ZPFrameOutPtr
>STYA ZPTmpPtr1
lda ZPFrameOutLen
sec
sbc #S.IP
sta ZPDataInLen
lda ZPFrameOutLen+1
sbc /S.IP
sta ZPDataInLen+1
clc
ldy #S.UDP.LENGTH
lda (ZPFrameOutPtr),y
* adc #0 RESERVED (all zero)
sta IP.CHECKSUM
iny
lda (ZPFrameOutPtr),y
adc #S.IP.PROTOCOL.UDP
sta IP.CHECKSUM+1
ldy #S.IP.SRC
ldx #4 4 words for SRC & DST IP
.10 lda (ZPFrameOutPtr),y
adc IP.CHECKSUM
sta IP.CHECKSUM
iny
lda (ZPFrameOutPtr),y
adc IP.CHECKSUM+1
sta IP.CHECKSUM+1
iny
dex
bne .10
ldy #S.IP
.1 jsr DecDataInLen
beq .8
lda (ZPTmpPtr1),y
adc IP.CHECKSUM
sta IP.CHECKSUM
iny
bne .20
inc ZPTmpPtr1+1
.20 jsr DecDataInLen
bne .2
lda #0
bra .21
.2 lda (ZPTmpPtr1),y
.21 adc IP.CHECKSUM+1
sta IP.CHECKSUM+1
iny
bne .1
inc ZPTmpPtr1+1
bra .1
.8 ldy #S.UDP.CHECKSUM
lda IP.CHECKSUM
adc #0 Don't forget to add last carry!!!
eor #$FF
sta (ZPFrameOutPtr),y
iny
lda IP.CHECKSUM+1
adc #0 Don't forget to add last carry!!!
eor #$FF
sta (ZPFrameOutPtr),y
rts
*--------------------------------------
DecDataInLen lda ZPDataInLen
bne .1
lda ZPDataInLen+1
beq .9
dec ZPDataInLen+1
.1 dec ZPDataInLen
lda #$FF Make NZ
.9 rts
*--------------------------------------
MAN MAN
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.UDP SAVE /A2OSX.SRC/LIB/LIBTCPIP.S.UDP
LOAD /A2OSX.SRC/LIB/LIBTCPIP.S LOAD /A2OSX.SRC/LIB/LIBTCPIP.S