Net DRV:moving to new GETINFO format

This commit is contained in:
Rémy GIBERT 2016-03-13 23:07:01 +01:00
parent e4a1825536
commit a0a69fc51d
3 changed files with 551 additions and 185 deletions

View File

@ -14,38 +14,63 @@ AUTO 6
ZPTmpPTR .EQ ZPDRV
*--------------------------------------
DEVID .EQ $33
REVID .EQ $46 CHIP=4,REV=6
*--------------------------------------
* SMSC L91C96 IO Registers
*--------------------------------------
L91C96.0.TCR .EQ $C080
L91C96.0.TCR.FDSE .EQ %10000000.00000000
L91C96.0.TCR.FUDPLX .EQ %00001000.00000000
L91C96.0.TCR.PADEN .EQ %00000000.10000000
L91C96.0.TCR.TXENA .EQ %00000000.00000001
L91C96.0.EPHSR .EQ $C082
L91C96.0.EPHSR.LINK .EQ %01000000.00000000
L91C96.0.RCR .EQ $C084
L91C96.0.RCR.RESET .EQ %10000000.00000000
L91C96.0.RCR.NOCRC .EQ %00000010.00000000
L91C96.0.RCR.RXENA .EQ %00000001.00000000
L91C96.0.RCR.ALLMUL .EQ %00000000.00000100
L91C96.0.RCR.PRMS .EQ %00000000.00000010
L91C96.0.RCR.RXABRT .EQ %00000000.00000001
L91C96.0.ECR .EQ $C086
L91C96.0.MIR .EQ $C088
L91C96.0.MCR .EQ $C08A
L91C96.1.CR .EQ $C080
L91C96.1.CR.NOWAIT .EQ %00010000.00000000
L91C96.1.BAR .EQ $C082
L91C96.1.IAR .EQ $C084
L91C96.1.GPR .EQ $C08A
L91C96.1.CTR .EQ $C08C
L91C96.1.CTR.AUTOREL .EQ %00000000.00001000
L91C96.2.MMUCR .EQ $C080
L91C96.2.MMUCR.ALLOC .EQ %00100000
L91C96.2.MMUCR.RESET .EQ %01000000
L91C96.2.MMUCR.REMREL .EQ %10000000
L91C96.2.MMUCR.NQPKT .EQ %11000000
L91C96.2.PNR .EQ $C082
L91C96.2.AAR .EQ $C083
L91C96.2.FIFO .EQ $C084
L91C96.2.PTR .EQ $C086
L91C96.2.PTR.RCVD .EQ %10000000.00000000
L91C96.2.PTR.AUTOI .EQ %01000000.00000000
L91C96.2.PTR.READ .EQ %00100000.00000000
L91C96.2.DATA .EQ $C088
L91C96.2.IST .EQ $C08C
L91C96.2.IST.ALLOC .EQ %00001000
L91C96.2.IST.RCV .EQ %00000001
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
@ -79,11 +104,12 @@ Dev.Detect sta hArgs
.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
cmp #REVID
bra .3
.2 inc DEV.HEADER.NAME+4
txa
@ -103,8 +129,9 @@ Dev.Detect sta hArgs
.3 stx DEVSLOTx0
lda hARGS
beq .4
sec
ror USERMAC
>SYSCALL SYS.GetMemPtrA
>STYA ZPTmpPTR
jsr DecodeMac
@ -175,8 +202,8 @@ Asc2NibbleA cmp #$30
rts
*--------------------------------------
CS.END
MSG.DETECT >PSTRING "LanCeGS/L91c96 Driver.\n"
MSG.DETECT.OK >PSTRING "LanCeGS/L91c96 Installed As Device : "
MSG.DETECT >PSTRING "LanCeGS/SMSC91C96 Driver.\n"
MSG.DETECT.OK >PSTRING "LanCeGS/SMSC91C96 Installed As Device : "
MSG.DETECT.KO >PSTRING "Hardware Not Found.\n"
hArgs .BS 1
*--------------------------------------
@ -208,7 +235,51 @@ L.DEVINFO .DA DEVINFO
* CC on success
* CS on error
*--------------------------------------
OPEN
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
bpl .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.AUTOREL
sta L91C96.1.CTR,x
lda /L91C96.1.CTR.AUTOREL
sta L91C96.1.CTR+1,x
clc
rts
*--------------------------------------
@ -218,14 +289,96 @@ OPEN
* CC no event
* CS event
*--------------------------------------
GETEVENT
.8 clc
GETEVENT ldx DEVSLOTx0
lda #2
sta L91C96.BSR,x
lda L91C96.2.IST,x
and #L91C96.2.IST.RCV
bne GETEVENT.RxOK
lda #ERRTNOFRAME
sec
rts
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
lda L91C96.2.DATA,x
lda L91C96.2.DATA+1,x
pha
and #$60 Broadcast?
asl
ldy #S.EVT.DATAHI
sta (pEvent),y
clc
pla #$10 = odd?
and #$10
beq .1
sec
.1 lda L91C96.2.DATA,x get lo byte count
sbc #3 compute FRAMELEN+2
sta FRAMELEN
tay
lda L91C96.2.DATA+1,x
sta FRAMELEN+1
>PUSHYA FRAMLEN+2
>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)
ldy #0
lda FRAMELEN
sbc #1 CC from SYSCALL
sta FRAMELEN
sta (ZPTmpPTR),y
iny
lda FRAMELEN+1
sbc #0
sta (ZPTmpPTR),y
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
lda L91C96.2.DATA+1,x
sta (ZPTmpPTR),y
iny
bne .2
inc ZPTmpPTR+1
bra .2
.8 lda #L91C96.2.MMUCR.REMREL
sta L91C96.2.MMUCR,x
clc
rts
.99 sec
rts
rts
*--------------------------------------
CLOSE jsr Reset
lda #0
sta L91C96.0.RCR,x
sta L91C96.0.RCR+1,x
clc
rts
*--------------------------------------
@ -235,7 +388,29 @@ CLOSE jsr Reset
* CC on success
* CS on error
*--------------------------------------
GETINFO >LDYA L.DEVINFO
GETINFO lda #S.DEVINFO.NET.STATUS.10
sta LINK.STATUS
ldx DEVSLOTx0
lda #0
sta 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.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
clc
rts
*--------------------------------------
@ -246,14 +421,124 @@ GETINFO >LDYA L.DEVINFO
* CC on success
* CS on error
*--------------------------------------
SEND
SEND >PULLW ZPTmpPTR
ldx DEVSLOTx0
lda #2
sta L91C96.BSR,x
lda (ZPTmpPTR)
sta FRAMELEN
clc
rts
adc #6 3 WORDs more Status, len & Control
pha
ldy #1
lda (ZPTmpPTR),y
sta FRAMELEN+1
adc #0
ply
bne .1
dec
.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
bra *
lda #ERRNOBUFFER
sec
rts
.3 lda L91C96.2.AAR,x
sta L91C96.2.PNR,x
lda #L91C96.2.PTR.AUTOI+2 skip status WORD
sta L91C96.2.PTR,x
lda /L91C96.2.PTR.AUTOI+2
sta L91C96.2.PTR+1,x
ldy #2+6+5 Add Src MAC Address
ldx #5
.4 lda MAC,x
sta (ZPTmpPTR),y
dey
dex
bpl .4
ldx DEVSLOTx0
lda FRAMELEN
pha
lsr
pla
sbc #$fb add 5 if odd, 6 if even
sta L91C96.2.DATA,x
lda FRAMELEN+1
sta L91C96.2.DATA+1,x
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
sta L91C96.2.DATA+1,x
iny
bne .5
inc ZPTmpPTR+1
bra .5
.70 lda #0
sta L91C96.2.DATA,x
sta L91C96.2.DATA+1,x
bra .8
.71 lda #$40 signal an extra (odd) byte
sta L91C96.2.DATA,x
pla
sta L91C96.2.DATA+1,x
.8 lda #L91C96.2.MMUCR.NQPKT
sta L91C96.2.MMUCR,x
clc
rts
.9 sec
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
Reset ldx DEVSLOTx0
lda #0
sta 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
.2 eor $C019
bpl .2
rts
*--------------------------------------
DecFrameLen lda FRAMELEN
@ -268,13 +553,13 @@ DecFrameLen lda FRAMELEN
DRV.CS.END
*--------------------------------------
DEVSLOTx0 .BS 1
USERMAC .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
LINK.STATUS .BS 1 OK/DUPLEX/SPEED
*--------------------------------------
MAN
SAVE DRV/LANCEGS.DRV.S

