mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-25 20:33:13 +00:00
452 lines
8.9 KiB
Plaintext
452 lines
8.9 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BUILD/DRV/LANCEGS.DRV
|
||
*--------------------------------------
|
||
.INB /A2OSX.BUILD/INC/MACROS.I
|
||
.INB /A2OSX.BUILD/INC/A2OSX.I
|
||
.INB /A2OSX.BUILD/INC/MLI.ERR.I
|
||
.INB /A2OSX.BUILD/INC/NET.I
|
||
.INB /A2OSX.BUILD/INC/NET.91C96.I
|
||
.INB /A2OSX.BUILD/INC/LIBTCPIP.I
|
||
*--------------------------------------
|
||
ZPTmpPTR .EQ ZPDRV
|
||
Size .EQ ZPDRV+2
|
||
Counter .EQ ZPDRV+4
|
||
*--------------------------------------
|
||
* 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
|
||
>LDYA L.MSG.DETECT
|
||
>SYSCALL PrintF.YA
|
||
|
||
ldx #$70
|
||
ldy #7
|
||
|
||
.1 lda A2osX.SLOTS,y IO based detection, avoid scanning in Disk Controller IO!!!!
|
||
bne .2
|
||
|
||
lda L91C96.BSR+1,x
|
||
cmp #DEVID
|
||
beq .3
|
||
|
||
.2 dec DEV.HEADER.NAME+4
|
||
txa
|
||
sec
|
||
sbc #$10
|
||
tax
|
||
dey
|
||
bne .1
|
||
|
||
>LDYA L.MSG.DETECT.KO
|
||
>SYSCALL PrintF.YA
|
||
|
||
lda #MLI.ERR.NODEV
|
||
sec
|
||
rts
|
||
|
||
.3 stx DEVSLOTx0
|
||
lda #A2osX.SLOTS.NET
|
||
sta A2osX.SLOTS,y
|
||
|
||
>LDYA ARGS
|
||
>STYA ZPTmpPTR
|
||
lda (ZPTmpPTR)
|
||
beq .4
|
||
|
||
sec
|
||
ror USERMAC
|
||
>SYSCALL GetMemPtr.A
|
||
>STYA ZPTmpPTR
|
||
jsr DecodeMac
|
||
bcc .4
|
||
lda #SYSMGR.ERRSYN
|
||
sec
|
||
rts
|
||
|
||
.4 >PUSHW L.DEV.HEADER.NAME
|
||
>LDYA L.MSG.DETECT.OK
|
||
>SYSCALL PrintF.YA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
.INB /A2OSX.SRC/DRV/X.NET.DRV.S
|
||
*--------------------------------------
|
||
CS.END
|
||
MSG.DETECT >CSTR "LanCeGS/SMSC91C96 Driver.\r\n"
|
||
MSG.DETECT.OK >CSTR "LanCeGS/SMSC91C96 Installed As Device : %S\r\n"
|
||
MSG.DETECT.KO >CSTR "Hardware Not Found.\r\n"
|
||
Args .BS 2
|
||
*--------------------------------------
|
||
* Device Header (16 Bytes)
|
||
*--------------------------------------
|
||
DEV.HEADER cld
|
||
jmp (DRV.CS.START,x)
|
||
.DA #0
|
||
.BS 6
|
||
DEV.HEADER.NAME >PSTR "ETH7"
|
||
*--------------------------------------
|
||
* Driver Code
|
||
*--------------------------------------
|
||
DRV.CS.START .DA STATUS
|
||
.DA READBLOCK
|
||
.DA WRITEBLOCK
|
||
.DA A2osX.BADCALL
|
||
.DA A2osX.BADCALL
|
||
.DA A2osX.BADCALL
|
||
.DA OPEN
|
||
.DA CLOSE
|
||
.DA A2osX.BADCALL
|
||
.DA A2osX.BADCALL
|
||
L.DEVSTAT .DA DEVSTAT
|
||
.DA 0 end or relocation
|
||
*--------------------------------------
|
||
STATUS lda #S.DEVSTAT.NET.STATUS.10
|
||
sta LINK.STATUS
|
||
|
||
ldx DEVSLOTx0
|
||
|
||
stz L91C96.BSR,x
|
||
lda L91C96.0.EPHSR,x
|
||
lda L91C96.0.EPHSR+1,x
|
||
and /L91C96.0.EPHSR.LINK
|
||
beq .1
|
||
lda LINK.STATUS
|
||
ora #S.DEVSTAT.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.DEVSTAT.NET.STATUS.FD
|
||
sta LINK.STATUS
|
||
|
||
.2 >LDYA L.DEVSTAT
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
READBLOCK ldx DEVSLOTx0
|
||
lda #2
|
||
sta L91C96.BSR,x
|
||
|
||
lda L91C96.2.IST,x
|
||
and #L91C96.2.IST.RCV
|
||
bne READBLOCK.RxOK
|
||
lda #ERR.DEV.NOFRAME
|
||
sec
|
||
rts
|
||
|
||
READBLOCK.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
|
||
|
||
lda L91C96.2.DATA,x Get Frame Status Word (lo)
|
||
lda L91C96.2.DATA,x Get Frame Status Word (HI)
|
||
|
||
asl
|
||
asl
|
||
asl #$10 = odd?
|
||
asl if odd, CS
|
||
|
||
lda L91C96.2.DATA,x get lo byte count
|
||
sbc #5 compute Size
|
||
sta Size
|
||
eor #$ff
|
||
sta Counter
|
||
tay
|
||
|
||
lda L91C96.2.DATA,x get hi byte count
|
||
sbc #0
|
||
sta Size+1
|
||
eor #$ff
|
||
sta Counter+1
|
||
eor #$ff
|
||
|
||
iny
|
||
bne .1
|
||
|
||
inc
|
||
.1 iny
|
||
bne .11
|
||
|
||
inc
|
||
.11 >SYSCALL GetMem.YA
|
||
bcs .99
|
||
>STYA ZPTmpPTR
|
||
stx .8+1
|
||
sty .8+3
|
||
sta .8+5
|
||
|
||
lda Size
|
||
sta (ZPTmpPTR)
|
||
ldy #1
|
||
lda Size+1
|
||
sta (ZPTmpPTR),y
|
||
|
||
iny
|
||
|
||
ldx DEVSLOTx0
|
||
|
||
.2 inc Counter
|
||
bne .21
|
||
inc Counter+1
|
||
beq .4
|
||
|
||
.21 lda L91C96.2.DATA,x
|
||
sta (ZPTmpPTR),y
|
||
iny
|
||
bne .3
|
||
inc ZPTmpPTR+1
|
||
|
||
.3 inc Counter
|
||
bne .31
|
||
inc Counter+1
|
||
beq .4
|
||
|
||
.31 lda L91C96.2.DATA,x
|
||
sta (ZPTmpPTR),y
|
||
iny
|
||
bne .2
|
||
inc ZPTmpPTR+1
|
||
bra .2
|
||
|
||
.4 lda #L91C96.2.MMUCR.REMREL
|
||
sta L91C96.2.MMUCR,x
|
||
|
||
.8 ldx #$ff hMem
|
||
ldy #$ff PtrLO
|
||
lda #$ff PtrHI
|
||
clc
|
||
.99 rts
|
||
*--------------------------------------
|
||
WRITEBLOCK >STYA ZPTmpPTR
|
||
|
||
ldx DEVSLOTx0
|
||
lda #2
|
||
sta L91C96.BSR,x
|
||
|
||
lda (ZPTmpPTR)
|
||
sta Size
|
||
eor #$ff
|
||
sta Counter
|
||
eor #$ff
|
||
|
||
clc
|
||
adc #6 3 WORDs more Status, len & Control
|
||
|
||
bne .10
|
||
clc LO byte is 0, no need for an extra empty page
|
||
|
||
.10 ldy #1
|
||
lda (ZPTmpPTR),y
|
||
sta Size+1
|
||
eor #$ff
|
||
sta Counter+1
|
||
eor #$ff
|
||
|
||
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
|
||
|
||
lda #ERR.DEV.NOBUFFER
|
||
sec
|
||
rts
|
||
|
||
.3 lda L91C96.2.AAR,x
|
||
sta L91C96.2.PNR,x
|
||
|
||
lda #L91C96.2.PTR.AUTOI
|
||
sta L91C96.2.PTR,x
|
||
lda /L91C96.2.PTR.AUTOI
|
||
sta L91C96.2.PTR+1,x
|
||
|
||
ldy #S.ETH.SRCMAC+5 Add Src MAC Address
|
||
ldx #5
|
||
.4 lda MAC,x
|
||
sta (ZPTmpPTR),y
|
||
dey
|
||
dex
|
||
bpl .4
|
||
|
||
ldx DEVSLOTx0
|
||
stz L91C96.2.DATA,x write fake status word
|
||
stz L91C96.2.DATA,x
|
||
|
||
lda Size
|
||
pha
|
||
eor #$01
|
||
lsr
|
||
pla
|
||
adc #$05 add 5 if odd, 6 if even
|
||
sta L91C96.2.DATA,x
|
||
lda Size+1
|
||
adc #$00
|
||
sta L91C96.2.DATA,x
|
||
|
||
ldy #2
|
||
|
||
.5 inc Counter
|
||
bne .51
|
||
inc Counter+1
|
||
beq .70
|
||
|
||
.51 lda (ZPTmpPTR),y
|
||
iny
|
||
bne .6
|
||
inc ZPTmpPTR+1
|
||
|
||
.6 inc Counter
|
||
bne .61
|
||
inc Counter+1
|
||
beq .71
|
||
|
||
.61 sta L91C96.2.DATA,x
|
||
lda (ZPTmpPTR),y
|
||
sta L91C96.2.DATA,x
|
||
iny
|
||
bne .5
|
||
inc ZPTmpPTR+1
|
||
bra .5
|
||
|
||
.70 lda #0
|
||
sta L91C96.2.DATA,x
|
||
sta L91C96.2.DATA,x
|
||
bra .8
|
||
|
||
.71 sta L91C96.2.DATA,x
|
||
lda #%00100000 signal an extra (odd) byte
|
||
sta L91C96.2.DATA,x
|
||
|
||
.8 lda #L91C96.2.MMUCR.NQPKT
|
||
sta L91C96.2.MMUCR,x
|
||
clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
OPEN jsr CLOSE
|
||
|
||
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
|
||
bmi .2
|
||
|
||
.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
|
||
lda #L91C96.1.CTR.DEFAULT+L91C96.1.CTR.AUTOREL
|
||
sta L91C96.1.CTR,x
|
||
lda /L91C96.1.CTR.DEFAULT+L91C96.1.CTR.AUTOREL
|
||
sta L91C96.1.CTR+1,x
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CLOSE ldx DEVSLOTx0
|
||
stz L91C96.BSR,x
|
||
|
||
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
|
||
|
||
lda $C019
|
||
.2 eor $C019
|
||
bpl .2
|
||
|
||
stz L91C96.0.RCR,x
|
||
stz L91C96.0.RCR+1,x
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
DRV.CS.END
|
||
DEVSLOTx0 .BS 1
|
||
USERMAC .BS 1
|
||
*--------------------------------------
|
||
DEVSTAT .DA #0
|
||
.BS 3 size
|
||
>PSTR "LanCEGS/L91C96"
|
||
.BS 1
|
||
.DA #S.DEVSTAT.T.NET
|
||
.BS 1 Subtype
|
||
.BS 2 Version
|
||
*--------------------------------------
|
||
FLAGS .DA #0
|
||
LINK.STATUS .BS 1 OK/DUPLEX/SPEED
|
||
MAC .BS 6
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/DRV/LANCEGS.DRV.S
|
||
ASM
|