diff --git a/src/libsrc/apple/uthernet.pla b/src/libsrc/apple/uthernet.pla index 8345cf6..3c0b350 100644 --- a/src/libsrc/apple/uthernet.pla +++ b/src/libsrc/apple/uthernet.pla @@ -27,6 +27,7 @@ byte rxdata_lo, rxdata_hi byte txcmd byte txlen byte isq +word rom[] byte pregidx byte pregdata // @@ -213,33 +214,36 @@ end // Identify Uthernet card and initialize // for slot = $90 to $F0 step $10 - if (peekiow(slot+TX_CMD) & $CC3F) == $09 - pokeiow(slot+PREG_INDEX, 0) - if peekiow(slot+PREG_DATA) == $630E - pokepreg($0114, $40) // RESET - rxdata_hi = slot + 1 - txcmd = slot + TX_CMD - txlen = slot + TX_LEN - isq = slot + INT_STATUS - pregidx = slot + PREG_INDEX - pregdata = slot + PREG_DATA - _pokefrml.1 = slot - _pokefrmh.1 = slot+1 - _peekfrml.1 = slot - _peekfrmh.1 = slot+1 - pokepreg($0158, utherMAC:0) // MAC addr - pokepreg($015A, utherMAC:2) // MAC addr - pokepreg($015C, utherMAC:4) // MAC addr - pokepreg($0102, $0100) // Recv cfg - pokepreg($0104, $0D00) // Recv ctrl - pokepreg($0106, $8200) // Xmit cfg - pokepreg($0112, $00C0) // Line ctrl - // - // Install etherip driver - // - puts("Found Uthernet I in slot #"); putc('0' + ((slot - $80) >> 4)); putln - setEtherDriver(@utherMAC, @peekfrmlen, @peekfrm, @pokefrmlen, @pokefrm) - return modkeep + rom = ((slot & $70) << 4) | $C000 + if rom=>$06 <> $3C86 or (slot == $0B or (rom->$05 <> $38 and rom->$07 <> $18)) // Skip slots with signature + if (peekiow(slot+TX_CMD) & $CC3F) == $0009 + pokeiow(slot+PREG_INDEX, 0) + if peekiow(slot+PREG_DATA) == $630E + pokepreg($0114, $40) // RESET + rxdata_hi = slot + 1 + txcmd = slot + TX_CMD + txlen = slot + TX_LEN + isq = slot + INT_STATUS + pregidx = slot + PREG_INDEX + pregdata = slot + PREG_DATA + _pokefrml.1 = slot + _pokefrmh.1 = slot+1 + _peekfrml.1 = slot + _peekfrmh.1 = slot+1 + pokepreg($0158, utherMAC:0) // MAC addr + pokepreg($015A, utherMAC:2) // MAC addr + pokepreg($015C, utherMAC:4) // MAC addr + pokepreg($0102, $0100) // Recv cfg + pokepreg($0104, $0D00) // Recv ctrl + pokepreg($0106, $8200) // Xmit cfg + pokepreg($0112, $00C0) // Line ctrl + // + // Install etherip driver + // + puts("Found Uthernet I in slot #"); putc('0' + ((slot - $80) >> 4)); putln + setEtherDriver(@utherMAC, @peekfrmlen, @peekfrm, @pokefrmlen, @pokefrm) + return modkeep + fin fin fin next diff --git a/src/libsrc/apple/uthernet2.pla b/src/libsrc/apple/uthernet2.pla index 2ce036f..57e4c59 100644 --- a/src/libsrc/apple/uthernet2.pla +++ b/src/libsrc/apple/uthernet2.pla @@ -72,6 +72,7 @@ const WIZ_RXMEM3 = $7800 // Wiznet indirect registers // byte slot +word rom[] word saveidx byte regidx byte regdata @@ -842,71 +843,74 @@ end // Identify Uthernet II card and initialize // for slot = $90 to $F0 step $10 - regdata = peekio(slot) - if (regdata & $E4) == $00 - pokeio(slot, $03) // Try setting auto-increment indirect I/F - if peekio(slot) == $03 - saveidx = peekiow(slot + 1) - peekio(slot + 3) // Dummy read to data register should increment index - if peekiow(slot + 1) == saveidx + 1 - // - // Good chance this is it - // - pokeio(slot, $80) // RESET - regidx = slot + 1 - regdata = slot + 3 - _pokedata.1 = regdata - _peekdata.1 = regdata - pokeio(slot, $03) // Auto-increment indirect I/F + enable ping - // - // The following looks redundant, but it sets up the peek/poke locations - // for peekreg(s)/pokereg(s) - // - pokeiow(regidx, WIZ_MR) - pokeio(regdata, $03) // Auto-increment indirect I/F + enable ping - peekio(regdata) - // - // Initialize common registers - // - pokeregs(WIZ_SHAR, @wizMAC, 6) // MAC addr - pokeregw(WIZ_RTR, 5000) // Timeout period to 500ms - pokereg(WIZ_RMSR, $55) // 2K Rx memory/channel - pokereg(WIZ_TMSR, $55) // 2K Tx memory/channel - // - // Print settings - // - puts("Found Uthernet II in slot #") - putc('0' + ((slot - $80) >> 4)) - putln - // - // Fill channel structure - // - saveidx = @wizChannel - for slot = 0 to 3 - saveidx=>channel_regs = WIZ_SREGS + (WIZ_SSIZE * slot) - saveidx=>channel_txmem = WIZ_TXMEM + (WIZ_TXSIZE * slot) - saveidx=>channel_rxmem = WIZ_RXMEM + (WIZ_RXSIZE * slot) - saveidx = saveidx + t_channel - next - // - // Fill in Net class - // - iNet:serviceIP = @wizServiceIP - iNet:openUDP = @wizOpenUDP - iNet:sendUDP = @wizSendUDP - iNet:closeUDP = @wizCloseUDP - iNet:listenTCP = @wizListenTCP - iNet:connectTCP = @wizConnectTCP - iNet:sendTCP = @wizSendTCP - iNet:closeTCP = @wizCloseTCP - iNet:setInterfaceIP = @setWizIP - iNet:getInterfaceHA = @getWizHA - iNet:setCallback = @wizSetCallback - iNet:setParam = @wizSetParam - return modkeep + rom = ((slot & $70) << 4) | $C000 + if rom=>$06 <> $3C86 or (slot == $0B or (rom->$05 <> $38 and rom->$07 <> $18)) // Skip slots with signature + regdata = peekio(slot) + if (regdata & $E4) == $00 + pokeio(slot, $03) // Try setting auto-increment indirect I/F + if peekio(slot) == $03 + saveidx = peekiow(slot + 1) + peekio(slot + 3) // Dummy read to data register should increment index + if peekiow(slot + 1) == saveidx + 1 + // + // Good chance this is it + // + pokeio(slot, $80) // RESET + regidx = slot + 1 + regdata = slot + 3 + _pokedata.1 = regdata + _peekdata.1 = regdata + pokeio(slot, $03) // Auto-increment indirect I/F + enable ping + // + // The following looks redundant, but it sets up the peek/poke locations + // for peekreg(s)/pokereg(s) + // + pokeiow(regidx, WIZ_MR) + pokeio(regdata, $03) // Auto-increment indirect I/F + enable ping + peekio(regdata) + // + // Initialize common registers + // + pokeregs(WIZ_SHAR, @wizMAC, 6) // MAC addr + pokeregw(WIZ_RTR, 5000) // Timeout period to 500ms + pokereg(WIZ_RMSR, $55) // 2K Rx memory/channel + pokereg(WIZ_TMSR, $55) // 2K Tx memory/channel + // + // Print settings + // + puts("Found Uthernet II in slot #") + putc('0' + ((slot - $80) >> 4)) + putln + // + // Fill channel structure + // + saveidx = @wizChannel + for slot = 0 to 3 + saveidx=>channel_regs = WIZ_SREGS + (WIZ_SSIZE * slot) + saveidx=>channel_txmem = WIZ_TXMEM + (WIZ_TXSIZE * slot) + saveidx=>channel_rxmem = WIZ_RXMEM + (WIZ_RXSIZE * slot) + saveidx = saveidx + t_channel + next + // + // Fill in Net class + // + iNet:serviceIP = @wizServiceIP + iNet:openUDP = @wizOpenUDP + iNet:sendUDP = @wizSendUDP + iNet:closeUDP = @wizCloseUDP + iNet:listenTCP = @wizListenTCP + iNet:connectTCP = @wizConnectTCP + iNet:sendTCP = @wizSendTCP + iNet:closeTCP = @wizCloseTCP + iNet:setInterfaceIP = @setWizIP + iNet:getInterfaceHA = @getWizHA + iNet:setCallback = @wizSetCallback + iNet:setParam = @wizSetParam + return modkeep + fin fin + pokeio(slot, regdata) // Restore register fin - pokeio(slot, regdata) // Restore register fin next // diff --git a/src/vmsrc/apple/cmd.pla b/src/vmsrc/apple/cmd.pla index 84e84fd..39f6036 100755 --- a/src/vmsrc/apple/cmd.pla +++ b/src/vmsrc/apple/cmd.pla @@ -972,7 +972,7 @@ def adddef(addr, deflast)#1 return defentry end 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 deftbl, deflast word moddep, rld, esd, sym @@ -1130,23 +1130,23 @@ def loadmod(mod)#1 // // Call init routine if it exists. // - fixup = 0 // This is repurposed for the return code + initcode = 0 if init init = init + defofst - fixup = adddef(init, @deflast)() - if fixup < modinitkeep + initcode = adddef(init, @deflast)() + if initcide < modinitkeep // // Free init routine unless initkeep // releaseheap(init) - if fixup < 0 - perr = -fixup + if initcode < 0 + perr = -initcode fin else - fixup = fixup & ~modinitkeep + initcode = initcode & ~modinitkeep fin fin - return fixup + return initcode end // // Command mode diff --git a/src/vmsrc/apple/cmdjit.pla b/src/vmsrc/apple/cmdjit.pla index 954ba3e..379198c 100755 --- a/src/vmsrc/apple/cmdjit.pla +++ b/src/vmsrc/apple/cmdjit.pla @@ -1025,7 +1025,7 @@ def adddef(isfirst, addr, deflast)#1 return defentry end 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 deftbl, deflast word moddep, rld, esd, sym @@ -1187,29 +1187,29 @@ def loadmod(mod)#1 return -perr fin // - // Free up rld+esd (and bytecode on 128K) in main memory. + // Free up rld+esd+bytecode in main memory. // releaseheap(modend) // // Call init routine if it exists. // - fixup = 0 // This is repurposed for the return code + initcode = 0 if init init = init + defofst - fixup = adddef(deffirst, init, @deflast)() - if fixup < modinitkeep + initcode = adddef(deffirst, init, @deflast)() + if initcode < modinitkeep // // Free init routine unless initkeep // xheap = init - if fixup < 0 - perr = -fixup + if initcode < 0 + perr = -initcode fin else - fixup = fixup & ~modinitkeep + initcode = initcode & ~modinitkeep fin fin - return fixup + return initcode end // // Command mode diff --git a/src/vmsrc/apple/sossys.pla b/src/vmsrc/apple/sossys.pla index 98e60cb..c3584b8 100755 --- a/src/vmsrc/apple/sossys.pla +++ b/src/vmsrc/apple/sossys.pla @@ -1047,7 +1047,7 @@ def adddef(isfirst, ext, addr, deflast)#1 return defentry end 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 deftbl, deflast, codeseg word moddep, rld, esd, sym @@ -1256,14 +1256,14 @@ def loadmod(mod)#1 // // Call init routine if it exists. // - fixup = 0 + initcode = 0 if init - fixup = adddef(deffirst, defext, init + defofst, @deflast)() - if fixup < 0 - perr = -fixup + initcode = adddef(deffirst, defext, init + defofst, @deflast)() + if initcode < 0 + perr = -initcode fin fin - return fixup + return initcode end def execmod(modfile)#1 byte moddci[17]