A2osX/SBIN/NETWORKD.S.txt

417 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
DBG .EQ 0
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
pBuf .BS 2
pNETCFG .BS 2
2020-08-11 18:55:28 +00:00
hEtcNetwork .BS 1
hBuf .BS 1
2019-05-09 21:00:23 +00:00
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
.DA #32 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-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 .8
>LDYAI 64
>SYSCALL GetMem
bcs .99
2019-02-23 22:01:58 +00:00
>STYA pBuf
stx hBuf
>STYA IOCTL+S.IOCTL.BUFPTR for CS.INIT.DEV
2019-02-23 22:01:58 +00:00
jsr CS.INIT.DEV
bcs .90
2019-01-15 16:37:32 +00:00
lda LibCnt
.1 inc
>SYSCALL ArgV
bcs .2
jsr CS.INIT.LIB
bcs .90
inc LibCnt
lda LibCnt
cmp #LIB.MAX
bne .1
2020-07-29 06:08:26 +00:00
.2 jsr CS.INIT.CONF
.90 php
pha
lda hBuf
>SYSCALL FreeMem
pla
plp
.99 rts
2019-02-23 22:01:58 +00:00
.8 >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
*--------------------------------------
2021-05-14 20:58:20 +00:00
CS.INIT.DEV >PUSHW L.DEVNAME
>PUSHBI 0
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
2021-05-04 17:31:21 +00:00
lda #S.IOCTL.S.GETDCB
sta IOCTL+S.IOCTL.S
2019-01-16 14:37:21 +00:00
ldx #IOCTL.STATUS
*--------------------------------------
CS.IOCTL lda DevID
>PUSHA
txa
>PUSHA
2020-04-02 06:32:25 +00:00
>PUSHW L.IOCTL
2019-01-16 14:37:21 +00:00
>SYSCALL IOCTL
CS.IOCTL.RTS rts
2019-01-15 16:37:32 +00:00
*--------------------------------------
* pBuf = DCB.NIC
*--------------------------------------
CS.INIT.LIB phy
2019-01-15 16:37:32 +00:00
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
bcs CS.IOCTL.RTS
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
bcs CS.IOCTL.RTS
2019-12-18 20:49:41 +00:00
2019-01-15 16:37:32 +00:00
>STYA pNETCFG
2020-02-14 07:21:56 +00:00
lda DevID
ldy #S.NETCFG.DevID
sta (pNETCFG),y
ldy #S.DCB.NIC.FLAGS
lda (pBuf),y
ldy #S.NETCFG.DevFlags
2020-02-14 07:21:56 +00:00
sta (pNETCFG),y
ldx #6
ldy #S.DCB.NIC.MAC
.2 lda (pBuf),y
pha
iny
dex
bne .2
ldx #6
2020-02-14 07:21:56 +00:00
ldy #S.NETCFG.MAC+5
.3 pla
2020-02-14 07:21:56 +00:00
sta (pNETCFG),y
dey
dex
bne .3
2019-01-05 20:33:08 +00:00
>PUSHW pNETCFG
ldx LibCnt
ldy hLIBs,x
ldx #LIBNET.SETCFG
jmp A2osX.LIBCALL
*--------------------------------------
CS.INIT.CONF >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
bcs .9
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
>PUSHWI 63
2020-08-20 13:20:33 +00:00
>SYSCALL FGetS
bcs .8
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
.8 lda hEtcNetwork
2020-02-28 07:21:46 +00:00
>SYSCALL FClose
2019-12-20 19:46:21 +00:00
* clc
.9 rts
2019-01-15 16:37:32 +00:00
*--------------------------------------
CS.RUN ldx #IOCTL.READ
jsr CS.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
2020-06-25 15:39:51 +00:00
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
2020-06-27 18:30:09 +00:00
dec
beq .9
2020-06-27 18:30:09 +00:00
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
ldx #IOCTL.CLOSE
jsr CS.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
*--------------------------------------
.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