mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 22:54:59 +00:00
282 lines
5.7 KiB
Plaintext
282 lines
5.7 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BOOT/DRV/LANCEGS.DRV
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
*--------------------------------------
|
||
ZPTmpPTR .EQ ZPDRV
|
||
*--------------------------------------
|
||
DEVID .EQ $33
|
||
*--------------------------------------
|
||
* SMSC L91C96 IO Registers
|
||
*--------------------------------------
|
||
L91C96.0.TCR .EQ $C080
|
||
L91C96.0.EPHSR .EQ $C082
|
||
L91C96.0.RCR .EQ $C084
|
||
L91C96.0.ECR .EQ $C086
|
||
L91C96.0.MIR .EQ $C088
|
||
L91C96.0.MCR .EQ $C08A
|
||
L91C96.1.CR .EQ $C080
|
||
L91C96.1.BAR .EQ $C082
|
||
L91C96.1.IAR .EQ $C084
|
||
L91C96.1.GPR .EQ $C08A
|
||
L91C96.1.CTR .EQ $C08C
|
||
L91C96.2.MMUCR .EQ $C080
|
||
L91C96.2.PNR .EQ $C082
|
||
L91C96.2.AAR .EQ $C083
|
||
L91C96.2.FIFO .EQ $C084
|
||
L91C96.2.PTR .EQ $C086
|
||
L91C96.2.DATA .EQ $C088
|
||
L91C96.2.IST .EQ $C08C
|
||
L91C96.2.ACK .EQ $C08C
|
||
L91C96.2.MSK .EQ $C08D
|
||
L91C96.3.MT .EQ $C080
|
||
L91C96.3.MGMT .EQ $C088
|
||
L91C96.3.REV .EQ $C08A
|
||
L91C96.3.RCV .EQ $C08C
|
||
|
||
|
||
|
||
L91C96.BSR .EQ $C08E
|
||
|
||
*--------------------------------------
|
||
ERRTNOFRAME .EQ 0
|
||
ERRNOBUFFER .EQ 1
|
||
ERRTIMEOUT .EQ 2
|
||
*--------------------------------------
|
||
* 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 SYS.PSTROutYA
|
||
|
||
ldx #$10
|
||
.1 lda L91C96.BSR+1,x
|
||
cmp #DEVID
|
||
bne .2
|
||
lda #3
|
||
sta L91C96.BSR,x
|
||
lda L91C96.3.REV,x
|
||
cmp #DEVID
|
||
beq .3
|
||
|
||
.2 inc DEV.HEADER.NAME+4
|
||
txa
|
||
clc
|
||
adc #$10
|
||
tax
|
||
cpx #$80
|
||
bne .1
|
||
|
||
>LDYA L.MSG.DETECT.KO
|
||
>SYSCALL SYS.PSTROutYA
|
||
|
||
lda #DEVMGR.ERRNOHW Not Found in any slot, exiting
|
||
sec
|
||
rts
|
||
|
||
.3 stx DEVSLOTx0
|
||
|
||
lda hARGS
|
||
|
||
beq .4
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>STYA ZPTmpPTR
|
||
jsr DecodeMac
|
||
bcc .4
|
||
lda #DEVMGR.ERRICL
|
||
sec
|
||
rts
|
||
|
||
.4 >LDYA L.MSG.DETECT.OK
|
||
>SYSCALL SYS.PSTROutYA
|
||
>LDYA L.DEV.HEADER.NAME
|
||
>SYSCALL SYS.PSTROutYA
|
||
lda #13
|
||
>SYSCALL SYS.COutA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
DecodeMac lda (ZPTmpPTR)
|
||
cmp #12
|
||
bne .9
|
||
|
||
ldy #1
|
||
ldx #0
|
||
|
||
.1 lda (ZPTmpPTR),y
|
||
jsr Asc2NibbleA
|
||
bcs .9
|
||
|
||
asl
|
||
asl
|
||
asl
|
||
asl
|
||
sta MAC,x
|
||
|
||
iny
|
||
lda (ZPTmpPTR),y
|
||
jsr Asc2NibbleA
|
||
bcs .9
|
||
|
||
ora MAC,x
|
||
sta MAC,x
|
||
inx
|
||
iny
|
||
cpy #13
|
||
bne .1
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
Asc2NibbleA cmp #$30
|
||
bcc .9
|
||
cmp #$3A
|
||
bcs .1
|
||
and #$0F
|
||
clc
|
||
rts
|
||
.1 cmp #$41
|
||
bcc .9
|
||
cmp #$47
|
||
bcs .9
|
||
sbc #$36
|
||
clc
|
||
rts
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
MSG.DETECT >PSTRING "LanCeGS/L91c96 Driver.\n"
|
||
MSG.DETECT.OK >PSTRING "LanCeGS/L91c96 Installed As Device : "
|
||
MSG.DETECT.KO >PSTRING "Hardware Not Found.\n"
|
||
hArgs .BS 1
|
||
*--------------------------------------
|
||
* 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
|
||
*--------------------------------------
|
||
OPEN
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* input :
|
||
* pEvent
|
||
* output :
|
||
* CC no event
|
||
* CS event
|
||
*--------------------------------------
|
||
GETEVENT
|
||
.8 clc
|
||
rts
|
||
|
||
.99 sec
|
||
rts
|
||
*--------------------------------------
|
||
CLOSE jsr Reset
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* in:
|
||
* out:
|
||
* Y,A = BUFFER PTR
|
||
* CC on success
|
||
* CS on error
|
||
*--------------------------------------
|
||
GETINFO >LDYA L.DEVINFO
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* in:
|
||
* PULLW = FRAME PTR
|
||
* PULLW = FRAME LEN
|
||
* out:
|
||
* CC on success
|
||
* CS on error
|
||
*--------------------------------------
|
||
SEND
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
* PRIVATE
|
||
*--------------------------------------
|
||
Reset ldx DEVSLOTx0
|
||
|
||
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
|
||
FRAMELEN .BS 2
|
||
*--------------------------------------
|
||
DEVINFO .DA #S.DEVINFO.TYPE.NET
|
||
DEVFLAGS .DA #0
|
||
MAC .BS 6
|
||
LINK.STATUS .BS 1
|
||
LINK.SPEED .BS 1 SPEED/DUPLEX
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE DRV/LANCEGS.DRV.S
|
||
ASM
|