1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-26 17:36:52 +00:00

Better Uthernet card detection

This commit is contained in:
David Schmenk 2018-04-23 12:02:58 -07:00
parent fb1f08bcc9
commit ea542905b7
5 changed files with 121 additions and 113 deletions

View File

@ -27,6 +27,7 @@ byte rxdata_lo, rxdata_hi
byte txcmd byte txcmd
byte txlen byte txlen
byte isq byte isq
word rom[]
byte pregidx byte pregidx
byte pregdata byte pregdata
// //
@ -213,33 +214,36 @@ end
// Identify Uthernet card and initialize // Identify Uthernet card and initialize
// //
for slot = $90 to $F0 step $10 for slot = $90 to $F0 step $10
if (peekiow(slot+TX_CMD) & $CC3F) == $09 rom = ((slot & $70) << 4) | $C000
pokeiow(slot+PREG_INDEX, 0) if rom=>$06 <> $3C86 or (slot == $0B or (rom->$05 <> $38 and rom->$07 <> $18)) // Skip slots with signature
if peekiow(slot+PREG_DATA) == $630E if (peekiow(slot+TX_CMD) & $CC3F) == $0009
pokepreg($0114, $40) // RESET pokeiow(slot+PREG_INDEX, 0)
rxdata_hi = slot + 1 if peekiow(slot+PREG_DATA) == $630E
txcmd = slot + TX_CMD pokepreg($0114, $40) // RESET
txlen = slot + TX_LEN rxdata_hi = slot + 1
isq = slot + INT_STATUS txcmd = slot + TX_CMD
pregidx = slot + PREG_INDEX txlen = slot + TX_LEN
pregdata = slot + PREG_DATA isq = slot + INT_STATUS
_pokefrml.1 = slot pregidx = slot + PREG_INDEX
_pokefrmh.1 = slot+1 pregdata = slot + PREG_DATA
_peekfrml.1 = slot _pokefrml.1 = slot
_peekfrmh.1 = slot+1 _pokefrmh.1 = slot+1
pokepreg($0158, utherMAC:0) // MAC addr _peekfrml.1 = slot
pokepreg($015A, utherMAC:2) // MAC addr _peekfrmh.1 = slot+1
pokepreg($015C, utherMAC:4) // MAC addr pokepreg($0158, utherMAC:0) // MAC addr
pokepreg($0102, $0100) // Recv cfg pokepreg($015A, utherMAC:2) // MAC addr
pokepreg($0104, $0D00) // Recv ctrl pokepreg($015C, utherMAC:4) // MAC addr
pokepreg($0106, $8200) // Xmit cfg pokepreg($0102, $0100) // Recv cfg
pokepreg($0112, $00C0) // Line ctrl pokepreg($0104, $0D00) // Recv ctrl
// pokepreg($0106, $8200) // Xmit cfg
// Install etherip driver pokepreg($0112, $00C0) // Line ctrl
// //
puts("Found Uthernet I in slot #"); putc('0' + ((slot - $80) >> 4)); putln // Install etherip driver
setEtherDriver(@utherMAC, @peekfrmlen, @peekfrm, @pokefrmlen, @pokefrm) //
return modkeep puts("Found Uthernet I in slot #"); putc('0' + ((slot - $80) >> 4)); putln
setEtherDriver(@utherMAC, @peekfrmlen, @peekfrm, @pokefrmlen, @pokefrm)
return modkeep
fin
fin fin
fin fin
next next

View File

