mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
326 lines
6.5 KiB
Plaintext
326 lines
6.5 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BOOT/DRV/SSC.I.DRV
|
||
*--------------------------------------
|
||
.INB /A2OSX.DEV/INC/MACROS.I
|
||
.INB /A2OSX.DEV/INC/A2OSX.I
|
||
*--------------------------------------
|
||
BUF.SIZE .EQ $20
|
||
BUF.MASK .EQ $1F
|
||
*--------------------------------------
|
||
ZPTmpPtr1 .EQ ZPDRV
|
||
*--------------------------------------
|
||
.INB DRV/X.SER.6551.S
|
||
*--------------------------------------
|
||
* see this :
|
||
* http://mirrors.apple2.org.za/apple.cabi.net/Applications/Telcom/SSC.DRIVER/SSC.DRIVER.TXT
|
||
* About False read issue in SSC
|
||
*--------------------------------------
|
||
* 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 DEV.HEADER-CS.START Device Header Offset
|
||
.DA DRV.CS.START-CS.START Driver Code Offset
|
||
.DA DRV.CS.END-DRV.CS.START Drv Code Length
|
||
*--------------------------------------
|
||
* 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.DEV.HEADER.NAME .DA DEV.HEADER.NAME
|
||
.DA 0 End Of Reloc Table
|
||
*--------------------------------------
|
||
Dev.Detect sta hArgs
|
||
>LDYA L.MSG.DETECT
|
||
>SYSCALL CPrintFYA
|
||
|
||
stz ZPTmpPtr1
|
||
lda #$C1
|
||
sta ZPTmpPtr1+1
|
||
|
||
.1 ldx #DEVSIG.Length-1
|
||
|
||
.2 ldy DEVSIG.Offset,x
|
||
lda (ZPTmpPtr1),y
|
||
cmp DEVSIG.Value,x
|
||
bne .3
|
||
dex
|
||
bpl .2
|
||
bra .4
|
||
|
||
.3 inc ZPTmpPtr1+1 no match, try next slot....
|
||
lda ZPTmpPtr1+1
|
||
cmp #$C8
|
||
bne .1
|
||
|
||
>LDYA L.MSG.DETECT.KO
|
||
>SYSCALL CPrintFYA
|
||
|
||
lda #DEVMGR.ERRNOHW Not Found in any slot, exiting
|
||
sec
|
||
rts
|
||
|
||
.4 lda ZPTmpPtr1+1
|
||
* sta DEVSLOTCn
|
||
and #$0F
|
||
sta DEVSLOT0n
|
||
ora #$30
|
||
sta DEV.HEADER.NAME+4
|
||
asl
|
||
asl
|
||
asl
|
||
asl
|
||
sta DEVSLOTn0
|
||
clc
|
||
adc #SSC.DATA+1
|
||
sta DEV.DATA.BFFF
|
||
|
||
>PUSHW L.DEV.HEADER.NAME
|
||
>LDYA L.MSG.DETECT.OK
|
||
>SYSCALL CPrintFYA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
DEVSIG.Offset .HS 05070B0C
|
||
DEVSIG.Value .HS 38180131
|
||
DEVSIG.Length .EQ DEVSIG.Value-DEVSIG.Offset
|
||
MSG.DETECT >CSTR "Apple SSC (Super Serial Card,//c Serial Port) Driver (IRQ Enabled).\n"
|
||
MSG.DETECT.OK >CSTR "SSC Installed As Device : %S\n"
|
||
MSG.DETECT.KO >CSTR "No SSC Found.\n"
|
||
hArgs .BS 1
|
||
*--------------------------------------
|
||
* Device Header (16 Bytes)
|
||
*--------------------------------------
|
||
DEV.HEADER cld
|
||
jmp (DRV.CS.START,x)
|
||
.HS 00 DevID
|
||
.DA #S.DEV.F.IRQ+S.DEV.F.EVENT+S.DEV.F.COUT+S.DEV.F.CHAR
|
||
DEV.HEADER.NAME >PSTR "COM1" NAME
|
||
.HS 00
|
||
.HS 00.00.00.00
|
||
*--------------------------------------
|
||
* Driver Code
|
||
*--------------------------------------
|
||
DRV.CS.START .DA OPEN
|
||
.DA GETEVENT
|
||
.DA COUT
|
||
.DA CLOSE
|
||
.DA GETINFO
|
||
.DA IRQ
|
||
L.DEVINFO .DA DEVINFO
|
||
.DA 0 end or relocation
|
||
*--------------------------------------
|
||
OPEN php
|
||
sei
|
||
ldx DEVSLOTn0
|
||
|
||
stz SSC.RESET,x
|
||
|
||
stz INBUF.PTR
|
||
stz INBUF.CNT
|
||
stz OUTBUF.PTR
|
||
stz OUTBUF.CNT
|
||
|
||
lda #SSC.CTL.CLKINT+SSC.CTL.B9600
|
||
sta SSC.CTL,x
|
||
|
||
lda #SSC.CMD.TE+SSC.CMD.DTR
|
||
sta SSC.CMD,x
|
||
|
||
lda SSC.DATA,x discard any garbage byte
|
||
lda SSC.STATUS,x clear any IRQ pending
|
||
|
||
plp
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
GETEVENT php
|
||
sei
|
||
lda INBUF.CNT
|
||
|
||
beq .9
|
||
|
||
ldx INBUF.PTR
|
||
lda INBUF,x
|
||
|
||
ldy #S.EVT.DATA
|
||
sta (pEvent),y
|
||
|
||
iny
|
||
lda #0
|
||
sta (pEvent),y
|
||
|
||
lda #S.EVT.F.KEY
|
||
sta (pEvent)
|
||
|
||
txa
|
||
inc
|
||
and #BUF.MASK
|
||
sta INBUF.PTR
|
||
dec INBUF.CNT
|
||
|
||
plp
|
||
clc
|
||
rts
|
||
|
||
.9 plp
|
||
lda #0
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
COUT php
|
||
sei
|
||
tay save char in Y
|
||
|
||
ldx DEVSLOTn0
|
||
lda SSC.STATUS,x
|
||
|
||
bit #SSC.STATUS.DCD+SSC.STATUS.DSR true when 0
|
||
bne .9
|
||
|
||
ldx OUTBUF.CNT Buffer Empty?
|
||
bne .10 not empty, queue char
|
||
|
||
and #SSC.STATUS.TDRE Register Empty ?
|
||
beq .10 not empty, queue char
|
||
|
||
tya yes, write directly to ACIA
|
||
ldx DEV.DATA.BFFF
|
||
sta $BFFF,x
|
||
|
||
plp
|
||
clc
|
||
rts
|
||
|
||
.10 cpx #BUF.SIZE
|
||
beq .9 Buffer Full!!
|
||
|
||
lda OUTBUF.PTR
|
||
clc
|
||
adc OUTBUF.CNT
|
||
and #BUF.MASK
|
||
tax
|
||
|
||
tya
|
||
sta OUTBUF,x
|
||
|
||
inc OUTBUF.CNT
|
||
|
||
* ldx DEVSLOTn0
|
||
lda #SSC.CMD.TEIRQ+SSC.CMD.DTR
|
||
sta SSC.CMD,x
|
||
plp
|
||
clc
|
||
rts
|
||
|
||
.9 plp
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CLOSE php
|
||
sei
|
||
ldx DEVSLOTn0
|
||
stz SSC.RESET,x
|
||
plp
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
GETINFO >LDYA L.DEVINFO
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* IRQ Handler
|
||
* on exit, CC if handled
|
||
*--------------------------------------
|
||
IRQ ldx DEVSLOTn0
|
||
lda SSC.STATUS,x IRQ from this device ?
|
||
* bpl .9 no, exit !!!!Applewin bug #308!!!!
|
||
|
||
bit #SSC.STATUS.RDRF incoming char?
|
||
beq .1
|
||
|
||
*------------ IRQ In
|
||
|
||
ldy SSC.DATA,x read data to clear IRQ
|
||
|
||
lda INBUF.CNT
|
||
cmp #BUF.SIZE
|
||
beq .8 buffer full, discard
|
||
|
||
clc
|
||
adc INBUF.PTR
|
||
and #BUF.MASK
|
||
tax
|
||
tya get back data
|
||
sta INBUF,x
|
||
|
||
inc INBUF.CNT
|
||
bra IRQ start over if
|
||
|
||
*------------ IRQ Out
|
||
|
||
.1 bit #SSC.STATUS.TDRE
|
||
beq .2 no transmit, no recieve, CTS changed!
|
||
|
||
lda OUTBUF.CNT something to transmit ?
|
||
beq .11 no, disable IRQ and exit
|
||
|
||
ldx OUTBUF.PTR
|
||
lda OUTBUF,x
|
||
ldy DEV.DATA.BFFF
|
||
sta $BFFF,y
|
||
|
||
dec OUTBUF.CNT
|
||
txa get back OUTBUF.PTR
|
||
inc
|
||
and #BUF.MASK
|
||
sta OUTBUF.PTR
|
||
clc
|
||
rts
|
||
|
||
.11 lda #SSC.CMD.TE+SSC.CMD.DTR
|
||
sta SSC.CMD,x
|
||
clc
|
||
rts
|
||
|
||
*------------ IRQ CTS High
|
||
|
||
.2
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
DRV.CS.END
|
||
DEVSLOT0n .BS 1
|
||
*DEVSLOTCn .BS 1
|
||
DEV.DATA.BFFF .BS 1
|
||
DEVSLOTn0 .BS 1
|
||
INBUF.PTR .BS 1
|
||
INBUF.CNT .BS 1
|
||
OUTBUF.PTR .BS 1
|
||
OUTBUF.CNT .BS 1
|
||
INBUF .BS BUF.SIZE
|
||
OUTBUF .BS BUF.SIZE
|
||
DEVINFO .DA #S.DEVINFO.TYPE.CHAR
|
||
.DA #0
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE DRV/SSC.DRV.I.S
|
||
ASM
|