Kernel 0.93+

This commit is contained in:
Rémy GIBERT 2019-10-06 14:50:43 +02:00
parent aee22a2832
commit 70357a5547
9 changed files with 239 additions and 145 deletions

Binary file not shown.

Binary file not shown.

View File

@ -12,7 +12,13 @@ NEW
*-------------------------------------- *--------------------------------------
TIMEOUT.MAX .EQ 40 40*100ms = 4 sec. TIMEOUT.MAX .EQ 40 40*100ms = 4 sec.
*-------------------------------------- *--------------------------------------
ZPPTR1 .EQ ZPBIN .DUMMY
.OR ZPBIN
ZS.START
ZPPTR1 .BS 2
EntryCount .BS 1
ZS.END
.ED
*-------------------------------------- *--------------------------------------
* File Header (16 Bytes) * File Header (16 Bytes)
*-------------------------------------- *--------------------------------------
@ -22,10 +28,10 @@ CS.START cld
.DA #1 BIN Layout Version 1 .DA #1 BIN Layout Version 1
.DA #S.PS.F.EVENT .DA #S.PS.F.EVENT
.DA #0 .DA #0
.DA CS.END-CS.START CS .DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START DS .DA DS.END-DS.START Data Segment Size
.DA #16 SS .DA #32 Stack Size
.DA #2 ZP .DA #ZS.END-ZS.START Zero Page Size
.DA 0 .DA 0
*-------------------------------------- *--------------------------------------
* Relocation Table * Relocation Table
@ -144,19 +150,26 @@ CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.GETCACHE
>LDYA L.MSG0 >LDYA L.MSG0
>SYSCALL puts >SYSCALL puts
ldx #K.ARPCACHE.SIZE lda #K.ARPCACHE.SIZE
sta EntryCount
.1 lda (ZPPTR1) .1 lda (ZPPTR1)
beq .4 beq .4
ldy #S.ARPCACHE.IP+4 ldy #S.ARPCACHE.IP+4
.2 dey .2 dey
>PUSHB (ZPPTR1),y >PUSHB (ZPPTR1),y
cpy #S.ARPCACHE.IP cpy #S.ARPCACHE.IP
bne .2 bne .2
ldy #S.ARPCACHE.MAC+6 ldy #S.ARPCACHE.MAC+6
.3 dey .3 dey
>PUSHB (ZPPTR1),y >PUSHB (ZPPTR1),y
cpy #S.ARPCACHE.MAC cpy #S.ARPCACHE.MAC
bne .3 bne .3
ldy #S.ARPCACHE.TTL+1 ldy #S.ARPCACHE.TTL+1
>PUSHB (ZPPTR1),y >PUSHB (ZPPTR1),y
dey dey
@ -164,17 +177,19 @@ CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.GETCACHE
>PUSHB (ZPPTR1) >PUSHB (ZPPTR1)
>PUSHBI 13 >PUSHBI 13
>LDYA L.MSG1 >LDYA L.MSG1
phx
>SYSCALL printf >SYSCALL printf
plx
.4 lda ZPPTR1 .4 lda ZPPTR1
clc clc
adc #S.ARPCACHE adc #S.ARPCACHE
sta ZPPTR1 sta ZPPTR1
bcc .5 bcc .5
inc ZPPTR1+1 inc ZPPTR1+1
.5 dex
.5 dec EntryCount
bne .1 bne .1
.8 lda #0 tell TSKMGR that all done ok, but .8 lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory sec we do not want to stay in memory
rts rts
@ -192,6 +207,7 @@ CS.DOEVENT lda (pEvent)
*-------------------------------------- *--------------------------------------
CS.QUIT lda hLIBTCPIP CS.QUIT lda hLIBTCPIP
beq .8 beq .8
>SYSCALL UnloadLib >SYSCALL UnloadLib
.8 clc .8 clc
rts rts

View File

