UTHERNET2:Work in progress

This commit is contained in:
Rémy GIBERT 2016-01-06 18:02:39 +01:00
parent 9a5469388a
commit 6666db9b91

View File

@ -13,17 +13,22 @@ AUTO 6
*-------------------------------------- *--------------------------------------
ZPTmpPTR .EQ ZPDRV ZPTmpPTR .EQ ZPDRV
*-------------------------------------- *--------------------------------------
DEVID .EQ $630E .MA AR.SELECT
lda /W5100.AR.]1
sta W5100.AR-$81,x
lda #W5100.AR.]1
sta W5100.AR-$80,x
.EM
*-------------------------------------- *--------------------------------------
* WIZnet W5100 IO Registers * WIZnet W5100 IO Registers
*-------------------------------------- *--------------------------------------
W5100.MR .EQ $C084 Mode Register W5100.MR .EQ $C080 Mode Register
W5100.MR.RST .EQ %10000000 W5100.MR.RST .EQ %10000000
W5100.MR.PB .EQ %00010000 W5100.MR.PB .EQ %00010000
W5100.MR.PPPOE .EQ %00001000 W5100.MR.PPPOE .EQ %00001000
W5100.MR.AI .EQ %00000010 W5100.MR.AI .EQ %00000010
W5100.MR.IND .EQ %00000001 W5100.MR.IND .EQ %00000001
W5100.AR .EQ $C085 Memory Pointer W5100.AR .EQ $C081 Memory Pointer
W5100.AR.GAR .EQ $0001 W5100.AR.GAR .EQ $0001
W5100.AR.SUBR .EQ $0005 W5100.AR.SUBR .EQ $0005
W5100.AR.SHAR .EQ $0009 W5100.AR.SHAR .EQ $0009
@ -55,7 +60,7 @@ W5100.AR.S0.TX.RD .EQ $0422
W5100.AR.S0.TX.WR .EQ $0424 W5100.AR.S0.TX.WR .EQ $0424
W5100.AR.S0.RX.RSR .EQ $0426 W5100.AR.S0.RX.RSR .EQ $0426
W5100.AR.S0.RX.RD .EQ $0428 W5100.AR.S0.RX.RD .EQ $0428
W5100.DR .EQ $C087 W5100.DR .EQ $C083
*-------------------------------------- *--------------------------------------
ERRTNOFRAME .EQ 0 ERRTNOFRAME .EQ 0
ERRNOBUFFER .EQ 1 ERRNOBUFFER .EQ 1
@ -85,22 +90,24 @@ Dev.Detect sta hArgs
>LDYA L.MSG.DETECT >LDYA L.MSG.DETECT
>SYSCALL SYS.PSTROutYA >SYSCALL SYS.PSTROutYA
ldx #$10 ldx #$10+$81
.1 stx DEVSLOTx0 .1 stx DEVSLOTxF
>LDYAI PP.ID lda #W5100.MR.RST
>STYA PacketPagePTR,x sta W5100.MR-$81,x
>LDYA PacketPageDATA,x
cpy #DEVID lda #W5100.MR.AI+W5100.MR.IND
bne .2 sta W5100.MR-$81,x
cmp /DEVID
lda W5100.MR-$81,x
cmp #W5100.MR.AI+W5100.MR.IND
beq .3 beq .3
.2 inc DEV.HEADER.NAME+4 inc DEV.HEADER.NAME+4
txa txa
clc clc
adc #$10 adc #$10
tax tax
cpx #$80 cpx #$80+$81
bne .1 bne .1
lda #DEVMGR.ERRNOHW lda #DEVMGR.ERRNOHW
@ -184,8 +191,9 @@ hArgs .BS 1
DEV.HEADER cld DEV.HEADER cld
jmp (DRV.CS.START,x) jmp (DRV.CS.START,x)
.DA #S.DEV.F.SHARE+S.DEV.F.EVENT .DA #S.DEV.F.SHARE+S.DEV.F.EVENT
DEV.HEADER.NAME >PSTRING "ETH1" NAME DEV.HEADER.NAME >PSTRING "ETH1" NAME
.HS 00.00 .DA #DEVMGR.NET.CAP.ARPOFFLOAD
.HS 00
.HS 00.00.00.00 .HS 00.00.00.00
*-------------------------------------- *--------------------------------------
* Driver Code * Driver Code
@ -207,29 +215,25 @@ L.DEVINFO .DA DEVINFO
* CS on error * CS on error
*-------------------------------------- *--------------------------------------
OPEN jsr Reset OPEN jsr Reset
>LDYAI PP.RxCTL >AR.SELECT SHAR
>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 ldy #0
>STYA PacketPagePTR,x .1 lda MAC,y
>LDYAI PP.LineCTL.LID+PP.LineCTL.SerRxOn+PP.LineCTL.SerTxOn+PP.LineCTL.Auto sta W5100.DR-$81,x
>STYA PacketPageDATA,x iny
cpy #6
bne .1
>AR.SELECT RMSR
lda #3 8k
sta W5100.DR-$81,x ...for Socket0 RX Buffer
sta W5100.DR-$81,x ...for Socket0 TX Buffer
>AR.SELECT S0.MR
lda #3 IPRAW
sta W5100.DR-$81,x for S0.MR
lda #1
sta W5100.DR-$81,x for S0.CR
clc clc
rts rts
*-------------------------------------- *--------------------------------------
@ -239,23 +243,15 @@ OPEN jsr Reset
* CC no event * CC no event
* CS event * CS event
*-------------------------------------- *--------------------------------------
GETEVENT ldx DEVSLOTx0 GETEVENT ldx DEVSLOTxF
>LDYAI PP.RxEvent
>STYA PacketPagePTR,x
>LDYA PacketPageDATA,x
and /PP.RxEvent.RxOK+PP.RxEvent.Brdcast+PP.RxEvent.IA
bne GETEVENT.RxOK bne GETEVENT.RxOK
lda #ERRTNOFRAME lda #ERRTNOFRAME
sec sec
rts rts
GETEVENT.RxOK GETEVENT.RxOK
and /PP.RxEvent.Brdcast
beq .10
lda #$80
.10 ldy #S.EVT.DATAHI
sta (pEvent),y
>LDYA RTDATA,x discard RxStatus
>LDYA RTDATA,x get RxLength
>STYA FRAMELEN >STYA FRAMELEN
>PUSHYA >PUSHYA
>PUSHBI 0 >PUSHBI 0
@ -274,22 +270,8 @@ GETEVENT.RxOK
lda #S.EVT.F.NET+S.EVT.F.hMEM1 lda #S.EVT.F.NET+S.EVT.F.hMEM1
sta (pEvent) sta (pEvent)
ldy #0 ldy #0
ldx DEVSLOTx0 ldx DEVSLOTxF
.1 lda RTDATA,x
sta (ZPTmpPTR),y
iny
bne .2
inc ZPTmpPTR+1
.2 jsr DecFrameLen
beq .8
lda RTDATA+1,x
sta (ZPTmpPTR),y
iny
bne .3
inc ZPTmpPTR+1
.3 jsr DecFrameLen
bne .1
.8 clc .8 clc
rts rts
@ -320,35 +302,7 @@ GETINFO >LDYA L.DEVINFO
SEND >PULLW ZPTmpPTR SEND >PULLW ZPTmpPTR
>PULLW FRAMELEN >PULLW FRAMELEN
ldy #11 Add Src MAC Address ldx DEVSLOTxF
ldx #5
.10 lda MAC,x
sta (ZPTmpPTR),y
dey
dex
bpl .10
ldx DEVSLOTx0
>LDYAI TxCMD.LID+TxCMD.TxStartFULL
>STYA TxCMD,x
>LDYA FRAMELEN
>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
bne SENDPREADY
bra *
lda #0
.2 dec
bne .2
dey
bne .1
bra * bra *
lda #ERRTIMEOUT lda #ERRTIMEOUT
sec sec
@ -360,14 +314,15 @@ SEND >PULLW ZPTmpPTR
SENDPREADY ldy #0 SENDPREADY ldy #0
.1 lda (ZPTmpPTR),y .1 lda (ZPTmpPTR),y
sta RTDATA,x
iny iny
bne .2 bne .2
inc ZPTmpPTR+1 inc ZPTmpPTR+1
.2 jsr DecFrameLen .2 jsr DecFrameLen
beq .8 beq .8
.3 lda (ZPTmpPTR),y .3 lda (ZPTmpPTR),y
sta RTDATA+1,x
iny iny
bne .5 bne .5
inc ZPTmpPTR+1 inc ZPTmpPTR+1
@ -378,11 +333,9 @@ SENDPREADY ldy #0
*-------------------------------------- *--------------------------------------
* PRIVATE * PRIVATE
*-------------------------------------- *--------------------------------------
Reset ldx DEVSLOTx0 Reset ldx DEVSLOTxF
>LDYAI PP.SelfCTL lda #W5100.MR.RST
>STYA PacketPagePTR,x sta W5100.MR-$81,x
>LDYAI PP.SelfCTL.LID+PP.SelfCTL.RESET
>STYA PacketPageDATA,x
rts rts
*-------------------------------------- *--------------------------------------
DecFrameLen lda FRAMELEN DecFrameLen lda FRAMELEN
@ -396,7 +349,7 @@ DecFrameLen lda FRAMELEN
*-------------------------------------- *--------------------------------------
DRV.CS.END DRV.CS.END
*-------------------------------------- *--------------------------------------
DEVSLOTx0 .BS 1 DEVSLOTxF .BS 1
FRAMELEN .BS 2 FRAMELEN .BS 2
*-------------------------------------- *--------------------------------------
DEVINFO .DA #S.DEVINFO.TYPE.NET DEVINFO .DA #S.DEVINFO.TYPE.NET