View File

@ -24,16 +24,6 @@ IntStatusQueue .EQ $C088 Interrupt Status Queue
PacketPagePTR .EQ $C08A PacketPage Pointer
PacketPageDATA .EQ $C08C PacketPage Data (DWORD)
*--------------------------------------
TxCMD.LID .EQ %00000000.00001001
TxCMD.TxStart5 .EQ %00000000.00000000 00 = start after 5 Bytes
TxCMD.TxStart381 .EQ %00000000.01000000 01 = start after 381 Bytes
TxCMD.TxStart1021 .EQ %00000000.10000000 10 = start after 1021 Bytes
TxCMD.TxStartFULL .EQ %00000000.11000000 11 = start after ENTIRE Frame
TxCMD.Force .EQ %00000001.00000000
TxCMD.OneColl .EQ %00000010.00000000
TxCMD.InhibitCRC .EQ %00010000.00000000
TxCMD.TxPadDis .EQ %00100000.00000000
*--------------------------------------
* PacketPage Offsets & Masks
*--------------------------------------
PP.ID .EQ $0000 Product ID code (RO)
@ -53,11 +43,21 @@ PP.RxCTL.RuntA .EQ %00100000.00000000
PP.RxCTL.ExtradataA .EQ %01000000.00000000
PP.TxCFG .EQ $0106 Transmit Configuration (RW)
PP.TxCMD .EQ $0108 Receiver Control (RW)
PP.TxCMD.LID .EQ %00000000.00001001
PP.TxCMD.TxStart5 .EQ %00000000.00000000 00 = start after 5 Bytes
PP.TxCMD.TxStart381 .EQ %00000000.01000000 01 = start after 381 Bytes
PP.TxCMD.TxStart1021 .EQ %00000000.10000000 10 = start after 1021 Bytes
PP.TxCMD.TxStartFULL .EQ %00000000.11000000 11 = start after ENTIRE Frame
PP.TxCMD.Force .EQ %00000001.00000000
PP.TxCMD.OneColl .EQ %00000010.00000000
PP.TxCMD.InhibitCRC .EQ %00010000.00000000
PP.TxCMD.TxPadDis .EQ %00100000.00000000
PP.BufCFG .EQ $010A
PP.LineCTL .EQ $0112 Line Control (RW)
PP.LineCTL.LID .EQ %00000000.00010011
PP.LineCTL.SerRxOn .EQ %00000000.01000000
PP.LineCTL.SerTxOn .EQ %00000000.10000000
PP.LineCTL.10BaseT .EQ %00000000.00000000
PP.LineCTL.AUIonly .EQ %00000001.00000000
PP.LineCTL.Auto .EQ %00000010.00000000
PP.SelfCTL .EQ $0114 Self Control (RW)
@ -284,6 +284,11 @@ OPEN jsr Reset
>LDYA MAC+4
>STYA PacketPageDATA,x
>LDYAI PP.TestCTL
>STYA PacketPagePTR,x
>LDYAI PP.TestCTL.LID+PP.TestCTL.FDX
>STYA PacketPageDATA,x
>LDYAI PP.LineCTL
>STYA PacketPagePTR,x
>LDYAI PP.LineCTL.LID+PP.LineCTL.SerRxOn+PP.LineCTL.SerTxOn+PP.LineCTL.Auto
@ -307,16 +312,27 @@ GETEVENT ldx DEVSLOTx0
lda #ERRTNOFRAME
sec
rts
GETEVENT.RxOK
and /PP.RxEvent.Brdcast
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
>LDYA RTDATA,x discard RxStatus
lda RTDATA+1,x get RxLength
sta FRAMELEN+1
pha
lda RTDATA,x
sta FRAMELEN
clc
adc #2
tay
pla
bcc .11
inc
.11 >PUSHYA FRAMLEN+2
>PUSHBI 0
>SYSCALL SYS.GetMem
bcs .99
@ -324,31 +340,37 @@ GETEVENT.RxOK
txa
ldy #S.EVT.DATALO
sta (pEvent),y
ldy #S.EVT.DATAW1
lda FRAMELEN
sta (pEvent),y
iny
lda FRAMELEN+1
sta (pEvent),y
lda #S.EVT.F.NET+S.EVT.F.hMEM1
sta (pEvent)
ldy #0
ldx DEVSLOTx0
lda FRAMELEN
sta (ZPTmpPTR)
ldy #1
lda FRAMELEN+1
sta (ZPTmpPTR),y
.1 lda RTDATA,x
iny
ldx DEVSLOTx0
.1 jsr DecFrameLen
beq .8
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
inc ZPTmpPTR+1
bne .1
.8 clc
rts
@ -365,7 +387,30 @@ CLOSE jsr Reset
* CC on success
* CS on error
*--------------------------------------
GETINFO >LDYA L.DEVINFO
GETINFO lda #S.DEVINFO.NET.STATUS.10
sta LINK.STATUS
ldx DEVSLOTx0
>LDYAI PP.LineST
>STYA PacketPagePTR,x
>LDYA PacketPageDATA,x
tya
and #PP.LineST.LinkOK
bne .1
lda LINK.STATUS
ora #S.DEVINFO.NET.STATUS.OK
sta LINK.STATUS
.1 >LDYAI PP.TestCTL
>STYA PacketPagePTR,x
>LDYA PacketPageDATA,x
and /PP.TestCTL.FDX
bne .2
lda LINK.STATUS
ora #S.DEVINFO.NET.STATUS.FD
sta LINK.STATUS
.2 >LDYA L.DEVINFO
clc
rts
*--------------------------------------
@ -377,9 +422,14 @@ GETINFO >LDYA L.DEVINFO
* CS on error
*--------------------------------------
SEND >PULLW ZPTmpPTR
>PULLW FRAMELEN
ldy #11 Add Src MAC Address
lda (ZPTmpPTR)
sta FRAMELEN
ldy #1
lda (ZPTmpPTR),y
sta FRAMELEN+1
ldy #2+6+5 Add Src MAC Address
ldx #5
.10 lda MAC,x
sta (ZPTmpPTR),y
@ -388,7 +438,7 @@ SEND >PULLW ZPTmpPTR
bpl .10
ldx DEVSLOTx0
>LDYAI TxCMD.LID+TxCMD.TxStartFULL
>LDYAI PP.TxCMD.LID+PP.TxCMD.TxStartFULL
>STYA TxCMD,x
>LDYA FRAMELEN
>STYA TxLength,x
@ -417,21 +467,25 @@ SEND >PULLW ZPTmpPTR
sec
rts
SENDPREADY ldy #0
.1 lda (ZPTmpPTR),y
SENDPREADY ldy #2
.1 jsr DecFrameLen
beq .8
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
.5 jsr DecFrameLen
bne .1
inc ZPTmpPTR+1
bne .1
.8 clc
rts
*--------------------------------------
@ -461,8 +515,7 @@ 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
LINK.STATUS .BS 1 OK/DUPLEX/SPEED
*--------------------------------------
MAN
SAVE DRV/UTHERNET.DRV.S

