Fixed hDev mess preventing correct output to screen, prepare for ARP offload

This commit is contained in:
Rémy GIBERT 2016-01-09 23:36:24 +01:00
parent 7fa7cbc094
commit 854930da78
3 changed files with 63 additions and 57 deletions

View File

@ -4,7 +4,6 @@ NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*--------------------------------------
* ARP.CLEAR
*--------------------------------------
@ -23,8 +22,8 @@ ARP.CLEAR ldx #K.ARPCACHE.SIZE*S.ARPCACHE
* CC: hit: MAC filled
* CS: missed
*--------------------------------------
ARP.QUERY >PULLW ZPARPIP IP
>PULLW ZPARPMAC MAC
ARP.QUERY >PULLW ZPPtrIP IP
>PULLW ZPPtrMAC MAC
jmp ARP.QUERY.I
*--------------------------------------
* ARP.ADD
@ -32,8 +31,8 @@ ARP.QUERY >PULLW ZPARPIP IP
* PULLW PTR to IP
* PULLW PTR to MAC
*--------------------------------------
ARP.ADD >PULLW ZPARPIP IP
>PULLW ZPARPMAC MAC
ARP.ADD >PULLW ZPPtrIP IP
>PULLW ZPPtrMAC MAC
lda #S.ARPCACHE.STATUS.RESOLVED
jmp ARP.ADD.I
*--------------------------------------
@ -78,27 +77,27 @@ ARP.RESOLVE ldy #S.IP.DST
lda ZPFrameBase1 Same network, query ARP for dest IP
clc
adc #S.IP.DST
sta ZPARPIP
sta ZPPtrIP
lda ZPFrameBase1+1
adc /S.IP.DST
sta ZPARPIP+1
sta ZPPtrIP+1
bra .6
.5 lda L.IPCFG Not Same network, query ARP for GW
clc
adc #S.IPCFG.GW
sta ZPARPIP
sta ZPPtrIP
lda L.IPCFG+1
adc /S.IPCFG.GW
sta ZPARPIP+1
sta ZPPtrIP+1
.6 lda ZPFrameBase1
clc
adc #S.ETH.DSTMAC
sta ZPARPMAC
sta ZPPtrMAC
lda ZPFrameBase1+1
adc /S.ETH.DSTMAC
sta ZPARPMAC+1
sta ZPPtrMAC+1
*--------------------------------------
ARP.QUERY.I ldx #0
@ -108,7 +107,7 @@ ARP.QUERY.I ldx #0
ldy #0
.2 lda ARP.CACHE+S.ARPCACHE.IP,x
cmp (ZPARPIP),y
cmp (ZPPtrIP),y
bne .5 wrong IP, try next...
inx
iny
@ -121,7 +120,7 @@ ARP.QUERY.I ldx #0
ldy #0 already resolved, get MAC
.3 lda ARP.CACHE+S.ARPCACHE.MAC,x
sta (ZPARPMAC),y
sta (ZPPtrMAC),y
inx
iny
cpy #6
@ -167,7 +166,7 @@ ARP.QUERY.I ldx #0
bpl .72
ldy #3
.73 lda (ZPARPIP),y
.73 lda (ZPPtrIP),y
pha
dey
bpl .73
@ -209,7 +208,7 @@ ARP.ADD.I sta Status
phx
ldy #0
.2 lda (ZPARPIP),y
.2 lda (ZPPtrIP),y
cmp ARP.CACHE+S.ARPCACHE.IP,x
bne .4
inx
@ -242,7 +241,7 @@ ARP.ADD.I sta Status
stz ARP.CACHE,x Init retry count
inx
ldy #0
.8 lda (ZPARPIP),y store IP in cache
.8 lda (ZPPtrIP),y store IP in cache
sta ARP.CACHE,x
inx
iny
@ -253,7 +252,7 @@ ARP.ADD.I sta Status
bpl .82 no MAC if "pending"
ldy #0
.81 lda (ZPARPMAC),y store MAC in cache
.81 lda (ZPPtrMAC),y store MAC in cache
sta ARP.CACHE,x
inx
iny

View File