@ -13,7 +13,8 @@ NEW
.DUMMY .DUMMY
.OR ZPBIN .OR ZPBIN
ZS.START ZS.START
ZPPTR1 .EQ ZPBIN ZPPTR1 .BS 2
EntryCount .BS 1
ZS.END ZS.END
.ED .ED
*-------------------------------------- *--------------------------------------
@ -26,7 +27,7 @@ CS.START cld
.DA #0 S.PS.F.EVENT .DA #0 S.PS.F.EVENT
.DA #0 .DA #0
.DA CS.END-CS.START Code Size (without Constants) .DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize .DA DS.END-DS.START Data Segment Size
.DA #32 Stack Size .DA #32 Stack Size
.DA #ZS.END-ZS.START Zero Page Size .DA #ZS.END-ZS.START Zero Page Size
.DA 0 .DA 0
@ -108,7 +109,8 @@ CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.DNS.GetCache
>SYSCALL puts >SYSCALL puts
lda #K.DNSCACHE.SIZE lda #K.DNSCACHE.SIZE
>STA.G EntryCount sta EntryCount
.1 lda (ZPPTR1) .1 lda (ZPPTR1)
beq .6 beq .6
@ -150,13 +152,13 @@ CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.DNS.GetCache
sta ZPPTR1 sta ZPPTR1
bcc .7 bcc .7
inc ZPPTR1+1 inc ZPPTR1+1
.7 >DEC.G EntryCount
.7 dec EntryCount
bne .8 bne .1
lda #0
sec sec
rts rts
.8 jmp .1
*-------------------------------------- *--------------------------------------
CS.EVENT sec CS.EVENT sec
rts rts
@ -182,7 +184,6 @@ MSG.USAGE .AS "Usage : Add a static entry, DNSINFO <host> <IP>\r\n"
*-------------------------------------- *--------------------------------------
DS.START DS.START
DST.IP .BS 4 DST.IP .BS 4
EntryCount .BS 1
DS.END DS.END
*-------------------------------------- *--------------------------------------
MAN MAN

View File

@ -3,8 +3,8 @@ NEW
.LIST OFF .LIST OFF
.OP 65C02 .OP 65C02
*-------------------------------------- *--------------------------------------
K.ARPCACHE.SIZE .EQ 10 K.ARPCACHE.SIZE .EQ 8
K.DNSCACHE.SIZE .EQ 10 K.DNSCACHE.SIZE .EQ 8
K.SKTTABLE.SIZE .EQ 16 K.SKTTABLE.SIZE .EQ 16
K.FRMQUEUE.SIZE .EQ 16 K.FRMQUEUE.SIZE .EQ 16
K.FRMSEND.RETRY .EQ 10 K.FRMSEND.RETRY .EQ 10

View File

