|
From: <hag...@us...> - 2008-05-30 12:27:55
|
Revision: 4155
http://jnode.svn.sourceforge.net/jnode/?rev=4155&view=rev
Author: hagar-wize
Date: 2008-05-30 05:27:50 -0700 (Fri, 30 May 2008)
Log Message:
-----------
reformat code
Modified Paths:
--------------
trunk/net/src/driver/org/jnode/driver/net/lance/BufferManager.java
trunk/net/src/driver/org/jnode/driver/net/lance/DWordIOAccess.java
trunk/net/src/driver/org/jnode/driver/net/lance/Descriptor.java
trunk/net/src/driver/org/jnode/driver/net/lance/DescriptorRing.java
trunk/net/src/driver/org/jnode/driver/net/lance/IOAccess.java
trunk/net/src/driver/org/jnode/driver/net/lance/InitializationBlock32Bit.java
trunk/net/src/driver/org/jnode/driver/net/lance/LanceConstants.java
trunk/net/src/driver/org/jnode/driver/net/lance/LanceCore.java
trunk/net/src/driver/org/jnode/driver/net/lance/LanceDriver.java
trunk/net/src/driver/org/jnode/driver/net/lance/LanceFlags.java
trunk/net/src/driver/org/jnode/driver/net/lance/RxDescriptor.java
trunk/net/src/driver/org/jnode/driver/net/lance/RxDescriptorRing.java
trunk/net/src/driver/org/jnode/driver/net/lance/TxDescriptor.java
trunk/net/src/driver/org/jnode/driver/net/lance/TxDescriptorRing.java
trunk/net/src/driver/org/jnode/driver/net/lance/WordIOAccess.java
trunk/net/src/driver/org/jnode/driver/net/loopback/LoopbackDevice.java
trunk/net/src/driver/org/jnode/driver/net/loopback/LoopbackDriver.java
trunk/net/src/driver/org/jnode/driver/net/loopback/LoopbackFinder.java
trunk/net/src/driver/org/jnode/driver/net/rtl8139/RTL8139Constants.java
Modified: trunk/net/src/driver/org/jnode/driver/net/lance/BufferManager.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/lance/BufferManager.java 2008-05-30 12:21:53 UTC (rev 4154)
+++ trunk/net/src/driver/org/jnode/driver/net/lance/BufferManager.java 2008-05-30 12:27:50 UTC (rev 4155)
@@ -18,7 +18,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.net.lance;
import org.apache.log4j.Logger;
@@ -30,115 +30,113 @@
import org.jnode.system.ResourceOwner;
/**
- *
* @author Chris Cole
- *
*/
public class BufferManager {
- static final public int DATA_BUFFER_SIZE = 1544;
+ static final public int DATA_BUFFER_SIZE = 1544;
- /** MemoryResource to hold initialization block, descriptor rings, and data buffers */
- private MemoryResource mem;
+ /**
+ * MemoryResource to hold initialization block, descriptor rings, and data buffers
+ */
+ private MemoryResource mem;
- private final InitializationBlock32Bit initBlock;
- private final RxDescriptorRing rxRing;
- private final TxDescriptorRing txRing;
-
- private final int size;
+ private final InitializationBlock32Bit initBlock;
+ private final RxDescriptorRing rxRing;
+ private final TxDescriptorRing txRing;
- public BufferManager(
- int rxRingLength,
- int txRingLength,
- int mode,
- EthernetAddress physicalAddr,
- long logicalAddr,
- ResourceManager rm,
- ResourceOwner owner) {
+ private final int size;
- // Compute the required size for the memory resource
- size =
- InitializationBlock32Bit.INIT_BLOCK_SIZE
- + ((rxRingLength + txRingLength)
- * (Descriptor.MESSAGE_DESCRIPTOR_SIZE
- + DATA_BUFFER_SIZE));
-
-
+ public BufferManager(
+ int rxRingLength,
+ int txRingLength,
+ int mode,
+ EthernetAddress physicalAddr,
+ long logicalAddr,
+ ResourceManager rm,
+ ResourceOwner owner) {
- // Get the memory
- try {
- mem =
- rm.claimMemoryResource(
- owner,
- null,
- size,
- ResourceManager.MEMMODE_NORMAL);
- } catch (ResourceNotFreeException e) {
- System.out.println("buffer memory resouce not free exception");
- }
+ // Compute the required size for the memory resource
+ size =
+ InitializationBlock32Bit.INIT_BLOCK_SIZE
+ + ((rxRingLength + txRingLength)
+ * (Descriptor.MESSAGE_DESCRIPTOR_SIZE
+ + DATA_BUFFER_SIZE));
- // define the offsets into the memory resource for the entities
- final int rxRingOffset = InitializationBlock32Bit.INIT_BLOCK_SIZE;
+ // Get the memory
+ try {
+ mem =
+ rm.claimMemoryResource(
+ owner,
+ null,
+ size,
+ ResourceManager.MEMMODE_NORMAL);
+ } catch (ResourceNotFreeException e) {
+ System.out.println("buffer memory resouce not free exception");
+ }
- final int txRingOffset =
- rxRingOffset + (rxRingLength * Descriptor.MESSAGE_DESCRIPTOR_SIZE);
+ // define the offsets into the memory resource for the entities
+ final int rxRingOffset = InitializationBlock32Bit.INIT_BLOCK_SIZE;
- final int rxDataBufferOffset =
- txRingOffset + (txRingLength * Descriptor.MESSAGE_DESCRIPTOR_SIZE);
+ final int txRingOffset =
+ rxRingOffset + (rxRingLength * Descriptor.MESSAGE_DESCRIPTOR_SIZE);
- final int txDataBufferOffset =
- rxDataBufferOffset + (rxRingLength * DATA_BUFFER_SIZE);
+ final int rxDataBufferOffset =
+ txRingOffset + (txRingLength * Descriptor.MESSAGE_DESCRIPTOR_SIZE);
- // Create and initialize the receive ring
- rxRing =
- new RxDescriptorRing(
- mem,
- rxRingOffset,
- rxRingLength,
- rxDataBufferOffset);
+ final int txDataBufferOffset =
+ rxDataBufferOffset + (rxRingLength * DATA_BUFFER_SIZE);
- // Create and initialize the transmit ring
- txRing =
- new TxDescriptorRing(
- mem,
- txRingOffset,
- txRingLength,
- txDataBufferOffset);
+ // Create and initialize the receive ring
+ rxRing =
+ new RxDescriptorRing(
+ mem,
+ rxRingOffset,
+ rxRingLength,
+ rxDataBufferOffset);
- // Create and initialize the initializtion block
- initBlock =
- new InitializationBlock32Bit(
- mem,
- 0,
- (short) mode,
- physicalAddr,
- logicalAddr,
- rxRing,
- txRing);
- }
+ // Create and initialize the transmit ring
+ txRing =
+ new TxDescriptorRing(
+ mem,
+ txRingOffset,
+ txRingLength,
+ txDataBufferOffset);
- /**
- * Gets the address of the initdata structure as a 32-bit int
- */
- public final int getInitDataAddressAs32Bit() {
- return mem.getAddress().toInt();
- }
+ // Create and initialize the initializtion block
+ initBlock =
+ new InitializationBlock32Bit(
+ mem,
+ 0,
+ (short) mode,
+ physicalAddr,
+ logicalAddr,
+ rxRing,
+ txRing);
+ }
- public void transmit(SocketBuffer buf) {
- final int len = buf.getSize();
- if (len > DATA_BUFFER_SIZE) {
- System.out.println("Length must be <= " + DATA_BUFFER_SIZE);
- }
+ /**
+ * Gets the address of the initdata structure as a 32-bit int
+ */
+ public final int getInitDataAddressAs32Bit() {
+ return mem.getAddress().toInt();
+ }
- txRing.transmit(buf);
- }
+ public void transmit(SocketBuffer buf) {
+ final int len = buf.getSize();
+ if (len > DATA_BUFFER_SIZE) {
+ System.out.println("Length must be <= " + DATA_BUFFER_SIZE);
+ }
- public SocketBuffer getPacket() {
- return rxRing.getPacket();
- }
+ txRing.transmit(buf);
+ }
- public void dumpData(Logger out) {
- initBlock.dumpData(out);
- rxRing.dumpData(out);
- txRing.dumpData(out);
+ public SocketBuffer getPacket() {
+ return rxRing.getPacket();
+ }
+
+ public void dumpData(Logger out) {
+ initBlock.dumpData(out);
+ rxRing.dumpData(out);
+ txRing.dumpData(out);
}
}
Modified: trunk/net/src/driver/org/jnode/driver/net/lance/DWordIOAccess.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/lance/DWordIOAccess.java 2008-05-30 12:21:53 UTC (rev 4154)
+++ trunk/net/src/driver/org/jnode/driver/net/lance/DWordIOAccess.java 2008-05-30 12:27:50 UTC (rev 4155)
@@ -18,47 +18,46 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.net.lance;
import org.jnode.system.IOResource;
/**
* @author Chris Cole
- *
*/
public class DWordIOAccess extends IOAccess implements LanceConstants {
- public DWordIOAccess(IOResource io, int iobase) {
- super(io, iobase);
- }
-
- public String getType() {
- return "DWord";
- }
-
- public void reset() {
- // Read triggers a reset
- io.inPortDword(iobase + DWIO_RESET);
- }
+ public DWordIOAccess(IOResource io, int iobase) {
+ super(io, iobase);
+ }
- public int getCSR(int csrnr) {
- io.outPortDword(iobase + DWIO_RAP, csrnr);
- return io.inPortDword(iobase + DWIO_RDP);
- }
+ public String getType() {
+ return "DWord";
+ }
- public void setCSR(int csrnr, int value) {
- io.outPortDword(iobase + DWIO_RAP, csrnr);
- io.outPortDword(iobase + DWIO_RDP, value);
- }
+ public void reset() {
+ // Read triggers a reset
+ io.inPortDword(iobase + DWIO_RESET);
+ }
- public int getBCR(int bcrnr) {
- io.outPortDword(iobase + DWIO_RAP, bcrnr);
- return io.inPortDword(iobase + DWIO_BDP);
- }
+ public int getCSR(int csrnr) {
+ io.outPortDword(iobase + DWIO_RAP, csrnr);
+ return io.inPortDword(iobase + DWIO_RDP);
+ }
- public void setBCR(int bcrnr, int value) {
- io.outPortDword(iobase + DWIO_RAP, bcrnr);
- io.outPortDword(iobase + DWIO_BDP, value);
- }
+ public void setCSR(int csrnr, int value) {
+ io.outPortDword(iobase + DWIO_RAP, csrnr);
+ io.outPortDword(iobase + DWIO_RDP, value);
+ }
+
+ public int getBCR(int bcrnr) {
+ io.outPortDword(iobase + DWIO_RAP, bcrnr);
+ return io.inPortDword(iobase + DWIO_BDP);
+ }
+
+ public void setBCR(int bcrnr, int value) {
+ io.outPortDword(iobase + DWIO_RAP, bcrnr);
+ io.outPortDword(iobase + DWIO_BDP, value);
+ }
}
Modified: trunk/net/src/driver/org/jnode/driver/net/lance/Descriptor.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/lance/Descriptor.java 2008-05-30 12:21:53 UTC (rev 4154)
+++ trunk/net/src/driver/org/jnode/driver/net/lance/Descriptor.java 2008-05-30 12:27:50 UTC (rev 4155)
@@ -18,7 +18,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.net.lance;
import org.apache.log4j.Logger;
@@ -27,80 +27,72 @@
/**
* @author Chris Cole
- *
*/
public class Descriptor {
- static final public int MESSAGE_DESCRIPTOR_SIZE = 0x10;
+ static final public int MESSAGE_DESCRIPTOR_SIZE = 0x10;
+ static final public int STATUS = 0x06;
+ static final public int STATUS_OWN = 0x8000;
+ static final public int STATUS_ERR = 0x4000;
+ static final public int STATUS_STP = 0x0200;
+ static final public int STATUS_ENP = 0x0100;
+ static final public int STATUS_BPE = 0x0080;
+ static final public int BCNT = 0x08;
- static final public int STATUS = 0x06;
+ protected final MemoryResource mem;
- static final public int STATUS_OWN = 0x8000;
+ protected final int offset;
- static final public int STATUS_ERR = 0x4000;
+ protected final int dataBufferOffset;
- static final public int STATUS_STP = 0x0200;
+ protected byte[] data;
- static final public int STATUS_ENP = 0x0100;
+ public Descriptor(MemoryResource mem, int offset, int dataBufferOffset) {
- static final public int STATUS_BPE = 0x0080;
+ this.mem = mem;
+ this.offset = offset;
+ this.dataBufferOffset = dataBufferOffset;
- static final public int BCNT = 0x08;
+ data = new byte[BufferManager.DATA_BUFFER_SIZE];
- protected final MemoryResource mem;
+ // final int buffAddress =
+ // Address.as32bit(Address.addressOfArrayData(data));
+ // Set the address
+ final int buffAddress = mem.getAddress().add(dataBufferOffset).toInt();
+ mem.setInt(offset + 0x00, buffAddress);
+ mem.setShort(offset + 0x04, (short) (-BufferManager.DATA_BUFFER_SIZE));
+ mem.setShort(offset + STATUS, (short) 0);
+ mem.setInt(offset + 0x08, 0);
+ mem.setInt(offset + 0x0C, 0);
+ }
- protected final int offset;
+ public boolean isOwnerSelf() {
+ return ((STATUS_OWN & mem.getShort(offset + STATUS)) == 0);
+ }
- protected final int dataBufferOffset;
+ public void setOwnerSelf(boolean self) {
+ if (self) {
+ mem.setShort(offset + STATUS, (short) (0x7FFF & mem.getShort(offset
+ + STATUS)));
+ } else {
+ mem.setShort(offset + STATUS, (short) (STATUS_OWN | mem
+ .getShort(offset + STATUS)));
+ }
+ }
- protected byte[] data;
+ public short getStatus() {
+ return mem.getShort(offset + STATUS);
+ }
- public Descriptor(MemoryResource mem, int offset, int dataBufferOffset) {
+ public void setStatus(short status) {
+ mem.setShort(offset + STATUS, status);
+ }
- this.mem = mem;
- this.offset = offset;
- this.dataBufferOffset = dataBufferOffset;
-
- data = new byte[BufferManager.DATA_BUFFER_SIZE];
-
- // final int buffAddress =
- // Address.as32bit(Address.addressOfArrayData(data));
- // Set the address
- final int buffAddress = mem.getAddress().add(dataBufferOffset).toInt();
- mem.setInt(offset + 0x00, buffAddress);
- mem.setShort(offset + 0x04, (short) (-BufferManager.DATA_BUFFER_SIZE));
- mem.setShort(offset + STATUS, (short) 0);
- mem.setInt(offset + 0x08, 0);
- mem.setInt(offset + 0x0C, 0);
- }
-
- public boolean isOwnerSelf() {
- return ((STATUS_OWN & mem.getShort(offset + STATUS)) == 0);
- }
-
- public void setOwnerSelf(boolean self) {
- if (self) {
- mem.setShort(offset + STATUS, (short) (0x7FFF & mem.getShort(offset
- + STATUS)));
- } else {
- mem.setShort(offset + STATUS, (short) (STATUS_OWN | mem
- .getShort(offset + STATUS)));
- }
- }
-
- public short getStatus() {
- return mem.getShort(offset + STATUS);
- }
-
- public void setStatus(short status) {
- mem.setShort(offset + STATUS, status);
- }
-
- public void dumpData(Logger out) {
- for (int i = 0; i <= MESSAGE_DESCRIPTOR_SIZE - 1; i += 4) {
- out.debug("0x"
- + NumberUtils.hex(mem.getAddress().toInt()
- + offset + i) + " : 0x" + NumberUtils.hex((byte) i)
- + " : 0x" + NumberUtils.hex(mem.getInt(offset + i)));
- }
- }
+ public void dumpData(Logger out) {
+ for (int i = 0; i <= MESSAGE_DESCRIPTOR_SIZE - 1; i += 4) {
+ out.debug("0x"
+ + NumberUtils.hex(mem.getAddress().toInt()
+ + offset + i) + " : 0x" + NumberUtils.hex((byte) i)
+ + " : 0x" + NumberUtils.hex(mem.getInt(offset + i)));
+ }
+ }
}
Modified: trunk/net/src/driver/org/jnode/driver/net/lance/DescriptorRing.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/lance/DescriptorRing.java 2008-05-30 12:21:53 UTC (rev 4154)
+++ trunk/net/src/driver/org/jnode/driver/net/lance/DescriptorRing.java 2008-05-30 12:27:50 UTC (rev 4155)
@@ -18,37 +18,36 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.net.lance;
import org.jnode.system.MemoryResource;
/**
* @author Chris Cole
- *
*/
public class DescriptorRing {
- protected final MemoryResource mem;
- protected final int offset;
- protected final int length;
- protected int currentDescriptor;
-
- public DescriptorRing(MemoryResource mem, int offset, int length) {
- this.mem = mem;
- this.offset = offset;
- this.length = length;
- }
-
- public int getSize() {
- return length * Descriptor.MESSAGE_DESCRIPTOR_SIZE;
- }
-
- public int getLength() {
- return length;
- }
-
- public int getAddressAs32() {
- return mem.getAddress().add(offset).toInt();
- }
+ protected final MemoryResource mem;
+ protected final int offset;
+ protected final int length;
+ protected int currentDescriptor;
+ public DescriptorRing(MemoryResource mem, int offset, int length) {
+ this.mem = mem;
+ this.offset = offset;
+ this.length = length;
+ }
+
+ public int getSize() {
+ return length * Descriptor.MESSAGE_DESCRIPTOR_SIZE;
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public int getAddressAs32() {
+ return mem.getAddress().add(offset).toInt();
+ }
+
}
Modified: trunk/net/src/driver/org/jnode/driver/net/lance/IOAccess.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/lance/IOAccess.java 2008-05-30 12:21:53 UTC (rev 4154)
+++ trunk/net/src/driver/org/jnode/driver/net/lance/IOAccess.java 2008-05-30 12:27:50 UTC (rev 4155)
@@ -18,59 +18,57 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.net.lance;
import org.jnode.system.IOResource;
/**
* @author Chris Cole
- *
*/
public abstract class IOAccess {
- protected IOResource io;
- protected int iobase;
-
- public IOAccess(IOResource io, int iobase) {
- this.io = io;
- this.iobase = iobase;
- }
-
- public abstract String getType();
+ protected IOResource io;
+ protected int iobase;
- /**
- * Reset the device.
- *
- */
- public abstract void reset();
+ public IOAccess(IOResource io, int iobase) {
+ this.io = io;
+ this.iobase = iobase;
+ }
- /**
- * Gets the contents of a Control and Status Register.
- *
- * @param csrnr
- */
- public abstract int getCSR(int csrnr);
+ public abstract String getType();
- /**
- * Sets the contents of a Control and Status Register.
- *
- * @param csrnr
- */
- public abstract void setCSR(int csrnr, int value);
+ /**
+ * Reset the device.
+ */
+ public abstract void reset();
- /**
- * Gets the contents of a Bus Configuration Register.
- *
- * @param bcrnr
- */
- public abstract int getBCR(int bcrnr);
+ /**
+ * Gets the contents of a Control and Status Register.
+ *
+ * @param csrnr
+ */
+ public abstract int getCSR(int csrnr);
- /**
- * Sets the contents of a Bus Configuration Register.
- *
- * @param bcrnr
- * @param value
- */
+ /**
+ * Sets the contents of a Control and Status Register.
+ *
+ * @param csrnr
+ */
+ public abstract void setCSR(int csrnr, int value);
+
+ /**
+ * Gets the contents of a Bus Configuration Register.
+ *
+ * @param bcrnr
+ */
+ public abstract int getBCR(int bcrnr);
+
+ /**
+ * Sets the contents of a Bus Configuration Register.
+ *
+ * @param bcrnr
+ * @param value
+ */
public abstract void setBCR(int bcrnr, int value);
}
Modified: trunk/net/src/driver/org/jnode/driver/net/lance/InitializationBlock32Bit.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/lance/InitializationBlock32Bit.java 2008-05-30 12:21:53 UTC (rev 4154)
+++ trunk/net/src/driver/org/jnode/driver/net/lance/InitializationBlock32Bit.java 2008-05-30 12:27:50 UTC (rev 4155)
@@ -18,7 +18,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.net.lance;
import org.apache.log4j.Logger;
@@ -28,62 +28,61 @@
/**
* @author Chris Cole
- *
*/
public class InitializationBlock32Bit {
- static public final int INIT_BLOCK_SIZE = 0x1C;
+ static public final int INIT_BLOCK_SIZE = 0x1C;
- private MemoryResource mem;
- private int offset;
+ private MemoryResource mem;
+ private int offset;
- public InitializationBlock32Bit(
- MemoryResource mem,
- int offset,
- short mode,
- EthernetAddress physicalAddr,
- long logicalAddr,
- RxDescriptorRing rxRing,
- TxDescriptorRing txRing) {
+ public InitializationBlock32Bit(
+ MemoryResource mem,
+ int offset,
+ short mode,
+ EthernetAddress physicalAddr,
+ long logicalAddr,
+ RxDescriptorRing rxRing,
+ TxDescriptorRing txRing) {
- this.mem = mem;
- this.offset = offset;
+ this.mem = mem;
+ this.offset = offset;
- // Populate the initial data structure
- mem.setShort(offset + 0x00, mode);
- mem.setByte(offset + 0x02, getEncodedRingLength(rxRing.getLength()));
- mem.setByte(offset + 0x03, getEncodedRingLength(txRing.getLength()));
- mem.setByte(offset + 0x04, physicalAddr.get(0));
- mem.setByte(offset + 0x05, physicalAddr.get(1));
- mem.setByte(offset + 0x06, physicalAddr.get(2));
- mem.setByte(offset + 0x07, physicalAddr.get(3));
- mem.setByte(offset + 0x08, physicalAddr.get(4));
- mem.setByte(offset + 0x09, physicalAddr.get(5));
- mem.setInt(offset + 0x0C, (int) (logicalAddr & 0xFFFFFFFF));
- mem.setInt(offset + 0x10, (int) ((logicalAddr >> 32) & 0xFFFFFFFF));
- mem.setInt(offset + 0x14, rxRing.getAddressAs32());
- mem.setInt(offset + 0x18, txRing.getAddressAs32());
- }
+ // Populate the initial data structure
+ mem.setShort(offset + 0x00, mode);
+ mem.setByte(offset + 0x02, getEncodedRingLength(rxRing.getLength()));
+ mem.setByte(offset + 0x03, getEncodedRingLength(txRing.getLength()));
+ mem.setByte(offset + 0x04, physicalAddr.get(0));
+ mem.setByte(offset + 0x05, physicalAddr.get(1));
+ mem.setByte(offset + 0x06, physicalAddr.get(2));
+ mem.setByte(offset + 0x07, physicalAddr.get(3));
+ mem.setByte(offset + 0x08, physicalAddr.get(4));
+ mem.setByte(offset + 0x09, physicalAddr.get(5));
+ mem.setInt(offset + 0x0C, (int) (logicalAddr & 0xFFFFFFFF));
+ mem.setInt(offset + 0x10, (int) ((logicalAddr >> 32) & 0xFFFFFFFF));
+ mem.setInt(offset + 0x14, rxRing.getAddressAs32());
+ mem.setInt(offset + 0x18, txRing.getAddressAs32());
+ }
- private byte getEncodedRingLength(int ringLength) {
- byte encoded = 0;
- while (ringLength != 1) {
- ringLength = ringLength >> 1;
- encoded += 1;
- }
- return (byte) (encoded << 4);
- }
+ private byte getEncodedRingLength(int ringLength) {
+ byte encoded = 0;
+ while (ringLength != 1) {
+ ringLength = ringLength >> 1;
+ encoded += 1;
+ }
+ return (byte) (encoded << 4);
+ }
- public void dumpData(Logger out) {
- out.debug("Intialization Block - 32 bit mode");
- for (int i = 0; i <= INIT_BLOCK_SIZE - 1; i += 4) {
- out.debug(
- "0x"
- + NumberUtils.hex(
- mem.getAddress().toInt() + offset + i)
- + " : 0x"
- + NumberUtils.hex((byte) i)
- + " : 0x"
- + NumberUtils.hex(mem.getInt(offset + i)));
- }
- }
+ public void dumpData(Logger out) {
+ out.debug("Intialization Block - 32 bit mode");
+ for (int i = 0; i <= INIT_BLOCK_SIZE - 1; i += 4) {
+ out.debug(
+ "0x"
+ + NumberUtils.hex(
+ mem.getAddress().toInt() + offset + i)
+ + " : 0x"
+ + NumberUtils.hex((byte) i)
+ + " : 0x"
+ + NumberUtils.hex(mem.getInt(offset + i)));
+ }
+ }
}
Modified: trunk/net/src/driver/org/jnode/driver/net/lance/LanceConstants.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/lance/LanceConstants.java 2008-05-30 12:21:53 UTC (rev 4154)
+++ trunk/net/src/driver/org/jnode/driver/net/lance/LanceConstants.java 2008-05-30 12:27:50 UTC (rev 4155)
@@ -18,7 +18,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.net.lance;
/**
@@ -26,107 +26,107 @@
*/
public interface LanceConstants {
- // Word I/O port offsets from iobase.
- public static final int R_ETH_ADDR_OFFSET = 0x00;
- public static final int WIO_RDP = 0x10; // Register data (RDP)
- public static final int WIO_RAP = 0x12; // RAP
- public static final int WIO_RESET = 0x14; // RESET
- public static final int WIO_BDP = 0x16; // Bus data (BDP)
+ // Word I/O port offsets from iobase.
+ public static final int R_ETH_ADDR_OFFSET = 0x00;
+ public static final int WIO_RDP = 0x10; // Register data (RDP)
+ public static final int WIO_RAP = 0x12; // RAP
+ public static final int WIO_RESET = 0x14; // RESET
+ public static final int WIO_BDP = 0x16; // Bus data (BDP)
- // Double Word I/O port offsets from iobase.
- public static final int DWIO_RDP = 0x10; // Register data (RDP)
- public static final int DWIO_RAP = 0x14; // RAP
- public static final int DWIO_RESET = 0x18; // RESET
- public static final int DWIO_BDP = 0x1c; // Bus data (BDP)
+ // Double Word I/O port offsets from iobase.
+ public static final int DWIO_RDP = 0x10; // Register data (RDP)
+ public static final int DWIO_RAP = 0x14; // RAP
+ public static final int DWIO_RESET = 0x18; // RESET
+ public static final int DWIO_BDP = 0x1c; // Bus data (BDP)
- // CSR0 bits
- public static final int CSR0_INIT = 0x0001;
- public static final int CSR0_STRT = 0x0002;
- public static final int CSR0_STOP = 0x0004;
- public static final int CSR0_TDMD = 0x0008;
- public static final int CSR0_TXON = 0x0010;
- public static final int CSR0_RXON = 0x0020;
- public static final int CSR0_IENA = 0x0040;
- public static final int CSR0_INTR = 0x0080;
- public static final int CSR0_IDON = 0x0100;
- public static final int CSR0_TINT = 0x0200;
- public static final int CSR0_RINT = 0x0400;
- public static final int CSR0_MERR = 0x0800;
- public static final int CSR0_MISS = 0x1000;
- public static final int CSR0_CERR = 0x2000;
- public static final int CSR0_BABL = 0x4000;
- public static final int CSR0_ERR = 0x8000;
+ // CSR0 bits
+ public static final int CSR0_INIT = 0x0001;
+ public static final int CSR0_STRT = 0x0002;
+ public static final int CSR0_STOP = 0x0004;
+ public static final int CSR0_TDMD = 0x0008;
+ public static final int CSR0_TXON = 0x0010;
+ public static final int CSR0_RXON = 0x0020;
+ public static final int CSR0_IENA = 0x0040;
+ public static final int CSR0_INTR = 0x0080;
+ public static final int CSR0_IDON = 0x0100;
+ public static final int CSR0_TINT = 0x0200;
+ public static final int CSR0_RINT = 0x0400;
+ public static final int CSR0_MERR = 0x0800;
+ public static final int CSR0_MISS = 0x1000;
+ public static final int CSR0_CERR = 0x2000;
+ public static final int CSR0_BABL = 0x4000;
+ public static final int CSR0_ERR = 0x8000;
- // CSR3 bits
- public static final int CSR3_BSWP = 0x0004;
- public static final int CSR3_EMBA = 0x0008;
- public static final int CSR3_DXMT2PD = 0x0010;
- public static final int CSR3_LAPPEN = 0x0020;
- public static final int CSR3_DXSUFLO = 0x0040;
- public static final int CSR3_IDONM = 0x0100;
- public static final int CSR3_TINTM = 0x0200;
- public static final int CSR3_RINTM = 0x0400;
- public static final int CSR3_MERRM = 0x0800;
- public static final int CSR3_MISSM = 0x1000;
- public static final int CSR3_BABLM = 0x4000;
+ // CSR3 bits
+ public static final int CSR3_BSWP = 0x0004;
+ public static final int CSR3_EMBA = 0x0008;
+ public static final int CSR3_DXMT2PD = 0x0010;
+ public static final int CSR3_LAPPEN = 0x0020;
+ public static final int CSR3_DXSUFLO = 0x0040;
+ public static final int CSR3_IDONM = 0x0100;
+ public static final int CSR3_TINTM = 0x0200;
+ public static final int CSR3_RINTM = 0x0400;
+ public static final int CSR3_MERRM = 0x0800;
+ public static final int CSR3_MISSM = 0x1000;
+ public static final int CSR3_BABLM = 0x4000;
- // CSR4 bits
- public static final int CSR4_JABM = 0x0001;
- public static final int CSR4_JAB = 0x0002;
- public static final int CSR4_TXSTRTM = 0x0004;
- public static final int CSR4_TXSTRT = 0x0008;
- public static final int CSR4_RCVCCOM = 0x0010;
- public static final int CSR4_RCVCCO = 0x0020;
- public static final int CSR4_UINT = 0x0040;
- public static final int CSR4_UINTCMD = 0x0080;
- public static final int CSR4_MFCOM = 0x0100;
- public static final int CSR4_MFCO = 0x0200;
- public static final int CSR4_ASTRP_RCV = 0x0400;
- public static final int CSR4_APAD_XMT = 0x0800;
- public static final int CSR4_DPOLL = 0x1000;
- public static final int CSR4_TIMER = 0x2000;
- public static final int CSR4_DMAPLUS = 0x4000;
- public static final int CSR4_EN124 = 0x8000;
+ // CSR4 bits
+ public static final int CSR4_JABM = 0x0001;
+ public static final int CSR4_JAB = 0x0002;
+ public static final int CSR4_TXSTRTM = 0x0004;
+ public static final int CSR4_TXSTRT = 0x0008;
+ public static final int CSR4_RCVCCOM = 0x0010;
+ public static final int CSR4_RCVCCO = 0x0020;
+ public static final int CSR4_UINT = 0x0040;
+ public static final int CSR4_UINTCMD = 0x0080;
+ public static final int CSR4_MFCOM = 0x0100;
+ public static final int CSR4_MFCO = 0x0200;
+ public static final int CSR4_ASTRP_RCV = 0x0400;
+ public static final int CSR4_APAD_XMT = 0x0800;
+ public static final int CSR4_DPOLL = 0x1000;
+ public static final int CSR4_TIMER = 0x2000;
+ public static final int CSR4_DMAPLUS = 0x4000;
+ public static final int CSR4_EN124 = 0x8000;
- // CSR5 bits
- public static final int CSR5_SPND = 0x0001;
- public static final int CSR5_MPMODE = 0x0002;
- public static final int CSR5_MPEN = 0x0004;
- public static final int CSR5_MPINTE = 0x0008;
- public static final int CSR5_MPINT = 0x0010;
- public static final int CSR5_MPPLBA = 0x0020;
- public static final int CSR5_EXDINTE = 0x0040;
- public static final int CSR5_EXDINT = 0x0080;
- public static final int CSR5_SLPINTE = 0x0100;
- public static final int CSR5_SLPINT = 0x0200;
- public static final int CSR5_SINTE = 0x0400;
- public static final int CSR5_SINT = 0x0800;
- //public static final int CSR5_RES = 0x1000;
- //public static final int CSR5_RES = 0x2000;
- public static final int CSR5_LTINTEN = 0x4000;
- public static final int CSR5_TOKINTD = 0x8000;
+ // CSR5 bits
+ public static final int CSR5_SPND = 0x0001;
+ public static final int CSR5_MPMODE = 0x0002;
+ public static final int CSR5_MPEN = 0x0004;
+ public static final int CSR5_MPINTE = 0x0008;
+ public static final int CSR5_MPINT = 0x0010;
+ public static final int CSR5_MPPLBA = 0x0020;
+ public static final int CSR5_EXDINTE = 0x0040;
+ public static final int CSR5_EXDINT = 0x0080;
+ public static final int CSR5_SLPINTE = 0x0100;
+ public static final int CSR5_SLPINT = 0x0200;
+ public static final int CSR5_SINTE = 0x0400;
+ public static final int CSR5_SINT = 0x0800;
+ //public static final int CSR5_RES = 0x1000;
+ //public static final int CSR5_RES = 0x2000;
+ public static final int CSR5_LTINTEN = 0x4000;
+ public static final int CSR5_TOKINTD = 0x8000;
- // CSR15 bits
- public static final int CSR15_DRX = 0x0001;
- public static final int CSR15_DTX = 0x0002;
- public static final int CSR15_LOOP = 0x0004;
- public static final int CSR15_DXMTFCS = 0x0008;
- public static final int CSR15_FCOLL = 0x0010;
- public static final int CSR15_DRTY = 0x0020;
- public static final int CSR15_INTL = 0x0040;
- public static final int CSR15_PROM = 0x8000;
+ // CSR15 bits
+ public static final int CSR15_DRX = 0x0001;
+ public static final int CSR15_DTX = 0x0002;
+ public static final int CSR15_LOOP = 0x0004;
+ public static final int CSR15_DXMTFCS = 0x0008;
+ public static final int CSR15_FCOLL = 0x0010;
+ public static final int CSR15_DRTY = 0x0020;
+ public static final int CSR15_INTL = 0x0040;
+ public static final int CSR15_PROM = 0x8000;
- // BCR2 bits
- public static final int BCR2_XMAUSEL = 0x0001;
- public static final int BCR2_ASEL = 0x0002;
- public static final int BCR2_AWAKE = 0x0004;
- public static final int BCR2_EADISEL = 0x0008;
- public static final int BCR2_DXCVRPOL = 0x0010;
- public static final int BCR2_DXCVRCTL = 0x0020;
- public static final int BCR2_INTLEVEL = 0x0080;
- public static final int BCR2_APROMWE = 0x0100;
- public static final int BCR2_TMAULOOP = 0x4000;
-
- // BCR9 bits
- public static final int BCR9_FDEN = 0x0001;
+ // BCR2 bits
+ public static final int BCR2_XMAUSEL = 0x0001;
+ public static final int BCR2_ASEL = 0x0002;
+ public static final int BCR2_AWAKE = 0x0004;
+ public static final int BCR2_EADISEL = 0x0008;
+ public static final int BCR2_DXCVRPOL = 0x0010;
+ public static final int BCR2_DXCVRCTL = 0x0020;
+ public static final int BCR2_INTLEVEL = 0x0080;
+ public static final int BCR2_APROMWE = 0x0100;
+ public static final int BCR2_TMAULOOP = 0x4000;
+
+ // BCR9 bits
+ public static final int BCR9_FDEN = 0x0001;
}
Modified: trunk/net/src/driver/org/jnode/driver/net/lance/LanceCore.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/lance/LanceCore.java 2008-05-30 12:21:53 UTC (rev 4154)
+++ trunk/net/src/driver/org/jnode/driver/net/lance/LanceCore.java 2008-05-30 12:27:50 UTC (rev 4155)
@@ -18,7 +18,7 @@
* along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.net.lance;
import java.security.PrivilegedExceptionAction;
@@ -50,459 +50,473 @@
/**
* This is the DeviceCore for LANCE and PCnet 32 compatable ethernet PCI drivers.
- *
- * The current implementation was specificaly designed for the AMD PCnet-PCI II
+ * <p/>
+ * The current implementation was specificaly designed for the AMD PCnet-PCI II
* Ethernet Controller (Am79C970A), but should work for other AMD PCnet PCI devices.
* The driver is based on information in the following specification from AMD.
* http://www.amd.com/files/connectivitysolutions/networking/archivednetworking/19436.pdf
- *
+ * <p/>
* Specificaly the following assumptions were made:
* - Device supports Software Style 2 (PCnet-PCI) which defines the layout of the initialaztion
- * block and the descriptor rings.
- *
+ * block and the descriptor rings.
+ * <p/>
* Note: It should be easy to expand this driver to remove these assuptions.
- *
+ *
* @author Chirs Cole
*/
public class LanceCore
- extends AbstractDeviceCore
- implements IRQHandler, LanceConstants, EthernetConstants {
+ extends AbstractDeviceCore
+ implements IRQHandler, LanceConstants, EthernetConstants {
- // This is the number of descriptors for the receive and transmit rings
- // Note: Valid numbers are 2^x where x is 0..8 (1, 2, 4, 8, 16, .., 512)
- private static final int RX_DESCRIPTOR_LENGTH = 4;
- private static final int TX_DESCRIPTOR_LENGTH = 4;
+ // This is the number of descriptors for the receive and transmit rings
+ // Note: Valid numbers are 2^x where x is 0..8 (1, 2, 4, 8, 16, .., 512)
+ private static final int RX_DESCRIPTOR_LENGTH = 4;
+ private static final int TX_DESCRIPTOR_LENGTH = 4;
- /** Device Driver */
- private final LanceDriver driver;
- /** Start of IO address space */
- private final int iobase;
- /** IO address space resource */
- private final IOResource ioResource;
- private final IOAccess io;
- /** IRQ resource */
- private final IRQResource irq;
- /** My ethernet address */
- private EthernetAddress hwAddress;
- /** Flags for the specific device found */
- private final LanceFlags flags;
- /** Manager for receive and transmit rings as well as data buffers */
- private final BufferManager bufferManager;
+ /**
+ * Device Driver
+ */
+ private final LanceDriver driver;
+ /**
+ * Start of IO address space
+ */
+ private final int iobase;
+ /**
+ * IO address space resource
+ */
+ private final IOResource ioResource;
+ private final IOAccess io;
+ /**
+ * IRQ resource
+ */
+ private final IRQResource irq;
+ /**
+ * My ethernet address
+ */
+ private EthernetAddress hwAddress;
+ /**
+ * Flags for the specific device found
+ */
+ private final LanceFlags flags;
+ /**
+ * Manager for receive and transmit rings as well as data buffers
+ */
+ private final BufferManager bufferManager;
- /**
- * Create a new instance and allocate all resources
- *
- * @throws ResourceNotFreeException
- */
- public LanceCore(
- LanceDriver driver,
- ResourceOwner owner,
- PCIDevice device,
- Flags flags)
- throws ResourceNotFreeException, DriverException {
+ /**
+ * Create a new instance and allocate all resources
+ *
+ * @throws ResourceNotFreeException
+ */
+ public LanceCore(
+ LanceDriver driver,
+ ResourceOwner owner,
+ PCIDevice device,
+ Flags flags)
+ throws ResourceNotFreeException, DriverException {
- this.driver = driver;
- this.flags = (LanceFlags) flags;
+ this.driver = driver;
+ this.flags = (LanceFlags) flags;
final PCIHeaderType0 config = device.getConfig().asHeaderType0();
- final int irq = config.getInterruptLine();
+ final int irq = config.getInterruptLine();
- final PCIBaseAddress[] addrs = config.getBaseAddresses();
- if (addrs.length < 1) {
- throw new DriverException("Cannot find iobase: not base addresses");
- }
- if (!addrs[0].isIOSpace()) {
- throw new DriverException("Cannot find iobase: first address is not I/O");
- }
+ final PCIBaseAddress[] addrs = config.getBaseAddresses();
+ if (addrs.length < 1) {
+ throw new DriverException("Cannot find iobase: not base addresses");
+ }
+ if (!addrs[0].isIOSpace()) {
+ throw new DriverException("Cannot find iobase: first address is not I/O");
+ }
- // Get the start of the IO address space
- iobase = addrs[0].getIOBase();
- final int iolength = addrs[0].getSize();
- log.debug(
- "Found Lance IOBase: 0x"
- + NumberUtils.hex(iobase)
- + ", length: "
- + iolength);
- ResourceManager rm;
- try {
- rm = (ResourceManager) InitialNaming.lookup(ResourceManager.NAME);
- } catch (NameNotFoundException ex) {
- throw new DriverException("Cannot find ResourceManager");
- }
- this.irq = rm.claimIRQ(owner, irq, this, true);
- try {
- ioResource = claimPorts(rm, owner, iobase, iolength);
- } catch (ResourceNotFreeException ex) {
- this.irq.release();
- throw ex;
- }
+ // Get the start of the IO address space
+ iobase = addrs[0].getIOBase();
+ final int iolength = addrs[0].getSize();
+ log.debug(
+ "Found Lance IOBase: 0x"
+ + NumberUtils.hex(iobase)
+ + ", length: "
+ + iolength);
+ ResourceManager rm;
+ try {
+ rm = (ResourceManager) InitialNaming.lookup(ResourceManager.NAME);
+ } catch (NameNotFoundException ex) {
+ throw new DriverException("Cannot find ResourceManager");
+ }
+ this.irq = rm.claimIRQ(owner, irq, this, true);
+ try {
+ ioResource = claimPorts(rm, owner, iobase, iolength);
+ } catch (ResourceNotFreeException ex) {
+ this.irq.release();
+ throw ex;
+ }
- // Determine the type of IO access (Word or DWord)
- io = getIOAccess();
- log.debug("IO Access set to " + io.getType());
+ // Determine the type of IO access (Word or DWord)
+ io = getIOAccess();
+ log.debug("IO Access set to " + io.getType());
- // Set the flags based on the version of the device found
- setFlags();
+ // Set the flags based on the version of the device found
+ setFlags();
- // Load the hw address
- this.hwAddress = loadHWAddress();
+ // Load the hw address
+ this.hwAddress = loadHWAddress();
- log.info(
- "Found "
- + this.flags.getChipName()
- + " at 0x"
- + NumberUtils.hex(iobase, 4)
- + " with MAC Address "
- + hwAddress);
+ log.info(
+ "Found "
+ + this.flags.getChipName()
+ + " at 0x"
+ + NumberUtils.hex(iobase, 4)
+ + " with MAC Address "
+ + hwAddress);
- // Create rx & tx descriptor rings, initdata and databuffers
- this.bufferManager =
- new BufferManager(
- RX_DESCRIPTOR_LENGTH,
- TX_DESCRIPTOR_LENGTH,
- CSR15_DRX | CSR15_DTX,
- hwAddress,
- 0,
- rm,
- owner);
+ // Create rx & tx descriptor rings, initdata and databuffers
+ this.bufferManager =
+ new BufferManager(
+ RX_DESCRIPTOR_LENGTH,
+ TX_DESCRIPTOR_LENGTH,
+ CSR15_DRX | CSR15_DTX,
+ hwAddress,
+ 0,
+ rm,
+ owner);
- // Enable device to become a bus master on the PCI bus.
+ // Enable device to become a bus master on the PCI bus.
config.setCommand(config.getCommand() | PCIConstants.PCI_COMMAND_MASTER);
- }
+ }
- private IOAccess getIOAccess() {
- // reset
- ioResource.inPortWord(iobase + WIO_RESET);
- ioResource.outPortWord(iobase + WIO_RAP, 0);
- if (ioResource.inPortWord(iobase + WIO_RDP) == 4) {
- ioResource.outPortWord(iobase + WIO_RAP, 88);
- if (ioResource.inPortWord(iobase + WIO_RAP) == 88) {
- return new WordIOAccess(ioResource, iobase);
- }
- }
+ private IOAccess getIOAccess() {
+ // reset
+ ioResource.inPortWord(iobase + WIO_RESET);
+ ioResource.outPortWord(iobase + WIO_RAP, 0);
+ if (ioResource.inPortWord(iobase + WIO_RDP) == 4) {
+ ioResource.outPortWord(iobase + WIO_RAP, 88);
+ if (ioResource.inPortWord(iobase + WIO_RAP) == 88) {
+ return new WordIOAccess(ioResource, iobase);
+ }
+ }
- ioResource.inPortDword(iobase + DWIO_RESET);
- ioResource.outPortDword(iobase + DWIO_RAP, 0);
- if (ioResource.inPortDword(iobase + DWIO_RDP) == 4) {
- ioResource.outPortDword(iobase + DWIO_RAP, 88);
- if ((ioResource.inPortDword(iobase + DWIO_RAP) & 0xFFFF) == 88) {
- return new DWordIOAccess(ioResource, iobase);
- }
- }
- return null;
- }
+ ioResource.inPortDword(iobase + DWIO_RESET);
+ ioResource.outPortDword(iobase + DWIO_RAP, 0);
+ if (ioResource.inPortDword(iobase + DWIO_RDP) == 4) {
+ ioResource.outPortDword(iobase + DWIO_RAP, 88);
+ if ((ioResource.inPortDword(iobase + DWIO_RAP) & 0xFFFF) == 88) {
+ return new DWordIOAccess(ioResource, iobase);
+ }
+ }
+ return null;
+ }
- /**
- * Initialize this device.
- */
- public void initialize() {
- // reset the chip
- io.reset();
+ /**
+ * Initialize this device.
+ */
+ public void initialize() {
+ // reset the chip
+ io.reset();
- // Set the Software Style to mode 2 (PCnet-PCI)
- // Note: this may not be compatable with older lance controllers (non PCnet)
- io.setBCR(20, 2);
+ // Set the Software Style to mode 2 (PCnet-PCI)
+ // Note: this may not be compatable with older lance controllers (non PCnet)
+ io.setBCR(20, 2);
- // TODO the device should be setup based on the flags for the chip version
- // Auto select port
- io.setBCR(2, BCR2_ASEL);
- // Enable full duplex
- io.setBCR(9, BCR9_FDEN);
- io.setCSR(4, CSR4_DMAPLUS | CSR4_APAD_XMT);
- io.setCSR(
- 5,
- CSR5_LTINTEN
- | CSR5_SINTE
- | CSR5_SLPINTE
- | CSR5_EXDINTE
- | CSR5_MPINTE);
+ // TODO the device should be setup based on the flags for the chip version
+ // Auto select port
+ io.setBCR(2, BCR2_ASEL);
+ // Enable full duplex
+ io.setBCR(9, BCR9_FDEN);
+ io.setCSR(4, CSR4_DMAPLUS | CSR4_APAD_XMT);
+ io.setCSR(
+ 5,
+ CSR5_LTINTEN
+ | CSR5_SINTE
+ | CSR5_SLPINTE
+ | CSR5_EXDINTE
+ | CSR5_MPINTE);
- // Set the address of the Initialization Block
- final int iaddr = bufferManager.getInitDataAddressAs32Bit();
- io.setCSR(1, iaddr & 0xFFFF);
- io.setCSR(2, (iaddr >> 16) & 0xFFFF);
+ // Set the address of the Initialization Block
+ final int iaddr = bufferManager.getInitDataAddressAs32Bit();
+ io.setCSR(1, iaddr & 0xFFFF);
+ io.setCSR(2, (iaddr >> 16) & 0xFFFF);
- // Initialize the device with the Initialization Block and enable interrupts
- io.setCSR(0, CSR0_INIT | CSR0_IENA);
- }
+ // Initialize the device with the Initialization Block and enable interrupts
+ io.setCSR(0, CSR0_INIT | CSR0_IENA);
+ }
- /**
- * Disable this device
- *
- */
- public void disable() {
- io.reset();
- io.setCSR(0, CSR0_STOP);
- }
+ /**
+ * Disable this device
+ */
+ public void disable() {
+ io.reset();
+ io.setCSR(0, CSR0_STOP);
+ }
- /**
- * Release all resources
- */
- public void release() {
- ioResource.release();
- irq.release();
- }
+ /**
+ * Release all resources
+ */
+ public void release() {
+ ioResource.release();
+ irq.release();
+ }
- /**
- * Gets the hardware address of this card.
- */
- public HardwareAddress getHwAddress() {
- return hwAddress;
- }
+ /**
+ * Gets the hardware address of this card.
+ */
+ public HardwareAddress getHwAddress() {
+ return hwAddress;
+ }
- /**
- * Read the hardware address
- */
- private final EthernetAddress loadHWAddress() {
- final byte[] addr = new byte[ETH_ALEN];
- for (int i = 0; i < addr.length; i++) {
- addr[i] =
- (byte) ioResource.inPortByte(iobase + R_ETH_ADDR_OFFSET + i);
- }
- return new EthernetAddress(addr, 0);
- }
+ /**
+ * Read the hardware address
+ */
+ private final EthernetAddress loadHWAddress() {
+ final byte[] addr = new byte[ETH_ALEN];
+ for (int i = 0; i < addr.length; i++) {
+ addr[i] =
+ (byte) ioResource.inPortByte(iobase + R_ETH_ADDR_OFFSET + i);
+ }
+ return new EthernetAddress(addr, 0);
+ }
- private final void setFlags() {
- int chipVersion = io.getCSR(88) | (io.getCSR(89) << 16);
- chipVersion = (chipVersion >> 12) & 0xffff;
+ private final void setFlags() {
+ int chipVersion = io.getCSR(88) | (io.getCSR(89) << 16);
+ chipVersion = (chipVersion >> 12) & 0xffff;
- flags.setForVersion(chipVersion);
- }
+ flags.setForVersion(chipVersion);
+ }
- /**
- * Transmit the given buffer
- * @param buf
- * @param timeout
- * @throws InterruptedException
- * @throws TimeoutException
- */
- public synchronized void transmit(SocketBuffer buf, HardwareAddress destination, long timeout)
- throws InterruptedException, TimeoutException {
- // Set the source address
- hwAddress.writeTo(buf, 6);
+ /**
+ * Transmit the given buffer
+ *
+ * @param buf
+ * @param timeout
+ * @throws InterruptedException
+ * @throws TimeoutException
+ */
+ public synchronized void transmit(SocketBuffer buf, HardwareAddress destination, long timeout)
+ throws InterruptedException, TimeoutException {
+ // Set the source address
+ hwAddress.writeTo(buf, 6);
- // debug dump for investigating VWWare 3 network problems
- // dumpDebugInfo();
+ // debug dump for investigating VWWare 3 network problems
+ // dumpDebugInfo();
- // ask buffer manager to send out the data
- bufferManager.transmit(buf);
+ // ask buffer manager to send out the data
+ bufferManager.transmit(buf);
- // force the device to poll current transmit descriptor for new data
- io.setCSR(0, io.getCSR(0) | CSR0_TDMD);
- }
+ // force the device to poll current transmit descriptor for new data
+ io.setCSR(0, io.getCSR(0) | CSR0_TDMD);
+ }
- /**
- * @see org.jnode.system.IRQHandler#handleInterrupt(int)
- */
- public void handleInterrupt(int irq) {
- while ((io.getCSR(0) & CSR0_INTR) != 0) {
- final int csr0 = io.getCSR(0);
- final int csr4 = io.getCSR(4);
- final int csr5 = io.getCSR(5);
+ /**
+ * @see org.jnode.system.IRQHandler#handleInterrupt(int)
+ */
+ public void handleInterrupt(int irq) {
+ while ((io.getCSR(0) & CSR0_INTR) != 0) {
+ final int csr0 = io.getCSR(0);
+ final int csr4 = io.getCSR(4);
+ final int csr5 = io.getCSR(5);
- io.setCSR(0, csr0);
- io.setCSR(4, csr4);
- io.setCSR(5, csr5);
+ io.setCSR(0, csr0);
+ io.setCSR(4, csr4);
+ io.setCSR(5, csr5);
- // check if interrupt is due to Initialization Done
- if ((csr0 & CSR0_IDON) != 0) {
- log.info(flags.getChipName() + " Initialization Complete");
+ // check if interrupt is due to Initialization Done
+ if ((csr0 & CSR0_IDON) != 0) {
+ log.info(flags.getChipName() + " Initialization Complete");
- // Now enable RX/TX
- io.setCSR(15, 0);
+ // Now enable RX/TX
+ io.setCSR(15, 0);
- // assert the Start and clear Initialization Done (IDON) flag
- // Note: there are reported errors due to setting IDON here but I have not seen any
- io.setCSR(0, CSR0_STRT | CSR0_IENA | CSR0_IDON);
- }
+ // assert the Start and clear Initialization Done (IDON) flag
+ // Note: there are reported errors due to setting IDON here but I have not seen any
+ io.setCSR(0, CSR0_STRT | CSR0_IENA | CSR0_IDON);
+ }
- // check if interrupt is due to Transmition Interrupt
- if ((csr0 & CSR0_TINT) != 0) {
- //log.debug("Transmition Interrupt");
- }
+ // check if interrupt is due to Transmition Interrupt
+ if ((csr0 & CSR0_TINT) != 0) {
+ //log.debug("Transmition Interrupt");
+ }
- // check if interrupt is due to Receive Interrupt
- if ((csr0 & CSR0_RINT) != 0) {
- //log.debug("Receive Interrupt");
- rxProcess();
- }
+ // check if interrupt is due to Receive Interrupt
+ if ((csr0 & CSR0_RINT) != 0) {
+ //log.debug("Receive Interrupt");
+ rxProcess();
+ }
- // check if interrupt is due an error
- if ((csr0 & CSR0_ERR) != 0) {
- log.debug("Error Interrupt");
+ // check if interrupt is due an error
+ if ((csr0 & CSR0_ERR) != 0) {
+ log.debug("Error Interrupt");
- // check if interrupt is due to Memory Error
- if ((csr0 & CSR0_MERR) != 0) {
- log.debug("Memory Error");
- }
+ // check if interrupt is due to Memory Error
+ if ((csr0 & CSR0_MERR) != 0) {
+ log.debug("Memory Error");
+ }
- // check if interrupt is due to Missed Frame
- if ((csr0 & CSR0_MISS) != 0) {
- log.debug("Missed Frame");
- }
+ // check if interrupt is due to Missed Frame
+ if ((csr0 & CSR0_MISS) != 0) {
+ log.debug("Missed Frame");
+ }
- // check if interrupt is due to Collision Error
- if ((csr0 & CSR0_CERR) != 0) {
- log.debug("Collision Error");
- }
+ // check if interrupt is due to Collision Error
+ if ((csr0 & CSR0_CERR) != 0) {
+ log.debug("Collision Error");
+ }
- // check if interrupt is due to a Bable transmitter time-out
- if ((csr0 & CSR0_BABL) != 0) {
- log.debug("Bable transmitter time-out");
- }
- }
+ // check if interrupt is due to a Bable transmitter time-out
+ if ((csr0 & CSR0_BABL) != 0) {
+ log.debug("Bable transmitter time-out");
+ }
+ }
- // check if interrupt is due to a Missed Frame Counter Overflow
- if ((csr4 & CSR4_MFCO) == CSR4_MFCO) {
- log.debug("Missed Frame Counter Overflow");
- }
+ // check if interrupt is due to a Missed Frame Counter Overflow
+ if ((csr4 & CSR4_MFCO) == CSR4_MFCO) {
+ log.debug("Missed Frame Counter Overflow");
+ }
- // check if interrupt is due to a User Interrupt
- if ((csr4 & CSR4_UINT) == CSR4_UINT) {
- log.debug("User Interrupt");
- }
+ // check if interrupt is due to a User Interrupt
+ if ((csr4 & CSR4_UINT) == CSR4_UINT) {
+ log.debug("User Interrupt");
+ }
- // check if interrupt is due to a Receive Collision Counter Overflow
- if ((csr4 & CSR4_RCVCCO) == CSR4_RCVCCO) {
- log.debug("Receive Collision Counter Overflow");
- }
+ // check if interrupt is due to a Receive Collision Counter Overflow
+ if ((csr4 & CSR4_RCVCCO) == CSR4_RCVCCO) {
+ log.debug("Receive Collision Counter Overflow");
+ }
- // check if interrupt is due to a Transmit Start
- if ((csr4 & CSR4_TXSTRT) == CSR4_TXSTRT) {
- log.debug("Transmit Start");
- }
+ // check if interrupt is due to a Transmit Start
+ if ((csr4 & CSR4_TXSTRT) == CSR4_TXSTRT) {
+ log.debug("Transmit Start");
+ }
- // check if interrupt is due to a Jabber Error
- if ((csr4 & CSR4_JAB) == CSR4_JAB) {
- log.debug("Jabber Error");
- }
+ // check if interrupt is due to a Jabber Error
+ if ((csr4 & CSR4_JAB) == CSR4_JAB) {
+ log.debug("Jabber Error");
+ }
- // check if interrupt is due to a Jabber Error
- if ((csr4 & CSR4_JAB) == CSR4_JAB) {
- log.debug("Jabber Error");
- }
+ // check if interrupt is due to a Jabber Error
+ if ((csr4 & CSR4_JAB) == CSR4_JAB) {
+ log.debug("Jabber Error");
+ }
- // check if interrupt is due to a System Interrupt
- if ((csr5 & CSR5_SINT) == CSR5_SINT) {
- log.debug("System Interrupt");
- }
+ // check if interrupt is due to a System Interrupt
+ if ((csr5 & CSR5_SINT) == CSR5_SINT) {
+ log.debug("System Interrupt");
+ }
- // check if interrupt is due to a Sleep Interrupt
- if ((csr5 & CSR5_SLPINT) == CSR5_SLPINT) {
- log.debug("Sleep Interrupt");
- }
+ // check if interrupt is due to a Sleep Interrupt
+ if ((csr5 & CSR5_SLPINT) == CSR5_SLPINT) {
+ log.debug("Sleep Interrupt");
+ }
- // check if interrupt is due to a Excessive Deferral Interrupt
- if ((csr5 & CSR5_EXDINT) == CSR5_EXDINT) {
- log.debug("Excessive Deferral Interrupt");
- }
+ // check if interrupt is due to a Excessive Deferral Interrupt
+ if ((csr5 & CSR5_EXDINT) == CSR5_EXDINT) {
+ log.debug("Excessive Deferral Interrupt");
+ }
- // check if interrupt is due to a Magic Packet Interrupt
- if ((csr5 & CSR5_MPINT) == CSR5_MPINT) {
- log.debug("Magic Packet Interrupt");
- }
+ // check if interrupt is due to a Magic Packet Interrupt
+ if ((csr5 & CSR5_MPINT) == CSR5_MPINT) {
+ log.debug("Magic Packet Interrupt");
+ }
- }
- }
+ }
+ }
- private void rxProcess() {
- SocketBuffer skbuf;
+ private void rxProcess() {
+ SocketBuffer skbuf;
- while ((skbuf = bufferManager.getPacket()) != null) {
- try {
- if (skbuf != null)
- driver.onReceive(skbuf);
- } catch (NetworkException e) {
- e.printStackTrace();
- } finally {
- }
- }
- }
+ while ((skbuf = bufferManager.getPacket()) != null) {
+ try {
+ if (skbuf != null)
+ driver.onReceive(skbuf);
+ } catch (NetworkException e) {
+ e.printStackTrace();
+ } finally {
+ }
+ }
+ }
- private IOResource claimPorts(
- final ResourceManager rm,
- final ResourceOwner owner,
- final int low,
- final int length)
- throws ResourceNotFreeException, DriverException {
- try {
- return (
- IOResource) AccessControllerUtils
- .doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws ResourceNotFreeException {
- return rm.claimIOResource(owner, low, length);
- }
- });
- } catch (ResourceNotFreeException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new DriverException("Unknown exception", ex);
- }
+ private IOResource claimPorts(
+ final ResourceManager rm,
+ final ResourceOwner owner,
+ final int low,
+ final int length)
+ throws ResourceNotFreeException, DriverException {
+ try {
+ return (
+ IOResource) AccessControllerUtils
+ .doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws ResourceNotFreeException {
+ return rm.claimIOResource(owner, low, length);
+ }
+ });
+ } catch (ResourceNotFreeException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ throw new DriverException("Unknown exception", ex);
+ }
- }
-
- final void dumpDebugInfo() {
- log.debug("Debug Dump");
- log.debug("CSR0 = " + io.getCSR(0));
-
- // stop the device so we can read all registers
- io.setCSR(0, CSR0_STOP);
-
- bufferManager.dumpData(log);
+ }
- int validVMWareLanceRegs[] =
- {
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 8,
- 9,
- 10,
- 11,
- 12,
- 13,
- 14,
- 15,
- 24,
- 25,
- 30,
- 31,
- 58,
- 76,
- 77,
- 80,
- 82,
- 88,
- 89,
- 112,
- 124 };
+ final void dumpDebugInfo() {
+ log.debug("Debug Dump");
+ log.debug("CSR0 = " + io.getCSR(0));
- for (int i = 0; i < validVMWareLanceRegs.length; i++) {
- int csr_val = io.getCSR(validVMWareLanceRegs[i]);
- log.debug(
- "CSR"
- + validVMWareLanceRegs[i]
- + " : "
- + NumberUtils.hex(csr_val, 4));
- }
+ // stop the device so we can read all registers
+ io.setCSR(0, CSR0_STOP);
- // try to start again, not sure if this works?
- io.setCSR(0, CSR0_STRT);
-
- /*
- for (int k = 0; k <= 22; k++) {
- int bcr_val = io.getBCR(k);
- log.debug("BCR" + k + " : " + NumberUtils.hex(bcr_val));
- }
+ bufferManager.dumpData(log);
- for (int j = 0; j <= 0x3F; j++) {
- int pci_val = device.readConfigByte(j);
- log.debug(
- "PCI" + NumberUtils.hex(j) + " : " + NumberUtils.hex(pci_val));
- }
- */
+ int validVMWareLanceRegs[] =
+ {
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12,
+ 13,
+ 14,
+ 15,
+ 24,
+ 25,
+ 30,
+ 31,
+ 58,
+ 76,
+ 77,
+ 80,
+ 82,
+ 88,
+ 89,
+ 112,
+ 124};
+
+ for (int i = 0; i < validVMWareLanceRegs.length; i++) {
+ int csr_val = io.getCSR(validVMWareLanceRegs[i]);
+ log.debug(
+ "CSR"
+ + validVMWareLanceRegs[i]
+ + " : "
+ + NumberUtils.hex(csr_val, 4));
+ }
+
+ // try to start again, not sure if this works?
+ io.setCSR(0, CSR0_STRT);
+
+ /*
+ for (int k = 0; k <= 22; k++) {
+ int bcr_val = io.getBCR(k);
+ log.debug("BCR" + k + " : " + NumberUtils.hex(bcr_val));
+ }
+
+ for (int j = 0; j <= 0x3F; j++) {
+ ...
[truncated message content] |