A2osX/DRV/UTHERNET.DRV.S.txt

401 lines
7.9 KiB
Plaintext
Raw Normal View History

2015-03-14 21:48:35 +00:00
PR#3
2015-06-03 18:30:57 +00:00
PREFIX /A2OSX.SRC
LOMEM $A00
2015-03-14 21:48:35 +00:00
INC 1
AUTO 6
2016-04-18 20:15:34 +00:00
.LIST OFF
2015-03-14 21:48:35 +00:00
.OP 65C02
.OR $2000
2015-06-03 18:30:57 +00:00
.TF /A2OSX.BOOT/DRV/UTHERNET.DRV
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-10-26 20:08:11 +00:00
.INB /A2OSX.DEV/INC/MACROS.I
.INB /A2OSX.DEV/INC/A2OSX.I
2017-02-04 22:07:06 +00:00
.INB /A2OSX.DEV/INC/NET.8900A.I
2016-10-26 20:08:11 +00:00
.INB /A2OSX.DEV/INC/LIBTCPIP.I
2015-03-14 21:48:35 +00:00
*--------------------------------------
ZPTmpPTR .EQ ZPDRV
*--------------------------------------
2015-06-03 18:30:57 +00:00
* File Header (16 Bytes)
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.START cld
2015-06-03 18:30:57 +00:00
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
2015-03-14 21:48:35 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
* 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
2015-06-03 18:30:57 +00:00
.DA 0 End Of Reloc Table
*--------------------------------------
2016-08-17 06:25:58 +00:00
Dev.Detect >STYA ARGS
2015-06-03 18:30:57 +00:00
>LDYA L.MSG.DETECT
>SYSCALL CPrintFYA
2015-06-03 18:30:57 +00:00
ldx #$70
.1 txa IO based detection, avoid scanning in Disk Controller IO!!!!
lsr
lsr
lsr
lsr
tay
lda A2osX.SLOTS,y
bne .2
>LDYAI PP.ID
2015-03-14 21:48:35 +00:00
>STYA PacketPagePTR,x
>LDYA PacketPageDATA,x
cpy #DEVID
bne .2
cmp /DEVID
beq .3
2015-06-03 18:30:57 +00:00
.2 dec DEV.HEADER.NAME+4
2015-03-14 21:48:35 +00:00
txa
sec
sbc #$10
2015-03-14 21:48:35 +00:00
tax
bne .1
2015-06-03 18:30:57 +00:00
>LDYA L.MSG.DETECT.KO
>SYSCALL CPrintFYA
2017-01-29 21:47:19 +00:00
lda #$28 MLI.ERR.NODEV
2015-03-14 21:48:35 +00:00
sec
rts
2015-06-03 18:30:57 +00:00
2016-01-10 22:16:07 +00:00
.3 stx DEVSLOTx0
txa
lsr
lsr
lsr
lsr
tay
lda #A2osX.SLOTS.NET
sta A2osX.SLOTS,y
2016-01-10 22:16:07 +00:00
>LDYAI PP.ID+2 Get Revision# of ths chip...
>STYA PacketPagePTR,x
>LDYA PacketPageDATA,x
>STYA DEVSTAT+S.DEVSTAT.VERSION set Hardware version
2016-08-17 06:25:58 +00:00
>LDYA ARGS
>STYA ZPTmpPTR
lda (ZPTmpPTR)
2016-04-18 20:15:34 +00:00
bne .4
2016-08-17 06:25:58 +00:00
2016-04-18 20:15:34 +00:00
lda #$00
sta MAC
lda #$0E
sta MAC+1
lda #$3A
sta MAC+2
lda A2osX.RANDOM16
eor A2osX.TIMER16
sta MAC+3
eor A2osX.RANDOM16+1
sta MAC+4
eor A2osX.TIMER16+1
sta MAC+5
bra .8
2015-06-03 18:30:57 +00:00
2016-08-17 06:25:58 +00:00
.4 jsr DecodeMac
2016-04-18 20:15:34 +00:00
bcc .8
2016-01-04 07:21:45 +00:00
lda #DEVMGR.ERRICL
2015-03-14 21:48:35 +00:00
sec
rts
.8 >PUSHW L.DEV.HEADER.NAME
>LDYA L.MSG.DETECT.OK
>SYSCALL CPrintFYA
clc
2015-06-03 18:30:57 +00:00
rts
*--------------------------------------
2016-03-20 22:12:57 +00:00
.INB DRV/X.NET.DRV.S
2015-06-03 18:30:57 +00:00
*--------------------------------------
CS.END
MSG.DETECT >CSTR "UtherNet/CS8900A Driver.\r\n"
MSG.DETECT.OK >CSTR "UtherNet/CS8900A Installed As Device : %S\r\n"
MSG.DETECT.KO >CSTR "Hardware Not Found.\r\n"
2016-08-17 06:25:58 +00:00
ARGS .BS 2
2015-06-03 18:30:57 +00:00
*--------------------------------------
* Device Header (16 Bytes)
*--------------------------------------
2017-01-12 17:43:45 +00:00
DEV.HEADER .DA DRV.CS.START
.DA #S.DEV.S.BLOCK+S.DEV.S.WRITE+S.DEV.S.READ
DEV.HEADER.NAME .DA #4
.AS "ETH7" NAME
2015-06-03 18:30:57 +00:00
*--------------------------------------
* Driver Code
*--------------------------------------
DRV.CS.START cld
jmp (.1,x)
.1 .DA STATUS
2017-01-12 17:43:45 +00:00
.DA READBLOCK
.DA WRITEBLOCK
.DA BADCALL
.DA BADCALL
.DA BADCALL
.DA OPEN
2015-06-03 18:30:57 +00:00
.DA CLOSE
2017-01-12 17:43:45 +00:00
.DA BADCALL
.DA BADCALL
L.DEVSTAT .DA DEVSTAT
2015-06-03 18:30:57 +00:00
.DA 0 end or relocation
*--------------------------------------
2017-01-29 21:47:19 +00:00
BADCALL lda #1 MLI.ERR.BADCALL
2017-01-12 17:43:45 +00:00
sec
rts
*--------------------------------------
STATUS lda #S.DEVSTAT.NET.STATUS.10
2017-01-12 17:43:45 +00:00
sta LINK.STATUS
2015-03-14 21:48:35 +00:00
2017-01-12 17:43:45 +00:00
ldx DEVSLOTx0
>LDYAI PP.LineST
2015-03-14 21:48:35 +00:00
>STYA PacketPagePTR,x
2017-01-12 17:43:45 +00:00
>LDYA PacketPageDATA,x
tya
and #PP.LineST.LinkOK
bne .1
lda LINK.STATUS
ora #S.DEVSTAT.NET.STATUS.OK
2017-01-12 17:43:45 +00:00
sta LINK.STATUS
.1 >LDYAI PP.TestCTL
2015-03-14 21:48:35 +00:00
>STYA PacketPagePTR,x
2017-01-12 17:43:45 +00:00
>LDYA PacketPageDATA,x
and /PP.TestCTL.FDX
bne .2
lda LINK.STATUS
ora #S.DEVSTAT.NET.STATUS.FD
2017-01-12 17:43:45 +00:00
sta LINK.STATUS
2015-03-14 21:48:35 +00:00
2017-01-12 17:43:45 +00:00
.2 >LDYA L.DEVSTAT
2015-06-03 18:30:57 +00:00
clc
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
2017-01-12 17:43:45 +00:00
READBLOCK ldx DEVSLOTx0
2015-03-14 21:48:35 +00:00
>LDYAI PP.RxEvent
>STYA PacketPagePTR,x
>LDYA PacketPageDATA,x
and /PP.RxEvent.RxOK+PP.RxEvent.Brdcast+PP.RxEvent.IA
2017-01-12 17:43:45 +00:00
bne READBLOCK.RxOK
2016-03-20 22:12:57 +00:00
lda #ERR.DEV.NOFRAME
2017-01-12 17:43:45 +00:00
READBLOCK.Err sec
2015-03-14 21:48:35 +00:00
rts
2016-03-13 22:07:01 +00:00
2017-01-12 17:43:45 +00:00
READBLOCK.RxOK and /PP.RxEvent.Brdcast
2015-03-14 21:48:35 +00:00
beq .10
lda #$80
2017-01-26 21:57:35 +00:00
.10 sta .8+3
2016-03-13 22:07:01 +00:00
>LDYA RTDATA,x discard RxStatus
lda RTDATA+1,x get RxLength
2016-04-07 06:13:41 +00:00
sta Size+1
2016-03-13 22:07:01 +00:00
pha
lda RTDATA,x
2016-04-07 06:13:41 +00:00
sta Size
2016-03-13 22:07:01 +00:00
clc
adc #2
tay
pla
2017-01-29 21:47:19 +00:00
adc #2
2016-03-13 22:07:01 +00:00
2017-01-29 21:47:19 +00:00
>PUSHYA Size+2
2015-06-03 18:30:57 +00:00
>PUSHBI 0
>SYSCALL GetMem
2017-01-12 17:43:45 +00:00
bcs READBLOCK.Err
2015-03-14 21:48:35 +00:00
>STYA ZPTmpPTR
2017-01-26 21:57:35 +00:00
stx .8+1
2017-01-29 21:47:19 +00:00
sty .8+3
sta .8+5
2016-04-07 06:13:41 +00:00
lda Size
2016-03-13 22:07:01 +00:00
sta (ZPTmpPTR)
2016-04-07 06:13:41 +00:00
eor #$ff
sta Counter
2016-03-13 22:07:01 +00:00
ldy #1
2016-04-07 06:13:41 +00:00
lda Size+1
2016-03-13 22:07:01 +00:00
sta (ZPTmpPTR),y
2016-04-07 06:13:41 +00:00
eor #$ff
sta Counter+1
2016-03-13 22:07:01 +00:00
iny
2015-06-03 18:30:57 +00:00
2016-03-13 22:07:01 +00:00
ldx DEVSLOTx0
2016-04-07 06:13:41 +00:00
.1 inc Counter
bne .12
inc Counter+1
2016-03-13 22:07:01 +00:00
beq .8
2016-04-07 06:13:41 +00:00
.12 lda RTDATA,x
2015-03-14 21:48:35 +00:00
sta (ZPTmpPTR),y
iny
bne .2
inc ZPTmpPTR+1
2016-03-13 22:07:01 +00:00
2016-04-07 06:13:41 +00:00
.2 inc Counter
bne .21
inc Counter+1
2015-03-14 21:48:35 +00:00
beq .8
2016-04-07 06:13:41 +00:00
.21 lda RTDATA+1,x
2015-03-14 21:48:35 +00:00
sta (ZPTmpPTR),y
iny
2016-03-13 22:07:01 +00:00
bne .1
2015-03-14 21:48:35 +00:00
inc ZPTmpPTR+1
2015-06-03 18:30:57 +00:00
bne .1
2016-03-13 22:07:01 +00:00
2017-01-29 21:47:19 +00:00
.8 ldx #$ff hMem
ldy #$ff PtrLO
lda #$ff PtrHI
2017-01-26 21:57:35 +00:00
clc
2015-03-14 21:48:35 +00:00
rts
2015-06-03 18:30:57 +00:00
*--------------------------------------
2017-01-26 21:57:35 +00:00
WRITEBLOCK >STYA ZPTmpPTR
2016-03-13 22:07:01 +00:00
lda (ZPTmpPTR)
2016-04-07 06:13:41 +00:00
sta Size
eor #$ff
sta Counter
2016-03-13 22:07:01 +00:00
ldy #1
lda (ZPTmpPTR),y
2016-04-07 06:13:41 +00:00
sta Size+1
eor #$ff
sta Counter+1
2016-03-13 22:07:01 +00:00
2015-03-14 21:48:35 +00:00
ldx DEVSLOTx0
2016-03-13 22:07:01 +00:00
>LDYAI PP.TxCMD.LID+PP.TxCMD.TxStartFULL
2015-03-14 21:48:35 +00:00
>STYA TxCMD,x
2016-04-07 06:13:41 +00:00
>LDYA Size
2015-03-14 21:48:35 +00:00
>STYA TxLength,x
>LDYAI PP.BusST
>STYA PacketPagePTR,x
ldy #16
.1 lda PacketPageDATA,x
and #PP.BusST.TxBidErr
bne .9
lda PacketPageDATA+1,x
and /PP.BusST.Rdy4TxNOW
2017-01-12 17:43:45 +00:00
bne WRITEBLOCK.1
2015-03-14 21:48:35 +00:00
lda #0
2016-03-20 22:12:57 +00:00
2015-03-14 21:48:35 +00:00
.2 dec
bne .2
2016-03-20 22:12:57 +00:00
2015-03-14 21:48:35 +00:00
dey
bne .1
2016-03-20 22:12:57 +00:00
.9 lda #ERR.DEV.NOBUFFER
2015-03-14 21:48:35 +00:00
sec
rts
2017-01-12 17:43:45 +00:00
WRITEBLOCK.1 ldy #S.ETH.SRCMAC+5
2016-04-18 20:15:34 +00:00
ldx #5
.10 lda MAC,x
sta (ZPTmpPTR),y
dey
dex
bpl .10
ldx DEVSLOTx0
ldy #2
2016-03-13 22:07:01 +00:00
2016-04-07 06:13:41 +00:00
.1 inc Counter
bne .11
inc Counter+1
2016-03-13 22:07:01 +00:00
beq .8
2016-04-07 06:13:41 +00:00
.11 lda (ZPTmpPTR),y
2015-03-14 21:48:35 +00:00
sta RTDATA,x
iny
bne .2
inc ZPTmpPTR+1
2016-03-13 22:07:01 +00:00
2016-04-07 06:13:41 +00:00
.2 inc Counter
bne .21
inc Counter+1
2015-03-14 21:48:35 +00:00
beq .8
2016-04-07 06:13:41 +00:00
.21 lda (ZPTmpPTR),y
2015-03-14 21:48:35 +00:00
sta RTDATA+1,x
iny
2016-03-13 22:07:01 +00:00
bne .1
2015-03-14 21:48:35 +00:00
inc ZPTmpPTR+1
bne .1
2016-03-13 22:07:01 +00:00
2015-03-14 21:48:35 +00:00
.8 clc
rts
*--------------------------------------
2017-01-26 21:57:35 +00:00
OPEN jsr CLOSE
2017-01-12 17:43:45 +00:00
>LDYAI PP.RxCTL
>STYA PacketPagePTR,x
>LDYAI PP.RxCTL.LID+PP.RxCTL.RxOKA+PP.RxCTL.IA+PP.RxCTL.BroadcastA
>STYA PacketPageDATA,x
>LDYAI PP.MAC
>STYA PacketPagePTR,x
>LDYA MAC
>STYA PacketPageDATA,x
>LDYAI PP.MAC+2
>STYA PacketPagePTR,x
>LDYA MAC+2
>STYA PacketPageDATA,x
>LDYAI PP.MAC+4
>STYA PacketPagePTR,x
>LDYA MAC+4
>STYA PacketPageDATA,x
>LDYAI PP.LineCTL
>STYA PacketPagePTR,x
>LDYAI PP.LineCTL.LID+PP.LineCTL.SerRxOn+PP.LineCTL.SerTxOn+PP.LineCTL.10BaseT
2017-01-12 17:43:45 +00:00
>STYA PacketPageDATA,x
clc
rts
*--------------------------------------
2017-01-26 21:57:35 +00:00
CLOSE ldx DEVSLOTx0
2015-03-14 21:48:35 +00:00
>LDYAI PP.SelfCTL
>STYA PacketPagePTR,x
>LDYAI PP.SelfCTL.LID+PP.SelfCTL.RESET
>STYA PacketPageDATA,x
>LDYAI PP.SelfCTL
>STYA PacketPagePTR,x
>LDYAI PP.SelfCTL.LID
>STYA PacketPageDATA,x
2017-01-26 21:57:35 +00:00
clc
2015-03-14 21:48:35 +00:00
rts
2016-04-18 20:15:34 +00:00
*--------------------------------------
2017-01-26 21:57:35 +00:00
DRV.CS.END
2015-03-14 21:48:35 +00:00
DEVSLOTx0 .BS 1
2016-04-07 06:13:41 +00:00
Size .BS 2
Counter .BS 2
*--------------------------------------
DEVSTAT .DA #S.DEV.S.BLOCK+S.DEV.S.WRITE+S.DEV.S.READ
.BS 3 size
>PSTR "Uthernet/CS8900A"
.DA #S.DEVSTAT.TYPE.NET
.BS 1 Subtype
.BS 2 Version
*--------------------------------------
FLAGS .DA #0
2016-03-13 22:07:01 +00:00
LINK.STATUS .BS 1 OK/DUPLEX/SPEED
MAC .BS 6
2015-03-14 21:48:35 +00:00
MAN
SAVE DRV/UTHERNET.DRV.S
ASM