A2osX/SBIN/NETWORKD.S.txt

284 lines
5.0 KiB
Plaintext
Raw Normal View History

2019-01-05 20:33:08 +00:00
NEW
PREFIX
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
.TF SBIN/NETWORKD
2019-01-15 16:37:32 +00:00
*--------------------------------------
LIB.MAX .EQ 4
2019-01-05 20:33:08 +00:00
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
2019-01-15 16:37:32 +00:00
.INB INC/MLI.I
2019-01-05 20:33:08 +00:00
.INB INC/MLI.E.I
2019-01-16 14:37:21 +00:00
.INB INC/NIC.I
2019-01-05 20:33:08 +00:00
.INB INC/ETH.I
2019-01-15 16:37:32 +00:00
.INB INC/LIB.NET.I
2019-01-05 20:33:08 +00:00
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
2019-01-15 16:37:32 +00:00
pNETCFG .BS 2
pBuf .BS 2
ZS.END .ED
2019-01-05 20:33:08 +00:00
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #16 Stack Size
.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.DEVNAME .DA DEVNAME
L.MSG.DEV.OK .DA MSG.DEV.OK
L.MSG.DEV.KO .DA MSG.DEV.KO
2019-01-15 16:37:32 +00:00
L.MSG.LIB .DA MSG.LIB
2019-01-05 20:33:08 +00:00
L.IOCTL .DA IOCTL
2019-01-16 14:37:21 +00:00
L.DCB.NIC .DA DCB.NIC
2019-01-15 16:37:32 +00:00
L.ETCNETWORK .DA ETCNETWORK
2019-01-05 20:33:08 +00:00
.DA 0
*--------------------------------------
2019-01-15 16:37:32 +00:00
CS.INIT jsr CS.INIT.DEV
bcs .9
jsr CS.INIT.LIBS
bcs .9
jsr CS.INIT.CONF
.9 rts
2019-01-05 20:33:08 +00:00
*--------------------------------------
2019-01-15 16:37:32 +00:00
CS.INIT.DEV >PUSHBI 0
2019-01-05 20:33:08 +00:00
>LDYA L.DEVNAME
>SYSCALL open
2019-01-15 16:37:32 +00:00
bcc .8
2019-01-05 20:33:08 +00:00
inc DEVNAME+8
lda DEVNAME+8
cmp #'8'
2019-01-15 16:37:32 +00:00
bne CS.INIT.DEV
2019-01-05 20:33:08 +00:00
>LDYA L.MSG.DEV.KO
>SYSCALL puts
lda #MLI.E.NODEV
sec
rts
2019-01-15 16:37:32 +00:00
.8 sta DevID
2019-01-05 20:33:08 +00:00
>PUSHW L.DEVNAME
>PUSHBI 2
>LDYA L.MSG.DEV.OK
>SYSCALL printf
2019-01-16 14:37:21 +00:00
>LDYA L.DCB.NIC
>STYA IOCTL+S.IOCTL.BUFPTR
lda #S.IOCTL.STATCODE.GETDCB
sta IOCTL+S.IOCTL.STATCODE
>PUSHW L.IOCTL
>PUSHBI IOCTL.STATUS
lda DevID
>SYSCALL IOCTL
2019-01-15 16:37:32 +00:00
rts
*--------------------------------------
CS.INIT.LIBS lda LibCnt
.1 inc
>SYSCALL ArgV
bcs .8
phy
pha
>PUSHYA
>PUSHBI 2
>LDYA L.MSG.LIB
>SYSCALL printf
pla
ply
2019-01-14 07:11:50 +00:00
>SYSCALL LoadLib
2019-01-15 16:37:32 +00:00
bcs .9
2019-01-14 16:37:56 +00:00
2019-01-15 16:37:32 +00:00
ldy LibCnt
sta hLIBs,y
inc LibCnt
2019-01-14 16:37:56 +00:00
2019-01-15 16:37:32 +00:00
tay
ldx #LIBNET.GETCFG
jsr A2osX.LIBCALL
>STYA pNETCFG
2019-01-14 16:37:56 +00:00
lda DevID
2019-01-15 16:37:32 +00:00
ldy #S.NETCFG.DevID
sta (pNETCFG),y
2019-01-05 20:33:08 +00:00
2019-01-17 15:05:48 +00:00
iny S.NETCFG.DevFlags
lda DCB.NIC+S.DCB.NIC.FLAGS
sta (pNETCFG),y
2019-01-16 14:37:21 +00:00
ldx #5
ldy #S.NETCFG.MAC+5
.2 lda DCB.NIC+S.DCB.NIC.MAC,x
sta (pNETCFG),y
dey
dex
bpl .2
2019-01-15 16:37:32 +00:00
lda LibCnt
cmp #LIB.MAX
bne .1
.8 clc
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
.9 rts
*--------------------------------------
CS.INIT.CONF >LDYAI 64
>SYSCALL GetMem
bcs .9
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
>STYA pBuf
stx hLineBuf
>PUSHWI 0
>PUSHBI S.FI.T.TXT
>PUSHBI O.RDONLY
>LDYA L.ETCNETWORK
>SYSCALL fopen
bcs .9
sta hNetworkFile
.1 >PUSHWI 63
>PUSHW pBuf
lda hNetworkFile
>SYSCALL fgets
bcs .8
>PUSHBI 0 PS Flags
>LDYA pBuf
>SYSCALL execL
bra .1
.8 lda hNetworkFile
>SYSCALL fclose
clc
.9 rts
*--------------------------------------
CS.RUN >PUSHW L.IOCTL
2019-01-05 20:33:08 +00:00
>PUSHBI IOCTL.READ
2019-01-14 16:37:56 +00:00
lda DevID
2019-01-05 20:33:08 +00:00
>SYSCALL IOCTL
2019-01-15 16:37:32 +00:00
bcs .8 No Frame
2019-01-05 20:33:08 +00:00
sta hFrameIn
2019-01-15 16:37:32 +00:00
ldx #0
.1 ldy hLIBs,x
beq .7
2019-01-05 20:33:08 +00:00
2019-01-14 07:11:50 +00:00
>PUSHW L.IOCTL
lda hFrameIn
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
phx
ldx #LIBNET.INCOMING
jsr A2osX.LIBCALL
plx
bcc .8
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
inx
bra .1
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
.7 lda hFrameIn
2019-01-05 20:33:08 +00:00
>SYSCALL freemem
2019-01-15 16:37:32 +00:00
.8 clc
rts
2019-01-05 20:33:08 +00:00
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .9
2019-01-15 16:37:32 +00:00
ldx #0
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
.1 ldy hLIBs,x
2019-01-05 20:33:08 +00:00
beq .9
2019-01-14 16:37:56 +00:00
2019-01-15 16:37:32 +00:00
phx
ldx #LIBNET.PULSE
2019-01-05 20:33:08 +00:00
lda (pEvent)
2019-01-15 16:37:32 +00:00
jsr A2osX.LIBCALL
plx
inx
bra .1
2019-01-05 20:33:08 +00:00
.9 sec never discard TIME event
rts
*--------------------------------------
2019-01-15 16:37:32 +00:00
CS.QUIT ldx #0
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
.1 lda hLIBs,x
beq .7
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
phx
>SYSCALL UnLoadLib
plx
inx
bra .1
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
.7 >PUSHWI 0
2019-01-05 20:33:08 +00:00
>PUSHBI IOCTL.CLOSE
2019-01-14 16:37:56 +00:00
lda DevID
2019-01-05 20:33:08 +00:00
>SYSCALL IOCTL
clc
rts
*--------------------------------------
CS.END
*--------------------------------------
DEVNAME .AZ "/DEV/ETH1"
2019-01-14 16:37:56 +00:00
MSG.DEV.KO .AZ "NETWORKD:No Device Found, exiting."
MSG.DEV.OK .AZ "NETWORKD:Bound To Device : %s\r\n"
2019-01-15 16:37:32 +00:00
MSG.LIB .AZ "NETWORKD:Loading %s ...\r\n"
2019-01-14 16:37:56 +00:00
DevID .BS 1
2019-01-15 16:37:32 +00:00
LibCnt .BS 1
hLIBs .BS LIB.MAX+1 for ending 0 if MAX libs
2019-01-05 20:33:08 +00:00
IOCTL .BS S.IOCTL
2019-01-16 14:37:21 +00:00
DCB.NIC .BS S.DCB.NIC
2019-01-15 16:37:32 +00:00
*ETCNETWORK .AZ "${ROOT}ETC/NETWORK"
ETCNETWORK .AZ "../ETC/NETWORK"
hNetworkFile .BS 1
hLineBuf .BS 1
2019-01-05 20:33:08 +00:00
hFrameIn .BS 1
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END .ED
*--------------------------------------
MAN
SAVE USR/SRC/SBIN/NETWORKD.S
ASM