@ -4,7 +4,6 @@ NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*--------------------------------------
DNS.CLEAR ldx #K.DNSCACHE.SIZE*S.DNSCACHE
.1 stz DNS.CACHE-1,x
@ -24,7 +23,7 @@ DNS.CLEAR ldx #K.DNSCACHE.SIZE*S.DNSCACHE
DNS.QUERY >PULLYA Get host string
jsr PSTR2DNSHostName
>PULLW ZPDNSIP Get IP address to fill
>PULLW ZPPtrIP Get IP address to fill
ldx #0
@ -34,17 +33,17 @@ DNS.QUERY >PULLYA Get host string
phx
lda DNS.CACHE+S.DNSCACHE.hNAME,x
>SYSCALL SYS.GetMemPtrA
>STYA ZPQuickPtr3
>STYA ZPPtrDNS
plx
ldy #0
.2 lda DNSHostname,y
bne .21
lda (ZPQuickPtr3),y
lda (ZPPtrDNS),y
beq .22
.21 cmp (ZPQuickPtr3),y
.21 cmp (ZPPtrDNS),y
bne .6
iny
bne .2
@ -54,7 +53,7 @@ DNS.QUERY >PULLYA Get host string
ldy #0
.3 lda DNS.CACHE+S.DNSCACHE.RDATA,x
sta (ZPDNSIP),y
sta (ZPPtrIP),y
inx
iny
cpy #4
@ -200,7 +199,7 @@ DNS.REQUEST jsr NEW.UDP.FRAME
*--------------------------------------
DNS.ADD >PULLYA Get host string
jsr PSTR2DNSHostName
>PULLW ZPDNSIP Get host IP address
>PULLW ZPPtrIP Get host IP address
lda #$80
sta DNSHostTTL+3
@ -223,13 +222,13 @@ DNS.ADD.I sta Status
lda DNS.CACHE+S.DNSCACHE.hNAME,x
phx
>SYSCALL SYS.GetMemPtrA
>STYA ZPQuickPtr3
>STYA ZPPtrDNS
plx
ldy #0
.2 lda DNSHostname,y
cmp (ZPQuickPtr3),y
cmp (ZPPtrDNS),y
bne .4
and #$FF End Of String?
@ -269,20 +268,20 @@ DNS.ADD.ENTRY phx
plx
rts
.10 >STYA ZPQuickPtr4
.10 >STYA ZPPtrDNS
txa
plx
sta DNS.CACHE+S.DNSCACHE.hNAME,x
ldy #0
.1 lda DNSHostname,y
sta (ZPQuickPtr4),y
sta (ZPPtrDNS),y
iny
cpy DNSHostnameLen
bne .1
lda #0
sta (ZPQuickPtr4),y
sta (ZPPtrDNS),y
DNS.UPD.ENTRY lda Status
sta DNS.CACHE+S.DNSCACHE.STATUS,x
@ -305,7 +304,7 @@ DNS.UPD.ENTRY lda Status
sta DNS.CACHE+S.DNSCACHE.TTL+3,x
ldy #0
.2 lda (ZPDNSIP),y
.2 lda (ZPPtrIP),y
sta DNS.CACHE+S.DNSCACHE.RDATA,x
inx
iny
@ -323,9 +322,9 @@ DNS.GETCACHE >LDYA L.DNS.CACHE
*--------------------------------------
* PRIVATE
*--------------------------------------
PSTR2DNSHostName >STYA ZPQuickPtr1
PSTR2DNSHostName >STYA ZPTmpPtr1
lda (ZPQuickPtr1)
lda (ZPTmpPtr1)
beq .9
cmp #K.DNS.MAXLEN-1
@ -341,7 +340,7 @@ PSTR2DNSHostName >STYA ZPQuickPtr1
ldx #0
.1 lda (ZPQuickPtr1),y
.1 lda (ZPTmpPtr1),y
and #$7f
cmp #'.'
beq .2

View File

