A2osX/DRV/X.SSC.DRV.S.txt

583 lines
10 KiB
Plaintext
Raw Normal View History

NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
.OP 65C02
.OR $2000
*--------------------------------------
.DO SSCIRQ=1
2018-07-23 15:28:42 +00:00
.TF DRV/SSC.I.DRV
.ELSE
2018-07-23 15:28:42 +00:00
.TF DRV/SSC.DRV
.FIN
*--------------------------------------
.DO SSCIRQ=1
BUF.SIZE .EQ $40
BUF.MASK .EQ $3F
.FIN
*--------------------------------------
2018-08-30 15:18:27 +00:00
ZPArgPtr .EQ ZPDRV
*--------------------------------------
* 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
2018-08-30 15:18:27 +00:00
.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
2018-08-30 15:18:27 +00:00
L.DRV.CS.START .DA DRV.CS.START
L.FD.DEV .DA FD.DEV
L.FD.DEV.NAME .DA FD.DEV.NAME
.DA 0 End Of Reloc Table
*--------------------------------------
Dev.Detect >STYA ARGS
>LDYA L.MSG.DETECT
2018-08-30 15:18:27 +00:00
>SYSCALL puts
2018-08-30 15:18:27 +00:00
stz ZPArgPtr
lda #$C1
2018-08-30 15:18:27 +00:00
sta ZPArgPtr+1
.1 and #$0f
tay
lda A2osX.S,y
bne .3
ldx #DEVSIG.Length-1
.2 ldy DEVSIG.Offset,x
2018-08-30 15:18:27 +00:00
lda (ZPArgPtr),y
cmp DEVSIG.Value,x
bne .3
dex
bpl .2
bra .4
2018-08-30 15:18:27 +00:00
.3 inc FD.DEV.NAME+3
inc ZPArgPtr+1 no match, try next slot....
lda ZPArgPtr+1
cmp #$C8
bne .1
>LDYA L.MSG.DETECT.KO
2018-08-30 15:18:27 +00:00
>SYSCALL puts
lda #MLI.E.NODEV Not Found in any slot, exiting
sec
rts
2018-08-30 15:18:27 +00:00
.4 lda ZPArgPtr+1
and #$0F
pha
tay
lda #A2osX.S.COM
sta A2osX.S,y
pla
asl
asl
asl
asl
clc
adc #$8F
sta DEVSLOTn08F
2018-08-30 15:18:27 +00:00
jsr Dev.ParseArgs
bcs .9
.8 >PUSHW L.FD.DEV.NAME
>PUSHBI 2
>LDYA L.MSG.DETECT.OK
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2018-08-30 15:18:27 +00:00
>PUSHWI DRV.END
>PUSHWI DRV.CS.END
>PUSHWI DRV.CS.START
>LDYA L.DRV.CS.START
>SYSCALL InsDrv
bcs .9
>STYA FD.DEV+S.FD.DEV.DRVPTR
>LDYA L.FD.DEV
>SYSCALL MKDEV
.9 rts
*--------------------------------------
Dev.ParseArgs >LDYA ARGS
>STYA ZPArgPTR
lda (ZPArgPTR)
beq .8
.8 clc
rts
*--------------------------------------
CS.END
DEVSIG.Offset .HS 05070B0C
DEVSIG.Value .HS 38180131
DEVSIG.Length .EQ DEVSIG.Value-DEVSIG.Offset
MSG.DETECT .DO SSCIRQ=1
2018-08-30 15:18:27 +00:00
.AZ "Apple SSC (Super Serial Card,//c Serial Port) Driver (IRQ Enabled)."
.ELSE
2018-08-30 15:18:27 +00:00
.AZ "Apple SSC (Super Serial Card,//c Serial Port) Driver."
.FIN
MSG.DETECT.OK .AZ "SSC Installed As Device : %s\r\n"
2018-08-30 15:18:27 +00:00
MSG.DETECT.KO .AZ "No SSC Found."
ARGS .BS 2
*--------------------------------------
2018-08-30 15:18:27 +00:00
FD.DEV .DA #S.FD.T.CDEV
.DA #0 HANDLER
.DA #0 BUSID
.DA #0 DEVID
.DA 0 BUSPTR
.BS 2 DRVPTR
FD.DEV.NAME .AZ "COM1" NAME
.HS 000000
*--------------------------------------
* Driver Code
*--------------------------------------
2018-08-30 15:18:27 +00:00
ZPIOCTL .EQ ZPDRV
2018-08-31 15:35:08 +00:00
ZPBufPtr .EQ ZPDRV+2
ZPCount .EQ ZPDRV+4
ZPCount2 .EQ ZPDRV+6
2018-08-30 15:18:27 +00:00
*--------------------------------------
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
.DO SSCIRQ=1
.DA IRQ
2018-08-30 15:18:27 +00:00
.ELSE
.DA A2osX.BADCALL
.FIN
.DA 0 end or relocation
*--------------------------------------
2018-08-30 15:18:27 +00:00
STATUS >STYA ZPIOCTL
ldy #S.IOCTL.STATCODE
lda (ZPIOCTL),y
beq .1
cmp #S.IOCTL.STATCODE.GETDIB
bne STATUS.DCB
ldx #S.DIB-1
.HS 2C bit abs
.1 ldx #3
ldy #S.IOCTL.BUFPTR
lda (ZPIOCTL),y
sta .3+1
iny
lda (ZPIOCTL),y
sta .3+2
.2 lda DIB,x
.3 sta $ffff,x SELF MODIFIED
dex
bpl .2
clc
rts
2018-08-30 15:18:27 +00:00
STATUS.DCB cmp #S.IOCTL.STATCODE.GETDCB
bne STATUS.9
ldy #S.IOCTL.BUFPTR
lda (ZPIOCTL),y
sta .3+1
iny
lda (ZPIOCTL),y
sta .3+2
ldx #S.DCB.COM-1
.2 lda DCB,x
.3 sta $ffff,x SELF MODIFIED
dex
bpl .2
clc
rts
2018-08-30 15:18:27 +00:00
STATUS.9 lda #MLI.E.BADCTL
sec
rts
*--------------------------------------
CONTROL >STYA ZPIOCTL
ldy #S.IOCTL.CTRLCODE
lda (ZPIOCTL),y
cmp #S.IOCTL.CTRLCODE.SETDCB
bne STATUS.9
.1 ldy #S.IOCTL.BUFPTR
lda (ZPIOCTL),y
sta .2+1
iny
lda (ZPIOCTL),y
sta .2+2
ldx #S.DCB.COM-1
.2 lda $ffff,x SELF MODIFIED
sta DCB,x
dex
bpl .2
*--------------------------------------
OPEN php
sei
ldx DEVSLOTn08F
stz SSC.RESET-$8F,x
lda #SSC.CTL.CLKINT+SSC.CTL.B9600+SSC.CTL.8D+SSC.CTL.1S+SSC.CMD.NOP
sta SSC.CTL-$8F,x
.DO SSCIRQ=1
lda #SSC.CMD.TEIRQ+SSC.CMD.TE+SSC.CMD.DTR
sta SSC.CMD-$8F,x
stz INBUF.HEAD
stz INBUF.TAIL
stz OUTBUF.HEAD
stz OUTBUF.TAIL
.ELSE
lda #SSC.CMD.RIRQDIS+SSC.CMD.TE+SSC.CMD.DTR
sta SSC.CMD-$8F,x
.FIN
lda SSC.DATA-$8F,x discard any garbage byte
lda SSC.STATUS-$8F,x clear any IRQ pending
plp
clc
rts
*--------------------------------------
CLOSE php
sei
ldx DEVSLOTn08F
stz SSC.RESET-$8F,x
plp
clc
rts
*--------------------------------------
2018-08-30 15:18:27 +00:00
READ >STYA ZPIOCTL
php
sei
2018-08-31 15:35:08 +00:00
ldy #S.IOCTL.BUFPTR
lda (ZPIOCTL),y
sta ZPBufPtr
iny
lda (ZPIOCTL),y
sta ZPBufPtr+1
* ldy #S.IOCTL.BYTECNT
iny
lda (ZPIOCTL),y
eor #$ff
sta ZPCount
iny
lda (ZPIOCTL),y
eor #$ff
sta ZPCount+1
stz ZPCount2
stz ZPCount2+1
ldx DEVSLOTn08F
.10 inc ZPCount
bne .11
inc ZPCount+1
beq .8
.11 .DO SSCIRQ=1
ldy INBUF.TAIL
cpy INBUF.HEAD
beq .2
2018-08-31 15:35:08 +00:00
lda INBUF,y
iny
cpy #BUF.SIZE
bne .1
2018-08-31 15:35:08 +00:00
ldy #0
2018-08-31 15:35:08 +00:00
.1 sty INBUF.TAIL
sta (ZPBufPtr)
inc ZPBufPtr
bne .12
inc ZPBufPtr+1
2018-08-31 15:35:08 +00:00
.12 inc ZPCount2
bne .10
inc ZPCount2+1
bra .10
2018-08-31 15:35:08 +00:00
.FIN
.2 lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDSR true when 0
bne .9
ldx DEVSLOTn08F
lda SSC.STATUS-$8F,x
and #SSC.STATUS.RDRF incoming char?
2018-08-31 15:35:08 +00:00
beq .8
sta (ZPBufPtr)
inc ZPBufPtr
bne .13
inc ZPBufPtr+1
2018-08-31 15:35:08 +00:00
.13 inc ZPCount2
bne .2
inc ZPCount2+1
bra .2
.8 lda ZPCount2
bne .81
ldx ZPCount2+1
beq .99
.81 ldy #S.IOCTL.BYTECNT
sta (ZPIOCTL),y
iny
txa
sta (ZPIOCTL),y
plp
clc
2018-08-31 15:35:08 +00:00
rts
2018-08-31 15:35:08 +00:00
.90 lda #0
.HS 2C BIT ABS
.9 lda #C.EOF
.99 plp
sec
2018-08-31 15:35:08 +00:00
rts
*--------------------------------------
2018-08-30 15:18:27 +00:00
WRITE >STYA ZPIOCTL
php
sei
2018-08-31 15:35:08 +00:00
ldy #S.IOCTL.BUFPTR
lda (ZPIOCTL),y
sta ZPBufPtr
iny
lda (ZPIOCTL),y
sta ZPBufPtr+1
* ldy #S.IOCTL.BYTECNT
iny
lda (ZPIOCTL),y
eor #$ff
sta ZPCount
iny
lda (ZPIOCTL),y
eor #$ff
sta ZPCount+1
.2 inc ZPCount
bne .3
inc ZPCount+1
beq .8
.3 .DO SSCIRQ=1
ldx DEVSLOTn08F
lda SSC.STATUS-$8F,x
bit #SSC.STATUS.nDSR true when 0
bne .90
lda OUTBUF.HEAD
cmp OUTBUF.TAIL Buffer Empty?
2018-08-31 15:35:08 +00:00
bne .6 not empty, queue char
lda SSC.STATUS-$8F,x
and #SSC.STATUS.TDRE Register Empty ?
2018-08-31 15:35:08 +00:00
beq .5 not empty, queue char
2018-08-31 15:35:08 +00:00
lda (ZPBufPtr) yes, write directly to ACIA
inc ZPBufPtr
bne .4
inc ZPBufPtr+1
.4 sta SSC.DATA-$8F,x
2018-08-31 15:35:08 +00:00
bra .2
2018-08-31 15:35:08 +00:00
.5 lda OUTBUF.HEAD
2018-08-31 15:35:08 +00:00
.6 tax
inc
and #BUF.MASK
cmp OUTBUF.TAIL
beq .9 Buffer Full!!
sta OUTBUF.HEAD
2018-08-31 15:35:08 +00:00
lda (ZPBufPtr)
inc ZPBufPtr
bne .7
inc ZPBufPtr+1
2018-08-31 15:35:08 +00:00
.7 sta OUTBUF,x
bra .2
.ELSE
ldx DEVSLOTn08F
2018-08-31 15:35:08 +00:00
.4 lda SSC.STATUS-$8F,x
2018-08-31 15:35:08 +00:00
* and #SSC.STATUS.DCD+SSC.STATUS.nDSR
* beq .9
and #SSC.STATUS.TDRE Outgoing char?
2018-08-31 15:35:08 +00:00
beq .4
2018-08-31 15:35:08 +00:00
lda (ZPBufPtr)
inc ZPBufPtr
bne .5
inc ZPBufPtr+1
.5 sta SSC.DATA-$8F,x
bra .2
.FIN
2018-08-31 15:35:08 +00:00
.8 plp
clc
2018-08-31 15:35:08 +00:00
rts
2018-08-31 15:35:08 +00:00
.90 lda #0
.HS 2C BIT ABS
.9 lda #C.EOF
plp
sec
rts
*--------------------------------------
* IRQ Handler
* on exit, CC if handled
*--------------------------------------
.DO SSCIRQ=1
IRQ ldx DEVSLOTn08F
lda SSC.STATUS-$8F,x
* and #SSC.STATUS.IRQ Useless
bpl .9 IRQ from this device ? no, exit !!!!Applewin bug #308!!!!
bit #SSC.STATUS.RDRF incoming char?
beq .2
*------------ IRQ In
pha
lda INBUF.HEAD
tay save actual head for later
inc
and #BUF.MASK
cmp INBUF.TAIL
beq .1 buffer full, discard and exit
sta INBUF.HEAD
lda SSC.DATA-$8F,x read data to clear IRQ
sta INBUF,y
.1 pla
*------------ IRQ Out
.2 bit #SSC.STATUS.TDRE
beq .8 no transmition possible....
ldy OUTBUF.TAIL something to transmit ?
cpy OUTBUF.HEAD
beq .8 in that case, HOW TO CLEAR IRQ ????
lda OUTBUF,y
sta SSC.DATA-$8F,x write data to clear IRQ
tya
inc
and #BUF.MASK
sta OUTBUF.TAIL
.8 clc
rts
.9 sec
rts
.FIN
*--------------------------------------
DRV.CS.END
DEVSLOTn08F .BS 1
.DO SSCIRQ=1
INBUF.TAIL .BS 1
INBUF.HEAD .BS 1
OUTBUF.TAIL .BS 1
OUTBUF.HEAD .BS 1
INBUF .BS BUF.SIZE
OUTBUF .BS BUF.SIZE
.FIN
*--------------------------------------
2018-08-30 15:18:27 +00:00
DIB .DO SSCIRQ=1
.DA #S.DIB.S.WRITE+S.DIB.S.READ+S.DIB.S.IRQ
.ELSE
2018-07-19 15:33:55 +00:00
.DA #S.DIB.S.WRITE+S.DIB.S.READ
.FIN
.DA #0,#0,#0
>PSTR "Serial Card/Port"
2018-07-19 15:33:55 +00:00
.DA #S.DIB.T.CHAR
.DA #0
2018-08-30 15:18:27 +00:00
.DA K.VER
*--------------------------------------
DCB .DA #S.DCB.T.COM
.DA #0 FLAGS
.DA >9600 BAUD (DWORD)
.DA #8 DATA
.DA #1 STOP
.DA #S.DCB.COM.P.NONE PARITY
.DA #S.DCB.COM.C.XONXOFF
*--------------------------------------
2018-08-30 15:18:27 +00:00
DRV.END
MAN
SAVE /A2OSX.SRC/DRV/X.SSC.DRV.S
LOAD /A2OSX.SRC/DRV/SSC.I.DRV.S
ASM