A2osX/SBIN/NETWORKD.S.txt

413 lines
7.1 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
2019-12-11 13:14:56 +00:00
.TF sbin/networkd
2019-01-15 16:37:32 +00:00
*--------------------------------------
LIB.MAX .EQ 4
2021-01-12 21:14:13 +00:00
DBG .EQ 2
2019-01-05 20:33:08 +00:00
*--------------------------------------
2020-06-09 13:40:21 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
.INB inc/nic.i
.INB inc/eth.i
.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
2020-08-11 18:55:28 +00:00
hEtcNetwork .BS 1
2019-05-09 21:00:23 +00:00
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
2020-06-09 13:40:21 +00:00
.DO DBG=1
.DA #128 Stack Size
.ELSE
2019-05-09 21:00:23 +00:00
.DA #64 Stack Size
2020-06-09 13:40:21 +00:00
.FIN
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
2020-07-29 06:08:26 +00:00
L.MSG.OK .DA MSG.OK
L.MSG.ERR .DA MSG.ERR
2019-05-10 14:49:53 +00:00
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
2020-06-09 13:40:21 +00:00
.DO DBG=1
L.MSG.DBG .DA MSG.DBG
2020-06-25 15:39:51 +00:00
L.MSG.DBG.REJECT .DA MSG.DBG.REJECT
2020-06-09 13:40:21 +00:00
.FIN
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
2020-07-29 06:08:26 +00:00
2019-01-15 16:37:32 +00:00
jsr CS.INIT.CONF
.9 rts
2019-02-23 22:01:58 +00:00
.99 >LDYA L.MSG.RUNNING
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2019-02-23 22:01:58 +00:00
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
2020-08-20 13:20:33 +00:00
>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
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2019-01-05 20:33:08 +00:00
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
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.DEV.OK
2019-01-05 20:33:08 +00:00
>PUSHW L.DEVNAME
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-02-14 07:21:56 +00:00
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
2020-03-23 07:08:27 +00:00
>PUSHB DevID
2019-01-16 14:37:21 +00:00
>PUSHBI IOCTL.STATUS
2020-04-02 06:32:25 +00:00
>PUSHW L.IOCTL
2019-01-16 14:37:21 +00:00
>SYSCALL IOCTL
2019-01-15 16:37:32 +00:00
rts
*--------------------------------------
CS.INIT.LIBS lda LibCnt
2020-02-14 07:21:56 +00:00
2019-01-15 16:37:32 +00:00
.1 inc
>SYSCALL ArgV
bcs .8
phy
pha
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.LIB
pla
pha
2019-01-15 16:37:32 +00:00
>PUSHYA
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-02-14 07:21:56 +00:00
2019-01-15 16:37:32 +00:00
pla
ply
2020-04-07 06:01:38 +00:00
2019-01-14 07:11:50 +00:00
>SYSCALL LoadLib
2020-07-29 06:08:26 +00:00
jsr CS.RUN.CheckErr
2019-05-10 14:49:53 +00:00
bcs CS.INIT.LIBS.9
2019-12-18 20:49:41 +00:00
2019-01-15 16:37:32 +00:00
ldy LibCnt
sta hLIBs,y
tay
ldx #LIBNET.GETCFG
jsr A2osX.LIBCALL
2019-12-18 20:49:41 +00:00
bcs CS.INIT.LIBS.9
2019-01-15 16:37:32 +00:00
>STYA pNETCFG
2020-02-14 07:21:56 +00:00
jsr CS.INIT.SETUP.NETCFG
2019-12-18 20:49:41 +00:00
>PUSHW pNETCFG
2019-12-20 19:46:21 +00:00
ldx LibCnt
ldy hLIBs,x
2019-12-18 20:49:41 +00:00
ldx #LIBNET.SETCFG
jsr A2osX.LIBCALL
bcs CS.INIT.LIBS.9
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
2019-12-18 20:49:41 +00:00
2019-01-15 16:37:32 +00:00
.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
*--------------------------------------
2020-02-14 07:21:56 +00:00
CS.INIT.SETUP.NETCFG
lda DevID
ldy #S.NETCFG.DevID
sta (pNETCFG),y
iny S.NETCFG.DevFlags
lda DCB.NIC+S.DCB.NIC.FLAGS
sta (pNETCFG),y
ldx #5
ldy #S.NETCFG.MAC+5
.2 lda DCB.NIC+S.DCB.NIC.MAC,x
sta (pNETCFG),y
dey
dex
bpl .2
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
2020-02-14 07:21:56 +00:00
>PUSHW L.ETCNETWORK
2019-05-10 14:49:53 +00:00
>PUSHBI O.RDONLY+O.TEXT
2020-02-14 07:21:56 +00:00
>PUSHBI S.FI.T.TXT
>PUSHWZ
2020-03-09 16:24:08 +00:00
>SYSCALL FOpen
2019-02-05 13:45:15 +00:00
bcs .98
2019-12-20 19:46:21 +00:00
2020-08-11 18:55:28 +00:00
sta hEtcNetwork
2019-12-20 19:46:21 +00:00
2020-12-23 14:54:57 +00:00
.1 >PUSHB hEtcNetwork
2019-01-15 16:37:32 +00:00
>PUSHW pBuf
2020-12-23 14:54:57 +00:00
>PUSHWI 64
2020-08-20 13:20:33 +00:00
>SYSCALL FGetS
2019-02-05 13:45:15 +00:00
bcs .80
2019-02-07 10:26:43 +00:00
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.EXEC
2019-05-10 14:49:53 +00:00
>PUSHW pBuf
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-05-10 14:49:53 +00:00
2020-01-24 14:21:08 +00:00
>PUSHW pBuf
2020-10-30 09:51:37 +00:00
>PUSHBI 0 S.PS.F.HOLD
2020-08-20 13:20:33 +00:00
>SYSCALL ExecL
2020-07-29 06:08:26 +00:00
jsr CS.RUN.CheckErr
>SLEEP
2019-01-15 16:37:32 +00:00
bra .1
2019-12-20 19:46:21 +00:00
2019-02-05 13:45:15 +00:00
.98 pha
jsr .81
pla
sec
2019-05-10 14:49:53 +00:00
rts
2019-12-20 19:46:21 +00:00
2020-08-11 18:55:28 +00:00
.80 lda hEtcNetwork
2020-02-28 07:21:46 +00:00
>SYSCALL FClose
2019-12-20 19:46:21 +00:00
2019-02-05 13:45:15 +00:00
.81 lda hLineBuf
>SYSCALL FreeMem
2019-12-20 19:46:21 +00:00
* clc
2019-02-05 13:45:15 +00:00
rts
2019-01-15 16:37:32 +00:00
*--------------------------------------
2020-03-23 07:08:27 +00:00
CS.RUN >PUSHB DevID
2019-01-05 20:33:08 +00:00
>PUSHBI IOCTL.READ
2020-04-02 06:32:25 +00:00
>PUSHW L.IOCTL
2020-03-23 07:08:27 +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-12-20 19:46:21 +00:00
2019-01-05 20:33:08 +00:00
sta hFrameIn
2020-06-09 13:40:21 +00:00
.DO DBG=1
>SYSCALL GetMemPtr
>STYA pBuf
2020-06-27 18:30:09 +00:00
jsr CS.RUN.FILTER
bcs .23
2020-06-11 21:04:56 +00:00
2020-06-09 13:40:21 +00:00
>PUSHW L.MSG.DBG
ldy #0
.22 >PUSHB (pBuf),y
iny
2020-06-27 18:30:09 +00:00
cpy #54
2020-06-09 13:40:21 +00:00
bne .22
2020-06-27 18:30:09 +00:00
>PUSHBI 54
2020-08-20 13:20:33 +00:00
>SYSCALL PrintF
2020-06-13 19:27:06 +00:00
.23 .FIN
2019-12-20 19:46:21 +00:00
2019-07-09 06:03:49 +00:00
ldx #0
2019-12-20 19:46:21 +00:00
2019-07-09 06:03:49 +00:00
.1 ldy hLIBs,x
beq .2
2019-12-20 19:46:21 +00:00
2019-07-09 06:03:49 +00:00
>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-12-20 19:46:21 +00:00
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
2020-06-25 15:39:51 +00:00
.2 .DO DBG=1
2020-06-27 18:30:09 +00:00
jsr CS.RUN.FILTER
bcs .33
2020-06-25 15:39:51 +00:00
>LDYA L.MSG.DBG.REJECT
>SYSCALL puts
.33 .FIN
lda hFrameIn
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2020-06-11 21:04:56 +00:00
jmp CS.RUN
2019-12-20 19:46:21 +00:00
2019-01-15 16:37:32 +00:00
.8 clc
rts
2020-06-27 18:30:09 +00:00
*--------------------------------------
.DO DBG=1
CS.RUN.FILTER lda (pBuf)
cmp #$ff
beq .9
dec
beq .9
ldy #S.ETH.EII.TYPE+1
lda (pBuf),y
bne .9
clc
rts
.9 sec
rts
.FIN
2019-01-05 20:33:08 +00:00
*--------------------------------------
2020-07-29 06:08:26 +00:00
CS.RUN.CheckErr pha
bcs .1
>LDYA L.MSG.OK
>SYSCALL PutS
pla
rts
.1 >PUSHW L.MSG.ERR
pla
pha
>PUSHA
>PUSHBI 1
>SYSCALL PrintF
pla
sec
rts
*--------------------------------------
2019-01-05 20:33:08 +00:00
CS.DOEVENT lda (pEvent)
bpl .9
2019-12-20 19:46:21 +00:00
2019-01-15 16:37:32 +00:00
ldx #0
2019-12-20 19:46:21 +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-12-20 19:46:21 +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
2019-12-20 19:46:21 +00:00
2019-01-15 16:37:32 +00:00
inx
bra .1
2019-12-20 19:46:21 +00:00
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-12-20 19:46:21 +00:00
2019-01-15 16:37:32 +00:00
.1 lda hLIBs,x
beq .7
2019-12-20 19:46:21 +00:00
2019-01-15 16:37:32 +00:00
phx
2020-08-20 13:20:33 +00:00
>SYSCALL UnloadLib
2019-01-15 16:37:32 +00:00
plx
inx
bra .1
2019-12-20 19:46:21 +00:00
2019-02-23 22:01:58 +00:00
.7 lda DevID
beq .8
2019-12-20 19:46:21 +00:00
2020-03-23 07:08:27 +00:00
>PUSHA
2019-01-05 20:33:08 +00:00
>PUSHBI IOCTL.CLOSE
2020-04-02 06:32:25 +00:00
>PUSHWZ
2019-10-03 06:25:27 +00:00
>SYSCALL IOCTL
2019-12-20 19:46:21 +00:00
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"
2020-07-29 13:10:11 +00:00
MSG.LIB .AZ "NETWORKD:Loading %s..."
MSG.EXEC .AZ "NETWORKD:Running %s..."
2020-07-29 06:08:26 +00:00
MSG.OK .AZ "[OK]"
MSG.ERR .AZ "[%h]\r\n"
2019-12-11 13:14:56 +00:00
ETCNETWORK .AZ "${BOOT}etc/network"
2020-06-09 13:40:21 +00:00
.DO DBG=1
2020-06-27 18:30:09 +00:00
MSG.DBG .AS "FRM ETH:%h%h%h%h%h%h.%h%h%h%h%h%h.%h%h\r\n"
.AS " IP :%h%h.%h%h.%h%h.%h%h.%h [%d] (%h%h) %d.%d.%d.%d>%d.%d.%d.%d\r\n"
.AZ " TCP:%D>%D %h%h%h%h %h%h%h%h %h %b [%h%h] (%h%h) %h%h\r\n"
2020-06-25 15:39:51 +00:00
MSG.DBG.REJECT .AZ "Rejected"
2020-06-09 13:40:21 +00:00
.FIN
2019-05-10 14:49:53 +00:00
*--------------------------------------
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
2020-06-09 13:40:21 +00:00
SAVE usr/src/sbin/networkd.s
2019-01-05 20:33:08 +00:00
ASM