A2osX/DRV/PPPSSC.DRV.S.txt

924 lines
15 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF drv/pppssc.drv
*--------------------------------------
DBG .EQ 0
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/kernel.i
.INB inc/mli.e.i
.INB inc/com.i
.INB inc/com.6551.i
.INB inc/nic.i
.INB inc/eth.i
.INB inc/libtcpip.i
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPArgsPtr .BS 2
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPPtr3 .BS 2
ZPBufLen .BS 2
FCS .BS 2
hETCFILE .BS 1
b7D .BS 1
Len .BS 1
bConfigured .BS 1
ZS.END .ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp Dev.Detect cld,jmp abs=DRV
.DA #$61 6502,Level 1 (65c02)
.DA #1 DRV Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length
.DA 0
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
L.MSG.DETECT .DA MSG.DETECT
L.MSG.DETECT.OK .DA MSG.DETECT.OK
L.MSG.DETECT.KO .DA MSG.DETECT.KO
L.DRV.CS.START .DA DRV.CS.START
L.FD.DEV .DA FD.DEV
L.FD.DEV.NAME .DA FD.DEV.NAME
L.ETCFILE .DA ETCFILE
L.MSG.ETCFILE .DA MSG.ETCFILE
L.MSG.UNEXPECTED .DA MSG.UNEXPECTED
L.MSG.SYNTAX .DA MSG.SYNTAX
L.MSG.LCPInit .DA MSG.LCPInit
L.MSG.LocalIP .DA MSG.LocalIP
L.MSG.RemoteIP .DA MSG.RemoteIP
.DO DBG=1
L.MSG.DUMPBUF .DA MSG.DUMPBUFS
.DA MSG.DUMPBUFR
L.MSG.HEXDUMP .DA MSG.HEXDUMP
.FIN
L.PPP.ConfReq .DA PPP.ConfReq
L.PPP.EchoRep .DA PPP.EchoRep
L.PPP.IPCPReq .DA PPP.IPCPReq
L.IN.Buf .DA IN.Buf
L.IN.Bufp1 .DA IN.Buf+1
L.OUT.Buf .DA OUT.Buf
J.LCP .DA LCP.ConfReq
.DA LCP.ConfAck
.DA LCP.ConfNak
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.EchoReq
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
.DA LCP.Discard
J.IPCP .DA IPCP.ConfReq
.DA IPCP.ConfAck
.DA IPCP.ConfNak
.DA IPCP.Discard
.DA IPCP.Discard
.DA IPCP.Discard
.DA IPCP.Discard
.DA 0 End Of Reloc Table
*--------------------------------------
Dev.Detect >STYA ZPArgsPtr
>LDYA L.MSG.DETECT
>SYSCALL PutS
stz ZPPtr1
lda #$C1
sta ZPPtr1+1
.1 and #$0f
tay
lda A2osX.S,y
bne .3
ldx #DEVSIG.Length-1
.2 ldy DEVSIG.Offset,x
lda (ZPPtr1),y
cmp DEVSIG.Value,x
bne .3
dex
bpl .2
bra .4
.3 inc FD.DEV.NAME+3
inc ZPPtr1+1 no match, try next slot....
lda ZPPtr1+1
cmp #$C8
bne .1
>LDYA L.MSG.DETECT.KO
>SYSCALL PutS
lda #MLI.E.NODEV Not Found in any slot, exiting
sec
rts
.4 lda ZPPtr1+1
asl
asl
asl
asl
clc
adc #$8F
sta DEVSLOTn08F
*--------------------------------------
jsr SSC.Init
jsr PPP.ETCFILE
bcs .9
jsr PPP.LCPInit
bcs .9
>PUSHW L.MSG.DETECT.OK
>PUSHW L.FD.DEV.NAME
>PUSHBI 2
>SYSCALL PrintF
bcs .9
>PUSHWI DRV.END
>PUSHWI DRV.CS.END-DRV.CS.START
>PUSHWI DRV.CS.START
>LDYA L.DRV.CS.START
>SYSCALL InsDrv
.9 bcs .99
>STYA FD.DEV+S.FD.DEV.DRVPTR
>PUSHW L.FD.DEV
>PUSHW L.FD.DEV.NAME
>SYSCALL MKDev
bcs .99
lda FD.DEV.NAME+3
and #$0F
tax
lda #A2osX.S.NIC
sta A2osX.S,x
* clc
rts
.99 ldx DEVSLOTn08F
stz SSC.RESET-$8F,x
Dev.Detect.RTS rts
*--------------------------------------
PPP.LCPInit >LDYA L.MSG.LCPInit
>SYSCALL PutS
>LDYA L.PPP.EchoRep Pre calculate EchoRep FCS
jsr PPP.FCS16.Set
>LDYA L.PPP.ConfReq
jsr PPP.FCS16.Set
.DO DBG=1
>LDYA L.PPP.ConfReq
ldx #0
jsr DumpBuf.PPP
.FIN
>LDYA L.PPP.ConfReq
jsr SSC.WritePPP
bcs .9
.1 jsr SSC.ReadPPP
bcs .9
tya
beq .1
sty ZPBufLen
stz ZPBufLen+1
.DO DBG=1
>LDYA L.IN.Buf
ldx #2
jsr DumpBuf.PPP
.FIN
jsr LCP.IN.JUMP
bcs .9
bit bConfigured
bpl .1
* clc
rts
.9 lda #MLI.E.IO
* sec
rts
*--------------------------------------
LCP.IN.JUMP lda IN.Buf+3
cmp #$21
bne LCP.Discard
lda IN.Buf+2
cmp #$C0
bne .1
lda IN.Buf+4
beq LCP.Discard
cmp #16
bcs LCP.Discard
asl
tax
jmp (J.LCP-2,x)
.1 cmp #$80
bne LCP.Discard
lda IN.Buf+4
beq LCP.Discard
cmp #8
bcs LCP.Discard
asl
tax
jmp (J.IPCP-2,x)
*--------------------------------------
LCP.Discard
IPCP.Discard
clc
rts
*--------------------------------------
LCP.ConfReq ldy #0
.1 lda IN.Buf,y FF03C021
sta OUT.Buf,y
iny
cpy #4
bne .1
lda #2 Configure-Ack
sta OUT.Buf,y
iny ID
lda IN.Buf,y
sta OUT.Buf,y
iny Len MSB
lda IN.Buf,y
sta OUT.Buf,y
sta ZPBufLen+1
iny Len LSB
lda IN.Buf,y
sta OUT.Buf,y
sta ZPBufLen
sec
sbc #4 minus LEN LEN ... FCS FCS
tax
iny First option ID
.2 lda IN.Buf,y
cmp #6 ACCM ?
bne .7
phy
phx
ldx #3
.3 lda IN.Buf+2,y
sta ACCM.OUT,x
iny
dex
bpl .3
plx
ply
.7 jsr LCP.Ack.Copy
bne .2
lda ZPBufLen
clc
adc #6
sta ZPBufLen
bcc .8
inc ZPBufLen+1
.8 >LDYA L.OUT.Buf
jsr PPP.FCS16.Set
.DO DBG=1
>LDYA L.OUT.Buf
ldx #0
jsr DumpBuf.PPP
.FIN
>LDYA L.OUT.Buf
jmp SSC.WritePPP
*--------------------------------------
LCP.Ack.Copy txa
sec
sbc IN.Buf+1,y
pha
ldx IN.Buf+1,y
.1 lda IN.Buf,y
sta OUT.Buf,y
iny
dex
bne .1
plx
rts
*--------------------------------------
LCP.Ack.Next txa
sec
sbc IN.Buf+1,y
tax
tya
clc
adc IN.Buf+1,y
tay
rts
*--------------------------------------
LCP.ConfAck >LDYA L.PPP.IPCPReq
jsr PPP.FCS16.Set
.DO DBG=1
>LDYA L.PPP.IPCPReq
ldx #0
jsr DumpBuf.PPP
.FIN
>LDYA L.PPP.IPCPReq
jmp SSC.WritePPP
*--------------------------------------
LCP.ConfNak
clc
rts
*--------------------------------------
LCP.EchoReq .DO DBG=1
>LDYA L.PPP.EchoRep
ldx #0
jsr DumpBuf.PPP
.FIN
>LDYA L.PPP.EchoRep
jmp SSC.WritePPP
*--------------------------------------
IPCP.ConfReq ldy #0
.1 lda IN.Buf,y FF038021
sta OUT.Buf,y
iny
cpy #4
bne .1
lda #2 Configure-Ack
sta OUT.Buf,y
iny ID
lda IN.Buf,y
sta OUT.Buf,y
iny Len MSB
lda IN.Buf,y
sta OUT.Buf,y
sta ZPBufLen+1
iny Len LSB
lda IN.Buf,y
sta OUT.Buf,y
sta ZPBufLen
sec
sbc #4 minus LEN LEN ... FCS FCS
tax
iny First option ID
.2 lda IN.Buf,y
cmp #3 IP ADDR ?
bne .7
phy
phx
>PUSHW L.MSG.RemoteIP
ldx #0
.3 lda IN.Buf+2,y
sta DCB.GW,x
>PUSHA
iny
inx
cpx #4
bne .3
>PUSHBI 4
>SYSCALL PrintF
plx
ply
.7 jsr LCP.Ack.Copy
bne .2
lda ZPBufLen
clc
adc #6
sta ZPBufLen
bcc .8
inc ZPBufLen+1
.8 >LDYA L.OUT.Buf
jsr PPP.FCS16.Set
.DO DBG=1
>LDYA L.OUT.Buf
ldx #0
jsr DumpBuf.PPP
.FIN
>LDYA L.OUT.Buf
jmp SSC.WritePPP
*--------------------------------------
IPCP.ConfAck sec
ror bConfigured
* clc
rts
*--------------------------------------
IPCP.ConfNak ldy #10
ldx #0
>PUSHW L.MSG.LocalIP
.1 lda IN.Buf,y
sta PPP.IPCPReq,y
sta DCB.IP,x
>PUSHA
inx
iny
cpy #14
bne .1
>PUSHBI 4
>SYSCALL PrintF
jmp LCP.ConfAck
*--------------------------------------
SSC.Init ldx DEVSLOTn08F
stz SSC.RESET-$8F,x
lda #SSC.CTL.1S+SSC.CTL.8D+SSC.CTL.CLKINT+SSC.CTL.B115200
sta SSC.CTL-$8F,x
lda #SSC.CMD.NOP+SSC.CMD.TE+SSC.CMD.RIRQDIS+SSC.CMD.DTR
sta SSC.CMD-$8F,x
lda SSC.DATA-$8F,x discard any garbage byte
lda SSC.STATUS-$8F,x clear any IRQ pending
rts
*--------------------------------------
SSC.WritePPP >STYA ZPPtr1
ldy #7
lda (ZPPtr1),y Len LO
clc
adc #6
eor #$ff
sta ZPPtr3
dey
lda (ZPPtr1),y Len HI
adc #0
eor #$ff
sta ZPPtr3+1
php
sei
ldx DEVSLOTn08F
ldy #0
.1 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne .9
bit #SSC.STATUS.TDRE Register Empty ?
bne .2
iny
bne .1
.9 lda #MLI.E.IO
plp
sec
rts
.2 lda #$7E
sta SSC.DATA-$8F,x
.3 inc ZPPtr3
bne .31
inc ZPPtr3+1
beq .8
.31 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.TDRE
beq .3
lda (ZPPtr1),y
cmp #$7D
beq .4
cmp #$7E
beq .4
cmp #$20
bcs .6
phx
phy
and #7
tax bit in byte
lda (ZPPtr1),y
lsr
lsr
lsr
tay
lda ACCM.OUT,y
and ACCM.BIT2MASK,x
cmp #1
ply
plx
lda (ZPPtr1),y
bcc .6
.4 lda #$7D
sta SSC.DATA-$8F,x
.5 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.TDRE
beq .5
lda (ZPPtr1),y
eor #%00100000
.6 sta SSC.DATA-$8F,x
iny
bne .3
inc ZPPtr1+1
bra .3
.8 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.TDRE
beq .8
lda #$7E
sta SSC.DATA-$8F,x
plp
clc
rts
*--------------------------------------
SSC.ReadPPP php
sei
ldx DEVSLOTn08F
.1 stz b7D
ldy #0
.2 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne .9
bit #SSC.STATUS.RDRF incoming char?
bne .3
iny
bne .2
.8 plp
clc
rts
.3 lda SSC.DATA-$8F,x
bit b7D
bmi .4
cmp #$7E
bne .4
ror b7D
bra .1
.4 cmp #$FF
bne .1
sta IN.Buf
ldy #1
stz b7D
.5 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne .9
bit #SSC.STATUS.RDRF incoming char?
beq .5
lda SSC.DATA-$8F,x
bit b7D
bmi .6
cmp #$7D
bne .7
ror b7D
bra .5
.6 stz b7D
eor #%00100000
sta IN.Buf,y
iny
bra .5
.7 cmp #$7E
beq .8
sta IN.Buf,y
iny
bra .5
.9 lda #MLI.E.IO
plp
sec
rts
*--------------------------------------
.DO DBG=1
DumpBuf.PPP >STYA ZPPtr1
stz ZPPtr2
stz ZPPtr2+1
ldy #7
lda (ZPPtr1),y Len LO
clc
adc #6
sta ZPPtr3
dey
lda (ZPPtr1),y Len HI
adc #0
sta ZPPtr3+1
>PUSHW L.MSG.DUMPBUF,x
>PUSHW ZPPtr3
>PUSHBI 2
>SYSCALL PrintF
bcs .9
.1 >PUSHW L.MSG.HEXDUMP
>PUSHW ZPPtr2
ldy #0
.2 >PUSHB (ZPPtr1),y
iny
cpy #16
bne .2
>PUSHBI 18
>SYSCALL PrintF
bcs .9
lda ZPPtr1
adc #16
sta ZPPtr1
lda ZPPtr1+1
adc #0
sta ZPPtr1+1
lda ZPPtr2
adc #16
sta ZPPtr2
lda ZPPtr2+1
adc #0
sta ZPPtr2+1
lda ZPPtr3
sec
sbc #16
sta ZPPtr3
lda ZPPtr3+1
sbc #0
sta ZPPtr3+1
bcc .9
ora ZPPtr3
bne .1
clc
.9 rts
.FIN
*--------------------------------------
PPP.FCS16.Check sec
.HS 90 BCC
PPP.FCS16.Set clc
php
>STYA ZPPtr1
lda #$ff
sta FCS
sta FCS+1
ldy #7
lda (ZPPtr1),y Len LO
clc
adc #4 add FF 00 XX XX but dont include FCS FCS
eor #$ff
sta ZPPtr2
dey
lda (ZPPtr1),y Len HI
adc #0
eor #$ff
sta ZPPtr2+1
ldy #0
.1 inc ZPPtr2
bne .2
inc ZPPtr2+1
beq .7
.2 lda (ZPPtr1),y
iny
bne .3
inc ZPPtr1+1
.3 eor FCS
tax
lda FCS.LO,x
eor FCS+1
sta FCS
lda FCS.HI,x
sta FCS+1
bra .1
.7 plp
bcc .8 CC = set
lda FCS
eor #$ff
eor (ZPPtr1),y
bne .9
iny
lda FCS+1
eor #$ff
eor (ZPPtr1),y
bne .9
clc
rts
.8 lda FCS
eor #$ff
sta (ZPPtr1),y
iny
lda FCS+1
eor #$ff
sta (ZPPtr1),y
.9 rts
*--------------------------------------
.INB usr/src/drv/pppssc.drv.s.e
*--------------------------------------
CS.END
*--------------------------------------
DEVSIG.Offset .HS 05070B0C
DEVSIG.Value .HS 38180131
DEVSIG.Length .EQ DEVSIG.Value-DEVSIG.Offset
MSG.DETECT .AZ "PPP Driver For Apple SSC."
MSG.DETECT.OK .AZ "PPP Installed As Device : %s\r\n"
MSG.DETECT.KO .AZ "No SSC Found."
ETCFILE .AZ "${ROOT}etc/ppp.conf"
*--------------------------------------
MSG.ETCFILE .AZ "Executing %s File...\r\n"
MSG.UNEXPECTED .AZ "\r\nERR:Unexpected reply From Modem\r\n{%s}\r\n"
MSG.SYNTAX .AZ "\r\nERR:Bad Syntax In ppp.conf\r\n{%s}\r\n"
MSG.LCPInit .AZ "LCP/IPCP Negotiation..."
MSG.LocalIP .AZ "Local IP is %d.%d.%d.%d\r\n"
MSG.RemoteIP .AZ "Remote IP is %d.%d.%d.%d\r\n"
.DO DBG=1
MSG.DUMPBUFS .AZ ">>Send:%H\r\n"
MSG.DUMPBUFR .AZ "Recv<<:%H\r\n"
MSG.HEXDUMP .AZ "%H:%h %h %h %h %h %h %h %h:%h %h %h %h %h %h %h %h\r\n"
.FIN
*--------------------------------------
FD.DEV .DA #S.FD.T.CDEV
.DA #0 HANDLER
.DA #0 BUSID
.DA #0 DEVID
.DA 0 BUSPTR
.BS 2 DRVPTR
.DA 0 DCBPTR
.DA 0 BUFPTR
FD.DEV.NAME .AZ "eth1"
*--------------------------------------
PPP.ConfReq .HS FF03
.HS C021 LCP
PPP.ConfReq.DATA
.HS 01 Configure-Request
.HS FF ID
.DA /PPP.ConfReq.LEN,#PPP.ConfReq.LEN
* .HS 01.04 MRU
* .DA /1400,#1400
.HS 02.06.000A0000 ACCM
.HS 05.06.EA4C2B41 MAGIC
* .HS 07.02
* .HS 08.02
PPP.ConfReq.LEN .EQ *-PPP.ConfReq.DATA
.BS 2 FCS
*--------------------------------------
PPP.IPCPReq .HS FF03
.HS 8021 IPCP
PPP.IPCPReq.DATA
.HS 01 Configure-Request
.HS FF ID
.DA /PPP.IPCPReq.LEN,#PPP.IPCPReq.LEN
* .HS 02.06.00.2D.0F.00 VJ
.HS 03.06.00.00.00.00 IP Address
PPP.IPCPReq.LEN .EQ *-PPP.IPCPReq.DATA
.BS 2 FCS
*--------------------------------------
IN.Buf .BS 256
OUT.Buf .BS 256
*--------------------------------------
.INB usr/src/drv/pppssc.drv.s.d
*--------------------------------------
MAN
SAVE usr/src/drv/pppssc.drv.s
ASM