@ -9,9 +9,11 @@ NEW
*\-------------------------------------- *\--------------------------------------
ARP.Clear lda hARPCache ARP.Clear lda hARPCache
bne .1 bne .1
>LDYAI K.ARPCACHE.SIZE*S.ARPCACHE >LDYAI K.ARPCACHE.SIZE*S.ARPCACHE
>SYSCALL2 GetMem0 >SYSCALL2 GetMem0
bcs .9 bcs .9
stx hARPCache stx hARPCache
rts rts
@ -36,21 +38,21 @@ ARP.Clear lda hARPCache
* CC: hit: MAC filled * CC: hit: MAC filled
* CS: missed * CS: missed
*\-------------------------------------- *\--------------------------------------
ARP.Query >PULLW ZPPtrIP IP ARP.Query jsr ARP.GetIP
>PULLW ZPPtrMAC MAC >PULLW ZPPtrMAC MAC
ldy #3
.1 lda (ZPPtrIP),y
sta ARP.TmpCache+S.ARPCACHE.IP,y
dey
bpl .1
jsr ARP.QUERY.I jsr ARP.QUERY.I
bcs .9 bcs .9
ldy #5 ldy #5
.2 lda ARP.TmpCache+S.ARPCACHE.MAC,y .2 lda ARP.TmpCache+S.ARPCACHE.MAC,y
sta (ZPPtrMAC),y sta (ZPPtrMAC),y
dey dey
bpl .2 bpl .2
clc
* clc
.9 rts .9 rts
*/-------------------------------------- */--------------------------------------
* # ARP.Add * # ARP.Add
@ -59,17 +61,10 @@ ARP.Query >PULLW ZPPtrIP IP
* PUSHW PTR to MAC * PUSHW PTR to MAC
* PUSHW PTR to IP * PUSHW PTR to IP
*\-------------------------------------- *\--------------------------------------
ARP.Add >PULLW ZPPtrIP IP ARP.Add jsr ARP.GetIP
>PULLW ZPPtrMAC MAC >PULLW ZPPtrMAC MAC
stz ARP.TmpCache+S.ARPCACHE.TTL
stz ARP.TmpCache+S.ARPCACHE.TTL+1
ldy #3
.1 lda (ZPPtrIP),y
sta ARP.TmpCache+S.ARPCACHE.IP,y
dey
bpl .1
ldy #5 ldy #5
.2 lda (ZPPtrMAC),y .2 lda (ZPPtrMAC),y
@ -77,18 +72,25 @@ ARP.Add >PULLW ZPPtrIP IP
dey dey
bpl .2 bpl .2
stz ARP.TmpCache+S.ARPCACHE.TTL
stz ARP.TmpCache+S.ARPCACHE.TTL+1
lda #S.ARPCACHE.S.RESOLVED+S.ARPCACHE.S.STATIC lda #S.ARPCACHE.S.RESOLVED+S.ARPCACHE.S.STATIC
ARP.ADD.I sta ARP.TmpCache ARP.ADD.I sta ARP.TmpCache
jsr ARP.FIND.BY.IP jsr ARP.FIND.BY.IP
bcc .1 bcc .1
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
bpl .2 bpl .2
clc clc
rts rts
*/-------------------------------------- */--------------------------------------
@ -106,28 +108,6 @@ ARP.GetCache lda hARPCache
*-------------------------------------- *--------------------------------------
* PRIVATE * PRIVATE
*-------------------------------------- *--------------------------------------
ARP.AddFromFrameInPtr
ldy #S.IP.SRC+3
ldx #3
.1 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.IP,x
dey
dex
bpl .1
ldy #S.ETH.SRCMAC+5
ldx #5
.2 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.MAC,x
dey
dex
bpl .2
lda #K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL
lda /K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL+1
lda #S.ARPCACHE.S.RESOLVED
jmp ARP.ADD.I
*--------------------------------------
ARP.IN ldy #S.ARP.TPA+3 ARP.IN ldy #S.ARP.TPA+3
ldx #3 ldx #3
@ -137,33 +117,42 @@ ARP.IN ldy #S.ARP.TPA+3
dey dey
dex dex
bpl .1 bpl .1
ldy #S.ARP.OPERATION+1 HI byte ldy #S.ARP.OPERATION+1 HI byte
lda (ZPFrameInPtr),y lda (ZPFrameInPtr),y
cmp #S.ARP.OPERATION.REQ cmp #S.ARP.OPERATION.REQ
beq ARP.IN.REQ beq ARP.IN.REQ
cmp #S.ARP.OPERATION.REP cmp #S.ARP.OPERATION.REP
beq ARP.IN.REP beq ARP.IN.REP
ARP.IN.EXIT lda hFrameIn ARP.IN.EXIT lda hFrameIn
beq .8 beq .8
stz hFrameIn stz hFrameIn
>SYSCALL2 FreeMem >SYSCALL2 FreeMem
.8 clc .8 clc
rts rts
ARP.IN.REQ ldy #S.ARP.SPA+3 ARP.IN.REQ ldy #S.ARP.SPA+3
ldx #3 ldx #3
.1 lda (ZPFrameInPtr),y .1 lda (ZPFrameInPtr),y
sta ARP.REP.TPA,x sta ARP.REP.TPA,x
dey dey
dex dex
bpl .1 bpl .1
ldy #S.ARP.SHA+5 ldy #S.ARP.SHA+5
ldx #5 ldx #5
.2 lda (ZPFrameInPtr),y .2 lda (ZPFrameInPtr),y
sta ARP.REP.DSTMAC,x sta ARP.REP.DSTMAC,x
sta ARP.REP.THA,x sta ARP.REP.THA,x
dey dey
dex dex
bpl .2 bpl .2
>LDYA L.ARP.REP >LDYA L.ARP.REP
jsr ARP.Send jsr ARP.Send
bra ARP.IN.EXIT bra ARP.IN.EXIT
@ -172,42 +161,38 @@ ARP.IN.REP lda #K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL sta ARP.TmpCache+S.ARPCACHE.TTL
lda /K.ARP.TTL lda /K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL+1 sta ARP.TmpCache+S.ARPCACHE.TTL+1
ldy #S.ARP.SPA+3 ldy #S.ARP.SPA+3
ldx #3 jsr ARP.GetIPFromFrameInPtrY
.1 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.IP,x
dey
dex
bpl .1
ldy #S.ARP.SHA+5 ldy #S.ARP.SHA+5
ldx #5 jsr ARP.GetMacFromFrameInPtrY
.2 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.MAC,x
dey
dex
bpl .2
lda #S.ARPCACHE.S.RESOLVED lda #S.ARPCACHE.S.RESOLVED
jsr ARP.ADD.I jsr ARP.ADD.I
jmp ARP.IN.EXIT bra ARP.IN.EXIT
*-------------------------------------- *--------------------------------------
ARP.QUERY.I jsr ARP.FIND.BY.IP ARP.QUERY.I jsr ARP.FIND.BY.IP
bcs .3 send an ARP request bcs .3 send an ARP request
lda (ZPCachePtr) get status... lda (ZPCachePtr) get status...
bpl .9 Pending... bpl .9 Pending...
ldy #S.ARPCACHE.MAC ldy #S.ARPCACHE.MAC
.2 lda (ZPCachePtr),y .2 lda (ZPCachePtr),y
sta ARP.TmpCache,y sta ARP.TmpCache,y
iny iny
cpy #S.ARPCACHE.MAC+6 cpy #S.ARPCACHE.MAC+6
bne .2 bne .2
ldy #S.ARPCACHE.TTL ldy #S.ARPCACHE.TTL
lda #K.ARP.TTL lda #K.ARP.TTL
sta (ZPCachePtr),y sta (ZPCachePtr),y
iny iny
lda /K.ARP.TTL lda /K.ARP.TTL
sta (ZPCachePtr),y sta (ZPCachePtr),y
clc clc
rts rts
@ -217,14 +202,17 @@ ARP.QUERY.I jsr ARP.FIND.BY.IP
sta ARP.REQ.TPA,x sta ARP.REQ.TPA,x
dex dex
bpl .4 bpl .4
>LDYA L.ARP.REQ >LDYA L.ARP.REQ
jsr ARP.Send jsr ARP.Send
bcs .99 bcs .99
lda #K.ARP.PENDING.TTL lda #K.ARP.PENDING.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL sta ARP.TmpCache+S.ARPCACHE.TTL
stz ARP.TmpCache+S.ARPCACHE.TTL+1 stz ARP.TmpCache+S.ARPCACHE.TTL+1
lda #S.ARPCACHE.S.PENDING lda #S.ARPCACHE.S.PENDING
jsr ARP.ADD.I jsr ARP.ADD.I
.9 lda #ERR.ARP.PENDING .9 lda #ERR.ARP.PENDING
sec sec
.99 rts .99 rts
@ -236,21 +224,21 @@ ARP.FIND.BY.IP jsr ARP.GetCache
beq .3 beq .3
ldy #S.ARPCACHE.IP ldy #S.ARPCACHE.IP
.2 lda ARP.TmpCache,y .2 lda ARP.TmpCache,y
cmp (ZPCachePtr),y cmp (ZPCachePtr),y
bne .3 bne .3
iny iny
cpy #S.ARPCACHE.IP+4 cpy #S.ARPCACHE.IP+4
bne .2 bne .2
clc clc
rts rts
.3 lda ZPCachePtr
clc .3 jsr ARP.NextCache
adc #S.ARPCACHE
sta ZPCachePtr dex
bcc .8
inc ZPCachePtr+1
.8 dex
bne .1 bne .1
sec sec
@ -263,9 +251,11 @@ ARP.FIND.FREE jsr ARP.GetCache
sta TmpDWord+1 sta TmpDWord+1
ldx #K.ARPCACHE.SIZE ldx #K.ARPCACHE.SIZE
.1 lda (ZPCachePtr) .1 lda (ZPCachePtr)
beq .8 beq .8
bpl .6 bpl .6
ldy #S.ARPCACHE.TTL ldy #S.ARPCACHE.TTL
lda (ZPCachePtr),y lda (ZPCachePtr),y
sec sec
@ -274,6 +264,7 @@ ARP.FIND.FREE jsr ARP.GetCache
lda (ZPCachePtr),y lda (ZPCachePtr),y
sbc TmpDWord+1 sbc TmpDWord+1
bcc .6 bcc .6
lda (ZPCachePtr),y lda (ZPCachePtr),y
sta TmpDWord+1 sta TmpDWord+1
dey dey
@ -282,27 +273,29 @@ ARP.FIND.FREE jsr ARP.GetCache
>LDYA ZPCachePtr >LDYA ZPCachePtr
>STYA ZPTmpPtr1 save lowest TTL slot ... >STYA ZPTmpPtr1 save lowest TTL slot ...
.6 lda ZPCachePtr .6 jsr ARP.NextCache
clc
adc #S.ARPCACHE dex
sta ZPCachePtr
bcc .7
inc ZPCachePtr+1
.7 dex
bne .1 bne .1
>LDYA ZPTmpPtr1 >LDYA ZPTmpPtr1
>STYA ZPCachePtr >STYA ZPCachePtr
lda #0 lda #0
sta (ZPCachePtr) sta (ZPCachePtr)
.8 clc .8 clc
rts rts
*-------------------------------------- *--------------------------------------
ARP.EXPIRE jsr ARP.GetCache ARP.EXPIRE jsr ARP.GetCache
ldx #K.ARPCACHE.SIZE ldx #K.ARPCACHE.SIZE
.1 lda (ZPCachePtr) .1 lda (ZPCachePtr)
beq .2 beq .2
and #S.ARPCACHE.S.STATIC and #S.ARPCACHE.S.STATIC
bne .2 bne .2
ldy #S.ARPCACHE.TTL ldy #S.ARPCACHE.TTL
sec sec
lda (ZPCachePtr),y lda (ZPCachePtr),y
@ -313,16 +306,71 @@ ARP.EXPIRE jsr ARP.GetCache
sbc #0 sbc #0
sta (ZPCachePtr),y sta (ZPCachePtr),y
bcs .2 bcs .2
lda #0 lda #0
sta (ZPCachePtr) sta (ZPCachePtr)
.2 lda ZPCachePtr
.2 jsr ARP.NextCache
dex
bne .1
rts
*--------------------------------------
ARP.NextCache lda ZPCachePtr
clc clc
adc #S.ARPCACHE adc #S.ARPCACHE
sta ZPCachePtr sta ZPCachePtr
bcc .3 bcc .8
inc ZPCachePtr+1 inc ZPCachePtr+1
.3 dex
bne .1 .8 rts
*--------------------------------------
ARP.GetIP >PULLW ZPPtrIP
ldy #3
.1 lda (ZPPtrIP),y
sta ARP.TmpCache+S.ARPCACHE.IP,y
dey
bpl .1
rts
*--------------------------------------
ARP.AddFromFrameInPtr
ldy #S.IP.SRC+3
jsr ARP.GetIPFromFrameInPtrY
ldy #S.ETH.SRCMAC+5
jsr ARP.GetMacFromFrameInPtrY
lda #K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL
lda /K.ARP.TTL
sta ARP.TmpCache+S.ARPCACHE.TTL+1
lda #S.ARPCACHE.S.RESOLVED
jmp ARP.ADD.I
*--------------------------------------
ARP.GetIPFromFrameInPtrY
ldx #3
.1 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.IP,x
dey
dex
bpl .1
rts
*--------------------------------------
ARP.GetMacFromFrameInPtrY
ldx #5
.1 lda (ZPFrameInPtr),y
sta ARP.TmpCache+S.ARPCACHE.MAC,x
dey
dex
bpl .1
rts rts
*-------------------------------------- *--------------------------------------
ARP.Send >STYA IOCTL+S.IOCTL.BUFPTR ARP.Send >STYA IOCTL+S.IOCTL.BUFPTR

