A2osX/SBIN/CIFSD.S.txt

347 lines
6.5 KiB
Plaintext
Raw Normal View History

2019-06-13 15:30:28 +00:00
NEW
AUTO 3,1 Enable MASM3 auto line num
.LIST OFF
.OP 65C02 Target CPU, must match CPU level in header
.OR $2000 usualy $2000, but any value > $100 allowed
2020-06-13 19:27:06 +00:00
.TF sbin/cifsd
2019-06-13 15:30:28 +00:00
*--------------------------------------
2020-06-13 19:27:06 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.e.i
.INB inc/eth.i
.INB inc/libtcpip.i
.INB inc/net.smb.i
2021-01-12 21:14:13 +00:00
.INB inc/libcifs.i
2019-06-14 15:16:48 +00:00
*--------------------------------------
2021-01-12 21:14:13 +00:00
TIMEOUT.MAX .EQ 250 25 sec.
2019-06-13 15:30:28 +00:00
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPIPCfgPtr .BS 2
2021-01-12 21:14:13 +00:00
hSocket .BS 1
2019-06-14 15:16:48 +00:00
TimeOut .BS 1
2021-01-12 21:14:13 +00:00
hSMBContext .BS 1
hMount .BS 1
ZS.END .ED
2019-06-13 15:30:28 +00:00
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
2019-06-14 15:16:48 +00:00
.DA #S.PS.F.EVENT
2019-06-13 15:30:28 +00:00
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #64 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
2019-10-03 06:25:27 +00:00
*--------------------------------------
2019-06-13 15:30:28 +00:00
.1 .DA CS.INIT
.DA CS.RUN
2021-01-12 21:14:13 +00:00
.DA CS.DOEVENT
2019-06-13 15:30:28 +00:00
.DA CS.QUIT
2019-06-14 15:16:48 +00:00
L.LIBTCPIP .DA LIBTCPIP
2021-01-12 21:14:13 +00:00
L.LIBCIFS .DA LIBCIFS
2019-06-14 15:16:48 +00:00
L.MSG.USAGE .DA MSG.USAGE
2021-01-14 21:39:36 +00:00
L.MSG.TCPIPERR .DA MSG.TCPIPERR
2019-06-14 15:16:48 +00:00
L.MSG.UNKNOWN .DA MSG.UNKNOWN
2021-01-14 21:39:36 +00:00
L.MSG.CONNECTED .DA MSG.CONNECTED
2021-02-11 22:08:22 +00:00
L.MSG.NOCONN .DA MSG.NOCONN
L.MSG.MOUNTED .DA MSG.MOUNTED
2019-06-13 15:30:28 +00:00
.DA 0
*--------------------------------------
* Called once at process creation
* Put code for loading LIB here
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib
2019-07-07 20:48:57 +00:00
bcs .9
2021-01-12 21:14:13 +00:00
2019-06-13 15:30:28 +00:00
sta hLIBTCPIP
2021-01-12 21:14:13 +00:00
>LDYA L.LIBCIFS
>SYSCALL LoadLib
bcs .9
sta hLIBCIFS
* clc
.9
CS.INIT.RTS rts
2020-06-13 19:27:06 +00:00
*--------------------------------------
* Called until exit with CS
* if RUN exits with CC, RUN entered again
*--------------------------------------
2021-01-12 21:14:13 +00:00
CS.RUN lda hSocket
beq .1
2020-06-13 19:27:06 +00:00
2021-01-12 21:14:13 +00:00
lda #0
clc
2019-06-13 15:30:28 +00:00
rts
2019-06-14 15:16:48 +00:00
2021-01-12 21:14:13 +00:00
.1 jsr CS.RUN.CheckTCPIP
bcs CS.INIT.RTS
jsr CS.RUN.CheckArgs
bcs CS.INIT.RTS
2019-07-12 06:22:32 +00:00
2019-07-07 20:48:57 +00:00
jsr CS.RUN.Connect
2021-01-12 21:14:13 +00:00
bcs CS.INIT.RTS
2020-06-13 19:27:06 +00:00
2021-01-12 21:14:13 +00:00
>PUSHB hSocket
>PUSHBI 0
>LIBCALL hLIBCIFS,LIBCIFS.Negotiate
2021-01-17 21:48:54 +00:00
bcs CS.INIT.RTS
2021-01-12 21:14:13 +00:00
sta hSMBContext
2021-01-14 21:39:36 +00:00
2021-01-12 21:14:13 +00:00
>PUSHB hSocket
>PUSHB hSMBContext
>PUSHWI 0
>PUSHWI 0
>PUSHBI 0
>LIBCALL hLIBCIFS,LIBCIFS.SessionSetup
2021-02-11 22:08:22 +00:00
bcs CS.INIT.RTS
2021-01-12 21:14:13 +00:00
>PUSHB hSocket
>PUSHB hSMBContext
lda #2
>SYSCALL ArgV
>PUSHYA
>PUSHBI 0
>LIBCALL hLIBCIFS,LIBCIFS.TreeConnect
2020-06-17 19:05:36 +00:00
bcs .9
2021-01-12 21:14:13 +00:00
2021-01-17 21:48:54 +00:00
>PUSHB hSocket
>PUSHB hSMBContext
lda #3
>SYSCALL ArgV
>PUSHYA
>LIBCALL hLIBCIFS,LIBCIFS.Mount
2021-02-11 22:08:22 +00:00
bcs .9
2021-01-12 21:14:13 +00:00
2021-01-17 21:48:54 +00:00
sta hMount
2021-05-19 12:44:47 +00:00
2021-02-11 22:08:22 +00:00
>PUSHW L.MSG.MOUNTED
2021-05-19 12:44:47 +00:00
2021-02-11 22:08:22 +00:00
lda #2
>SYSCALL ArgV
>PUSHYA
2021-05-19 12:44:47 +00:00
2021-02-11 22:08:22 +00:00
lda #3
>SYSCALL ArgV
>PUSHYA
2021-05-19 12:44:47 +00:00
2021-02-11 22:08:22 +00:00
>PUSHBI 4
>SYSCALL PrintF
2021-01-12 21:14:13 +00:00
2021-01-17 21:48:54 +00:00
lda #0
2020-06-13 19:27:06 +00:00
clc
2019-07-07 20:48:57 +00:00
.9 rts
2021-01-12 21:14:13 +00:00
*--------------------------------------
CS.RUN.CheckTCPIP
>LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ?
bcs .9
2020-06-13 19:27:06 +00:00
2021-01-12 21:14:13 +00:00
>STYA ZPIPCfgPtr
lda (ZPIPCfgPtr) Configured ?
bmi .1
>LDYA L.MSG.TCPIPERR
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2021-01-12 21:14:13 +00:00
2019-06-13 15:30:28 +00:00
lda #E.SYN
sec
2021-01-12 21:14:13 +00:00
.9 rts
.1 lda #AF.INET
>STA.G SA.LOCAL
>STA.G SA.REMOTE
ldy #S.IPCFG.IP+3
.3 lda (ZPIPCfgPtr),y
pha
dey
cpy #S.IPCFG.IP-1
bne .3
ldy #SA.LOCAL+S.SOCKADDR.ADDR
.4 pla
sta (pData),y
iny
cpy #SA.LOCAL+S.SOCKADDR.ADDR+4
bne .4
lda #TCP.PORT.CIFS
>STA.G SA.REMOTE+S.SOCKADDR.PORT
iny
lda /TCP.PORT.CIFS
sta (pData),y
clc
2019-06-13 15:30:28 +00:00
rts
*--------------------------------------
CS.RUN.CheckArgs
ldy #S.PS.ARGC
2020-02-28 07:21:46 +00:00
lda (pPS),y
2019-06-13 15:30:28 +00:00
cmp #3
2021-01-12 21:14:13 +00:00
bcs .1
2019-06-14 15:16:48 +00:00
2021-01-12 21:14:13 +00:00
>LDYA L.MSG.USAGE
>SYSCALL PutS
lda #E.SYN
sec
rts
.1 lda #TIMEOUT.MAX
2019-06-14 15:16:48 +00:00
sta TimeOut
2021-01-12 21:14:13 +00:00
.2 >PUSHEA.G SA.REMOTE+S.SOCKADDR.ADDR
2019-06-14 15:16:48 +00:00
lda #1
>SYSCALL ArgV
>PUSHYA
2020-08-23 19:46:37 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GetByName
2021-01-12 21:14:13 +00:00
bcc .3
2019-06-14 15:16:48 +00:00
>SLEEP
lda TimeOut
2021-01-12 21:14:13 +00:00
bne .2
2020-06-13 19:27:06 +00:00
>PUSHW L.MSG.UNKNOWN
2019-06-14 15:16:48 +00:00
lda #1
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2021-02-11 22:08:22 +00:00
lda #ERR.SKT.NOCONN
2019-06-14 15:16:48 +00:00
sec
2021-01-12 21:14:13 +00:00
rts
2019-06-14 15:16:48 +00:00
2021-01-12 21:14:13 +00:00
.3 lda #2
>SYSCALL ArgV
2019-06-14 15:16:48 +00:00
clc
2021-01-14 21:39:36 +00:00
CS.RUN.CheckArgs.RTS
2019-06-14 15:16:48 +00:00
rts
2019-06-13 15:30:28 +00:00
*--------------------------------------
2021-05-19 12:44:47 +00:00
CS.RUN.Connect >PUSHBI S.SOCKET.T.SEQPKT
>PUSHBI 0 no protocol
2019-06-14 15:16:48 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket
2021-02-11 22:08:22 +00:00
bcs .9
2019-06-14 15:16:48 +00:00
2021-01-12 21:14:13 +00:00
sta hSocket
2019-06-14 15:16:48 +00:00
2021-05-19 12:44:47 +00:00
>PUSHA
2019-07-07 20:48:57 +00:00
>PUSHEA.G SA.LOCAL
2019-06-14 15:16:48 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind
bcs .9
2021-01-12 21:14:13 +00:00
lda #TIMEOUT.MAX
sta TimeOut
.1 >SLEEP
2021-05-19 12:44:47 +00:00
>PUSHB hSocket
2021-03-12 12:50:03 +00:00
>PUSHEA.G SA.REMOTE
>LIBCALL hLIBTCPIP,LIBTCPIP.Connect
bcc .8
2021-01-12 21:14:13 +00:00
ldx TimeOut
bne .1
2021-02-11 22:08:22 +00:00
.9 pha
2021-05-19 12:44:47 +00:00
2021-02-11 22:08:22 +00:00
>PUSHW L.MSG.NOCONN
lda #1
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
pla
2021-01-12 21:14:13 +00:00
sec
rts
2021-01-14 21:39:36 +00:00
.8 >PUSHW L.MSG.CONNECTED
lda #1
>SYSCALL ArgV
2020-06-17 19:05:36 +00:00
>PUSHYA
>PUSHBI 2
2020-08-23 19:46:37 +00:00
>SYSCALL PrintF
2021-02-11 22:08:22 +00:00
rts
2019-06-13 15:30:28 +00:00
*--------------------------------------
2019-06-14 15:16:48 +00:00
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
2021-01-12 21:14:13 +00:00
2019-06-14 15:16:48 +00:00
lda TimeOut
beq .9
2021-01-12 21:14:13 +00:00
2019-06-14 15:16:48 +00:00
dec TimeOut
2021-02-11 22:08:22 +00:00
2019-06-14 15:16:48 +00:00
.9 sec do not discard TIMER event
2019-06-13 15:30:28 +00:00
rts
*--------------------------------------
2021-01-12 21:14:13 +00:00
CS.QUIT lda hMount
beq .1
2019-06-13 15:30:28 +00:00
2021-01-12 21:14:13 +00:00
>SYSCALL UMount
2020-06-17 19:05:36 +00:00
2021-01-12 21:14:13 +00:00
.1 lda hSocket
beq .2
2020-06-17 19:05:36 +00:00
2021-01-12 21:14:13 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
2020-06-17 19:05:36 +00:00
2021-01-12 21:14:13 +00:00
.2 lda hLIBCIFS
beq .3
2020-06-17 19:05:36 +00:00
2021-01-12 21:14:13 +00:00
>SYSCALL UnloadLib
2020-06-17 19:05:36 +00:00
2021-01-12 21:14:13 +00:00
.3 lda hLIBTCPIP
beq .8
>SYSCALL UnloadLib
.8 clc
2020-06-17 19:05:36 +00:00
rts
*--------------------------------------
2019-06-13 15:30:28 +00:00
CS.END
*--------------------------------------
* Initialized DATA
*--------------------------------------
2020-06-13 19:27:06 +00:00
LIBTCPIP .AZ "libtcpip"
2019-06-13 15:30:28 +00:00
hLIBTCPIP .BS 1
2021-01-12 21:14:13 +00:00
LIBCIFS .AZ "libcifs"
hLIBCIFS .BS 1
2019-06-14 15:16:48 +00:00
MSG.USAGE .AZ "Usage : CIFSD <ip|host> sharename mountpoint"
2021-01-14 21:39:36 +00:00
MSG.TCPIPERR .AZ "CIFSD:TCP/IP Not initialized properly."
2021-01-12 21:14:13 +00:00
MSG.UNKNOWN .AZ "CIFSD:%s: Unknown host\r\n"
2021-02-11 22:08:22 +00:00
MSG.NOCONN .AZ "CIFSD:No Connection To %s\r\n"
MSG.CONNECTED .AZ "CIFSD:Connected To %s\r\n"
MSG.MOUNTED .AZ "CIFSD:%s Mounted As %s\r\n"
2019-06-13 15:30:28 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
2019-06-14 15:16:48 +00:00
SA.LOCAL .BS 1 S.SOCKADDR.AF
2019-06-13 15:30:28 +00:00
.BS 1
.BS 4 S.SOCKADDR.ADDR
.BS 2 S.SOCKADDR.PORT
2019-06-14 15:16:48 +00:00
SA.REMOTE .BS 1 S.SOCKADDR.AF
2019-06-13 15:30:28 +00:00
.BS 1
.BS 4 S.SOCKADDR.ADDR
2019-06-14 15:16:48 +00:00
.BS 2 S.SOCKADDR.PORT
2019-06-13 15:30:28 +00:00
DS.END
.ED
*--------------------------------------
MAN
2020-08-09 19:47:42 +00:00
SAVE usr/src/sbin/cifsd.s
2019-06-13 15:30:28 +00:00
ASM