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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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