View File

@ -8,9 +8,11 @@ NEW
* ## RETURN VALUE * ## RETURN VALUE
*\-------------------------------------- *\--------------------------------------
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
dex dex
bne .1 bne .1
clc clc
rts rts
*/-------------------------------------- */--------------------------------------
@ -38,12 +40,14 @@ DNS.Query.I jsr DNS.FIND.BY.NAME
sta ZPCachePtr sta ZPCachePtr
bcc .1 bcc .1
inc ZPCachePtr+1 inc ZPCachePtr+1
.1 ldy #3 .1 ldy #3
.2 lda (ZPCachePtr),y .2 lda (ZPCachePtr),y
sta (ZPPtrIP),y sta (ZPPtrIP),y
dey dey
bpl .2 bpl .2
clc clc
rts rts
@ -124,11 +128,13 @@ DNS.REQUEST.SEND
>PUSHW L.DNS.MSG >PUSHW L.DNS.MSG
lda hDNSSocket lda hDNSSocket
jmp SKT.SendTo jmp SKT.SendTo
.8 clc .8 clc
rts rts
*-------------------------------------- *--------------------------------------
DNS.CSTR2DNS lda (ZPPtrDNS) DNS.CSTR2DNS lda (ZPPtrDNS)
beq .9 beq .9
>LDYA ZPPtrDNS >LDYA ZPPtrDNS
>SYSCALL2 strlen >SYSCALL2 strlen
@ -143,22 +149,30 @@ DNS.CSTR2DNS lda (ZPPtrDNS)
phy save len for later phy save len for later
ldx #0 ldx #0
dey dey
.1 lda (ZPPtrDNS),y .1 lda (ZPPtrDNS),y
and #$7f and #$7f
cmp #'.' cmp #'.'
beq .2 beq .3
cmp #'A' cmp #'A'
bcc .10 bcc .2
cmp #'Z'+1 cmp #'Z'+1
bcs .10 bcs .2
adc #$20 adc #$20
.10 inx
bra .3 .2 inx
.2 txa bra .4
.3 txa
ldx #0 ldx #0
.3 sta DNS.MSG.NAME+1,y
.4 sta DNS.MSG.NAME+1,y
dey dey
bpl .1 bpl .1
stx DNS.MSG.NAME stx DNS.MSG.NAME
pla Get back Len pla Get back Len
sec +1 sec +1
@ -166,6 +180,7 @@ DNS.CSTR2DNS lda (ZPPtrDNS)
tay tay
* clc * clc
rts rts
.9 sec .9 sec
rts rts
*/-------------------------------------- */--------------------------------------
@ -177,16 +192,20 @@ DNS.CSTR2DNS lda (ZPPtrDNS)
*\-------------------------------------- *\--------------------------------------
DNS.Add >PULLW ZPPtrDNS Get host string DNS.Add >PULLW ZPPtrDNS Get host string
>PULLW ZPPtrIP Get host IP address >PULLW ZPPtrIP Get host IP address
ldy #3 ldy #3
.1 lda (ZPPtrIP),y .1 lda (ZPPtrIP),y
sta DNS.TmpCache+S.DNSCACHE.IP,y sta DNS.TmpCache+S.DNSCACHE.IP,y
dey dey
bpl .1 bpl .1
stz DNS.TmpCache+S.DNSCACHE.TTL stz DNS.TmpCache+S.DNSCACHE.TTL
stz DNS.TmpCache+S.DNSCACHE.TTL+1 stz DNS.TmpCache+S.DNSCACHE.TTL+1
stz DNS.TmpCache+S.DNSCACHE.TTL+2 stz DNS.TmpCache+S.DNSCACHE.TTL+2
stz DNS.TmpCache+S.DNSCACHE.TTL+3 stz DNS.TmpCache+S.DNSCACHE.TTL+3
lda #S.DNSCACHE.STATUS.RESOLVED+S.DNSCACHE.STATUS.STATIC lda #S.DNSCACHE.STATUS.RESOLVED+S.DNSCACHE.STATUS.STATIC
DNS.ADD.I sta DNS.TmpCache DNS.ADD.I sta DNS.TmpCache
jsr DNS.FIND.BY.NAME jsr DNS.FIND.BY.NAME
bcc .2 Found, go update... bcc .2 Found, go update...
@ -196,18 +215,22 @@ DNS.ADD.I sta DNS.TmpCache
>LDYA ZPPtrDNS >LDYA ZPPtrDNS
>SYSCALL2 strdup >SYSCALL2 strdup
bcs .9 bcs .9
txa txa
ldy #S.DNSCACHE.hNAME ldy #S.DNSCACHE.hNAME
sta (ZPCachePtr),y sta (ZPCachePtr),y
.2 lda DNS.TmpCache .2 lda DNS.TmpCache
sta (ZPCachePtr) sta (ZPCachePtr)
ldy #S.DNSCACHE.ID ldy #S.DNSCACHE.ID
.3 lda DNS.TmpCache,y .3 lda DNS.TmpCache,y
sta (ZPCachePtr),y sta (ZPCachePtr),y
iny iny
cpy #S.DNSCACHE cpy #S.DNSCACHE
bne .3 bne .3
clc clc
.9 rts .9 rts
*/-------------------------------------- */--------------------------------------
@ -218,15 +241,18 @@ DNS.ADD.I sta DNS.TmpCache
* Y,A = PTR to DNS.CACHE * Y,A = PTR to DNS.CACHE
*\-------------------------------------- *\--------------------------------------
DNS.GetCAche >LDYA L.DNS.CACHE DNS.GetCAche >LDYA L.DNS.CACHE
>STYA ZPCachePtr
clc clc
rts rts
*-------------------------------------- *--------------------------------------
DNS.FIND.BY.NAME DNS.FIND.BY.NAME
>LDYA L.DNS.CACHE jsr DNS.GetCAche
>STYA ZPCachePtr
ldx #K.DNSCACHE.SIZE ldx #K.DNSCACHE.SIZE
.1 lda (ZPCachePtr) .1 lda (ZPCachePtr)
beq .6 empty DNS cache entry? beq .6 empty DNS cache entry?
phx phx
>PUSHW ZPPtrDNS >PUSHW ZPPtrDNS
ldy #S.DNSCACHE.hNAME ldy #S.DNSCACHE.hNAME
@ -235,20 +261,17 @@ DNS.FIND.BY.NAME
>SYSCALL2 StrCaseCmp >SYSCALL2 StrCaseCmp
plx plx
bcc .8 bcc .8
.6 lda ZPCachePtr
clc .6 jsr DNS.NextCache
adc #S.DNSCACHE
sta ZPCachePtr dex
bcc .7
inc ZPCachePtr+1
.7 dex
bne .1 bne .1
sec sec
.8 rts .8 rts
*-------------------------------------- *--------------------------------------
DNS.UPDATE.BY.ID DNS.UPDATE.BY.ID
>LDYA L.DNS.CACHE jsr DNS.GetCAche
>STYA ZPCachePtr
ldx #K.DNSCACHE.SIZE ldx #K.DNSCACHE.SIZE
.1 lda (ZPCachePtr) .1 lda (ZPCachePtr)
@ -267,26 +290,25 @@ DNS.UPDATE.BY.ID
lda #S.DNSCACHE.STATUS.RESOLVED lda #S.DNSCACHE.STATUS.RESOLVED
sta (ZPCachePtr) sta (ZPCachePtr)
ldy #S.DNSCACHE.TTL ldy #S.DNSCACHE.TTL
.2 lda DNS.TmpCache,y .2 lda DNS.TmpCache,y
sta (ZPCachePtr),y sta (ZPCachePtr),y
iny iny
cpy #S.DNSCACHE cpy #S.DNSCACHE
bne .2 bne .2
clc clc
rts rts
.6 lda ZPCachePtr
clc .6 jsr DNS.NextCache
adc #S.DNSCACHE
sta ZPCachePtr dex
bcc .7
inc ZPCachePtr+1
.7 dex
bne .1 bne .1
sec sec
rts rts
*-------------------------------------- *--------------------------------------
DNS.FIND.FREE >LDYA L.DNS.CACHE DNS.FIND.FREE jsr DNS.GetCAche
>STYA ZPCachePtr
lda #$ff lda #$ff
sta TmpDWord sta TmpDWord
sta TmpDWord+1 sta TmpDWord+1
@ -320,14 +342,11 @@ DNS.FIND.FREE >LDYA L.DNS.CACHE
>STYA ZPTmpPtr1 save lowest TTL slot ... >STYA ZPTmpPtr1 save lowest TTL slot ...
.6 plx .6 plx
.7 lda ZPCachePtr .7 jsr DNS.NextCache
clc
adc #S.DNSCACHE dex
sta ZPCachePtr
bcc .71
inc ZPCachePtr+1
.71 dex
bne .1 no empty slot found, discard lowest TTL bne .1 no empty slot found, discard lowest TTL
>LDYA ZPTmpPtr1 >LDYA ZPTmpPtr1
>STYA ZPCachePtr >STYA ZPCachePtr
jsr DNS.FREE jsr DNS.FREE
@ -335,8 +354,8 @@ DNS.FIND.FREE >LDYA L.DNS.CACHE
.8 clc .8 clc
rts rts
*-------------------------------------- *--------------------------------------
DNS.EXPIRE >LDYA L.DNS.CACHE DNS.EXPIRE jsr DNS.GetCAche
>STYA ZPCachePtr
ldx #K.DNSCACHE.SIZE ldx #K.DNSCACHE.SIZE
.1 lda (ZPCachePtr) .1 lda (ZPCachePtr)
beq .7 empty DNS cache entry? beq .7 empty DNS cache entry?
@ -344,24 +363,25 @@ DNS.EXPIRE >LDYA L.DNS.CACHE
bit #S.DNSCACHE.STATUS.STATIC bit #S.DNSCACHE.STATUS.STATIC
bne .7 bne .7
phx phx
ldy #S.DNSCACHE.TTL ldy #S.DNSCACHE.TTL
ldx #4 ldx #4
clc clc
.2 lda (ZPCachePtr),y .2 lda (ZPCachePtr),y
sbc #0 sbc #0
sta (ZPCachePtr),y sta (ZPCachePtr),y
iny iny
dex dex
bne .2 bne .2
bcs .6 bcs .6
jsr DNS.FREE jsr DNS.FREE
.6 plx .6 plx
.7 lda ZPCachePtr
clc .7 jsr DNS.NextCache
adc #S.DNSCACHE
sta ZPCachePtr
bcc .8
inc ZPCachePtr+1
.8 dex .8 dex
bne .1 bne .1
@ -478,6 +498,15 @@ DNS.POLL lda hDNSSocket
clc clc
rts rts
*-------------------------------------- *--------------------------------------
DNS.NextCache lda ZPCachePtr
clc
adc #S.DNSCACHE
sta ZPCachePtr
bcc .8
inc ZPCachePtr+1
.8 rts
*--------------------------------------
MAN MAN
SAVE USR/SRC/LIB/LIBTCPIP.S.DNS SAVE USR/SRC/LIB/LIBTCPIP.S.DNS
LOAD USR/SRC/LIB/LIBTCPIP.S LOAD USR/SRC/LIB/LIBTCPIP.S

