A2osX/BIN/IPCONFIG.S.txt
2018-12-18 15:37:07 +01:00

420 lines
8.5 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
PREFIX
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
.TF BIN/DEV/IPCONFIG2
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/MLI.E.I
.INB INC/NIC.I
.INB INC/ETH.I
.INB INC/LIBTCPIP.I
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
pIPCFG .BS 2
pFD .BS 2
pDEV .BS 2
ZS.END
.ED
*--------------------------------------
* 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 CS
.DA DS.END-DS.START DS
.DA #16 SS
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.MSG.USAGE .DA MSG.USAGE
L.MSG0 .DA MSG0
L.MSG0.NL .DA MSG0.NL
L.MSG0.L .DA MSG0.L
L.MSG1.DEV .DA MSG1.DEV
L.MSG1.DEV.ARP .DA MSG1.DEV.ARP
L.MSG1.DEV.IP .DA MSG1.DEV.IP
L.MSG1.LINK.OK .DA MSG1.LINK.OK
L.MSG1.LINK.KO .DA MSG1.LINK.KO
L.MSG1.LINKSPEED .DA MSG1.LINKSPEED
L.MSG1.DPLX.FD .DA MSG1.DPLX.FD
L.MSG1.DPLX.HD .DA MSG1.DPLX.HD
L.MSG2 .DA MSG2
L.MSG2.C .DA MSG2.C
L.MSG2.U .DA MSG2.U
L.MSG2.DHCPSRVR .DA MSG2.DHCPSRVR
L.MSG2.IP .DA MSG2.IP
L.MSG2.GW .DA MSG2.GW
L.MSG2.DNS .DA MSG2.DNS
L.MSG2.HOSTNAME .DA MSG2.HOSTNAME
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.MSG.DNS.ADD .DA MSG.DNS.ADD
L.HOSTNAME .DA HOSTNAME
L.TCPIP.CONF .DA TCPIP.CONF
L.HOSTS .DA HOSTS
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib
bcs .9
sta hLIBTCPIP
.9 rts
*--------------------------------------
CS.RUN
.1 >INC.G ArgCount
>SYSCALL ArgV
bcs .7
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .99
ldy #1
lda (ZPPtr1),y
ldx OptionList
.2 cmp OptionList,x
beq .3
dex
bne .2
.99 >PUSHBI 0
>LDYA L.MSG.USAGE
>SYSCALL printf
lda #E.SYN
sec
rts
.3 ldy OptionVars-1,x
lda #$80
sta (pData),y
bra .1
.7
*--------------------------------------
CS.RUN.STATUS >PUSHBI 0
>LDYA L.MSG0
>SYSCALL printf
>LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG
>STYA pIPCFG
ldy #S.IPCFG.hFD
lda (pIPCFG),y
bne .1
>LDYA L.MSG0.NL
>SYSCALL puts
jmp CS.RUN.DONE
.1 >STA.G FD.ETH
>SYSCALL GetMemPtr
>STYA pFD
>PUSHEA.G DIB
>LDA.G FD.ETH
>SYSCALL GetDevStatus
>LEA.G DCB.NIC
>STYA.G IOCTL+S.IOCTL.BUFPTR
lda #S.IOCTL.STATCODE.GETDCB
>STA.G IOCTL+S.IOCTL.STATCODE
>PUSHEA.G IOCTL
>PUSHBI IOCTL.STATUS
>LDA.G FD.ETH
>SYSCALL IOCTL
CS.RUN.DUMP >LDYA L.MSG0.L
>SYSCALL puts
ldy #DCB.NIC+S.DCB.NIC.MAC+5
ldx #6
.1 lda (pData),y
>PUSHA
dey
dex
bne .1
>PUSHEA.G DIB+S.DIB.IDS
lda #S.FD.DEV.NAME
clc
adc pFD
tay
lda /S.FD.DEV.NAME
adc pFD+1
>PUSHYA
>PUSHB.G FD.ETH
>PUSHBI 11
>LDYA L.MSG1.DEV
>SYSCALL printf
>LDA.G DCB.NIC+S.DCB.NIC.FLAGS
and #S.DCB.NIC.FLAGS.ARPOFFLOAD
beq .2
lda #1
.2 >PUSHA
>PUSHBI 1
>LDYA L.MSG1.DEV.ARP
>SYSCALL printf
>LDA.G DCB.NIC+S.DCB.NIC.FLAGS
and #S.DCB.NIC.FLAGS.IPOFFLOAD
beq .3
lda #1
.3
>PUSHA
>PUSHBI 1
>LDYA L.MSG1.DEV.IP
>SYSCALL printf
>LDA.G DCB.NIC+S.DCB.NIC.LINK
and #S.DCB.NIC.LINK.OK
bne CS.RUN.LINK
>LDYA L.MSG1.LINK.KO
>SYSCALL puts
bra CS.RUN.DUMPIP
CS.RUN.LINK >LDYA L.MSG1.LINK.OK
>SYSCALL puts
>PUSHBI 0
>LDYA L.MSG1.LINKSPEED
>SYSCALL printf
>LDA.G DCB.NIC+S.DCB.NIC.SPEED
and #$0F
tax
.4 phx
lda #'0'
>SYSCALL PutChar
plx
dex
bne .4
>LDA.G DCB.NIC+S.DCB.NIC.LINK
and #S.DCB.NIC.LINK.FD
bne .5
>LDYA L.MSG1.DPLX.HD
bra .6
.5 >LDYA L.MSG1.DPLX.FD
.6 >SYSCALL puts
CS.RUN.DUMPIP >PUSHBI 0
>LDYA L.MSG2
>SYSCALL printf
lda (pIPCFG)
and #S.IPCFG.STATUS.OK
beq .11
>LDYA L.MSG2.C
bra .10
.11 >LDYA L.MSG2.U
.10 >SYSCALL puts
ldy #S.IPCFG.DHCPSRVR+3
ldx #4
.2 >PUSHB (pIPCFG),y
dey
dex
bne .2
>PUSHBI 4
>LDYA L.MSG2.DHCPSRVR
>SYSCALL printf
ldy #S.IPCFG.IP+7 IP/MASK
ldx #8
.3 >PUSHB (pIPCFG),y
dey
dex
bne .3
>PUSHBI 8
>LDYA L.MSG2.IP
>SYSCALL printf
ldy #S.IPCFG.GW+3
ldx #4
.4 >PUSHB (pIPCFG),y
dey
dex
bne .4
>PUSHBI 4
>LDYA L.MSG2.GW
>SYSCALL printf
ldy #S.IPCFG.DNS1+7
ldx #8
.5 >PUSHB (pIPCFG),y
dey
dex
bne .5
>PUSHBI 8
>LDYA L.MSG2.DNS
>SYSCALL printf
lda pIPCFG
clc
adc #S.IPCFG.DOMAIN
tay
lda pIPCFG+1
adc #0
>PUSHYA
lda pIPCFG
clc
adc #S.IPCFG.HOSTNAME
tay
lda pIPCFG+1
adc #0
>PUSHYA
>PUSHBI 4
>LDYA L.MSG2.HOSTNAME
>SYSCALL printf
CS.RUN.DONE lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
beq .8
>SYSCALL UnloadLib
.8 clc
rts
*--------------------------------------
.INB USR/SRC/SBIN/IPCONFIG.S.DEV
*--------------------------------------
CS.END
LIBTCPIP .AZ "libtcpip"
*--------------------------------------
OptionList >PSTR "DESdes"
OptionVars .DA #bDHCP,#bETC,#bSet,#bDHCP,#bETC,#bSet
*--------------------------------------
MSG.USAGE .AS "Usage : IPCONFIG <switches>\r\n"
.AS " -D : Try to get IP address from DHCP\r\n"
.AS " -E : Read ETC files\r\n"
.AZ " -S : Set/Reset TCPIP configuration (-E, then -D if required)\r\n"
*--------------------------------------
MSG0 .AZ "TCP/IP Status : "
MSG0.L .AZ "Loaded"
MSG0.NL .AZ "Not Loaded"
*--------------------------------------
MSG1.DEV .AS "Device Configuration :\r\n"
.AS " FD.ETH : $%h\r\n"
.AS " Device Name : %s\r\n"
.AS " Device Type : %S\r\n"
.AZ " HW Address : %02h:%02h:%02h:%02h:%02h:%02h\r\n"
MSG1.DEV.ARP .AZ " ARP Offload : %d\r\n"
MSG1.DEV.IP .AS " IP Offload : %d\r\n"
.AZ " Link Status : "
MSG1.LINK.OK .AZ "OK"
MSG1.LINK.KO .AZ "Media Disconnected"
MSG1.LINKSPEED .AZ " Link Speed : 1"
MSG1.DPLX.FD .AZ " Mbit/s,Full Duplex"
MSG1.DPLX.HD .AZ " Mbit/s,Half Duplex"
*--------------------------------------
MSG2 .AZ "IP Configuration : "
MSG2.C .AZ "Configured"
MSG2.U .AZ "Not Configured"
MSG2.DHCPSRVR .AZ " DHCP Server : %d.%d.%d.%d\r\n"
MSG2.IP .AZ " IP/Mask : %d.%d.%d.%d/%d.%d.%d.%d\r\n"
MSG2.GW .AZ " Gateway : %d.%d.%d.%d\r\n"
MSG2.DNS .AZ " DNS : %d.%d.%d.%d,%d.%d.%d.%d\r\n"
MSG2.HOSTNAME .AZ " Hostname : %s.%s\r\n"
hLIBTCPIP .BS 1
*--------------------------------------
DEVNAME .AZ "/DEV/ETH1"
MSG.DEV.KO .AZ "No Device Found, exiting."
MSG.DEV.OK .AZ "Bound To Device : %s\r\n"
MSG.CFG .AZ "Reading %s..."
MSG.CFG.KO .AZ "Failed!!! [%h]\r\n"
MSG.CFG.OK .AZ "OK."
MSG.DNS.ADD .AZ " - Adding static host %d.%d.%d.%d %s..."
*--------------------------------------
HOSTNAME .AZ "${ROOT}ETC/HOSTNAME"
TCPIP.CONF .AZ "${ROOT}ETC/TCPIP.CONF"
HOSTS .AZ "${ROOT}ETC/HOSTS"
*--------------------------------------
CFG.DefaultHost .AZ "a2osx-XXXX"
CFG.Keywords >PSTR "address"
>PSTR "netmask"
>PSTR "gateway"
>PSTR "nameserver"
>PSTR "dnsdomain"
.DA #0
CFG.hBuf1 .BS 1
CFG.hBuf2 .BS 1
CFG.hBuf3 .BS 1
CFG.hCfgPath .BS 1
CFG.hCfgFile .BS 1
CFG.IP .BS 4
CFG.HOSTS.SScanF .AZ "%d.%d.%d.%d %s %s"
*--------------------------------------
.DUMMY
.OR 0
DS.START
ArgCount .BS 1
bDHCP .BS 1
bETC .BS 1
bSet .BS 1
FD.ETH .BS 1
IOCTL .BS S.IOCTL
DIB .BS S.DIB
DCB.NIC .BS S.DCB.NIC
DS.END .ED
*--------------------------------------
MAN
SAVE USR/SRC/SBIN/IPCONFIG.S
ASM