|
From: <hag...@us...> - 2008-05-30 14:55:42
|
Revision: 4157
http://jnode.svn.sourceforge.net/jnode/?rev=4157&view=rev
Author: hagar-wize
Date: 2008-05-30 07:55:37 -0700 (Fri, 30 May 2008)
Log Message:
-----------
reformat code
Modified Paths:
--------------
trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xConstants.java
trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xCore.java
trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xDriver.java
trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xFlags.java
trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xRxRing.java
trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xTxBuffer.java
trunk/net/src/driver/org/jnode/driver/net/bcm570x/BCM570xConstants.java
trunk/net/src/driver/org/jnode/driver/net/bcm570x/BCM570xCore.java
trunk/net/src/driver/org/jnode/driver/net/bcm570x/BCM570xDriver.java
trunk/net/src/driver/org/jnode/driver/net/bcm570x/BCM570xFlags.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Buffer.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Constants.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Core.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Driver.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Flags.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Registers.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100RxFD.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Stats.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100TxFD.java
trunk/net/src/driver/org/jnode/driver/net/eepro100/EEPRO100Utils.java
trunk/net/src/driver/org/jnode/driver/net/event/LinkStatusEvent.java
trunk/net/src/driver/org/jnode/driver/net/ne2000/Ne2000Constants.java
trunk/net/src/driver/org/jnode/driver/net/ne2000/Ne2000Core.java
trunk/net/src/driver/org/jnode/driver/net/ne2000/Ne2000Driver.java
trunk/net/src/driver/org/jnode/driver/net/ne2000/Ne2000Flags.java
trunk/net/src/driver/org/jnode/driver/net/ne2000/Ne2000PacketHeader.java
trunk/net/src/driver/org/jnode/driver/net/ne2000/pci/Ne2000PCI.java
trunk/net/src/driver/org/jnode/driver/net/ne2000/pci/Ne2000PCIDriver.java
trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2CommFrame.java
trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2CommandResponse.java
trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2Constants.java
trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2Core.java
trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2Driver.java
trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2Flags.java
trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2IO.java
trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2InfoFrame.java
trunk/net/src/driver/org/jnode/driver/net/prism2/Prism2Record.java
trunk/net/src/driver/org/jnode/driver/net/spi/AbstractDeviceCore.java
trunk/net/src/driver/org/jnode/driver/net/spi/AbstractNetDriver.java
trunk/net/src/driver/org/jnode/driver/net/spi/NetDeviceEventProcessor.java
trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetConstant.java
trunk/net/src/driver/org/jnode/driver/net/usb/UsbNetDeviceToDriverMapper.java
trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDevice.java
trunk/net/src/driver/org/jnode/driver/net/usb/bluetooth/UsbBluetoothDriver.java
trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessDeviceCore.java
trunk/net/src/driver/org/jnode/driver/net/wireless/spi/WirelessEthernetDriver.java
Modified: trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xConstants.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xConstants.java 2008-05-30 12:54:00 UTC (rev 4156)
+++ trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xConstants.java 2008-05-30 14:55:37 UTC (rev 4157)
@@ -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._3c90x;
/**
@@ -26,95 +26,287 @@
*/
public interface _3c90xConstants {
- /* Register definitions for the 3c905 ***/
- public static final int regPowerMgmtCtrl_w = 0x7c; /** 905B Revision Only **/
- public static final int regUpMaxBurst_w = 0x7a; /** 905B Revision Only **/
- public static final int regDnMaxBurst_w = 0x78; /** 905B Revision Only **/
- public static final int regDebugControl_w = 0x74; /** 905B Revision Only **/
- public static final int regDebugData_l = 0x70; /** 905B Revision Only **/
- public static final int regRealTimeCnt_l = 0x40; /** Universal **/
- public static final int regUpBurstThresh_b = 0x3e; /** 905B Revision Only **/
- public static final int regUpPoll_b = 0x3d; /** 905B Revision Only **/
- public static final int regUpPriorityThresh_b = 0x3c; /** 905B Revision Only **/
- public static final int regUpListPtr_l = 0x38; /** Universal **/
- public static final int regCountdown_w = 0x36; /** Universal **/
- public static final int regFreeTimer_w = 0x34; /** Universal **/
- public static final int regUpPktStatus_l = 0x30; /** Universal with Exception; pg 130 **/
- public static final int regTxFreeThresh_b = 0x2f; /** 90X Revision Only **/
- public static final int regDnPoll_b = 0x2d; /** 905B Revision Only **/
- public static final int regDnPriorityThresh_b = 0x2c; /** 905B Revision Only **/
- public static final int regDnBurstThresh_b = 0x2a; /** 905B Revision Only **/
- public static final int regDnListPtr_l = 0x24; /** Universal with Exception; pg 107 **/
+ /* Register definitions for the 3c905 ***/
+ public static final int regPowerMgmtCtrl_w = 0x7c;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regUpMaxBurst_w = 0x7a;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regDnMaxBurst_w = 0x78;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regDebugControl_w = 0x74;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regDebugData_l = 0x70;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regRealTimeCnt_l = 0x40;
+ /**
+ * Universal *
+ */
+ public static final int regUpBurstThresh_b = 0x3e;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regUpPoll_b = 0x3d;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regUpPriorityThresh_b = 0x3c;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regUpListPtr_l = 0x38;
+ /**
+ * Universal *
+ */
+ public static final int regCountdown_w = 0x36;
+ /**
+ * Universal *
+ */
+ public static final int regFreeTimer_w = 0x34;
+ /**
+ * Universal *
+ */
+ public static final int regUpPktStatus_l = 0x30;
+ /**
+ * Universal with Exception; pg 130 *
+ */
+ public static final int regTxFreeThresh_b = 0x2f;
+ /**
+ * 90X Revision Only *
+ */
+ public static final int regDnPoll_b = 0x2d;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regDnPriorityThresh_b = 0x2c;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regDnBurstThresh_b = 0x2a;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regDnListPtr_l = 0x24;
+ /**
+ * Universal with Exception; pg 107 *
+ */
public static final int regDmaCtrl_l = 0x20; /** Universal with Exception; pg 106 **/
- /** **/
- public static final int regIntStatusAuto_w = 0x1e; /** 905B Revision Only **/
- public static final int regTxStatus_b = 0x1b; /** Universal with Exception; pg 113 **/
- public static final int regTimer_b = 0x1a; /** Universal **/
- public static final int regTxPktId_b = 0x18; /** 905B Revision Only **/
+ /** **/
+ public static final int regIntStatusAuto_w = 0x1e;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regTxStatus_b = 0x1b;
+ /**
+ * Universal with Exception; pg 113 *
+ */
+ public static final int regTimer_b = 0x1a;
+ /**
+ * Universal *
+ */
+ public static final int regTxPktId_b = 0x18;
+ /**
+ * 905B Revision Only *
+ */
public static final int regCommandIntStatus_w = 0x0e; /** Universal (Command Variations) **/
- /** following are windowed registers **/
- // Registers7
- public static final int regPowerMgmtEvent_7_w = 0x0c; /** 905B Revision Only **/
- public static final int regVlanEtherType_7_w = 0x04; /** 905B Revision Only **/
- public static final int regVlanMask_7_w = 0x00; /** 905B Revision Only **/
+ /**
+ * following are windowed registers *
+ */
+ // Registers7
+ public static final int regPowerMgmtEvent_7_w = 0x0c;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regVlanEtherType_7_w = 0x04;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regVlanMask_7_w = 0x00;
+ /**
+ * 905B Revision Only *
+ */
- // Registers6
- public static final int regBytesXmittedOk_6_w = 0x0c; /** Universal **/
- public static final int regBytesRcvdOk_6_w = 0x0a; /** Universal **/
- public static final int regUpperFramesOk_6_b = 0x09; /** Universal **/
- public static final int regFramesDeferred_6_b = 0x08; /** Universal **/
- public static final int regFramesRecdOk_6_b = 0x07; /** Universal with Exceptions; pg 142 **/
- public static final int regFramesXmittedOk_6_b = 0x06; /** Universal **/
- public static final int regRxOverruns_6_b = 0x05; /** Universal **/
- public static final int regLateCollisions_6_b = 0x04; /** Universal **/
- public static final int regSingleCollisions_6_b = 0x03; /** Universal **/
- public static final int regMultipleCollisions_6_b = 0x02; /** Universal **/
- public static final int regSqeErrors_6_b = 0x01; /** Universal **/
- public static final int regCarrierLost_6_b = 0x00; /** Universal **/
+ // Registers6
+ public static final int regBytesXmittedOk_6_w = 0x0c;
+ /**
+ * Universal *
+ */
+ public static final int regBytesRcvdOk_6_w = 0x0a;
+ /**
+ * Universal *
+ */
+ public static final int regUpperFramesOk_6_b = 0x09;
+ /**
+ * Universal *
+ */
+ public static final int regFramesDeferred_6_b = 0x08;
+ /**
+ * Universal *
+ */
+ public static final int regFramesRecdOk_6_b = 0x07;
+ /**
+ * Universal with Exceptions; pg 142 *
+ */
+ public static final int regFramesXmittedOk_6_b = 0x06;
+ /**
+ * Universal *
+ */
+ public static final int regRxOverruns_6_b = 0x05;
+ /**
+ * Universal *
+ */
+ public static final int regLateCollisions_6_b = 0x04;
+ /**
+ * Universal *
+ */
+ public static final int regSingleCollisions_6_b = 0x03;
+ /**
+ * Universal *
+ */
+ public static final int regMultipleCollisions_6_b = 0x02;
+ /**
+ * Universal *
+ */
+ public static final int regSqeErrors_6_b = 0x01;
+ /**
+ * Universal *
+ */
+ public static final int regCarrierLost_6_b = 0x00;
+ /**
+ * Universal *
+ */
- // Registers5
- public static final int regIndicationEnable_5_w = 0x0c; /** Universal **/
- public static final int regInterruptEnable_5_w = 0x0a; /** Universal **/
- public static final int regTxReclaimThresh_5_b = 0x09; /** 905B Revision Only **/
- public static final int regRxFilter_5_b = 0x08; /** Universal **/
- public static final int regRxEarlyThresh_5_w = 0x06; /** Universal **/
- public static final int regTxStartThresh_5_w = 0x00; /** Universal **/
-
- // Registers4
- public static final int regUpperBytesOk_4_b = 0x0d; /** Universal **/
- public static final int regBadSSD_4_b = 0x0c; /** Universal **/
- public static final int regMediaStatus_4_w = 0x0a; /** Universal with Exceptions; pg 201 **/
- public static final int regPhysicalMgmt_4_w = 0x08; /** Universal **/
- public static final int regNetworkDiagnostic_4_w = 0x06; /** Universal with Exceptions; pg 203 **/
- public static final int regFifoDiagnostic_4_w = 0x04; /** Universal with Exceptions; pg 196 **/
- public static final int regVcoDiagnostic_4_w = 0x02; /** Undocumented? **/
+ // Registers5
+ public static final int regIndicationEnable_5_w = 0x0c;
+ /**
+ * Universal *
+ */
+ public static final int regInterruptEnable_5_w = 0x0a;
+ /**
+ * Universal *
+ */
+ public static final int regTxReclaimThresh_5_b = 0x09;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regRxFilter_5_b = 0x08;
+ /**
+ * Universal *
+ */
+ public static final int regRxEarlyThresh_5_w = 0x06;
+ /**
+ * Universal *
+ */
+ public static final int regTxStartThresh_5_w = 0x00;
+ /**
+ * Universal *
+ */
- // Registers3
- public static final int regTxFree_3_w = 0x0c; /** Universal **/
- public static final int regRxFree_3_w = 0x0a; /** Universal with Exceptions; pg 125 **/
+ // Registers4
+ public static final int regUpperBytesOk_4_b = 0x0d;
+ /**
+ * Universal *
+ */
+ public static final int regBadSSD_4_b = 0x0c;
+ /**
+ * Universal *
+ */
+ public static final int regMediaStatus_4_w = 0x0a;
+ /**
+ * Universal with Exceptions; pg 201 *
+ */
+ public static final int regPhysicalMgmt_4_w = 0x08;
+ /**
+ * Universal *
+ */
+ public static final int regNetworkDiagnostic_4_w = 0x06;
+ /**
+ * Universal with Exceptions; pg 203 *
+ */
+ public static final int regFifoDiagnostic_4_w = 0x04;
+ /**
+ * Universal with Exceptions; pg 196 *
+ */
+ public static final int regVcoDiagnostic_4_w = 0x02;
+ /**
+ * Undocumented? *
+ */
+
+ // Registers3
+ public static final int regTxFree_3_w = 0x0c;
+ /**
+ * Universal *
+ */
+ public static final int regRxFree_3_w = 0x0a;
+ /**
+ * Universal with Exceptions; pg 125 *
+ */
public static final int regResetMediaOptions_3_w = 0x08; /** Media Options on B Revision; **/
- /** Reset Options on Non-B Revision **/
- public static final int regMacControl_3_w = 0x06; /** Universal with Exceptions; pg 199 **/
- public static final int regMaxPktSize_3_w = 0x04; /** 905B Revision Only **/
+ /**
+ * Reset Options on Non-B Revision *
+ */
+ public static final int regMacControl_3_w = 0x06;
+ /**
+ * Universal with Exceptions; pg 199 *
+ */
+ public static final int regMaxPktSize_3_w = 0x04;
+ /**
+ * 905B Revision Only *
+ */
public static final int regInternalConfig_3_l = 0x00; /** Universal; different bit **/
- /** definitions; pg 59 **/
+ /**
+ * definitions; pg 59 *
+ */
- // Registers2
- public static final int regResetOptions_2_w = 0x0c; /** 905B Revision Only **/
- public static final int regStationMask_2_3w = 0x06; /** Universal with Exceptions; pg 127 **/
- public static final int regStationAddress_2_3w = 0x00; /** Universal with Exceptions; pg 127 **/
+ // Registers2
+ public static final int regResetOptions_2_w = 0x0c;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regStationMask_2_3w = 0x06;
+ /**
+ * Universal with Exceptions; pg 127 *
+ */
+ public static final int regStationAddress_2_3w = 0x00;
+ /**
+ * Universal with Exceptions; pg 127 *
+ */
- // Registers1
- public static final int regRxStatus_1_w = 0x0a; /** 90X Revision Only; Pg 126 **/
+ // Registers1
+ public static final int regRxStatus_1_w = 0x0a;
+ /**
+ * 90X Revision Only; Pg 126 *
+ */
- // Registers0
- public static final int regEepromData_0_w = 0x0c; /** Universal **/
- public static final int regEepromCommand_0_w = 0x0a; /** Universal **/
- public static final int regBiosRomData_0_b = 0x08; /** 905B Revision Only **/
- public static final int regBiosRomAddr_0_l = 0x04; /** 905B Revision Only **/
+ // Registers0
+ public static final int regEepromData_0_w = 0x0c;
+ /**
+ * Universal *
+ */
+ public static final int regEepromCommand_0_w = 0x0a;
+ /**
+ * Universal *
+ */
+ public static final int regBiosRomData_0_b = 0x08;
+ /**
+ * 905B Revision Only *
+ */
+ public static final int regBiosRomAddr_0_l = 0x04;
+ /**
+ * 905B Revision Only *
+ */
- /* The names for the eight register windows ***/
+ /* The names for the eight register windows ***/
public static final int winPowerVlan7 = 0x07;
public static final int winStatistics6 = 0x06;
public static final int winTxRxControl5 = 0x05;
@@ -124,64 +316,108 @@
public static final int winUnused1 = 0x01;
public static final int winEepromBios0 = 0x00;
- /* Command definitions for the 3c90X ***/
- public static final int cmdGlobalReset = 0x00; /** Universal with Exceptions; pg 151 **/
- public static final int cmdSelectRegisterWindow = 0x01; /** Universal **/
- public static final int cmdEnableDcConverter = 0x02; /** **/
- public static final int cmdRxDisable = 0x03; /** **/
- public static final int cmdRxEnable = 0x04; /** Universal **/
- public static final int cmdRxReset = 0x05; /** Universal **/
- public static final int cmdStallCtl = 0x06; /** Universal **/
- public static final int cmdTxEnable = 0x09; /** Universal **/
- public static final int cmdTxDisable = 0x0A; /** **/
- public static final int cmdTxReset = 0x0B; /** Universal **/
- public static final int cmdRequestInterrupt = 0x0C; /** **/
- public static final int cmdAcknowledgeInterrupt = 0x0D; /** Universal **/
- public static final int cmdSetInterruptEnable = 0x0E; /** Universal **/
- public static final int cmdSetIndicationEnable = 0x0F; /** Universal **/
- public static final int cmdSetRxFilter = 0x10; /** Universal **/
- public static final int cmdSetRxEarlyThresh = 0x11; /** **/
- public static final int cmdSetTxStartThresh = 0x13; /** **/
- public static final int cmdStatisticsEnable = 0x15; /** **/
- public static final int cmdStatisticsDisable = 0x16; /** **/
- public static final int cmdDisableDcConverter = 0x17; /** **/
- public static final int cmdSetTxReclaimThresh = 0x18; /** **/
- public static final int cmdSetHashFilterBit = 0x19; /** **/
+ /* Command definitions for the 3c90X ***/
+ public static final int cmdGlobalReset = 0x00;
+ /**
+ * Universal with Exceptions; pg 151 *
+ */
+ public static final int cmdSelectRegisterWindow = 0x01;
+ /**
+ * Universal *
+ */
+ public static final int cmdEnableDcConverter = 0x02;
+ /** **/
+ public static final int cmdRxDisable = 0x03;
+ /** **/
+ public static final int cmdRxEnable = 0x04;
+ /**
+ * Universal *
+ */
+ public static final int cmdRxReset = 0x05;
+ /**
+ * Universal *
+ */
+ public static final int cmdStallCtl = 0x06;
+ /**
+ * Universal *
+ */
+ public static final int cmdTxEnable = 0x09;
+ /**
+ * Universal *
+ */
+ public static final int cmdTxDisable = 0x0A;
+ /** **/
+ public static final int cmdTxReset = 0x0B;
+ /**
+ * Universal *
+ */
+ public static final int cmdRequestInterrupt = 0x0C;
+ /** **/
+ public static final int cmdAcknowledgeInterrupt = 0x0D;
+ /**
+ * Universal *
+ */
+ public static final int cmdSetInterruptEnable = 0x0E;
+ /**
+ * Universal *
+ */
+ public static final int cmdSetIndicationEnable = 0x0F;
+ /**
+ * Universal *
+ */
+ public static final int cmdSetRxFilter = 0x10;
+ /**
+ * Universal *
+ */
+ public static final int cmdSetRxEarlyThresh = 0x11;
+ /** **/
+ public static final int cmdSetTxStartThresh = 0x13;
+ /** **/
+ public static final int cmdStatisticsEnable = 0x15;
+ /** **/
+ public static final int cmdStatisticsDisable = 0x16;
+ /** **/
+ public static final int cmdDisableDcConverter = 0x17;
+ /** **/
+ public static final int cmdSetTxReclaimThresh = 0x18;
+ /** **/
+ public static final int cmdSetHashFilterBit = 0x19;
+ /** **/
- /* Values for int status register bitmask **/
- public static final int INT_INTERRUPTLATCH = (1<<0);
- public static final int INT_HOSTERROR = (1<<1);
- public static final int INT_TXCOMPLETE = (1<<2);
- public static final int INT_RXCOMPLETE = (1<<4);
- public static final int INT_RXEARLY = (1<<5);
- public static final int INT_INTREQUESTED = (1<<6);
- public static final int INT_UPDATESTATS = (1<<7);
- public static final int INT_LINKEVENT = (1<<8);
- public static final int INT_DNCOMPLETE = (1<<9);
- public static final int INT_UPCOMPLETE = (1<<10);
- public static final int INT_CMDINPROGRESS = (1<<12);
- public static final int INT_WINDOWNUMBER = (7<<13);
-
+ /* Values for int status register bitmask **/
+ public static final int INT_INTERRUPTLATCH = (1 << 0);
+ public static final int INT_HOSTERROR = (1 << 1);
+ public static final int INT_TXCOMPLETE = (1 << 2);
+ public static final int INT_RXCOMPLETE = (1 << 4);
+ public static final int INT_RXEARLY = (1 << 5);
+ public static final int INT_INTREQUESTED = (1 << 6);
+ public static final int INT_UPDATESTATS = (1 << 7);
+ public static final int INT_LINKEVENT = (1 << 8);
+ public static final int INT_DNCOMPLETE = (1 << 9);
+ public static final int INT_UPCOMPLETE = (1 << 10);
+ public static final int INT_CMDINPROGRESS = (1 << 12);
+ public static final int INT_WINDOWNUMBER = (7 << 13);
+
/* UpPktStatus bits */
- public static final int upPktLenMask = 0x1FFF;
- public static final int upError = (1<<14);
- public static final int upComplete = (1<<15);
- public static final int upOverrun = (1<<16);
- public static final int runtFrame = (1<<17);
- public static final int alignmentError = (1<<18);
- public static final int crcError = (1<<19);
- public static final int oversizedFrame = (1<<20);
- public static final int dribbleBits = (1<<23);
- public static final int upOverflow = (1<<24);
- public static final int ipChecksumError = (1<<25);
- public static final int tcpChecksumError = (1<<26);
- public static final int udpChecksumError = (1<<27);
- public static final int impliedBufferEnable = (1<<28);
- public static final int ipChecksumChecked = (1<<29);
- public static final int tcpChecksumChecked = (1<<30);
- public static final int udpChecksumChecked = (1<<31);
-
- /* Driver specific values */
- public static final int RX_FRAMES = 32;
- public static final int MAX_SERVICE = 32;
+ public static final int upPktLenMask = 0x1FFF;
+ public static final int upError = (1 << 14);
+ public static final int upComplete = (1 << 15);
+ public static final int upOverrun = (1 << 16);
+ public static final int runtFrame = (1 << 17);
+ public static final int alignmentError = (1 << 18);
+ public static final int crcError = (1 << 19);
+ public static final int oversizedFrame = (1 << 20);
+ public static final int dribbleBits = (1 << 23);
+ public static final int upOverflow = (1 << 24);
+ public static final int ipChecksumError = (1 << 25);
+ public static final int tcpChecksumError = (1 << 26);
+ public static final int udpChecksumError = (1 << 27);
+ public static final int impliedBufferEnable = (1 << 28);
+ public static final int ipChecksumChecked = (1 << 29);
+ public static final int tcpChecksumChecked = (1 << 30);
+ public static final int udpChecksumChecked = (1 << 31);
+
+ /* Driver specific values */
+ public static final int RX_FRAMES = 32;
+ public static final int MAX_SERVICE = 32;
}
Modified: trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xCore.java
===================================================================
--- trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xCore.java 2008-05-30 12:54:00 UTC (rev 4156)
+++ trunk/net/src/driver/org/jnode/driver/net/_3c90x/_3c90xCore.java 2008-05-30 14:55:37 UTC (rev 4157)
@@ -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._3c90x;
import java.util.ArrayList;
@@ -52,604 +52,643 @@
*/
public class _3c90xCore extends AbstractDeviceCore implements _3c90xConstants, IRQHandler, EthernetConstants {
- /** Start of IO address space */
- private final int iobase;
- /** IO address space */
- private final IOResource io;
- /** IRQ */
- private final IRQResource irq;
- /** My ethernet address */
- private EthernetAddress hwAddress;
- /** The driver i'm a part of */
- private final _3c90xDriver driver;
- /** My flags */
- private final _3c90xFlags flags;
- /** Is a transmission active? */
- private boolean tx_active;
- /** Active register window */
- private int reg_window = 0xff;
- /** The receive buffer ring */
- private final _3c90xRxRing rxRing;
- /** The transmit buffer */
- private final _3c90xTxBuffer txBuffer;
- /** Is the device a B revision */
- private final boolean Brev;
-
- /**
- * Create a new instance
- * @param flags
- */
- public _3c90xCore(
- _3c90xDriver driver,
- ResourceOwner owner,
- PCIDevice device,
- _3c90xFlags flags)
- throws DriverException, ResourceNotFreeException {
- final int irq = getIRQ(device, flags);
- this.driver = driver;
- this.flags = flags;
- this.tx_active = false;
+ /**
+ * Start of IO address space
+ */
+ private final int iobase;
+ /**
+ * IO address space
+ */
+ private final IOResource io;
+ /**
+ * IRQ
+ */
+ private final IRQResource irq;
+ /**
+ * My ethernet address
+ */
+ private EthernetAddress hwAddress;
+ /**
+ * The driver i'm a part of
+ */
+ private final _3c90xDriver driver;
+ /**
+ * My flags
+ */
+ private final _3c90xFlags flags;
+ /**
+ * Is a transmission active?
+ */
+ private boolean tx_active;
+ /**
+ * Active register window
+ */
+ private int reg_window = 0xff;
+ /**
+ * The receive buffer ring
+ */
+ private final _3c90xRxRing rxRing;
+ /**
+ * The transmit buffer
+ */
+ private final _3c90xTxBuffer txBuffer;
+ /**
+ * Is the device a B revision
+ */
+ private final boolean Brev;
- // Get the start of the IO address space
- this.iobase = getIOBase(device, flags);
- final int iolength = getIOLength(device, flags);
- final 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 {
- io = rm.claimIOResource(owner, iobase, iolength);
- } catch (ResourceNotFreeException ex) {
- this.irq.release();
- throw ex;
- }
- this.rxRing = new _3c90xRxRing(RX_FRAMES, rm);
- this.txBuffer = new _3c90xTxBuffer(rm);
+ /**
+ * Create a new instance
+ *
+ * @param flags
+ */
+ public _3c90xCore(
+ _3c90xDriver driver,
+ ResourceOwner owner,
+ PCIDevice device,
+ _3c90xFlags flags)
+ throws DriverException, ResourceNotFreeException {
+ final int irq = getIRQ(device, flags);
+ this.driver = driver;
+ this.flags = flags;
+ this.tx_active = false;
- // Reset the device
- reset();
-
- // Determine Brev flag
- switch (readEEProm(0x03)) {
- case 0x9000: /** 10 Base TPO **/
- case 0x9001: /** 10/100 T4 **/
- case 0x9050: /** 10/100 TPO **/
- case 0x9051: /** 10 Base Combo **/
- //case 0x9200: /** 3Com905C-TXM **/
- Brev = false;
- break;
+ // Get the start of the IO address space
+ this.iobase = getIOBase(device, flags);
+ final int iolength = getIOLength(device, flags);
+ final 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 {
+ io = rm.claimIOResource(owner, iobase, iolength);
+ } catch (ResourceNotFreeException ex) {
+ this.irq.release();
+ throw ex;
+ }
+ this.rxRing = new _3c90xRxRing(RX_FRAMES, rm);
+ this.txBuffer = new _3c90xTxBuffer(rm);
- case 0x9004: /** 10 Base TPO **/
- case 0x9005: /** 10 Base Combo **/
- case 0x9006: /** 10 Base TPO and Base2 **/
- case 0x900A: /** 10 Base FL **/
- case 0x9055: /** 10/100 TPO **/
- case 0x9056: /** 10/100 T4 **/
- case 0x905A: /** 10 Base FX **/
- default:
- Brev = true;
- break;
- }
+ // Reset the device
+ reset();
- // Read the eeprom
- final int[] eeprom = new int[0x21];
- for (int i = 0; i < 0x17; i++) {
- eeprom[i] = readEEProm(i);
- //Syslog.debug("eeprom[" + NumberUtils.hex(i, 2) + "]=" + NumberUtils.hex(eeprom[i], 4));
- }
- final byte[] hwAddrArr = new byte[ETH_ALEN];
- hwAddrArr[0] = (byte)(eeprom[0x0a]>>8);
- hwAddrArr[1] = (byte)(eeprom[0x0a]&0xFF);
- hwAddrArr[2] = (byte)(eeprom[0x0b]>>8);
- hwAddrArr[3] = (byte)(eeprom[0x0b]&0xFF);
- hwAddrArr[4] = (byte)(eeprom[0x0c]>>8);
- hwAddrArr[5] = (byte)(eeprom[0x0c]&0xFF);
- this.hwAddress = new EthernetAddress(hwAddrArr, 0);
+ // Determine Brev flag
+ switch (readEEProm(0x03)) {
+ case 0x9000: /** 10 Base TPO **/
+ case 0x9001: /** 10/100 T4 **/
+ case 0x9050: /** 10/100 TPO **/
+ case 0x9051: /** 10 Base Combo **/
+ //case 0x9200: /** 3Com905C-TXM **/
+ Brev = false;
+ break;
- log.debug(
- "Found "
- + flags.getName()
- + " IRQ="
- + irq
- + ", IOBase=0x"
- + NumberUtils.hex(iobase)
- + ", MAC Address="
- + hwAddress);
- }
+ case 0x9004: /** 10 Base TPO **/
+ case 0x9005: /** 10 Base Combo **/
+ case 0x9006: /** 10 Base TPO and Base2 **/
+ case 0x900A: /** 10 Base FL **/
+ case 0x9055: /** 10/100 TPO **/
+ case 0x9056: /** 10/100 T4 **/
+ case 0x905A: /** 10 Base FX **/
+ default:
+ Brev = true;
+ break;
+ }
- /**
- * Gets the ethernet address of this device
- */
- public HardwareAddress getHwAddress() {
- return hwAddress;
- }
+ // Read the eeprom
+ final int[] eeprom = new int[0x21];
+ for (int i = 0; i < 0x17; i++) {
+ eeprom[i] = readEEProm(i);
+ //Syslog.debug("eeprom[" + NumberUtils.hex(i, 2) + "]=" + NumberUtils.hex(eeprom[i], 4));
+ }
+ final byte[] hwAddrArr = new byte[ETH_ALEN];
+ hwAddrArr[0] = (byte) (eeprom[0x0a] >> 8);
+ hwAddrArr[1] = (byte) (eeprom[0x0a] & 0xFF);
+ hwAddrArr[2] = (byte) (eeprom[0x0b] >> 8);
+ hwAddrArr[3] = (byte) (eeprom[0x0b] & 0xFF);
+ hwAddrArr[4] = (byte) (eeprom[0x0c] >> 8);
+ hwAddrArr[5] = (byte) (eeprom[0x0c] & 0xFF);
+ this.hwAddress = new EthernetAddress(hwAddrArr, 0);
- /**
- * Initialize the device
- */
- public synchronized void initialize() {
- // First reset the device
- reset();
-
- // Now initialize our buffers
- rxRing.initialize();
-
- /** Program the MAC address into the station address registers **/
- setWindow(winAddressing2);
- final int a0 = ((hwAddress.get(1) & 0xFF) << 8) | (hwAddress.get(0) & 0xFF);
- final int a1 = ((hwAddress.get(3) & 0xFF) << 8) | (hwAddress.get(2) & 0xFF);
- final int a2 = ((hwAddress.get(5) & 0xFF) << 8) | (hwAddress.get(4) & 0xFF);
- setReg16(regStationAddress_2_3w+0, a0);
- setReg16(regStationAddress_2_3w+2, a1);
- setReg16(regStationAddress_2_3w+4, a2);
- setReg16(regStationMask_2_3w+0, 0);
- setReg16(regStationMask_2_3w+2, 0);
- setReg16(regStationMask_2_3w+4, 0);
-
- // Determine the link type
- final ArrayList<String> connectors = new ArrayList<String>();
- final int linktype = determineLinkType(connectors);
- log.debug("Found connectors " + connectors);
+ log.debug(
+ "Found "
+ + flags.getName()
+ + " IRQ="
+ + irq
+ + ", IOBase=0x"
+ + NumberUtils.hex(iobase)
+ + ", MAC Address="
+ + hwAddress);
+ }
- /** enable DC converter for 10-Base-T **/
- if (linktype == 0x0003) {
- issueCommand(cmdEnableDcConverter, 0, 0);
- }
+ /**
+ * Gets the ethernet address of this device
+ */
+ public HardwareAddress getHwAddress() {
+ return hwAddress;
+ }
- /** Set the link to the type we just determined. **/
- setWindow(winTxRxOptions3);
- int cfg = getReg32(regInternalConfig_3_l);
- cfg &= ~(0xF<<20);
- cfg |= (linktype<<20);
- setReg32(regInternalConfig_3_l, cfg);
- //log.debug("Setting linktype to 0x" + NumberUtils.hex(linktype));
+ /**
+ * Initialize the device
+ */
+ public synchronized void initialize() {
+ // First reset the device
+ reset();
- /** Now that we set the xcvr type, reset the Tx and Rx, re-enable. **/
- issueCommand(cmdTxReset, 0x00, 10);
- while ((getReg16(regCommandIntStatus_w) & INT_CMDINPROGRESS) != 0) {
- /* loop */
- }
+ // Now initialize our buffers
+ rxRing.initialize();
- if (!Brev) {
- setReg8(regTxFreeThresh_b, 0x01);
- }
+ /** Program the MAC address into the station address registers **/
+ setWindow(winAddressing2);
+ final int a0 = ((hwAddress.get(1) & 0xFF) << 8) | (hwAddress.get(0) & 0xFF);
+ final int a1 = ((hwAddress.get(3) & 0xFF) << 8) | (hwAddress.get(2) & 0xFF);
+ final int a2 = ((hwAddress.get(5) & 0xFF) << 8) | (hwAddress.get(4) & 0xFF);
+ setReg16(regStationAddress_2_3w + 0, a0);
+ setReg16(regStationAddress_2_3w + 2, a1);
+ setReg16(regStationAddress_2_3w + 4, a2);
+ setReg16(regStationMask_2_3w + 0, 0);
+ setReg16(regStationMask_2_3w + 2, 0);
+ setReg16(regStationMask_2_3w + 4, 0);
- issueCommand(cmdTxEnable, 0, 0);
+ // Determine the link type
+ final ArrayList<String> connectors = new ArrayList<String>();
+ final int linktype = determineLinkType(connectors);
+ log.debug("Found connectors " + connectors);
- /**
- ** reset of the receiver on B-revision cards re-negotiates the link
- ** takes several seconds (a computer eternity)
- **/
- if (Brev) {
- issueCommand(cmdRxReset, 0x04, 10);
- } else {
- issueCommand(cmdRxReset, 0x00, 10);
- }
- while ((getReg16(regCommandIntStatus_w) & INT_CMDINPROGRESS) != 0) {
- /* loop */
- }
+ /** enable DC converter for 10-Base-T **/
+ if (linktype == 0x0003) {
+ issueCommand(cmdEnableDcConverter, 0, 0);
+ }
- /** Set the RX filter = receive only individual pkts & bcast. **/
- issueCommand(cmdSetRxFilter, 0x01 + 0x04, 0);
- //issueCommand(cmdSetRxFilter, 0x1F, 0);
- issueCommand(cmdRxEnable, 0, 0);
- setReg32(regUpListPtr_l, rxRing.getFirstUPDAddress().toInt());
+ /** Set the link to the type we just determined. **/
+ setWindow(winTxRxOptions3);
+ int cfg = getReg32(regInternalConfig_3_l);
+ cfg &= ~(0xF << 20);
+ cfg |= (linktype << 20);
+ setReg32(regInternalConfig_3_l, cfg);
+ //log.debug("Setting linktype to 0x" + NumberUtils.hex(linktype));
- /**
- ** set Indication and Interrupt flags , acknowledge any IRQ's
- **/
- final int intMask = INT_HOSTERROR | INT_TXCOMPLETE | INT_RXCOMPLETE | INT_UPDATESTATS | INT_LINKEVENT | INT_UPCOMPLETE | INT_INTREQUESTED;
- issueCommand(cmdSetInterruptEnable, /*0x7FF*/intMask, 0);
- issueCommand(cmdSetIndicationEnable, 0x7FF, 0);
- issueCommand(cmdAcknowledgeInterrupt, 0x661, 0);
-
- log.debug("initialize done");
- }
+ /** Now that we set the xcvr type, reset the Tx and Rx, re-enable. **/
+ issueCommand(cmdTxReset, 0x00, 10);
+ while ((getReg16(regCommandIntStatus_w) & INT_CMDINPROGRESS) != 0) {
+ /* loop */
+ }
- /**
- * Disable the device
- */
- public synchronized void disable() {
- reset();
- }
+ if (!Brev) {
+ setReg8(regTxFreeThresh_b, 0x01);
+ }
- /**
- * Release all resources
- */
- public void release() {
- io.release();
- log.debug("irq.release");
- irq.release();
- log.debug("end of release");
- }
+ issueCommand(cmdTxEnable, 0, 0);
- /**
- * 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);
+ /**
+ ** reset of the receiver on B-revision cards re-negotiates the link
+ ** takes several seconds (a computer eternity)
+ **/
+ if (Brev) {
+ issueCommand(cmdRxReset, 0x04, 10);
+ } else {
+ issueCommand(cmdRxReset, 0x00, 10);
+ }
+ while ((getReg16(regCommandIntStatus_w) & INT_CMDINPROGRESS) != 0) {
+ /* loop */
+ }
- //final int txStatus = getReg8(regTxStatus_b);
- //log.debug("Waiting for transmit txStatus=0x" + NumberUtils.hex(txStatus, 2));
+ /** Set the RX filter = receive only individual pkts & bcast. **/
+ issueCommand(cmdSetRxFilter, 0x01 + 0x04, 0);
+ //issueCommand(cmdSetRxFilter, 0x1F, 0);
+ issueCommand(cmdRxEnable, 0, 0);
+ setReg32(regUpListPtr_l, rxRing.getFirstUPDAddress().toInt());
- // Wait until we can start transmitting
- final long start = System.currentTimeMillis();
- while (tx_active) {
- final long now = System.currentTimeMillis();
- if (now-start > timeout) {
- throw new TimeoutException("Timeout in claiming transmitter");
- }
- wait(timeout);
- }
- tx_active = true;
- //log.debug("Going for transmit");
+ /**
+ ** set Indication and Interrupt flags , acknowledge any IRQ's
+ **/
+ final int intMask = INT_HOSTERROR | INT_TXCOMPLETE | INT_RXCOMPLETE | INT_UPDATESTATS | INT_LINKEVENT |
+ INT_UPCOMPLETE | INT_INTREQUESTED;
+ issueCommand(cmdSetInterruptEnable, /*0x7FF*/intMask, 0);
+ issueCommand(cmdSetIndicationEnable, 0x7FF, 0);
+ issueCommand(cmdAcknowledgeInterrupt, 0x661, 0);
- txBuffer.initialize(buf);
-
- // Stall the download engine
- issueCommand(cmdStallCtl, 2, 1);
-
- // Set the address of the txBuffer
- setReg32(regDnListPtr_l, txBuffer.getFirstDPDAddress().toInt());
+ log.debug("initialize done");
+ }
- // UnStall the download engine
- issueCommand(cmdStallCtl, 3, 1);
- //log.debug("Leaving transmit txStatus=0x" + NumberUtils.hex(getReg8(regTxStatus_b), 2));
- }
+ /**
+ * Disable the device
+ */
+ public synchronized void disable() {
+ reset();
+ }
- /**
- * @see org.jnode.system.IRQHandler#handleInterrupt(int)
- */
- public synchronized void handleInterrupt(int irq) {
-
- int intStatus = getReg16(regCommandIntStatus_w);
- int loops = 0;
- while ((intStatus & ~INT_WINDOWNUMBER) != 0) {
- //log.debug("IntStatus flags on " + flags.getName() + ": 0x" + NumberUtils.hex(intStatus, 4));
- loops++;
- if (loops > MAX_SERVICE) {
- log.error("Too much work in intterupt, IntStatus=0x" + NumberUtils.hex(intStatus));
- //issueCommand(cmdAcknowledgeInterrupt, intStatus & ~INT_WINDOWNUMBER, 0);
- return;
- }
- if ((intStatus & INT_TXCOMPLETE) != 0) {
- //log.debug("TxComplete on " + flags.getName());
- processTxComplete();
- } else if ((intStatus & INT_UPDATESTATS) != 0) {
- log.debug("UpdateStats on " + flags.getName());
- processUpdateStats();
- } else if ((intStatus & INT_LINKEVENT) != 0) {
- //log.debug("LinkEvent on " + flags.getName());
- processLinkEvent();
- } else if ((intStatus & INT_UPCOMPLETE) != 0) {
- //log.debug("UpComplete on " + flags.getName());
- processUpComplete();
- } else if ((intStatus & INT_INTERRUPTLATCH) != 0) {
- issueCommand(cmdAcknowledgeInterrupt, INT_INTERRUPTLATCH, 0);
- } else {
- log.debug("Unknown IntStatus flags set on " + flags.getName() + ": IntStatus=0x" + NumberUtils.hex(intStatus, 4));
- issueCommand(cmdAcknowledgeInterrupt, intStatus & ~INT_WINDOWNUMBER, 0);
- }
- intStatus = getReg16(regCommandIntStatus_w);
- }
+ /**
+ * Release all resources
+ */
+ public void release() {
+ io.release();
+ log.debug("irq.release");
+ irq.release();
+ log.debug("end of release");
+ }
- //issueCommand(cmdAcknowledgeInterrupt, INT_INTERRUPTLATCH, 0);
+ /**
+ * 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);
- //log.debug("Done IRQ on " + flags.getName() + ": 0x" + NumberUtils.hex(intStatus, 4));
- }
-
- /**
- * Process a TxComplete interrupt
- */
- private final void processTxComplete() {
- tx_active = false;
- notifyAll();
- setReg8(regTxStatus_b, 0xFF); // Ack TxComplete, by writing any value
- }
-
- /**
- * Process an UpdateStats interrupt
- */
- private final void processUpdateStats() {
- // TODO Implement update stats
- }
-
- /**
- * Process a LinkEvent interrupt
- */
- private final void processLinkEvent() {
- // Read IntStatusAuto ack. the interrupt
- //getReg16(regIntStatusAuto_w);
- issueCommand(cmdAcknowledgeInterrupt, 0x02, 0);
- //issueCommand(cmdRxEnable, 0, 0);
- }
-
- /**
- * Process an UpComplete interrupt
- */
- private final void processUpComplete() {
- // Read all packets
- final int nrFrames = rxRing.getNrFrames();
-
- // Stall uploading first
- issueCommand(cmdStallCtl, 0x00, 1);
-
- for (int i = 0; i < nrFrames; i++) {
- final int pktStatus = rxRing.getPktStatus(i);
- if (pktStatus != 0) {
- //log.debug("PktStatus[" + NumberUtils.hex(i, 2) + "]=0x" + NumberUtils.hex(pktStatus));
- if ((pktStatus & upComplete) != 0) {
- final SocketBuffer skbuf = rxRing.getPacket(i);
- try {
- //log.debug("Read packet at index 0x" + NumberUtils.hex(i));
- driver.onReceive(skbuf);
- } catch (NetworkException ex) {
- log.debug("Error in onReceive", ex);
- } finally {
- rxRing.setPktStatus(i, 0);
- }
- }
- }
- }
-
- // UnStall uploading
- issueCommand(cmdStallCtl, 0x01, 0);
-
- // Ack interrupt
- issueCommand(cmdAcknowledgeInterrupt, INT_UPCOMPLETE, 0);
- }
-
- /**
- * Reset this device
- */
- private void reset() {
- issueCommand(cmdGlobalReset, 0xff, 10);
+ //final int txStatus = getReg8(regTxStatus_b);
+ //log.debug("Waiting for transmit txStatus=0x" + NumberUtils.hex(txStatus, 2));
- /** global reset command resets station mask, non-B revision cards
- ** require explicit reset of values
- **/
- setWindow(winAddressing2);
- setReg16(regStationAddress_2_3w+0, 0);
- setReg16(regStationAddress_2_3w+2, 0);
- setReg16(regStationAddress_2_3w+4, 0);
+ // Wait until we can start transmitting
+ final long start = System.currentTimeMillis();
+ while (tx_active) {
+ final long now = System.currentTimeMillis();
+ if (now - start > timeout) {
+ throw new TimeoutException("Timeout in claiming transmitter");
+ }
+ wait(timeout);
+ }
+ tx_active = true;
+ //log.debug("Going for transmit");
- /** Issue transmit reset, wait for command completion **/
- issueCommand(cmdTxReset, 0, 10);
- issueCommand(cmdRxReset, 0, 10);
- issueCommand(cmdSetInterruptEnable, 0, 0);
- /** enable rxComplete and txComplete **/
- issueCommand(cmdSetIndicationEnable, 0x0014, 0);
- /** acknowledge any pending status flags **/
- issueCommand(cmdAcknowledgeInterrupt, 0x661, 0);
- }
+ txBuffer.initialize(buf);
- /**
- * Gets the first IO-Address used by the given device
- * @param device
- * @param flags
- */
- protected int getIOBase(Device device, _3c90xFlags flags)
- throws DriverException {
- final PCIHeaderType0 config = ((PCIDevice)device).getConfig().asHeaderType0();
- 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");
- }
- return addrs[0].getIOBase();
- }
+ // Stall the download engine
+ issueCommand(cmdStallCtl, 2, 1);
- /**
- * Gets the number of IO-Addresses used by the given device
- * @param device
- * @param flags
- */
- protected int getIOLength(Device device, _3c90xFlags flags)
- throws DriverException {
- final PCIHeaderType0 config = ((PCIDevice)device).getConfig().asHeaderType0();
- 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");
- }
- return addrs[0].getSize();
- }
+ // Set the address of the txBuffer
+ setReg32(regDnListPtr_l, txBuffer.getFirstDPDAddress().toInt());
- /**
- * Gets the IRQ used by the given device
- * @param device
- * @param flags
- */
- protected int getIRQ(Device device, _3c90xFlags flags)
- throws DriverException {
- final PCIHeaderType0 config = ((PCIDevice)device).getConfig().asHeaderType0();
- return config.getInterruptLine();
- }
-
- /**
- * Determine which connectors are physically available on the device.
- * Determine the link type based on that.
- * @param connectors
- */
- private final int determineLinkType(Collection<String> connectors) {
- /** Read the media options register, print a message and set default
- ** xcvr.
- **
- ** Uses Media Option command on B revision, Reset Option on non-B
- ** revision cards -- same register address
- **/
- setWindow(winTxRxOptions3);
- int mopt = getReg16(regResetMediaOptions_3_w);
+ // UnStall the download engine
+ issueCommand(cmdStallCtl, 3, 1);
+ //log.debug("Leaving transmit txStatus=0x" + NumberUtils.hex(getReg8(regTxStatus_b), 2));
+ }
- /* mask out VCO bit that is defined as 10baseFL bit on B-rev cards */
- if (!Brev) {
- mopt &= 0x7F;
- }
- //log.debug("mopt=0x" + NumberUtils.hex(mopt));
-
- int linktype = 0x0008;
- if ((mopt & 0x01) != 0) {
- connectors.add("100Base-T4");
- linktype = 0x0006;
- }
- if ((mopt & 0x04) != 0) {
- connectors.add("100Base-FX");
- linktype = 0x0005;
- }
- if ((mopt & 0x10) != 0) {
- connectors.add("10Base-2");
- linktype = 0x0003;
- }
- if ((mopt & 0x20) != 0) {
- connectors.add("AUI");
- linktype = 0x0001;
- }
- if ((mopt & 0x40) != 0) {
- connectors.add("MII");
- linktype = 0x0006;
- }
- if ((mopt & 0xA) == 0xA) {
- connectors.add("10Base-T / 100Base-TX");
- linktype = 0x0008;
- } else if ((mopt & 0xA) == 0x2) {
- connectors.add("100Base-TX");
- linktype = 0x0008;
- } else if ((mopt & 0xA) == 0x8) {
- connectors.add("10Base-T");
- linktype = 0x0008;
- }
-
- return linktype;
- }
-
- /**
- * Execute a command on the NIC
- * @param command
- * @param param
- */
- private final void issueCommand(int command, int param, long sleep) {
- // Calculate the complete command + param value
- final int v = (command << 11) | (param & 0x7FF);
- // Wait for the previous command to complete
- while ((getReg16(regCommandIntStatus_w) & INT_CMDINPROGRESS) != 0) {
- /* loop */
- }
- // Send the command
- setReg16(regCommandIntStatus_w, v);
- if (sleep > 0) {
- // Sleep for long commands
- try {
- Thread.sleep(sleep);
- } catch (InterruptedException ex) {
- // Ignore
- }
- }
- // Wait for the command to complete
- int loops = 0;
- while ((getReg16(regCommandIntStatus_w) & INT_CMDINPROGRESS) != 0) {
- /* loop */
- loops++;
- }
- //log.debug("Loops=" + loops + ", cmd=0x" + NumberUtils.hex(v));
- }
+ /**
+ * @see org.jnode.system.IRQHandler#handleInterrupt(int)
+ */
+ public synchronized void handleInterrupt(int irq) {
- /**
- * Read data from the serial eeprom
- * @param address
- */
- private int readEEProm(int address) {
- /** Select correct window **/
- setWindow(winEepromBios0);
+ int intStatus = getReg16(regCommandIntStatus_w);
+ int loops = 0;
+ while ((intStatus & ~INT_WINDOWNUMBER) != 0) {
+ //log.debug("IntStatus flags on " + flags.getName() + ": 0x" + NumberUtils.hex(intStatus, 4));
+ loops++;
+ if (loops > MAX_SERVICE) {
+ log.error("Too much work in intterupt, IntStatus=0x" + NumberUtils.hex(intStatus));
+ //issueCommand(cmdAcknowledgeInterrupt, intStatus & ~INT_WINDOWNUMBER, 0);
+ return;
+ }
+ if ((intStatus & INT_TXCOMPLETE) != 0) {
+ //log.debug("TxComplete on " + flags.getName());
+ processTxComplete();
+ } else if ((intStatus & INT_UPDATESTATS) != 0) {
+ log.debug("UpdateStats on " + flags.getName());
+ processUpdateStats();
+ } else if ((intStatus & INT_LINKEVENT) != 0) {
+ //log.debug("LinkEvent on " + flags.getName());
+ processLinkEvent();
+ } else if ((intStatus & INT_UPCOMPLETE) != 0) {
+ //log.debug("UpComplete on " + flags.getName());
+ processUpComplete();
+ } else if ((intStatus & INT_INTERRUPTLATCH) != 0) {
+ issueCommand(cmdAcknowledgeInterrupt, INT_INTERRUPTLATCH, 0);
+ } else {
+ log.debug("Unknown IntStatus flags set on " + flags.getName() + ": IntStatus=0x" +
+ NumberUtils.hex(intStatus, 4));
+ issueCommand(cmdAcknowledgeInterrupt, intStatus & ~INT_WINDOWNUMBER, 0);
+ }
+ intStatus = getReg16(regCommandIntStatus_w);
+ }
- /** Make sure the eeprom isn't busy **/
- while (((1<<15) & getReg16(regEepromCommand_0_w)) != 0) {
- /* Loop */
- }
+ //issueCommand(cmdAcknowledgeInterrupt, INT_INTERRUPTLATCH, 0);
- /** Read the value. **/
- setReg16(regEepromCommand_0_w, address + ((0x02)<<6));
- try {
- Thread.sleep(2);
- } catch (InterruptedException ex) {
- // Ignore
- }
- while (((1<<15) & getReg16(regEepromCommand_0_w)) != 0) {
- /* Loop */
- }
-
- return getReg16(regEepromData_0_w) & 0xFFFF;
- }
-
- /**
- * Sets the current register window
- * @param w
- */
- private final void setWindow(int w) {
- if (reg_window != w) {
- issueCommand(cmdSelectRegisterWindow, w, 0);
- reg_window = w;
- }
- }
-
- /**
- * Reads a 8-bit NIC register
- * @param reg
- */
- /*private final int getReg8(int reg) {
- return io.inPortByte(iobase + reg);
- }*/
-
- /**
- * Reads a 16-bit NIC register
- * @param reg
- */
- private final int getReg16(int reg) {
- return io.inPortWord(iobase + reg);
- }
-
- /**
- * Reads a 32-bit NIC register
- * @param reg
- */
- private final int getReg32(int reg) {
- return io.inPortDword(iobase + reg);
- }
-
- /**
- * Writes a 8-bit NIC register
- * @param reg
- * @param value
- */
- private final void setReg8(int reg, int value) {
- io.outPortByte(iobase + reg, value);
- }
- /**
- * Writes a 16-bit NIC register
- * @param reg
- * @param value
- */
- private final void setReg16(int reg, int value) {
+ //log.debug("Done IRQ on " + flags.getName() + ": 0x" + NumberUtils.hex(intStatus, 4));
+ }
+
+ /**
+ * Process a TxComplete interrupt
+ */
+ private final void processTxComplete() {
+ tx_active = false;
+ notifyAll();
+ setReg8(regTxStatus_b, 0xFF); // Ack TxComplete, by writing any value
+ }
+
+ /**
+ * Process an UpdateStats interrupt
+ */
+ private final void processUpdateStats() {
+ // TODO Implement update stats
+ }
+
+ /**
+ * Process a LinkEvent interrupt
+ */
+ private final void processLinkEvent() {
+ // Read IntStatusAuto ack. the interrupt
+ //getReg16(regIntStatusAuto_w);
+ issueCommand(cmdAcknowledgeInterrupt, 0x02, 0);
+ //issueCommand(cmdRxEnable, 0, 0);
+ }
+
+ /**
+ * Process an UpComplete interrupt
+ */
+ private final void processUpComplete() {
+ // Read all packets
+ final int nrFrames = rxRing.getNrFrames();
+
+ // Stall uploading first
+ issueCommand(cmdStallCtl, 0x00, 1);
+
+ for (int i = 0; i < nrFrames; i++) {
+ final int pktStatus = rxRing.getPktStatus(i);
+ if (pktStatus != 0) {
+ //log.debug("PktStatus[" + NumberUtils.hex(i, 2) + "]=0x" + NumberUtils.hex(pktStatus));
+ if ((pktStatus & upComplete) != 0) {
+ final SocketBuffer skbuf = rxRing.getPacket(i);
+ try {
+ //log.debug("Read packet at index 0x" + NumberUtils.hex(i));
+ driver.onReceive(skbuf);
+ } catch (NetworkException ex) {
+ log.debug("Error in onReceive", ex);
+ } finally {
+ rxRing.setPktStatus(i, 0);
+ }
+ }
+ }
+ }
+
+ // UnStall uploading
+ issueCommand(cmdStallCtl, 0x01, 0);
+
+ // Ack interrupt
+ issueCommand(cmdAcknowledgeInterrupt, INT_UPCOMPLETE, 0);
+ }
+
+ /**
+ * Reset this device
+ */
+ private void reset() {
+ issueCommand(cmdGlobalReset, 0xff, 10);
+
+ /** global reset command resets station mask, non-B revision cards
+ ** require explicit reset of values
+ **/
+ setWindow(winAddressing2);
+ setReg16(regStationAddress_2_3w + 0, 0);
+ setReg16(regStationAddress_2_3w + 2, 0);
+ setReg16(regStationAddress_2_3w + 4, 0);
+
+ /** Issue transmit reset, wait for command completion **/
+ issueCommand(cmdTxReset, 0, 10);
+ issueCommand(cmdRxReset, 0, 10);
+ issueCommand(cmdSetInterruptEnable, 0, 0);
+ /** enable rxComplete and txComplete **/
+ issueCommand(cmdSetIndicationEnable, 0x0014, 0);
+ /** acknowledge any pending status flags **/
+ issueCommand(cmdAcknowledgeInterrupt, 0x661, 0);
+ }
+
+ /**
+ * Gets the first IO-Address used by the given device
+ *
+ * @param device
+ * @param flags
+ */
+ protected int getIOBase(Device device, _3c90xFlags flags)
+ throws DriverException {
+ final PCIHeaderType0 config = ((PCIDevice) device).getConfig().asHeaderType0();
+ 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");
+ }
+ return addrs[0].getIOBase();
+ }
+
+ /**
+ * Gets the number of IO-Addresses used by the given device
+ *
+ * @param device
+...
[truncated message content] |