A2osX/SBIN/CIFSD.S.txt

234 lines
5.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
.TF SBIN/CIFSD
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
2019-06-14 15:16:48 +00:00
.INB INC/ETH.I
.INB INC/LIBTCPIP.I
2019-10-03 06:25:27 +00:00
.INB INC/NET.SMB.I
2019-06-14 15:16:48 +00:00
*--------------------------------------
TIMEOUT.MAX .EQ 100 10 sec.
2019-06-13 15:30:28 +00:00
*--------------------------------------
* Zero Page Segment, up to 32 bytes
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPIPCfgPtr .BS 2
2019-06-14 15:16:48 +00:00
TimeOut .BS 1
2019-06-13 15:30:28 +00:00
ZS.END
.ED
*--------------------------------------
* 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
.DA CS.DOEVENT
.DA CS.QUIT
2019-06-14 15:16:48 +00:00
L.LIBTCPIP .DA LIBTCPIP
L.MSG.USAGE .DA MSG.USAGE
L.MSG.UNKNOWN .DA MSG.UNKNOWN
2019-07-07 20:48:57 +00:00
L.SMB.Negotiate .DA SMB.Negotiate
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
2019-06-13 15:30:28 +00:00
sta hLIBTCPIP
>LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ?
2019-07-07 20:48:57 +00:00
bcs .9
2019-06-13 15:30:28 +00:00
>STYA ZPIPCfgPtr
lda (ZPIPCfgPtr) Configured ?
2019-07-07 20:48:57 +00:00
bmi .8
2019-06-13 15:30:28 +00:00
lda #E.SYN
sec
rts
2019-06-14 15:16:48 +00:00
2019-07-07 20:48:57 +00:00
.8 clc
.9 rts
2019-06-13 15:30:28 +00:00
*--------------------------------------
* Called until exit with CS
* if RUN exits with CC, RUN entered again
*--------------------------------------
CS.RUN jsr CS.RUN.CheckArgs
bcs .90
2019-07-12 06:22:32 +00:00
2019-07-07 20:48:57 +00:00
jsr CS.RUN.Connect
2019-07-12 06:22:32 +00:00
>DEBUG
2019-07-07 20:48:57 +00:00
bcs .9
jsr CS.RUN.Negotiate
2019-06-13 15:30:28 +00:00
lda #0
sec
2019-07-07 20:48:57 +00:00
.9 rts
2019-06-13 15:30:28 +00:00
.90 >LDYA L.MSG.USAGE
>SYSCALL puts
lda #E.SYN
sec
rts
*--------------------------------------
CS.RUN.CheckArgs
ldy #S.PS.ARGC
lda (pPs),y
cmp #3
bcc .9
2019-06-14 15:16:48 +00:00
lda #TIMEOUT.MAX
sta TimeOut
.1 >PUSHEA.G SA.REMOTE+S.SOCKADDR.ADDR
lda #1
>SYSCALL ArgV
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME
bcc .2
>SLEEP
lda TimeOut
bne .1
lda #1
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
>LDYA L.MSG.UNKNOWN
>SYSCALL printf
sec
2019-07-07 20:48:57 +00:00
.9 rts
.2 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.REMOTE+S.SOCKADDR.PORT
.4 pla
sta (pData),y
iny
cpy #SA.REMOTE+S.SOCKADDR.PORT+4
bne .4
lda #TCP.PORT.CIFS
>STA.G SA.REMOTE+S.SOCKADDR.PORT
iny
lda /TCP.PORT.CIFS
sta (pData),y
2019-06-14 15:16:48 +00:00
clc
rts
2019-06-13 15:30:28 +00:00
*--------------------------------------
2019-06-14 15:16:48 +00:00
CS.RUN.Connect >PUSHBI 0 no protocol
2019-07-07 20:48:57 +00:00
lda #S.SOCKET.T.SEQPACKET
2019-06-14 15:16:48 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket
bcs .9
>STA.G hSocket
2019-07-07 20:48:57 +00:00
>PUSHEA.G SA.LOCAL
2019-06-14 15:16:48 +00:00
>LDA.G hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind
bcs .9
2019-07-07 20:48:57 +00:00
>PUSHEA.G SA.REMOTE
2019-06-14 15:16:48 +00:00
>LDA.G hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Connect
.9 rts
*--------------------------------------
2019-07-07 20:48:57 +00:00
CS.RUN.Negotiate
>PUSHWI SMB.Negotiate.end-SMB.Negotiate
>PUSHW L.SMB.Negotiate
>LDA.G hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Send
rts
*--------------------------------------
2019-06-13 15:30:28 +00:00
* Called if option S.PS.F.EVENT enabled in Header
* Timer Event : every 10th seconds
*--------------------------------------
2019-06-14 15:16:48 +00:00
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
lda TimeOut
beq .9
dec TimeOut
.9 sec do not discard TIMER event
2019-06-13 15:30:28 +00:00
rts
*--------------------------------------
* Called once, when RUN exited with CS
* Put code for unloading LIB here
*--------------------------------------
CS.QUIT lda hLIBTCPIP
beq .8
>SYSCALL UnloadLib
.8 clc
rts
*--------------------------------------
CS.END
*--------------------------------------
* Initialized DATA
*--------------------------------------
2019-11-11 14:21:06 +00:00
LIBTCPIP .AZ "LIBTCPIP"
2019-06-13 15:30:28 +00:00
hLIBTCPIP .BS 1
2019-06-14 15:16:48 +00:00
MSG.USAGE .AZ "Usage : CIFSD <ip|host> sharename mountpoint"
MSG.UNKNOWN .AZ "%s: Unknown host\r\n"
2019-06-13 15:30:28 +00:00
*--------------------------------------
2019-07-07 20:48:57 +00:00
SMB.Negotiate .DA #$FF
.AS "SMB"
.DA #S.SMB.HEADER.CMD.NEGOTIATE
.HS 00000000
.DA #0 S.SMB.HEADER.FLAGS
.DA /S.SMB.HEADER.FLAGS2.LONGNAMES
.DA #S.SMB.HEADER.FLAGS2.LONGNAMES
.DA 0 PIDHI
.HS 0000000000000000 SECFEAT
.DA 0 RSVD
.DA $FFFF TID
.DA $FEFF PIDLO
.DA 0 UID
.DA 0 MID
.DA #0 WORD COUNT
.DA /SMB.Negotiate.end-*
.DA #SMB.Negotiate.end-*
.DA #2
.AZ "NT LM 0.12"
SMB.Negotiate.end .EQ *
*--------------------------------------
2019-06-13 15:30:28 +00:00
* Per Process DATA segement (0 filled before INIT)
*--------------------------------------
.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-10-03 06:25:27 +00:00
hSocket .BS 1
2019-06-13 15:30:28 +00:00
DS.END
.ED
*--------------------------------------
MAN
SAVE USR/SRC/SBIN/CIFSD
ASM