A2osX/SBIN/NETWORKD.S.txt

278 lines
5.3 KiB
Plaintext
Raw Normal View History

2019-01-05 20:33:08 +00:00
NEW
2019-07-26 14:23:07 +00:00
AUTO 3,1
2019-01-05 20:33:08 +00:00
.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
2019-05-09 21:00:23 +00:00
hNetworkFile .BS 1
hLineBuf .BS 1
hFrameIn .BS 1
2019-01-15 16:37:32 +00:00
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
2019-05-09 21:00:23 +00:00
.DA #64 Stack Size
2019-01-05 20:33:08 +00:00
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
2019-10-03 06:25:27 +00:00
*--------------------------------------
2019-01-05 20:33:08 +00:00
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
2019-02-23 22:01:58 +00:00
L.MSG.RUNNING .DA MSG.RUNNING
2019-01-05 20:33:08 +00:00
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-05-10 14:49:53 +00:00
L.MSG.EXEC .DA MSG.EXEC
L.DEVNAME .DA DEVNAME
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-02-23 22:01:58 +00:00
CS.INIT lda DevID
bne .99
jsr CS.INIT.DEV
2019-01-15 16:37:32 +00:00
bcs .9
jsr CS.INIT.LIBS
bcs .9
jsr CS.INIT.CONF
.9 rts
2019-02-23 22:01:58 +00:00
.99 >LDYA L.MSG.RUNNING
>SYSCALL puts
lda #0
sec
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-10-23 09:34:25 +00:00
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-05-10 14:49:53 +00:00
bcs CS.INIT.LIBS.9
2019-01-15 16:37:32 +00:00
ldy LibCnt
sta hLIBs,y
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-03-11 07:01:40 +00:00
inc LibCnt
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-10-03 06:25:27 +00:00
CS.INIT.LIBS.9 rts
2019-01-15 16:37:32 +00:00
*--------------------------------------
CS.INIT.CONF >LDYAI 64
>SYSCALL GetMem
2019-05-10 14:49:53 +00:00
bcs CS.INIT.LIBS.9
2019-01-05 20:33:08 +00:00
2019-01-15 16:37:32 +00:00
>STYA pBuf
stx hLineBuf
2019-06-07 15:02:51 +00:00
>PUSHWZ
2019-01-15 16:37:32 +00:00
>PUSHBI S.FI.T.TXT
2019-05-10 14:49:53 +00:00
>PUSHBI O.RDONLY+O.TEXT
2019-01-15 16:37:32 +00:00
>LDYA L.ETCNETWORK
>SYSCALL fopen
2019-02-05 13:45:15 +00:00
bcs .98
2019-01-15 16:37:32 +00:00
sta hNetworkFile
2019-05-10 14:49:53 +00:00
.1 >PUSHWI 64
2019-01-15 16:37:32 +00:00
>PUSHW pBuf
lda hNetworkFile
>SYSCALL fgets
2019-02-05 13:45:15 +00:00
bcs .80
2019-02-07 10:26:43 +00:00
2019-05-10 14:49:53 +00:00
>PUSHW pBuf
>PUSHBI 2
>LDYA L.MSG.EXEC
>SYSCALL printf
>PUSHBI 0 S.PS.F.HOLD+S.PS.F.NOHUP
2019-01-15 16:37:32 +00:00
>LDYA pBuf
>SYSCALL execL
bra .1
2019-02-05 13:45:15 +00:00
.98 pha
jsr .81
pla
sec
2019-05-10 14:49:53 +00:00
rts
2019-02-05 13:45:15 +00:00
.80 lda hNetworkFile
2019-01-15 16:37:32 +00:00
>SYSCALL fclose
2019-02-05 13:45:15 +00:00
.81 lda hLineBuf
>SYSCALL FreeMem
2019-01-15 16:37:32 +00:00
clc
2019-02-05 13:45:15 +00:00
rts
2019-01-15 16:37:32 +00:00
*--------------------------------------
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-09-07 06:41:17 +00:00
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-07-09 06:03:49 +00:00
ldx #0
.1 ldy hLIBs,x
beq .2
>PUSHW L.IOCTL
2019-07-07 20:48:57 +00:00
lda hFrameIn
2019-07-09 06:03:49 +00:00
phx
2019-01-15 16:37:32 +00:00
ldx #LIBNET.INCOMING
jsr A2osX.LIBCALL
plx
2019-07-09 06:03:49 +00:00
bcc CS.RUN
2019-01-15 16:37:32 +00:00
inx
2019-07-09 06:03:49 +00:00
bra .1
2019-01-05 20:33:08 +00:00
2019-07-09 06:03:49 +00:00
.2 lda hFrameIn
2019-01-05 20:33:08 +00:00
>SYSCALL freemem
2019-07-09 06:03:49 +00:00
bra CS.RUN
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
.1 ldy hLIBs,x
2019-01-05 20:33:08 +00:00
beq .9
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
.1 lda hLIBs,x
beq .7
phx
>SYSCALL UnLoadLib
plx
inx
bra .1
2019-02-23 22:01:58 +00:00
.7 lda DevID
beq .8
pha
2019-06-07 15:02:51 +00:00
>PUSHWZ
2019-01-05 20:33:08 +00:00
>PUSHBI IOCTL.CLOSE
2019-02-23 22:01:58 +00:00
pla
2019-10-03 06:25:27 +00:00
>SYSCALL IOCTL
2019-02-23 22:01:58 +00:00
.8 clc
2019-01-05 20:33:08 +00:00
rts
*--------------------------------------
CS.END
*--------------------------------------
2019-02-23 22:01:58 +00:00
MSG.RUNNING .AZ "NETWORKD:Already loaded, exiting."
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-05-10 14:49:53 +00:00
MSG.EXEC .AZ "NETWORKD:Running %s ...\r\n"
ETCNETWORK .AZ "${BOOT}ETC/NETWORK"
*--------------------------------------
DevID .BS 1
LibCnt .BS 1
hLIBs .BS LIB.MAX+1 for ending 0 if MAX libs
2019-12-03 15:42:17 +00:00
DEVNAME .AZ "/dev/eth1"
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-05 20:33:08 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END .ED
*--------------------------------------
MAN
SAVE USR/SRC/SBIN/NETWORKD.S
ASM