From 6666db9b915f32620d14007f69497c0e1b7b21c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20GIBERT?= Date: Wed, 6 Jan 2016 18:02:39 +0100 Subject: [PATCH] UTHERNET2:Work in progress --- DRV/UTHERNET2.DRV.S.txt | 155 ++++++++++++++-------------------------- 1 file changed, 54 insertions(+), 101 deletions(-) diff --git a/DRV/UTHERNET2.DRV.S.txt b/DRV/UTHERNET2.DRV.S.txt index 434f8284..f29a4dbe 100644 --- a/DRV/UTHERNET2.DRV.S.txt +++ b/DRV/UTHERNET2.DRV.S.txt @@ -13,17 +13,22 @@ AUTO 6 *-------------------------------------- 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 *-------------------------------------- -W5100.MR .EQ $C084 Mode Register +W5100.MR .EQ $C080 Mode Register W5100.MR.RST .EQ %10000000 W5100.MR.PB .EQ %00010000 W5100.MR.PPPOE .EQ %00001000 W5100.MR.AI .EQ %00000010 W5100.MR.IND .EQ %00000001 -W5100.AR .EQ $C085 Memory Pointer +W5100.AR .EQ $C081 Memory Pointer W5100.AR.GAR .EQ $0001 W5100.AR.SUBR .EQ $0005 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.RX.RSR .EQ $0426 W5100.AR.S0.RX.RD .EQ $0428 -W5100.DR .EQ $C087 +W5100.DR .EQ $C083 *-------------------------------------- ERRTNOFRAME .EQ 0 ERRNOBUFFER .EQ 1 @@ -85,22 +90,24 @@ Dev.Detect sta hArgs >LDYA L.MSG.DETECT >SYSCALL SYS.PSTROutYA - ldx #$10 -.1 stx DEVSLOTx0 - >LDYAI PP.ID - >STYA PacketPagePTR,x - >LDYA PacketPageDATA,x - cpy #DEVID - bne .2 - cmp /DEVID + ldx #$10+$81 +.1 stx DEVSLOTxF + lda #W5100.MR.RST + sta W5100.MR-$81,x + + lda #W5100.MR.AI+W5100.MR.IND + sta W5100.MR-$81,x + + lda W5100.MR-$81,x + cmp #W5100.MR.AI+W5100.MR.IND beq .3 -.2 inc DEV.HEADER.NAME+4 + inc DEV.HEADER.NAME+4 txa clc adc #$10 tax - cpx #$80 + cpx #$80+$81 bne .1 lda #DEVMGR.ERRNOHW @@ -184,8 +191,9 @@ hArgs .BS 1 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 +DEV.HEADER.NAME >PSTRING "ETH1" NAME + .DA #DEVMGR.NET.CAP.ARPOFFLOAD + .HS 00 .HS 00.00.00.00 *-------------------------------------- * Driver Code @@ -207,29 +215,25 @@ L.DEVINFO .DA DEVINFO * CS on error *-------------------------------------- OPEN jsr Reset - >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 + >AR.SELECT SHAR - >LDYAI PP.LineCTL - >STYA PacketPagePTR,x - >LDYAI PP.LineCTL.LID+PP.LineCTL.SerRxOn+PP.LineCTL.SerTxOn+PP.LineCTL.Auto - >STYA PacketPageDATA,x + ldy #0 +.1 lda MAC,y + sta W5100.DR-$81,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 rts *-------------------------------------- @@ -239,23 +243,15 @@ OPEN jsr Reset * CC no event * CS event *-------------------------------------- -GETEVENT ldx DEVSLOTx0 - >LDYAI PP.RxEvent - >STYA PacketPagePTR,x - >LDYA PacketPageDATA,x - and /PP.RxEvent.RxOK+PP.RxEvent.Brdcast+PP.RxEvent.IA +GETEVENT ldx DEVSLOTxF + + + bne GETEVENT.RxOK lda #ERRTNOFRAME sec rts 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 >PUSHYA >PUSHBI 0 @@ -274,22 +270,8 @@ GETEVENT.RxOK lda #S.EVT.F.NET+S.EVT.F.hMEM1 sta (pEvent) 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 rts @@ -320,35 +302,7 @@ GETINFO >LDYA L.DEVINFO SEND >PULLW ZPTmpPTR >PULLW FRAMELEN - ldy #11 Add Src MAC Address - 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 + ldx DEVSLOTxF bra * lda #ERRTIMEOUT sec @@ -360,14 +314,15 @@ SEND >PULLW ZPTmpPTR SENDPREADY ldy #0 .1 lda (ZPTmpPTR),y - sta RTDATA,x + iny bne .2 inc ZPTmpPTR+1 .2 jsr DecFrameLen beq .8 .3 lda (ZPTmpPTR),y - sta RTDATA+1,x + + iny bne .5 inc ZPTmpPTR+1 @@ -378,11 +333,9 @@ SENDPREADY ldy #0 *-------------------------------------- * PRIVATE *-------------------------------------- -Reset ldx DEVSLOTx0 - >LDYAI PP.SelfCTL - >STYA PacketPagePTR,x - >LDYAI PP.SelfCTL.LID+PP.SelfCTL.RESET - >STYA PacketPageDATA,x +Reset ldx DEVSLOTxF + lda #W5100.MR.RST + sta W5100.MR-$81,x rts *-------------------------------------- DecFrameLen lda FRAMELEN @@ -396,7 +349,7 @@ DecFrameLen lda FRAMELEN *-------------------------------------- DRV.CS.END *-------------------------------------- -DEVSLOTx0 .BS 1 +DEVSLOTxF .BS 1 FRAMELEN .BS 2 *-------------------------------------- DEVINFO .DA #S.DEVINFO.TYPE.NET