@ -15,9 +15,11 @@ AUTO 6
ZPFrameBase1 .EQ ZPLIB
ZPFrameLen1 .EQ ZPLIB+2
ZPFramePtr1 .EQ ZPLIB+4
ZPARPIP .EQ ZPLIB+6
ZPARPMAC .EQ ZPLIB+8
ZPDNSIP .EQ ZPLIB+12
ZPPtrIP .EQ ZPLIB+6
ZPPtrMAC .EQ ZPLIB+8
ZPPtrDNS .EQ ZPLIB+10
ZPTmpPtr1 .EQ ZPLIB+12
ZPTmpPtr2 .EQ ZPLIB+14
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -98,14 +100,20 @@ SET.IPCFG >PUSHBI K.PROTOID.IP
GET.IPCFG lda #K.PROTOID.IP
>SYSCALL SYS.GetNetCfgA
bcs GET.IPCFG.RTS
>STYA ZPQuickPtr1
>STYA ZPTmpPtr1
ldy #S.IPCFG
.1 dey
lda (ZPQuickPtr1),y
lda (ZPTmpPtr1),y
sta IPCFG,y
tya
bne .1
>LDYA ZPQuickPtr1
ldx #S.IPCFG.HDEV
lda IPCFG,x
>SYSCALL SYS.GetDevByIDA
>STYA NetDevJmp+1
>LDYA ZPTmpPtr1
clc
GET.IPCFG.RTS rts
*--------------------------------------
@ -363,13 +371,8 @@ SEND.ARP.FRAME.I
*--------------------------------------
SEND.ETH.FRAME >PUSHW ZPFrameLen1
>PUSHW ZPFrameBase1
ldx #S.IPCFG.HDEV
lda IPCFG,x
>SYSCALL SYS.GetDevByIDA
>STYA pDev
ldx #DEVMGR.NET.SEND
jsr pDevJmp
jsr NetDevJmp
rts
*--------------------------------------
UDP.LISTENER >PULLW ZPFrameBase1
@ -417,45 +420,46 @@ ToLowerCaseA cmp #'A'
ComputeChecksum >PULLA
clc
adc ZPFrameBase1
sta ZPQuickPtr1
sta ZPTmpPtr1
>PULLA
adc ZPFrameBase1+1
sta ZPQuickPtr1+1
sta ZPTmpPtr1+1
>PULLA
clc
adc ZPFrameBase1
sta ZPQuickPtr2
sta TmpOffset
>PULLA
adc ZPFrameBase1+1
sta ZPQuickPtr2+1
sta TmpOffset+1
stz IP.CHECKSUM RESET.IP.CHECKSUM
stz IP.CHECKSUM+1
stz IP.CHECKSUM+2
stz IP.CHECKSUM+3
ldy #1
.1 lda (ZPQuickPtr1),y
.1 lda (ZPTmpPtr1),y
clc
adc IP.CHECKSUM
sta IP.CHECKSUM
lda (ZPQuickPtr1)
lda (ZPTmpPtr1)
adc IP.CHECKSUM+1
sta IP.CHECKSUM+1
bcc .3
inc IP.CHECKSUM+2
bne .3
inc IP.CHECKSUM+3
.3 lda ZPQuickPtr1
.3 lda ZPTmpPtr1
clc
adc #2
sta ZPQuickPtr1
sta ZPTmpPtr1
bcc .4
inc ZPQuickPtr1+1
.4 cmp ZPQuickPtr2
inc ZPTmpPtr1+1
.4 cmp TmpOffset
bne .1
lda ZPQuickPtr1+1
cmp ZPQuickPtr2+1
lda ZPTmpPtr1+1
cmp TmpOffset+1
bne .1
lda IP.CHECKSUM
clc
@ -467,6 +471,8 @@ ComputeChecksum >PULLA
eor #$FF
rts
*--------------------------------------
NetDevJmp jmp *
*--------------------------------------
CS.END
*--------------------------------------
bFirstLoad .DA #0
@ -486,6 +492,8 @@ DYNPORT.UDP.LAST .BS 2
DYNPORT.TCP.LAST .BS 2
DYNPORT.UDP .BS K.DYNPORT.MAX*4
DYNPORT.TCP .BS K.DYNPORT.MAX*4
*TmpCounter .BS 2
TmpOffset .BS 2
*--------------------------------------
MAN
SAVE LIB/LIBTCPIP.S