mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-22 16:31:07 +00:00
304 lines
6.8 KiB
Plaintext
304 lines
6.8 KiB
Plaintext
NEW
|
||
PREFIX /A2OSX.BUILD
|
||
AUTO 4,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BUILD/LIB/LIBTCPIP.O
|
||
*--------------------------------------
|
||
.INB /A2OSX.BUILD/INC/MACROS.I
|
||
.INB /A2OSX.BUILD/INC/A2OSX.I
|
||
.INB /A2OSX.BUILD/INC/MLI.ERR.I
|
||
.INB /A2OSX.BUILD/INC/NIC.I
|
||
.INB /A2OSX.BUILD/INC/LIBTCPIP.I
|
||
*--------------------------------------
|
||
ZPFrameInPtr .EQ ZPLIB
|
||
ZPFrameInLen .EQ ZPLIB+2
|
||
|
||
ZPDataInPtr .EQ ZPLIB+4
|
||
ZPDataInLen .EQ ZPLIB+6
|
||
|
||
ZPFrameOutPtr .EQ ZPLIB+8
|
||
ZPFrameOutLen .EQ ZPLIB+10
|
||
|
||
ZPDataOutPtr .EQ ZPLIB+12
|
||
ZPDataOutLen .EQ ZPLIB+14
|
||
|
||
ZPPtrIP .EQ ZPLIB+16
|
||
ZPPtrMAC .EQ ZPLIB+18
|
||
ZPPtrDNS .EQ ZPLIB+20
|
||
ZPPtrSKT .EQ ZPLIB+22
|
||
|
||
ZPCachePtr .EQ ZPLIB+24
|
||
ZPTmpPtr1 .EQ ZPLIB+26
|
||
ZPTmpPtr2 .EQ ZPLIB+28
|
||
ZPTmpPtr3 .EQ ZPLIB+30
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
jmp (.1,x)
|
||
.DA #$61 6502,Level 1 (65c02)
|
||
.DA #1 BIN Layout Version 1
|
||
.DA 0
|
||
.DA CS.END-CS.START
|
||
.DA 0
|
||
.DA 0
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA LIB.LOAD
|
||
.DA LIB.UNLOAD
|
||
|
||
.DA SET.IPCFG
|
||
.DA GET.IPCFG
|
||
|
||
.DA POLL
|
||
.DA PULSEA
|
||
|
||
.DA ARP.CLEAR
|
||
.DA ARP.QUERY
|
||
.DA ARP.ADD
|
||
.DA ARP.GetCACHE
|
||
|
||
.DA DNS.CLEAR
|
||
.DA DNS.QUERY
|
||
.DA DNS.ADD
|
||
.DA DNS.GetCACHE
|
||
|
||
.DA HST.GETBYNAME
|
||
.DA HST.GETBYADDR
|
||
|
||
.DA SKT.New
|
||
.DA SKT.CLOSEA
|
||
.DA SKT.GETTABLE
|
||
.DA SKT.GETA
|
||
|
||
.DA SKT.AcceptA
|
||
.DA SKT.MkNodA
|
||
|
||
.DA SKT.Write
|
||
.DA SKT.Read
|
||
.DA SKT.ReadA
|
||
.DA SKT.PutC
|
||
.DA SKT.PutS
|
||
.DA SKT.GetC.A
|
||
.DA SKT.GetS
|
||
*--------------------------------------
|
||
L.IPCFG .DA IPCFG
|
||
L.ARP.REQ .DA ARP.REQ
|
||
L.ARP.REP .DA ARP.REP
|
||
L.DNS.SOCKET .DA DNS.SOCKET
|
||
L.DNS.MSG .DA DNS.MSG
|
||
L.ARP.CACHE .DA ARP.CACHE
|
||
L.DNS.CACHE .DA DNS.CACHE
|
||
L.SKT.Template .DA SKT.Template
|
||
L.TmpByte .DA TmpByte
|
||
L.TCP.IN.JMP .DA TCP.IN.JMP.CLOSED
|
||
.DA TCP.IN.JMP.LISTEN
|
||
.DA TCP.IN.JMP.SYNSENT
|
||
.DA TCP.IN.JMP.SYNRCVD
|
||
.DA TCP.IN.JMP.ESTBLSH
|
||
.DA TCP.IN.JMP.CLWAIT
|
||
.DA TCP.IN.JMP.LASTACK
|
||
.DA TCP.IN.JMP.FINWT1
|
||
.DA TCP.IN.JMP.FINWT2
|
||
.DA TCP.IN.JMP.CLOSING
|
||
.DA TCP.IN.JMP.TIMEWT
|
||
.DA 0
|
||
*--------------------------------------
|
||
LIB.LOAD ldx bFirstLoad
|
||
bne .8
|
||
sta NODE.SSOCK+S.NODE.HANDLER
|
||
jsr ARP.CLEAR
|
||
jsr DNS.CLEAR
|
||
|
||
>LDYAI K.SKTTABLE.SIZE*S.SOCKET
|
||
>SYSCALL GetMem0.YA
|
||
bcs .9
|
||
|
||
stx hSocketTable
|
||
|
||
inc bFirstLoad
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
LIB.UNLOAD lda hSocketTable
|
||
beq .8
|
||
|
||
>SYSCALL FreeMem.A
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
POLL ldx #DEVMGR.READBLOCK
|
||
jsr NetDevJmp
|
||
bcs .99 No Frame
|
||
|
||
stx hFrameIn
|
||
>STYA ZPFrameInPtr
|
||
|
||
lda (ZPFrameInPtr) Get Frame Len
|
||
sta ZPFrameInLen
|
||
ldy #1
|
||
lda (ZPFrameInPtr),y
|
||
sta ZPFrameInLen+1
|
||
|
||
ldy #S.ETH.ETHERTYPE
|
||
lda (ZPFrameInPtr),y
|
||
tax
|
||
iny
|
||
lda (ZPFrameInPtr),y
|
||
|
||
cmp #S.ETH.ETHERTYPE.ARP
|
||
bne .1
|
||
cpx /S.ETH.ETHERTYPE.ARP
|
||
bne .1
|
||
|
||
jmp ARP.IN
|
||
|
||
.1 cmp #S.ETH.ETHERTYPE.IP
|
||
bne .9
|
||
cpx /S.ETH.ETHERTYPE.IP
|
||
bne .9
|
||
|
||
jmp IP.IN
|
||
|
||
.9 lda hFrameIn
|
||
>SYSCALL FreeMem.A
|
||
.99 rts
|
||
*--------------------------------------
|
||
* Expire = every sec
|
||
* Retry = every 100 msec
|
||
*--------------------------------------
|
||
PULSEA and #S.EVT.F.T1SEC
|
||
beq .1
|
||
jsr ARP.EXPIRE
|
||
jsr DNS.EXPIRE
|
||
|
||
.1 jsr DNS.POLL
|
||
jmp FRM.RETRY
|
||
*--------------------------------------
|
||
GetDynPort inc DYNPORT.LAST
|
||
bne .1
|
||
inc DYNPORT.LAST+1
|
||
|
||
lda DYNPORT.LAST
|
||
cmp #K.DYNPORT.END
|
||
lda DYNPORT.LAST+1
|
||
sbc /K.DYNPORT.END
|
||
|
||
bcs .1
|
||
|
||
>LDAXI K.DYNPORT.START
|
||
sta DYNPORT.LAST
|
||
stx DYNPORT.LAST+1
|
||
rts CC
|
||
|
||
.1 lda DYNPORT.LAST
|
||
ldx DYNPORT.LAST+1
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
NetDevJmp jmp *
|
||
*--------------------------------------
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.ARP
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.CFG
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.DNS
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.FRM
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.HST
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.ICMP
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.IP
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.SKT
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.TCP
|
||
.INB /A2OSX.SRC/LIB/LIBTCPIP.S.UDP
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
ARP.REQ .DA S.ARP-2 Frame size
|
||
ARP.REQ.DSTMAC .HS FFFFFFFFFFFF
|
||
ARP.REQ.SRCMAC .BS 6
|
||
ARP.REQ.ETYPE .DA /S.ETH.ETHERTYPE.ARP
|
||
.DA #S.ETH.ETHERTYPE.ARP
|
||
.HS 0001.0800.06.04
|
||
ARP.REQ.OP .DA /S.ARP.OPERATION.REQ
|
||
.DA #S.ARP.OPERATION.REQ
|
||
ARP.REQ.SHA .BS 6
|
||
ARP.REQ.SPA .BS 4
|
||
ARP.REQ.THA .BS 6
|
||
ARP.REQ.TPA .BS 4
|
||
*--------------------------------------
|
||
ARP.REP .DA S.ARP-2 Frame size
|
||
ARP.REP.DSTMAC .BS 6
|
||
ARP.REP.SRCMAC .BS 6
|
||
ARP.REP.ETYPE .DA /S.ETH.ETHERTYPE.ARP
|
||
.DA #S.ETH.ETHERTYPE.ARP
|
||
.HS 0001.0800.06.04
|
||
ARP.REP.OP .DA /S.ARP.OPERATION.REP
|
||
.DA #S.ARP.OPERATION.REP
|
||
ARP.REP.SHA .BS 6
|
||
ARP.REP.SPA .BS 4
|
||
ARP.REP.THA .BS 6
|
||
ARP.REP.TPA .BS 4
|
||
*--------------------------------------
|
||
DNS.SOCKET .DA #S.SOCKET.SOCK.DGRAM
|
||
.BS 3
|
||
DNS.SOCKET.SA .BS 4
|
||
DNS.SOCKET.SP .DA 0 Dynamic
|
||
DNS.SOCKET.DA .BS 4
|
||
DNS.SOCKET.DP .DA UDP.PORT.DNS
|
||
*--------------------------------------
|
||
DNS.MSG.LEN .BS 2
|
||
DNS.MSG
|
||
DNS.MSG.ID .BS 2
|
||
.DA /S.DNS.F.RD Flags=query
|
||
.DA #S.DNS.F.RD
|
||
.DA $100 QDCOUNT
|
||
.BS 6 ANCOUNT,NSCOUNT,ARCOUNT
|
||
DNS.MSG.NAME .BS K.DNS.MAXLEN+6
|
||
*--------------------------------------
|
||
IPCFG .BS S.IPCFG
|
||
ARP.CACHE .BS K.ARPCACHE.SIZE*S.ARPCACHE
|
||
DNS.CACHE .BS K.DNSCACHE.SIZE*S.DNSCACHE
|
||
FRM.QUEUE.Tail .BS 1
|
||
FRM.QUEUE.Head .BS 1
|
||
FRM.QUEUE.hMem .BS K.FRMQUEUE.SIZE
|
||
FRM.QUEUE.State .BS K.FRMQUEUE.SIZE
|
||
FRM.QUEUE.Retry .BS K.FRMQUEUE.SIZE
|
||
*--------------------------------------
|
||
bFirstLoad .DA #0
|
||
hSocketTable .BS 1
|
||
DevFlags .BS 1
|
||
DYNPORT.LAST .DA K.DYNPORT.START
|
||
hDNSSocket1 .BS 1
|
||
hDNSSocket2 .BS 1
|
||
DNS.HostName .BS K.DNS.MAXLEN+1
|
||
DNS.TmpCache .BS S.DNSCACHE
|
||
ARP.TmpCache .BS S.ARP
|
||
SKT.Template .BS S.SOCKET
|
||
SKT.TCBCache .BS S.TCB
|
||
TmpByte .BS 1
|
||
TmpDWord .BS 4
|
||
TmpOffset .BS 2
|
||
hFrameIn .BS 1
|
||
hFrameOut .BS 1
|
||
bTextMode .BS 1
|
||
HST.DecStr .BS 4
|
||
HST.IP .BS 5
|
||
IP.ID .BS 2
|
||
IP.CHECKSUM .BS 4
|
||
NODE.SSOCK .BS 1 S.NODE.HANDLER
|
||
.DA #S.NODE.T.SSOCK
|
||
.BS 1 S.NODE.SSOCK.HSKT
|
||
.DA #0 S.NODE.SSOCK.OPEN
|
||
.DA #0 S.NODE.SSOCK.CLOSE
|
||
.DA #0
|
||
.DA #0
|
||
.DA #0 S.NODE.SSOCK.STATUS
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/LIB/LIBTCPIP.S
|
||
ASM
|