@ -72,6 +72,7 @@ const WIZ_RXMEM3 = $7800
// Wiznet indirect registers // Wiznet indirect registers
// //
byte slot byte slot
word rom[]
word saveidx word saveidx
byte regidx byte regidx
byte regdata byte regdata
@ -842,71 +843,74 @@ end
// Identify Uthernet II card and initialize // Identify Uthernet II card and initialize
// //
for slot = $90 to $F0 step $10 for slot = $90 to $F0 step $10
regdata = peekio(slot) rom = ((slot & $70) << 4) | $C000
if (regdata & $E4) == $00 if rom=>$06 <> $3C86 or (slot == $0B or (rom->$05 <> $38 and rom->$07 <> $18)) // Skip slots with signature
pokeio(slot, $03) // Try setting auto-increment indirect I/F regdata = peekio(slot)
if peekio(slot) == $03 if (regdata & $E4) == $00
saveidx = peekiow(slot + 1) pokeio(slot, $03) // Try setting auto-increment indirect I/F
peekio(slot + 3) // Dummy read to data register should increment index if peekio(slot) == $03
if peekiow(slot + 1) == saveidx + 1 saveidx = peekiow(slot + 1)
// peekio(slot + 3) // Dummy read to data register should increment index
// Good chance this is it if peekiow(slot + 1) == saveidx + 1
// //
pokeio(slot, $80) // RESET // Good chance this is it
regidx = slot + 1 //
regdata = slot + 3 pokeio(slot, $80) // RESET
_pokedata.1 = regdata regidx = slot + 1
_peekdata.1 = regdata regdata = slot + 3
pokeio(slot, $03) // Auto-increment indirect I/F + enable ping _pokedata.1 = regdata
// _peekdata.1 = regdata
// The following looks redundant, but it sets up the peek/poke locations pokeio(slot, $03) // Auto-increment indirect I/F + enable ping
// for peekreg(s)/pokereg(s) //
// // The following looks redundant, but it sets up the peek/poke locations
pokeiow(regidx, WIZ_MR) // for peekreg(s)/pokereg(s)
pokeio(regdata, $03) // Auto-increment indirect I/F + enable ping //
peekio(regdata) pokeiow(regidx, WIZ_MR)
// pokeio(regdata, $03) // Auto-increment indirect I/F + enable ping
// Initialize common registers peekio(regdata)
// //
pokeregs(WIZ_SHAR, @wizMAC, 6) // MAC addr // Initialize common registers
pokeregw(WIZ_RTR, 5000) // Timeout period to 500ms //
pokereg(WIZ_RMSR, $55) // 2K Rx memory/channel pokeregs(WIZ_SHAR, @wizMAC, 6) // MAC addr
pokereg(WIZ_TMSR, $55) // 2K Tx memory/channel pokeregw(WIZ_RTR, 5000) // Timeout period to 500ms
// pokereg(WIZ_RMSR, $55) // 2K Rx memory/channel
// Print settings pokereg(WIZ_TMSR, $55) // 2K Tx memory/channel
// //
puts("Found Uthernet II in slot #") // Print settings
putc('0' + ((slot - $80) >> 4)) //
putln puts("Found Uthernet II in slot #")
// putc('0' + ((slot - $80) >> 4))
// Fill channel structure putln
// //
saveidx = @wizChannel // Fill channel structure
for slot = 0 to 3 //
saveidx=>channel_regs = WIZ_SREGS + (WIZ_SSIZE * slot) saveidx = @wizChannel
saveidx=>channel_txmem = WIZ_TXMEM + (WIZ_TXSIZE * slot) for slot = 0 to 3
saveidx=>channel_rxmem = WIZ_RXMEM + (WIZ_RXSIZE * slot) saveidx=>channel_regs = WIZ_SREGS + (WIZ_SSIZE * slot)
saveidx = saveidx + t_channel saveidx=>channel_txmem = WIZ_TXMEM + (WIZ_TXSIZE * slot)
next saveidx=>channel_rxmem = WIZ_RXMEM + (WIZ_RXSIZE * slot)
// saveidx = saveidx + t_channel
// Fill in Net class next
// //
iNet:serviceIP = @wizServiceIP // Fill in Net class
iNet:openUDP = @wizOpenUDP //
iNet:sendUDP = @wizSendUDP iNet:serviceIP = @wizServiceIP
iNet:closeUDP = @wizCloseUDP iNet:openUDP = @wizOpenUDP
iNet:listenTCP = @wizListenTCP iNet:sendUDP = @wizSendUDP
iNet:connectTCP = @wizConnectTCP iNet:closeUDP = @wizCloseUDP
iNet:sendTCP = @wizSendTCP iNet:listenTCP = @wizListenTCP
iNet:closeTCP = @wizCloseTCP iNet:connectTCP = @wizConnectTCP
iNet:setInterfaceIP = @setWizIP iNet:sendTCP = @wizSendTCP
iNet:getInterfaceHA = @getWizHA iNet:closeTCP = @wizCloseTCP
iNet:setCallback = @wizSetCallback iNet:setInterfaceIP = @setWizIP
iNet:setParam = @wizSetParam iNet:getInterfaceHA = @getWizHA
return modkeep iNet:setCallback = @wizSetCallback
iNet:setParam = @wizSetParam
return modkeep
fin
fin fin
pokeio(slot, regdata) // Restore register
fin fin
pokeio(slot, regdata) // Restore register
fin fin
next next
// //

