mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-04 03:05:43 +00:00
243 lines
4.9 KiB
Plaintext
243 lines
4.9 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BOOT/SBIN/TCPIP
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
.INB INC/LIBTCPIP.I
|
||
*--------------------------------------
|
||
ZPIPCfgPtr .EQ ZPBIN
|
||
ZPIPDevPtr .EQ ZPBIN+2
|
||
*--------------------------------------
|
||
* 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 Code Length To Relocate
|
||
.DA 0
|
||
.DA 0
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.LIBTCPIP .DA LIBTCPIP
|
||
L.DEVNAME .DA DEVNAME
|
||
L.MSG.DEV.KO .DA MSG.DEV.KO
|
||
L.MSG.DEV.OK .DA MSG.DEV.OK
|
||
L.MSG.CFG .DA MSG.CFG
|
||
L.MSG.CFG.KO .DA MSG.CFG.KO
|
||
L.MSG.CFG.OK .DA MSG.CFG.OK
|
||
L.HOSTNAME .DA HOSTNAME
|
||
L.TCPIP.CONF .DA TCPIP.CONF
|
||
L.HOSTS .DA HOSTS
|
||
L.IPCFG .DA IPCFG
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT >LDYA L.LIBTCPIP
|
||
>SYSCALL SYS.LoadLibYA
|
||
bcs .99
|
||
sta hLIBTCPIP
|
||
|
||
jsr CS.INIT.DEV
|
||
bcs .99
|
||
|
||
jsr CFG.Read continue even if error opening CFG file
|
||
|
||
lda IPCFG+S.IPCFG.HOSTNAME
|
||
bne .4
|
||
|
||
ldy #0
|
||
.2 lda DefaultHostName,y
|
||
beq .3
|
||
sta IPCFG+S.IPCFG.HOSTNAME,y
|
||
iny
|
||
bne .2
|
||
|
||
.3 lda A2osX.TIMER16
|
||
jsr A2CharAX
|
||
sta IPCFG+S.IPCFG.HOSTNAME,y
|
||
iny
|
||
txa
|
||
sta IPCFG+S.IPCFG.HOSTNAME,y
|
||
iny
|
||
|
||
lda A2osX.TIMER16+1
|
||
jsr A2CharAX
|
||
sta IPCFG+S.IPCFG.HOSTNAME,y
|
||
iny
|
||
txa
|
||
sta IPCFG+S.IPCFG.HOSTNAME,y
|
||
iny
|
||
|
||
lda #0
|
||
sta IPCFG+S.IPCFG.HOSTNAME,y
|
||
|
||
.4 >PUSHW L.IPCFG
|
||
>LIBCALL hLIBTCPIP,LIBTCPIP.SET.IPCFG
|
||
|
||
lda (pPs)
|
||
ora #S.PS.F.EVENT Now accept events
|
||
sta (pPs)
|
||
|
||
clc
|
||
.99 rts
|
||
*--------------------------------------
|
||
CS.INIT.DEV >LDYA L.DEVNAME
|
||
>SYSCALL SYS.GetDevByNameYA
|
||
bcc .1
|
||
inc DEVNAME+4
|
||
lda DEVNAME+4
|
||
cmp #'8'
|
||
bne CS.INIT.DEV
|
||
|
||
>LDYA L.MSG.DEV.KO
|
||
>SYSCALL SYS.PrintFYA
|
||
lda #DEVMGR.ERRDNF
|
||
sec
|
||
rts
|
||
|
||
.1 >STYA pNetDevJmp+1
|
||
txa
|
||
sta hNetDev
|
||
sta IPCFG+S.IPCFG.HDEV
|
||
|
||
>PUSHW L.DEVNAME
|
||
>LDYA L.MSG.DEV.OK
|
||
>SYSCALL SYS.PrintFYA
|
||
|
||
ldx #DEVMGR.OPEN
|
||
jsr pNetDevJmp
|
||
bcs .9
|
||
|
||
ldx #DEVMGR.GETINFO
|
||
jsr pNetDevJmp
|
||
bcs .9
|
||
>STYA ZPIPDevPtr
|
||
|
||
ldy #S.DEVINFO.NET.MAC
|
||
ldx #S.IPCFG.MAC
|
||
|
||
.2 lda (ZPIPDevPtr),y
|
||
sta IPCFG,x
|
||
iny
|
||
inx
|
||
cpx #S.IPCFG.MAC+6
|
||
bne .2
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT clc
|
||
lda (pEvent)
|
||
bit #S.EVT.F.NET
|
||
beq .1
|
||
|
||
ldy #S.EVT.hDEV
|
||
lda (pEvent),y
|
||
cmp hNetDev
|
||
bne .9
|
||
|
||
ldy #S.EVT.DATALO Get Frame hMem
|
||
lda (pEvent),y
|
||
>LIBCALL hLIBTCPIP,LIBTCPIP.RCVD.FRAMEA
|
||
rts
|
||
|
||
.1 bit #S.EVT.F.T10TH
|
||
beq .9 S.EVT.F.T1SEC
|
||
>LIBCALL hLIBTCPIP,LIBTCPIP.PULSEA
|
||
|
||
.9 sec never discard TIME event
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT lda IPCFG+S.IPCFG.HDEV
|
||
beq .1
|
||
ldx #DEVMGR.CLOSE
|
||
jsr pNetDevJmp
|
||
|
||
.1 lda hLIBTCPIP
|
||
>SYSCALL SYS.UnloadLibA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
A2CharAX pha
|
||
lsr
|
||
lsr
|
||
lsr
|
||
lsr
|
||
and #$0F
|
||
ora #$30
|
||
cmp #'9'+1
|
||
bcc .1
|
||
adc #6
|
||
.1 tax
|
||
pla
|
||
and #$0F
|
||
ora #$30
|
||
cmp #'9'+1
|
||
bcc .8
|
||
adc #6
|
||
.8 rts
|
||
*--------------------------------------
|
||
pNetDevJmp jmp *
|
||
*--------------------------------------
|
||
.INB SBIN/TCPIP.S.CFG
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
LIBTCPIP >PSTRING "libtcpip.o"
|
||
DEVNAME >PSTRING "ETH1"
|
||
MSG.DEV.KO >CSTRING "TCPIP:No Device Found, exiting.\n"
|
||
MSG.DEV.OK >CSTRING "TCPIP:Bound To Device : %S\n"
|
||
MSG.CFG >CSTRING "TCPIP:Reading %S..."
|
||
MSG.CFG.KO >CSTRING "Failed!!! [%h]\n"
|
||
MSG.CFG.OK >CSTRING "OK.\n"
|
||
*--------------------------------------
|
||
HOSTNAME >PSTRING "${A2OSX}ETC/HOSTNAME"
|
||
TCPIP.CONF >PSTRING "${A2OSX}ETC/TCPIP.CONF"
|
||
HOSTS >PSTRING "${A2OSX}ETC/HOSTS"
|
||
DefaultHostName >CSTRING "a2osx-"
|
||
CFG.Keywords >PSTRING "DOMAIN"
|
||
>PSTRING "IP"
|
||
>PSTRING "MASK"
|
||
>PSTRING "GW"
|
||
>PSTRING "DNS1"
|
||
>PSTRING "DNS2"
|
||
CFG.Keyword.Map .DA #0 End Of Keyword table and NA Keyword
|
||
.DA #S.IPCFG.IP
|
||
.DA #S.IPCFG.MASK
|
||
.DA #S.IPCFG.GW
|
||
.DA #S.IPCFG.DNS1
|
||
.DA #S.IPCFG.DNS2
|
||
hLIBTCPIP .BS 1
|
||
hNetDev .BS 1
|
||
IPCFG .BS S.IPCFG
|
||
CFG.hCfgFile .BS 1
|
||
CFG.FileLen .BS 2
|
||
CFG.Keyword .BS 1
|
||
CFG.StrBuf .BS 4
|
||
CFG.HexByte .BS 1
|
||
CFG.IP .BS 5
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SBIN/TCPIP.S
|
||
ASM
|