A2osX/DRV/PPPSSC.DRV.S.D.txt

759 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
*--------------------------------------
* Driver Code
*--------------------------------------
INBUF.SIZE .EQ 4096
*--------------------------------------
ZPIOCTL .EQ ZPDRV
ZPBufPtr .EQ ZPDRV+2
ZPCount .EQ ZPDRV+4
ZPnCount .EQ ZPDRV+6
ZPFCS .EQ ZPDRV+8
*--------------------------------------
DRV.CS.START cld
jmp (.1,x)
.1 .DA STATUS
.DA A2osX.BADCALL
.DA A2osX.BADCALL
.DA A2osX.BADCALL
.DA CONTROL
.DA A2osX.BADCALL
.DA OPEN
.DA CLOSE
.DA READ
.DA WRITE
.DA 0 end or relocation
*--------------------------------------
STATUS jsr STATUS.CONTROL.Init
ldy #S.IOCTL.S
lda (ZPIOCTL),y
beq .1
cmp #S.IOCTL.S.GETDIB
bne STATUS.DCB
ldy #S.DIB-1
.HS 2C bit abs
.1 ldy #3
.2 lda DIB,y
sta (ZPBufPtr),y
dey
bpl .2
clc
rts
STATUS.DCB cmp #S.IOCTL.S.GETDCB
bne .3
ldy #S.DCB.NIC-1
.2 lda DCB,y
sta (ZPBufPtr),y
dey
bpl .2
clc
rts
.3 cmp #S.IOCTL.S.EOF
bne STATUS.9
lda DIB+S.DIB.S
and #S.DIB.S.OPENED
beq OPEN.E
lda INBUF.CNT
ora INBUF.CNT+1
bne .8 NO DATA? eof = TRUE
lda #1
clc
rts
.8 lda #0
clc
rts
STATUS.9 lda #MLI.E.BADCTL
sec
rts
*--------------------------------------
CONTROL jsr STATUS.CONTROL.Init
ldy #S.IOCTL.C
lda (ZPIOCTL),y
cmp #S.IOCTL.C.SETDCB
bne STATUS.9
ldy #S.DCB.NIC-1
.2 lda (ZPBufPtr),y
sta DCB,y
dey
bpl .2
*--------------------------------------
OPEN lda DIB+S.DIB.S
bit #S.DIB.S.OPENED
beq OPEN.1
OPEN.E lda #MLI.E.OPEN
sec
rts
OPEN.1 >LDYAI INBUF.SIZE
>SYSCALL2 GetMem
bcs .9
stx hINBUF
sta INBUF.BASEH
>STYA READ.BUF+1
>STYA READ.SSC.BUF+1
stz INBUF.TAIL
stz INBUF.TAIL+1
stz INBUF.HEAD
stz INBUF.HEAD+1
stz INBUF.CNT
stz INBUF.CNT+1
ldx DEVSLOTn08F
lda #C.XOFF
jsr WRITE.Byte
lda #S.DIB.S.OPENED
tsb DIB+S.DIB.S
clc
.9 rts
*--------------------------------------
CLOSE php
sei
ldx DEVSLOTn08F
stz SSC.RESET-$8F,x
lda #S.DIB.S.OPENED
trb DIB+S.DIB.S
lda hINBUF
>SYSCALL2 FreeMem
plp
clc
rts
*--------------------------------------
READ >STYA ZPIOCTL
jsr READ.SSC
bcs .99
.1 jsr READ.Sync
bcs .98
cmp #$C0 C021 = LCP
beq .6
tay 0021 = IP
bne .1
jsr READ.GetByteEsc
bcs .98
cmp #$21
bne .1
jsr READ.GetByteEsc
bcs .98
cmp #$45 45 = S.IP.V.IHL
bne .1
jsr READ.GetByteEsc
bcs .98
* tay ignore DSCP.ECN
* bne .1
jsr READ.GetByteEsc HHLL = S.IP.TOTAL.LENGTH
bcs .98
sta ZPCount+1
eor #$ff
sta ZPnCount+1
jsr READ.GetByteEsc
bcs .98
sta ZPCount
eor #$ff
* clc
adc #4 already 4 bytes read
sta ZPnCount
bcc .2
inc ZPnCount+1
.2 jsr READ.NewFrame
bcs .99
phx hFrame
jsr READ.GetFrame
pla
bcc .99
>SYSCALL2 FreeMem
lda #MLI.E.IO
sec
rts
.6 jsr READ.GetByteEsc
bcs .98
cmp #$21
bne .1
jsr READ.GetByteEsc
bcs .98
cmp #$09
bne .1
jsr READ.SendEchoRep
bra .1
.98 lda #E.NODATA
.99 rts
*--------------------------------------
READ.SSC php
sei
ldx DEVSLOTn08F
lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne READ.SSC.98
lda #C.XON
jsr WRITE.Byte
READ.SSC.1 ldy #0
READ.SSC.2 lda SSC.STATUS-$8F,x
and #SSC.STATUS.RDRF
bne READ.SSC.3
iny
bne READ.SSC.2
lda #C.XOFF
jsr WRITE.Byte
plp
clc
rts
READ.SSC.3 lda SSC.DATA-$8F,x
READ.SSC.BUF sta $FFFF SELF MODIFIED
inc READ.SSC.BUF+1
bne .1
inc READ.SSC.BUF+2
.1 inc INBUF.CNT
bne .2
inc INBUF.CNT+1
.2 inc INBUF.HEAD
bne READ.SSC.1
inc INBUF.HEAD+1
lda INBUF.HEAD+1
cmp /INBUF.SIZE
bne READ.SSC.1
stz INBUF.HEAD+1
lda INBUF.BASEH
sta READ.SSC.BUF+2
bra READ.SSC.1
READ.SSC.98 lda #MLI.E.IO
plp
sec
rts
*--------------------------------------
READ.NewFrame lda ZPCount
clc
adc #S.ETH.EII
ldy #S.IOCTL.BYTECNT
sta (ZPIOCTL),y
pha
lda ZPCount+1
adc /S.ETH.EII
iny
sta (ZPIOCTL),y
ply
>SYSCALL2 GetMem
bcs .9
>STYA ZPBufPtr
phy
ldy #S.IOCTL.BUFPTR+1
sta (ZPIOCTL),y
dey
pla
sta (ZPIOCTL),y
ldy #S.ETH.EII.TYPE
lda /S.ETH.EII.TYPE.IP
sta (ZPBufPtr),y
iny
lda #S.ETH.EII.TYPE.IP
sta (ZPBufPtr),y
ldy #S.IP.V.IHL.DSCP.ECN
lda #$45
sta (ZPBufPtr),y
iny
lda #0
sta (ZPBufPtr),y
iny S.IP.TOTAL.LENGTH
lda ZPCount+1
sta (ZPBufPtr),y
iny
lda ZPCount
sta (ZPBufPtr),y
iny
tya
* clc
adc ZPBufPtr
sta ZPBufPtr
bcc .8
inc ZPBufPtr+1
clc
.8
* clc
.9 rts
*--------------------------------------
READ.GetFrame inc ZPnCount
bne .1
inc ZPnCount+1
beq .2
.1 jsr READ.GetByteEsc
bcs .9
sta (ZPBufPtr)
inc ZPBufPtr
bne READ.GetFrame
inc ZPBufPtr+1
bra READ.GetFrame
.2 jsr READ.GetByteEsc skip FCS HI
bcs .9
jsr READ.GetByteEsc skip FCS LO
bcs .9
jsr READ.GetByte
bcs .9
eor #$7E
beq .9
sec
.9 rts
*--------------------------------------
READ.Sync jsr READ.GetByte
bcs READ.GetByte.RTS
.1 cmp #$7E
bne READ.Sync
jsr READ.GetByte
bcs READ.GetByte.RTS
cmp #$FF
bne .1
jsr READ.GetByteEsc
bcs READ.GetByte.RTS
cmp #$03
bne .1
*--------------------------------------
READ.GetByteEsc jsr READ.GetByte
bcs READ.GetByte.9
cmp #$7D
bne READ.GetByte.8
jsr READ.GetByte
bcs READ.GetByte.9
eor #%00100000
* clc
rts
READ.GetByte lda INBUF.CNT
bne READ.GetByte.1
lda INBUF.CNT+1
beq READ.GetByte.9
dec INBUF.CNT+1
READ.GetByte.1 dec INBUF.CNT
READ.BUF lda $FFFF SELF MODIFIED
inc READ.BUF+1
bne READ.GetByte.8
inc READ.BUF+2
inc INBUF.TAIL+1
ldy INBUF.TAIL+1
cpy /INBUF.SIZE
bne READ.GetByte.8
stz INBUF.TAIL+1
ldy INBUF.BASEH
sty READ.BUF+2
READ.GetByte.8 clc
rts
READ.GetByte.9 sec
READ.GetByte.RTS
rts
*--------------------------------------
READ.SendEchoRep
ldx DEVSLOTn08F
lda #$7E
jsr WRITE.Byte
ldy #0
.1 lda PPP.EchoRep,y
phy
jsr WRITE.ByteEsc
ply
iny
cpy #PPP.EchoRep.TOTAL
bne .1
lda #$7E
jmp WRITE.Byte
*--------------------------------------
* 7E FF 03 00 21 ... FCS FCS 7E
*--------------------------------------
WRITE >STYA ZPIOCTL
ldy #S.IOCTL.BUFPTR
lda (ZPIOCTL),y
clc
adc #S.ETH.EII
sta ZPBufPtr
iny
lda (ZPIOCTL),y
adc /S.ETH.EII
sta ZPBufPtr+1
iny #S.IOCTL.BYTECNT
lda (ZPIOCTL),y
sec
sbc #S.ETH.EII
eor #$ff
sta ZPCount
iny
lda (ZPIOCTL),y
sbc /S.ETH.EII
eor #$ff
sta ZPCount+1
ldx DEVSLOTn08F
php
sei
lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDCD true when 0
bne .9
lda #$ff
sta ZPFCS
sta ZPFCS+1
lda #$7E
jsr WRITE.Byte
lda #$FF
jsr WRITE.ByteEscFCS
lda #$03
jsr WRITE.ByteEscFCS
lda #$00
jsr WRITE.ByteEscFCS
lda #$21
jsr WRITE.ByteEscFCS
.1 inc ZPCount
bne .2
inc ZPCount+1
beq .8
.2 lda (ZPBufPtr)
jsr WRITE.ByteEscFCS
inc ZPBufPtr
bne .1
inc ZPBufPtr+1
bra .1
.8 lda ZPFCS
eor #$ff
jsr WRITE.ByteEsc
lda ZPFCS+1
eor #$ff
jsr WRITE.ByteEsc
lda #$7E
jsr WRITE.Byte
plp
clc
rts
.9 lda #MLI.E.IO
plp
sec
rts
*--------------------------------------
WRITE.ByteEscFCS
pha
eor ZPFCS
tay
lda FCS.LO,y
eor ZPFCS+1
sta ZPFCS
lda FCS.HI,y
sta ZPFCS+1
pla
*--------------------------------------
WRITE.ByteEsc cmp #$7D
beq .1
cmp #$7E
beq .1
cmp #$20
bcs WRITE.Byte
* pha
* and #7
* tay bit mask
* lda ACCM.BIT2MASK,y
* sta .10+1
* pla
* pha
* lsr
* lsr
* lsr
* tay
* lda ACCM.OUT,y
*.10 and #$FF SELF MODIFIED
* beq WRITE.Byte.1
* pla
.1 eor #%00100000
pha
lda #$7D
jsr WRITE.Byte
.HS 89 BIT imm
WRITE.Byte pha
WRITE.Byte.1 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.TDRE Register Empty ?
beq WRITE.Byte.1
pla
sta SSC.DATA-$8F,x
rts
*--------------------------------------
STATUS.CONTROL.Init
>STYA ZPIOCTL
ldy #S.IOCTL.BUFPTR
lda (ZPIOCTL),y
sta ZPBufPtr
iny
lda (ZPIOCTL),y
sta ZPBufPtr+1
rts
*--------------------------------------
DRV.CS.END
*--------------------------------------
DEVSLOTn08F .BS 1
hINBUF .BS 1
INBUF.BASEH .BS 1
INBUF.TAIL .BS 2
INBUF.HEAD .BS 2
INBUF.CNT .BS 2
*--------------------------------------
DIB .DA #0
.DA #0,#0,#0 size
>PSTR "SSC/PPP Driver "
.DA #S.DIB.T.NIC
.DA #0
.DA K.VER
*--------------------------------------
DCB .DA #S.DCB.T.NIC
.DA #S.DCB.NIC.FLAGS.ARPOFFLOAD
.DA #S.DCB.NIC.LINK.OK+S.DCB.NIC.LINK.FD
.DA #S.DCB.NIC.SPEED.10
.HS 000A1A123456 MAC
DCB.IP .BS 4
DCB.MASK .HS FF.FF.FF.FF
DCB.GW .BS 4
*--------------------------------------
ACCM.IN .HS 000A0000
ACCM.OUT .HS FFFFFFFF
*--------------------------------------
ACCM.BIT2MASK .HS 0102040810204080
*--------------------------------------
PPP.EchoRep .HS FF03
.HS C021 LCP
PPP.EchoRep.DATA
.HS 0A Echo-Reply
.HS FF ID
.DA /PPP.EchoRep.LEN,#PPP.EchoRep.LEN
.HS 05.06.EA4C2B41 MAGIC
PPP.EchoRep.LEN .EQ *-PPP.EchoRep.DATA
.BS 2 FCS
PPP.EchoRep.TOTAL .EQ *-PPP.EchoRep
*--------------------------------------
FCS.LO .DA #$0000,#$1189,#$2312,#$329b,#$4624,#$57ad,#$6536,#$74bf
.DA #$8c48,#$9dc1,#$af5a,#$bed3,#$ca6c,#$dbe5,#$e97e,#$f8f7
.DA #$1081,#$0108,#$3393,#$221a,#$56a5,#$472c,#$75b7,#$643e
.DA #$9cc9,#$8d40,#$bfdb,#$ae52,#$daed,#$cb64,#$f9ff,#$e876
.DA #$2102,#$308b,#$0210,#$1399,#$6726,#$76af,#$4434,#$55bd
.DA #$ad4a,#$bcc3,#$8e58,#$9fd1,#$eb6e,#$fae7,#$c87c,#$d9f5
.DA #$3183,#$200a,#$1291,#$0318,#$77a7,#$662e,#$54b5,#$453c
.DA #$bdcb,#$ac42,#$9ed9,#$8f50,#$fbef,#$ea66,#$d8fd,#$c974
.DA #$4204,#$538d,#$6116,#$709f,#$0420,#$15a9,#$2732,#$36bb
.DA #$ce4c,#$dfc5,#$ed5e,#$fcd7,#$8868,#$99e1,#$ab7a,#$baf3
.DA #$5285,#$430c,#$7197,#$601e,#$14a1,#$0528,#$37b3,#$263a
.DA #$decd,#$cf44,#$fddf,#$ec56,#$98e9,#$8960,#$bbfb,#$aa72
.DA #$6306,#$728f,#$4014,#$519d,#$2522,#$34ab,#$0630,#$17b9
.DA #$ef4e,#$fec7,#$cc5c,#$ddd5,#$a96a,#$b8e3,#$8a78,#$9bf1
.DA #$7387,#$620e,#$5095,#$411c,#$35a3,#$242a,#$16b1,#$0738
.DA #$ffcf,#$ee46,#$dcdd,#$cd54,#$b9eb,#$a862,#$9af9,#$8b70
.DA #$8408,#$9581,#$a71a,#$b693,#$c22c,#$d3a5,#$e13e,#$f0b7
.DA #$0840,#$19c9,#$2b52,#$3adb,#$4e64,#$5fed,#$6d76,#$7cff
.DA #$9489,#$8500,#$b79b,#$a612,#$d2ad,#$c324,#$f1bf,#$e036
.DA #$18c1,#$0948,#$3bd3,#$2a5a,#$5ee5,#$4f6c,#$7df7,#$6c7e
.DA #$a50a,#$b483,#$8618,#$9791,#$e32e,#$f2a7,#$c03c,#$d1b5
.DA #$2942,#$38cb,#$0a50,#$1bd9,#$6f66,#$7eef,#$4c74,#$5dfd
.DA #$b58b,#$a402,#$9699,#$8710,#$f3af,#$e226,#$d0bd,#$c134
.DA #$39c3,#$284a,#$1ad1,#$0b58,#$7fe7,#$6e6e,#$5cf5,#$4d7c
.DA #$c60c,#$d785,#$e51e,#$f497,#$8028,#$91a1,#$a33a,#$b2b3
.DA #$4a44,#$5bcd,#$6956,#$78df,#$0c60,#$1de9,#$2f72,#$3efb
.DA #$d68d,#$c704,#$f59f,#$e416,#$90a9,#$8120,#$b3bb,#$a232
.DA #$5ac5,#$4b4c,#$79d7,#$685e,#$1ce1,#$0d68,#$3ff3,#$2e7a
.DA #$e70e,#$f687,#$c41c,#$d595,#$a12a,#$b0a3,#$8238,#$93b1
.DA #$6b46,#$7acf,#$4854,#$59dd,#$2d62,#$3ceb,#$0e70,#$1ff9
.DA #$f78f,#$e606,#$d49d,#$c514,#$b1ab,#$a022,#$92b9,#$8330
.DA #$7bc7,#$6a4e,#$58d5,#$495c,#$3de3,#$2c6a,#$1ef1,#$0f78
*--------------------------------------
FCS.HI .DA /$0000,/$1189,/$2312,/$329b,/$4624,/$57ad,/$6536,/$74bf
.DA /$8c48,/$9dc1,/$af5a,/$bed3,/$ca6c,/$dbe5,/$e97e,/$f8f7
.DA /$1081,/$0108,/$3393,/$221a,/$56a5,/$472c,/$75b7,/$643e
.DA /$9cc9,/$8d40,/$bfdb,/$ae52,/$daed,/$cb64,/$f9ff,/$e876
.DA /$2102,/$308b,/$0210,/$1399,/$6726,/$76af,/$4434,/$55bd
.DA /$ad4a,/$bcc3,/$8e58,/$9fd1,/$eb6e,/$fae7,/$c87c,/$d9f5
.DA /$3183,/$200a,/$1291,/$0318,/$77a7,/$662e,/$54b5,/$453c
.DA /$bdcb,/$ac42,/$9ed9,/$8f50,/$fbef,/$ea66,/$d8fd,/$c974
.DA /$4204,/$538d,/$6116,/$709f,/$0420,/$15a9,/$2732,/$36bb
.DA /$ce4c,/$dfc5,/$ed5e,/$fcd7,/$8868,/$99e1,/$ab7a,/$baf3
.DA /$5285,/$430c,/$7197,/$601e,/$14a1,/$0528,/$37b3,/$263a
.DA /$decd,/$cf44,/$fddf,/$ec56,/$98e9,/$8960,/$bbfb,/$aa72
.DA /$6306,/$728f,/$4014,/$519d,/$2522,/$34ab,/$0630,/$17b9
.DA /$ef4e,/$fec7,/$cc5c,/$ddd5,/$a96a,/$b8e3,/$8a78,/$9bf1
.DA /$7387,/$620e,/$5095,/$411c,/$35a3,/$242a,/$16b1,/$0738
.DA /$ffcf,/$ee46,/$dcdd,/$cd54,/$b9eb,/$a862,/$9af9,/$8b70
.DA /$8408,/$9581,/$a71a,/$b693,/$c22c,/$d3a5,/$e13e,/$f0b7
.DA /$0840,/$19c9,/$2b52,/$3adb,/$4e64,/$5fed,/$6d76,/$7cff
.DA /$9489,/$8500,/$b79b,/$a612,/$d2ad,/$c324,/$f1bf,/$e036
.DA /$18c1,/$0948,/$3bd3,/$2a5a,/$5ee5,/$4f6c,/$7df7,/$6c7e
.DA /$a50a,/$b483,/$8618,/$9791,/$e32e,/$f2a7,/$c03c,/$d1b5
.DA /$2942,/$38cb,/$0a50,/$1bd9,/$6f66,/$7eef,/$4c74,/$5dfd
.DA /$b58b,/$a402,/$9699,/$8710,/$f3af,/$e226,/$d0bd,/$c134
.DA /$39c3,/$284a,/$1ad1,/$0b58,/$7fe7,/$6e6e,/$5cf5,/$4d7c
.DA /$c60c,/$d785,/$e51e,/$f497,/$8028,/$91a1,/$a33a,/$b2b3
.DA /$4a44,/$5bcd,/$6956,/$78df,/$0c60,/$1de9,/$2f72,/$3efb
.DA /$d68d,/$c704,/$f59f,/$e416,/$90a9,/$8120,/$b3bb,/$a232
.DA /$5ac5,/$4b4c,/$79d7,/$685e,/$1ce1,/$0d68,/$3ff3,/$2e7a
.DA /$e70e,/$f687,/$c41c,/$d595,/$a12a,/$b0a3,/$8238,/$93b1
.DA /$6b46,/$7acf,/$4854,/$59dd,/$2d62,/$3ceb,/$0e70,/$1ff9
.DA /$f78f,/$e606,/$d49d,/$c514,/$b1ab,/$a022,/$92b9,/$8330
.DA /$7bc7,/$6a4e,/$58d5,/$495c,/$3de3,/$2c6a,/$1ef1,/$0f78
*--------------------------------------
DRV.END
*--------------------------------------
MAN
SAVE usr/src/drv/pppssc.drv.s.d
LOAD usr/src/drv/pppssc.drv.s
ASM