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

View File

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

View File

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