A2osX/DRV/LANCEGS.DRV.S.txt

454 lines
9.2 KiB
Plaintext
Raw Normal View History

2016-01-10 22:16:07 +00:00
PR#3
PREFIX /A2OSX.SRC
NEW
2016-01-10 22:16:07 +00:00
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/DRV/LANCEGS.DRV
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
2016-03-20 22:12:57 +00:00
.INB INC/LIBTCPIP.I
2016-01-10 22:16:07 +00:00
*--------------------------------------
ZPTmpPTR .EQ ZPDRV
*--------------------------------------
.INB DRV/X.NET.91C96.S
2016-01-10 22:16:07 +00:00
*--------------------------------------
* 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 >STYA Args
2016-01-10 22:16:07 +00:00
>LDYA L.MSG.DETECT
>SYSCALL SYS.PrintFYA
2016-01-10 22:16:07 +00:00
ldx #$10
.1 lda L91C96.BSR+1,x
cmp #DEVID
2016-03-30 15:54:47 +00:00
beq .3
2016-01-10 22:16:07 +00:00
2016-03-30 15:54:47 +00:00
inc DEV.HEADER.NAME+4
2016-01-10 22:16:07 +00:00
txa
clc
adc #$10
tax
2016-03-30 15:54:47 +00:00
bpl .1 not yat at $80
2016-01-10 22:16:07 +00:00
>LDYA L.MSG.DETECT.KO
>SYSCALL SYS.PrintFYA
2016-01-10 22:16:07 +00:00
lda #DEVMGR.ERRNOHW Not Found in any slot, exiting
sec
rts
.3 stx DEVSLOTx0
>LDYA ARGS
>STYA ZPTmpPTR
lda (ZPTmpPTR)
2016-01-10 22:16:07 +00:00
beq .4
2016-03-13 22:07:01 +00:00
sec
ror USERMAC
2016-01-10 22:16:07 +00:00
>SYSCALL SYS.GetMemPtrA
>STYA ZPTmpPTR
jsr DecodeMac
bcc .4
lda #DEVMGR.ERRICL
sec
rts
.4 >PUSHW L.DEV.HEADER.NAME
>LDYA L.MSG.DETECT.OK
>SYSCALL SYS.PrintFYA
2016-01-10 22:16:07 +00:00
clc
rts
*--------------------------------------
2016-03-20 22:12:57 +00:00
.INB DRV/X.NET.DRV.S
2016-01-10 22:16:07 +00:00
*--------------------------------------
CS.END
MSG.DETECT >CSTRING "LanCeGS/SMSC91C96 Driver.\n"
MSG.DETECT.OK >CSTRING "LanCeGS/SMSC91C96 Installed As Device : %S\n"
MSG.DETECT.KO >CSTRING "Hardware Not Found.\n"
Args .BS 2
2016-01-10 22:16:07 +00:00
*--------------------------------------
* Device Header (16 Bytes)
*--------------------------------------
DEV.HEADER cld
jmp (DRV.CS.START,x)
.DA #S.DEV.F.SHARE+S.DEV.F.EVENT
DEV.HEADER.NAME >PSTRING "ETH1" NAME
.HS 00.00
.HS 00.00.00.00
*--------------------------------------
* Driver Code
*--------------------------------------
DRV.CS.START .DA OPEN
.DA GETEVENT
.DA $FFFF no COUT
.DA CLOSE
.DA GETINFO
.DA $FFFF no IRQ
.DA SEND
.DA $FFFF no SETIPCFG
L.DEVINFO .DA DEVINFO
.DA 0 end or relocation
*--------------------------------------
* input :
* none
* output :
* CC on success
* CS on error
*--------------------------------------
2016-03-13 22:07:01 +00:00
OPEN jsr Reset will select L91C96.0
lda #L91C96.0.TCR.FDSE+L91C96.0.TCR.FUDPLX+L91C96.0.TCR.PADEN+L91C96.0.TCR.TXENA
sta L91C96.0.TCR,x
lda /L91C96.0.TCR.FDSE+L91C96.0.TCR.FUDPLX+L91C96.0.TCR.PADEN+L91C96.0.TCR.TXENA
sta L91C96.0.TCR+1,x
lda #L91C96.0.RCR.NOCRC+L91C96.0.RCR.RXENA+L91C96.0.RCR.ALLMUL
sta L91C96.0.RCR,x
lda /L91C96.0.RCR.NOCRC+L91C96.0.RCR.RXENA+L91C96.0.RCR.ALLMUL
sta L91C96.0.RCR+1,x
lda #1
sta L91C96.BSR,x
lda #L91C96.1.CR.NOWAIT
sta L91C96.1.CR,x
lda /L91C96.1.CR.NOWAIT
sta L91C96.1.CR+1,x
ldy #0
bit USERMAC
2016-03-31 20:07:47 +00:00
bmi .2
2016-03-13 22:07:01 +00:00
.1 lda L91C96.1.IAR,x
sta MAC,y
inx
iny
cpy #6
bne .1
bra .3
.2 lda MAC,y
sta L91C96.1.IAR,x
inx
iny
cpy #6
bne .2
.3 ldx DEVSLOTx0
2016-03-30 15:54:47 +00:00
lda #L91C96.1.CTR.DEFAULT+L91C96.1.CTR.AUTOREL
2016-03-13 22:07:01 +00:00
sta L91C96.1.CTR,x
2016-03-30 15:54:47 +00:00
lda /L91C96.1.CTR.DEFAULT+L91C96.1.CTR.AUTOREL
2016-03-13 22:07:01 +00:00
sta L91C96.1.CTR+1,x
2016-01-10 22:16:07 +00:00
clc
rts
*--------------------------------------
* input :
* pEvent
* output :
* CC no event
* CS event
*--------------------------------------
2016-03-13 22:07:01 +00:00
GETEVENT ldx DEVSLOTx0
lda #2
sta L91C96.BSR,x
lda L91C96.2.IST,x
and #L91C96.2.IST.RCV
bne GETEVENT.RxOK
2016-03-20 22:12:57 +00:00
lda #ERR.DEV.NOFRAME
2016-03-13 22:07:01 +00:00
sec
2016-01-10 22:16:07 +00:00
rts
2016-03-13 22:07:01 +00:00
GETEVENT.RxOK lda #L91C96.2.PTR.RCVD+L91C96.2.PTR.AUTOI+L91C96.2.PTR.READ
sta L91C96.2.PTR,x
lda /L91C96.2.PTR.RCVD+L91C96.2.PTR.AUTOI+L91C96.2.PTR.READ
sta L91C96.2.PTR+1,x
2016-03-30 15:54:47 +00:00
lda L91C96.2.DATA,x Get Frame Status Word (lo)
lda L91C96.2.DATA,x Get Frame Status Word (HI)
asl #$60 = Broadcast?
2016-03-13 22:07:01 +00:00
ldy #S.EVT.DATAHI
sta (pEvent),y
2016-03-30 15:54:47 +00:00
asl
asl #$10 = odd?
asl if odd, CS
lda L91C96.2.DATA,x get lo byte count
sbc #5 compute FRAMELEN
2016-03-13 22:07:01 +00:00
sta FRAMELEN
tay
2016-03-30 15:54:47 +00:00
lda L91C96.2.DATA,x get hi byte count
sbc #0
2016-03-13 22:07:01 +00:00
sta FRAMELEN+1
2016-03-30 15:54:47 +00:00
iny
bne .1
inc
.1 iny
bne .11
inc
.11 >PUSHYA FRAMLEN+2
2016-03-13 22:07:01 +00:00
>PUSHBI 0
>SYSCALL SYS.GetMem
bcs .99
>STYA ZPTmpPTR
txa
ldy #S.EVT.DATALO
sta (pEvent),y
lda #S.EVT.F.NET+S.EVT.F.hMEM1
sta (pEvent)
lda FRAMELEN
2016-03-30 15:54:47 +00:00
sta (ZPTmpPTR)
ldy #1
2016-03-13 22:07:01 +00:00
lda FRAMELEN+1
sta (ZPTmpPTR),y
2016-03-30 15:54:47 +00:00
2016-03-13 22:07:01 +00:00
iny
ldx DEVSLOTx0
.2 jsr DecFrameLen
beq .8
lda L91C96.2.DATA,x
sta (ZPTmpPTR),y
iny
bne .3
inc ZPTmpPTR+1
.3 jsr DecFrameLen
beq .8
2016-03-30 06:30:41 +00:00
lda L91C96.2.DATA,x
2016-03-13 22:07:01 +00:00
sta (ZPTmpPTR),y
iny
bne .2
inc ZPTmpPTR+1
bra .2
.8 lda #L91C96.2.MMUCR.REMREL
sta L91C96.2.MMUCR,x
clc
2016-01-10 22:16:07 +00:00
rts
2016-03-13 22:07:01 +00:00
.99 sec
rts
2016-01-10 22:16:07 +00:00
*--------------------------------------
CLOSE jsr Reset
clc
rts
*--------------------------------------
* in:
* out:
* Y,A = BUFFER PTR
* CC on success
* CS on error
*--------------------------------------
2016-03-13 22:07:01 +00:00
GETINFO lda #S.DEVINFO.NET.STATUS.10
sta LINK.STATUS
ldx DEVSLOTx0
2016-03-30 15:54:47 +00:00
stz L91C96.BSR,x
2016-03-13 22:07:01 +00:00
lda L91C96.0.EPHSR,x
lda L91C96.0.EPHSR+1,x
and /L91C96.0.EPHSR.LINK
beq .1
lda LINK.STATUS
ora #S.DEVINFO.NET.STATUS.OK
sta LINK.STATUS
.1 lda L91C96.0.TCR,x
lda L91C96.0.TCR+1,x
and /L91C96.0.TCR.FDSE
bne .2
lda LINK.STATUS
ora #S.DEVINFO.NET.STATUS.FD
sta LINK.STATUS
.2 >LDYA L.DEVINFO
2016-01-10 22:16:07 +00:00
clc
rts
*--------------------------------------
* in:
* PULLW = FRAME PTR
* PULLW = FRAME LEN
* out:
* CC on success
* CS on error
*--------------------------------------
2016-03-13 22:07:01 +00:00
SEND >PULLW ZPTmpPTR
ldx DEVSLOTx0
lda #2
sta L91C96.BSR,x
lda (ZPTmpPTR)
sta FRAMELEN
2016-01-10 22:16:07 +00:00
clc
2016-03-13 22:07:01 +00:00
adc #6 3 WORDs more Status, len & Control
2016-03-31 20:07:47 +00:00
bne .10
clc LO byte is 0, no need for an extra empty page
2016-03-31 20:07:47 +00:00
.10 ldy #1
2016-03-13 22:07:01 +00:00
lda (ZPTmpPTR),y
sta FRAMELEN+1
adc #0
.1 ora #L91C96.2.MMUCR.ALLOC
sta L91C96.2.MMUCR,x
ldy #0
.2 lda L91C96.2.IST,x
and #L91C96.2.IST.ALLOC
bne .3
dey
bne .2
2016-03-20 22:12:57 +00:00
lda #ERR.DEV.NOBUFFER
2016-03-13 22:07:01 +00:00
sec
rts
.3 lda L91C96.2.AAR,x
sta L91C96.2.PNR,x
2016-03-30 06:30:41 +00:00
lda #L91C96.2.PTR.AUTOI
2016-03-13 22:07:01 +00:00
sta L91C96.2.PTR,x
2016-03-30 06:30:41 +00:00
lda /L91C96.2.PTR.AUTOI
2016-03-13 22:07:01 +00:00
sta L91C96.2.PTR+1,x
2016-03-30 06:30:41 +00:00
ldy #S.ETH.SRCMAC+5 Add Src MAC Address
2016-03-13 22:07:01 +00:00
ldx #5
.4 lda MAC,x
sta (ZPTmpPTR),y
dey
dex
bpl .4
ldx DEVSLOTx0
2016-03-30 15:54:47 +00:00
stz L91C96.2.DATA,x write fake status word
2016-03-30 06:30:41 +00:00
stz L91C96.2.DATA,x
2016-03-13 22:07:01 +00:00
lda FRAMELEN
pha
2016-03-30 15:54:47 +00:00
eor #$01
2016-03-13 22:07:01 +00:00
lsr
pla
2016-03-30 15:54:47 +00:00
adc #$05 add 5 if odd, 6 if even
2016-03-13 22:07:01 +00:00
sta L91C96.2.DATA,x
lda FRAMELEN+1
2016-03-30 15:54:47 +00:00
adc #$00
2016-03-30 06:30:41 +00:00
sta L91C96.2.DATA,x
2016-03-13 22:07:01 +00:00
ldy #2
.5 jsr DecFrameLen
beq .70
lda (ZPTmpPTR),y
iny
bne .6
inc ZPTmpPTR+1
.6 pha
jsr DecFrameLen
beq .71
pla
sta L91C96.2.DATA,x
lda (ZPTmpPTR),y
2016-03-30 06:30:41 +00:00
sta L91C96.2.DATA,x
2016-03-13 22:07:01 +00:00
iny
bne .5
inc ZPTmpPTR+1
bra .5
.70 lda #0
sta L91C96.2.DATA,x
2016-03-30 06:30:41 +00:00
sta L91C96.2.DATA,x
2016-03-13 22:07:01 +00:00
bra .8
2016-03-30 15:54:47 +00:00
.71 pla
2016-03-13 22:07:01 +00:00
sta L91C96.2.DATA,x
2016-03-30 15:54:47 +00:00
lda #%00100000 signal an extra (odd) byte
2016-03-30 06:30:41 +00:00
sta L91C96.2.DATA,x
2016-03-13 22:07:01 +00:00
.8 lda #L91C96.2.MMUCR.NQPKT
sta L91C96.2.MMUCR,x
clc
rts
.9 sec
rts
2016-01-10 22:16:07 +00:00
*--------------------------------------
* PRIVATE
*--------------------------------------
Reset ldx DEVSLOTx0
2016-03-30 15:54:47 +00:00
stz L91C96.BSR,x
2016-03-13 22:07:01 +00:00
lda #L91C96.0.RCR.RESET
sta L91C96.0.RCR,x
lda /L91C96.0.RCR.RESET
sta L91C96.0.RCR+1,x
lda $C019 we can use VBL as we are not on //c
.1 eor $C019
bpl .1
2016-03-30 15:54:47 +00:00
lda $C019
2016-03-13 22:07:01 +00:00
.2 eor $C019
bpl .2
2016-03-30 15:54:47 +00:00
stz L91C96.0.RCR,x
stz L91C96.0.RCR+1,x
2016-01-10 22:16:07 +00:00
rts
*--------------------------------------
DecFrameLen lda FRAMELEN
bne .1
lda FRAMELEN+1
beq .8
dec FRAMELEN+1
.1 dec FRAMELEN
lda #1 Make something NZ
.8 rts
*--------------------------------------
DRV.CS.END
*--------------------------------------
DEVSLOTx0 .BS 1
2016-03-13 22:07:01 +00:00
USERMAC .BS 1
2016-01-10 22:16:07 +00:00
FRAMELEN .BS 2
*--------------------------------------
DEVINFO .DA #S.DEVINFO.TYPE.NET
DEVFLAGS .DA #0
MAC .BS 6
2016-03-13 22:07:01 +00:00
LINK.STATUS .BS 1 OK/DUPLEX/SPEED
2016-01-10 22:16:07 +00:00
*--------------------------------------
MAN
SAVE DRV/LANCEGS.DRV.S
ASM