View File

@ -972,7 +972,7 @@ def adddef(addr, deflast)#1
return defentry return defentry
end end
def loadmod(mod)#1 def loadmod(mod)#1
word rdlen, modsize, bytecode, codefix, defofst, defcnt, init, fixup word rdlen, modsize, bytecode, codefix, defofst, defcnt, init, initcode[], fixup
word addr, defaddr, modaddr, modfix, modofst, modend word addr, defaddr, modaddr, modfix, modofst, modend
word deftbl, deflast word deftbl, deflast
word moddep, rld, esd, sym word moddep, rld, esd, sym
@ -1130,23 +1130,23 @@ def loadmod(mod)#1
// //
// Call init routine if it exists. // Call init routine if it exists.
// //
fixup = 0 // This is repurposed for the return code initcode = 0
if init if init
init = init + defofst init = init + defofst
fixup = adddef(init, @deflast)() initcode = adddef(init, @deflast)()
if fixup < modinitkeep if initcide < modinitkeep
// //
// Free init routine unless initkeep // Free init routine unless initkeep
// //
releaseheap(init) releaseheap(init)
if fixup < 0 if initcode < 0
perr = -fixup perr = -initcode
fin fin
else else
fixup = fixup & ~modinitkeep initcode = initcode & ~modinitkeep
fin fin
fin fin
return fixup return initcode
end end
// //
// Command mode // Command mode

View File

@ -1025,7 +1025,7 @@ def adddef(isfirst, addr, deflast)#1
return defentry return defentry
end end
def loadmod(mod)#1 def loadmod(mod)#1
word rdlen, modsize, bytecode, codefix, defofst, defcnt, init, fixup word rdlen, modsize, bytecode, codefix, defofst, defcnt, init, initcode[], fixup
word addr, defaddr, modaddr, modfix, modofst, modend word addr, defaddr, modaddr, modfix, modofst, modend
word deftbl, deflast word deftbl, deflast
word moddep, rld, esd, sym word moddep, rld, esd, sym
@ -1187,29 +1187,29 @@ def loadmod(mod)#1
return -perr return -perr
fin fin
// //
// Free up rld+esd (and bytecode on 128K) in main memory. // Free up rld+esd+bytecode in main memory.
// //
releaseheap(modend) releaseheap(modend)
// //
// Call init routine if it exists. // Call init routine if it exists.
// //
fixup = 0 // This is repurposed for the return code initcode = 0
if init if init
init = init + defofst init = init + defofst
fixup = adddef(deffirst, init, @deflast)() initcode = adddef(deffirst, init, @deflast)()
if fixup < modinitkeep if initcode < modinitkeep
// //
// Free init routine unless initkeep // Free init routine unless initkeep
// //
xheap = init xheap = init
if fixup < 0 if initcode < 0
perr = -fixup perr = -initcode
fin fin
else else
fixup = fixup & ~modinitkeep initcode = initcode & ~modinitkeep
fin fin
fin fin
return fixup return initcode
end end
// //
// Command mode // Command mode

View File

@ -1047,7 +1047,7 @@ def adddef(isfirst, ext, addr, deflast)#1
return defentry return defentry
end end
def loadmod(mod)#1 def loadmod(mod)#1
word refnum[], deffirst, rdlen, modsize, bytecode, codefix, defofst, defcnt, init, fixup word refnum[], deffirst, rdlen, modsize, bytecode, codefix, defofst, defcnt, init, initcode[], fixup
word addr, defaddr, modaddr, modfix, modofst, modend word addr, defaddr, modaddr, modfix, modofst, modend
word deftbl, deflast, codeseg word deftbl, deflast, codeseg
word moddep, rld, esd, sym word moddep, rld, esd, sym
@ -1256,14 +1256,14 @@ def loadmod(mod)#1
// //
// Call init routine if it exists. // Call init routine if it exists.
// //
fixup = 0 initcode = 0
if init if init
fixup = adddef(deffirst, defext, init + defofst, @deflast)() initcode = adddef(deffirst, defext, init + defofst, @deflast)()
if fixup < 0 if initcode < 0
perr = -fixup perr = -initcode
fin fin
fin fin
return fixup return initcode
end end
def execmod(modfile)#1 def execmod(modfile)#1
byte moddci[17] byte moddci[17]