View File

@ -200,14 +200,17 @@ IP.SetDestMAC ldy #S.IP.DST
dex dex
bpl .5 bpl .5
bra .8 bra .8
.6 ldx #3 Not Same network, query ARP for GW .6 ldx #3 Not Same network, query ARP for GW
.7 lda IPCFG+S.IPCFG.GW,x .7 lda IPCFG+S.IPCFG.GW,x
sta ARP.TmpCache+S.ARPCACHE.IP,x sta ARP.TmpCache+S.ARPCACHE.IP,x
dex dex
bpl .7 bpl .7
.8 jsr ARP.QUERY.I .8 jsr ARP.QUERY.I
bcs .99 bcs .99
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

View File

@ -1099,23 +1099,20 @@ SKT.PullhFDDataInPtrLen
>PULLW ZPDataInLen !!!use DataInPtr/Len >PULLW ZPDataInLen !!!use DataInPtr/Len
rts rts
*-------------------------------------- *--------------------------------------
SKT.PullLocAddr >PULLW ZPTmpPtr1 SKT.PullLocAddr clc
.HS B0 BCS
ldy #S.SOCKADDR-1
.1 lda (ZPTmpPtr1),y
sta SKT.LOC.ADDR,y
dey
bpl .1
rts
*-------------------------------------- *--------------------------------------
SKT.PullRemAddr >PULLW ZPTmpPtr1 SKT.PullRemAddr sec
>PULLW ZPTmpPtr1
ldy #S.SOCKADDR-1 ldy #S.SOCKADDR-1
ldx #S.SOCKADDR-1
bcc .1
ldx #S.SOCKADDR+S.SOCKADDR-1
.1 lda (ZPTmpPtr1),y .1 lda (ZPTmpPtr1),y
sta SKT.REM.ADDR,y sta SKT.LOC.ADDR,x
dex
dey dey
bpl .1 bpl .1