View File

@ -1,6 +1,6 @@
PR#3
PREFIX /A2OSX.SRC
NEW
LOMEM $C00
INC 1
AUTO 6
.LIST OFF
@ -16,9 +16,9 @@ ZPTmpPTR .EQ ZPDRV
*--------------------------------------
.MA AR.SELECT
lda /W5100.AR.]1
sta W5100.AR-$81,x
sta W5100.AR,x
lda #W5100.AR.]1
sta W5100.AR-$80,x
sta W5100.AR+1,x
.EM
*--------------------------------------
* WIZnet W5100 IO Registers
@ -96,23 +96,23 @@ Dev.Detect sta hArgs
>LDYA L.MSG.DETECT
>SYSCALL SYS.PSTROutYA
ldx #$10+$81
ldx #$10
.1 lda #W5100.MR.RST
sta W5100.MR-$81,x
sta W5100.MR,x
lda #W5100.MR.AI+W5100.MR.IND
sta W5100.MR-$81,x
sta W5100.MR,x
lda W5100.MR-$81,x
lda W5100.MR,x
cmp #W5100.MR.AI+W5100.MR.IND
bne .2
>AR.SELECT RTR Double Check with RTR default value...
lda W5100.DR-$81,x Get RTR HI
lda W5100.DR,x Get RTR HI
cmp /2000
bne .2
lda W5100.DR-$81,x Get RTR LO
lda W5100.DR,x Get RTR LO
cmp #2000
beq .3
@ -121,7 +121,7 @@ Dev.Detect sta hArgs
clc
adc #$10
tax
cpx #$80+$81
cpx #$80
bne .1
>LDYA L.MSG.DETECT.KO
@ -131,11 +131,11 @@ Dev.Detect sta hArgs
sec
rts
.3 stx DEVSLOTxF
.3 stx DEVSLOTx0
lda hARGS
beq .4
>SYSCALL SYS.GetMemPtrA
>STYA ZPTmpPTR
jsr DecodeMac
@ -233,74 +233,66 @@ DRV.CS.START .DA OPEN
L.DEVINFO .DA DEVINFO
.DA 0 end or relocation
*--------------------------------------
* input :
* none
* output :
* CC on success
* CS on error
*--------------------------------------
OPEN jsr Reset
>AR.SELECT SHAR
ldy #0
.1 lda MAC,y
sta W5100.DR-$81,x
sta W5100.DR,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
sta W5100.DR,x ...for Socket0 RX Buffer
sta W5100.DR,x ...for Socket0 TX Buffer
>AR.SELECT S0.MR
lda #3 IPRAW
sta W5100.DR-$81,x for S0.MR
sta W5100.DR,x for S0.MR
* >AR.SELECT S0.CR
lda #1 OPEN
sta W5100.DR-$81,x for S0.CR
sta W5100.DR,x for S0.CR
clc
rts
*--------------------------------------
* input :
* pEvent
* output :
* CC no event
* CS event
*--------------------------------------
GETEVENT ldx DEVSLOTxF
GETEVENT ldx DEVSLOTx0
>AR.SELECT S0.CR
lda W5100.DR,x
bne .9
>AR.SELECT S0.RX.RSR
lda W5100.DR-$81,x get the received size HI
sta RX.Size+1
lda W5100.DR-$81,x LO
sta RX.Size
ora RX.Size+1
lda W5100.DR,x get the received size HI
sta RXTX.Size+1
lda W5100.DR,x LO
sta RXTX.Size
ora RXTX.Size+1
bne GETEVENT.RxOK
lda #ERRTNOFRAME
.9 lda #ERRTNOFRAME
sec
rts
GETEVENT.RxOK clc
lda W5100.DR-$81,x get the received ptr HI
lda W5100.DR,x get the received ptr HI
and /RXTX.MASK
sta RX.Ptr+1
sta RXTX.Ptr+1
adc /RX.BASE
tay
lda W5100.DR-$81,x LO
lda W5100.DR,x LO
* and #RXTX.MASK $ff
sta RX.Ptr
sta RXTX.Ptr
sta W5100.AR-$81,x
sta W5100.AR,x
tya
sta W5100.AR-$80,x
sta W5100.AR+1,x
lda RX.Size
lda RXTX.Size
clc
adc #S.IP
sta FRAMELEN
lda RX.Size+1
lda RXTX.Size+1
adc /S.IP
sta FRAMELEN+1
@ -312,16 +304,18 @@ GETEVENT.RxOK clc
txa
ldy #S.EVT.DATALO
sta (pEvent),y
ldy #S.EVT.DATAW1
lda FRAMELEN
sta (pEvent),y
iny
sta (ZPTmpPTR)
ldy #1
lda FRAMELEN+1
sta (pEvent),y
sta (ZPTmpPTR),y
lda #S.EVT.F.NET+S.EVT.F.hMEM1
sta (pEvent)
ldy #0
ldx DEVSLOTxF
ldx DEVSLOTx0
ldy #S.IP.DST
@ -347,19 +341,19 @@ GETEVENT.RxOK clc
bra .2
.8 >AR.SELECT S0.RX.RD
lda RX.Size
lda RXTX.Size
clc
adc #6
tay
lda RX.Size+1
lda RXTX.Size+1
adc #0
sta W5100.DR-$81,x
sta W5100.DR,x
tya
sta W5100.DR-$80,x
sta W5100.DR+1,x
>AR.SELECT S0.CR
lda #$40 RECV
sta W5100.DR-$81,x
sta W5100.DR,x
clc
rts
@ -370,64 +364,82 @@ 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 >PULLW ZPTmpPTR
>PULLW FRAMELEN
ldx DEVSLOTxF
bra *
lda #ERRTIMEOUT
lda (ZPTmpPTR)
sec
rts
.9 bra *
sbc #S.IP
sta RXTX.Size
ldy #1
lda (ZPTmpPTR),y
sbc /S.IP
sta RXTX.Size
ldx DEVSLOTx0
>AR.SELECT S0.TX.FSR
lda W5100.DR,x get send size HI
pha
lda W5100.DR+1,x LO
sec
sbc RXTX.Size
pla
sbc RXTX.Size+1
bcs SEND.READY
lda #ERRNOBUFFER
sec
rts
SENDPREADY ldy #0
.1 lda (ZPTmpPTR),y
SEND.READY >AR.SELECT S0.DIPR
ldy #S.IP.DST
.1 lda (ZPTmpPTR),y
sta W5100.DR,x
iny
cpy #S.IP.DST+4
bne .1
>AR.SELECT S0.TX.WR
lda W5100.DR,x
pha
lda W5100.DR,x
clc
adc TX.Base
sta RXTX.Ptr
pla
adc TX.Base+1
sta RXTX.Ptr+1
ldy #S.IP
.2 lda (ZPTmpPTR),y
jsr PutTxByte
bcs .8
iny
bne .2
inc ZPTmpPTR+1
.2 jsr DecFrameLen
beq .8
.3 lda (ZPTmpPTR),y
iny
bne .5
inc ZPTmpPTR+1
.5 jsr DecFrameLen
bne .1
.8 clc
rts
bra .2
.8 >AR.SELECT S0.CR
lda #$20 SEND
sta W5100.DR,x
clc
rts
*--------------------------------------
SETIPCFG >PULLW ZPTmpPTR
>AR.SELECT GAR
ldx DEVSLOTxF
ldx DEVSLOTx0
ldy #S.IPCFG.GW
.1 lda (ZPTmpPTR),y
sta W5100.DR-$81,x
sta W5100.DR,x
iny
cpy #S.IPCFG.GW+4
bne .1
@ -436,7 +448,7 @@ SETIPCFG >PULLW ZPTmpPTR
ldy #S.IPCFG.MASK
.2 lda (ZPTmpPTR),y
sta W5100.DR-$81,x
sta W5100.DR,x
iny
cpy #S.IPCFG.MASK+4
bne .2
@ -445,7 +457,7 @@ SETIPCFG >PULLW ZPTmpPTR
ldy #S.IPCFG.IP
.3 lda (ZPTmpPTR),y
sta W5100.DR-$81,x
sta W5100.DR,x
iny
cpy #S.IPCFG.IP+4
bne .3
@ -453,62 +465,78 @@ SETIPCFG >PULLW ZPTmpPTR
clc
rts
*--------------------------------------
* PRIVATE
*--------------------------------------
Reset ldx DEVSLOTxF
Reset ldx DEVSLOTx0
lda #W5100.MR.RST
sta W5100.MR-$81,x
sta W5100.MR,x
rts
*--------------------------------------
GetRxByte lda RX.Size
GetRxByte lda RXTX.Size
bne .1
lda RX.Size+1
lda RXTX.Size+1
beq .9
dec RX.Size+1
.1 dec RX.Size
dec RXTX.Size+1
.1 dec RXTX.Size
lda W5100.DR-$81,x
inc RX.Ptr
lda W5100.DR,x
pha
inc RXTX.Ptr
bne .8
inc RX.Ptr+1
lda RX.Ptr+1
inc RXTX.Ptr+1
lda RXTX.Ptr+1
and /RXTX.MASK
bne .8
sta RX.Ptr+1
sta RXTX.Ptr+1
lda /RX.Base
sta W5100.AR-$81,x
sta W5100.AR,x
lda #RX.Base
sta W5100.AR-$80,x
.8 clc
sta W5100.AR+1,x
.8 pla
clc
rts
.9 sec
rts
*--------------------------------------
DecFrameLen lda FRAMELEN
PutTxByte pha
lda RXTX.Size
bne .1
lda FRAMELEN+1
beq .8
dec FRAMELEN+1
.1 dec FRAMELEN
lda #1 Make something NZ
.8 rts
*--------------------------------------
lda RXTX.Size+1
beq .9
dec RXTX.Size+1
.1 dec RXTX.Size
pla
sta W5100.DR,x
inc RXTX.Ptr
bne .8
inc RXTX.Ptr+1
lda RXTX.Ptr+1
and /RXTX.MASK
bne .8
sta RXTX.Ptr+1
lda /TX.Base
sta W5100.AR,x
lda #TX.Base
sta W5100.AR+1,x
.8 clc
rts
.9 pla
sec
rts
DRV.CS.END
*--------------------------------------
DEVSLOTxF .BS 1
DEVSLOTx0 .BS 1
USERMAC .BS 1
FRAMELEN .BS 2
RX.Size .BS 2
RX.Ptr .BS 2
*--------------------------------------
RXTX.Size .BS 2
RXTX.Ptr .BS 2
DEVINFO .DA #S.DEVINFO.TYPE.NET
DEVFLAGS .DA #S.DEVINFO.FLAGS.ARPOFFLOAD
DEVFLAGS .DA #S.DEVINFO.NET.FLAGS.ARPOFFLOAD
MAC .BS 6
LINK.STATUS .BS 1
LINK.SPEED .BS 1 SPEED/DUPLEX
*--------------------------------------
LINK.STATUS .DA #S.DEVINFO.NET.STATUS.OK+S.DEVINFO.NET.STATUS.FD+S.DEVINFO.NET.STATUS.100
MAN
SAVE DRV/UTHERNET2.DRV.S
ASM