#ifndef __APPLE_3COM_3C90X_DEFINES_H
#define __APPLE_3COM_3C90X_DEFINES_H
#include <IOKit/IOTypes.h>
#define DefineWindowRegisterAccessors( b, w, o, n ) \
inline void set ## n( UInt ## b value ) \
{ \
setRegisterWindow( w ); \
writeRegister ## b( o, value ); \
} \
inline UInt ## b get ## n() \
{ \
setRegisterWindow( w ); \
return readRegister ## b( o ); \
}
#define DefineGlobalRegisterAccessors( b, o, n ) \
inline void set ## n( UInt ## b value ) \
{ \
writeRegister ## b( o, value ); \
} \
inline UInt ## b get ## n() \
{ \
return readRegister ## b( o ); \
}
#define Bit( p ) (1 << p)
#define BitField( p, w, r, b ) \
k ## r ## b ## Shift = p, \
k ## r ## b ## Mask = (((1 << (w)) - 1) << p),
#define GetBitField( r, b, v ) \
(((v) & k ## r ## b ## Mask) >> k ## r ## b ## Shift)
#define SetBitField( r, b, v ) \
(((v) << k ## r ## b ## Shift) & k ## r ## b ## Mask)
#define ReadBitField( r, b ) \
((( get##r() & k ## r ## b ## Mask) >> k ## r ## b ## Shift))
#define kTxRingSize 64
#define kRxRingSize 32
enum {
kInvalidRegisterWindow = 0xff
};
enum {
kApertureSizeBoomerang = 0x40,
kApertureSizeCyclone = 0x80
};
enum {
kEEPROMSizeBoomerang = 0x18,
kEEPROMSizeCyclone = 0x21,
kEEPROMSizeTornado = 0x100
};
enum {
kDescriptorAlignment = 8
};
enum {
kASIC_40_0502_00x = 0,
kASIC_40_0483_00x = 1,
kASIC_40_0476_001 = 3,
kASIC_Unknown
};
enum AdapterType {
kAdapterType3C90x = 0, kAdapterType3C90xB, kAdapterType3C90xC, kAdapterTypeCount
};
enum MediaPort {
kMediaPort10BaseT = 0,
kMediaPortAUI = 1,
kMediaPortAuto = 2,
kMediaPortDefault = 2,
kMediaPort10Base2 = 3,
kMediaPort100BaseTX = 4,
kMediaPort100BaseFX = 5,
kMediaPortMII = 6,
kMediaPort100BaseT4 = 7, kMediaPortAutoNeg = 8,
kMediaPortCount
};
typedef UInt32 MIILink;
enum {
kMIILinkNone = 0,
kMIILink10BT = Bit(0),
kMIILink10BT_FD = Bit(1),
kMIILink100TX = Bit(2),
kMIILink100TX_FD = Bit(3),
kMIILink100T4 = Bit(4),
kMIILinkNway = Bit(31)
};
#define kMIILinkMask ( kMIILink10BT | \
kMIILink10BT_FD | \
kMIILink100TX | \
kMIILink100TX_FD | \
kMIILink100T4 )
enum LinkSpeed {
kLinkSpeed10,
kLinkSpeed100
};
enum DuplexMode {
kHalfDuplex,
kFullDuplex
};
enum LinkState {
kLinkFail,
kLinkPass,
kLinkChanged
};
enum {
kRxPacketBufferSize = ( 1514 + 4 + 4 )
};
enum {
kPeriodicTimerMSInterval = 3000
};
typedef UInt8 PHYAddress;
typedef UInt8 PHYRegAddr;
typedef UInt16 PHYWord;
enum {
kMediaCodeDef = 0x0000,
kMediaCodeSQE = 0x0008,
kMediaCode10TP = 0x00C0,
kMediaCodeLink = 0x0080,
kMediaCodeMask = 0x00CC
};
typedef struct {
char * name; UInt16 speed; UInt16 mediaCode; bool selectable; UInt32 ioType; } MediaPortInfo;
typedef struct {
MediaPort mediaPort; MIILink phyLink; MIILink phyLinkActive; PHYAddress phyAddress; PHYWord phyStatus; UInt32 phyID;
bool phyConfigured; DuplexMode duplexMode; LinkSpeed linkSpeed; UInt32 linkStatus; UInt32 miiLinkMask; UInt32 mediaPortMask; UInt32 mediaPortFDMask; bool syncStatus;
} MediaState;
typedef struct {
UInt16 deviceID; AdapterType type; char * name; } AdapterInfo;
extern const AdapterInfo adapterInfoTable[];
extern const UInt32 adapterInfoTableCount;
extern const MediaPortInfo mediaPortTable[];
enum {
#define CommandCode(x) ((x)<<11)
GlobalReset = CommandCode(0),
SelectWindow = CommandCode(1),
EnableDCConv = CommandCode(2),
RxDisable = CommandCode(3),
RxEnable = CommandCode(4),
RxReset = CommandCode(5),
UpStall = CommandCode(6),
UpUnStall = CommandCode(6) + 1,
DnStall = CommandCode(6) + 2,
DnUnStall = CommandCode(6) + 3,
TxDone = CommandCode(7),
RxDiscard = CommandCode(8),
TxEnable = CommandCode(9),
TxDisable = CommandCode(10),
TxReset = CommandCode(11),
ReqIntr = CommandCode(12),
AckIntr = CommandCode(13),
#define kAckInterruptLatch 0x01
#define kAckTxAvailable 0x08
#define kAckRxEarly 0x20
#define kAckIntRequested 0x40
#define kAckLinkEvent 0x100 // read AutoNegExp to ack LinkEvents
#define kAckDnComplete 0x200
#define kAckUpComplete 0x400
SetIntrEnable = CommandCode(14),
SetIndEnable = CommandCode(15),
SetRxFilter = CommandCode(16),
#define kFilterIndividual 0x01
#define kFilterMulticast 0x02
#define kFilterBroadcast 0x04
#define kFilterPromiscuous 0x08
#define kFilterMulticastHash 0x10
SetRxEarlyThresh = CommandCode(17),
SetTxAvailThresh = CommandCode(18),
SetTxStartThresh = CommandCode(19),
StartDMAUp = CommandCode(20),
StartDMADown = CommandCode(20) + 1,
StatsEnable = CommandCode(21),
StatsDisable = CommandCode(22),
DisableDCConv = CommandCode(23),
SetTxReclaimThresh = CommandCode(24),
SetHashFilterBit = CommandCode(25),
#define kHashFilterBitOn 0x0400
#define kHashFilterBitOff 0x0000
};
enum {
eepromAddr0 = 0x00,
eepromAddr1 = 0x01,
eepromAddr2 = 0x02,
eepromID = 0x03,
eepromDate = 0x04,
eepromDiv = 0x05,
eepromCode = 0x06,
eepromManID = 0x07,
eepromPCIParm = 0x08,
eepromRomInfo = 0x09,
eepromOAddr0 = 0x0a,
eepromOAddr1 = 0x0b,
eepromOAddr2 = 0x0c,
eepromSoftInfo = 0x0d,
eepromComp = 0x0e,
eepromSoftInfo2 = 0x0f,
eepromCapable = 0x10,
eepromRsvd1 = 0x11,
eepromConfig0 = 0x12,
eepromConfig1 = 0x13,
eepromRsvd2 = 0x14,
eepromSoftInfo3 = 0x15,
eepromRsvd3 = 0x16,
eepromSubVenID = 0x17, eepromSubID = 0x18,
eepromMediaOpt = 0x19,
eepromRsvd4 = 0x1a,
eepromRsvd5 = 0x1b,
eepromRsvd6 = 0x1c,
eepromRsvd7 = 0x1d,
eepromRsvd8 = 0x1e,
eepromRsvd9 = 0x1f,
eepromChecksum = 0x20,
eepromChecksum2 = 0xff, eepromChecksum3 = 0x3ff };
enum {
BitField( 0, 1, CommandStatus, InterruptLatch )
BitField( 1, 1, CommandStatus, HostError )
BitField( 2, 1, CommandStatus, TxComplete )
BitField( 3, 1, CommandStatus, TxAvailable )
BitField( 4, 1, CommandStatus, RxComplete )
BitField( 5, 1, CommandStatus, RxEarly )
BitField( 6, 1, CommandStatus, IntRequested )
BitField( 7, 1, CommandStatus, UpdateStats )
BitField( 8, 1, CommandStatus, LinkEvent )
BitField( 9, 1, CommandStatus, DnComplete )
BitField( 10, 1, CommandStatus, UpComplete )
BitField( 11, 1, CommandStatus, BusMasterInProgress )
BitField( 12, 1, CommandStatus, CmdInProgress )
BitField( 13, 3, CommandStatus, CurrentWindow )
};
enum {
BitField( 0, 6, EEPROMCommand, Address )
BitField( 6, 2, EEPROMCommand, Opcode )
BitField( 8, 4, EEPROMCommand, AddressHigh ) BitField( 15, 1, EEPROMCommand, Busy )
kEEPROMOpcodeEnable = SetBitField( EEPROMCommand, Opcode, 0 ),
kEEPROMOpcodeWrite = SetBitField( EEPROMCommand, Opcode, 1 ),
kEEPROMOpcodeRead = SetBitField( EEPROMCommand, Opcode, 2 ),
kEEPROMOpcodeErase = SetBitField( EEPROMCommand, Opcode, 3 ),
};
enum {
BitField( 1, 1, PowerMgmtEvent, MagicPktEnable )
};
enum {
BitField( 0, 3, InternalConfig, RAMSize ) BitField( 3, 1, InternalConfig, RAMWidth ) BitField( 6, 2, InternalConfig, ROMSize )
BitField( 8, 1, InternalConfig, DisableBadSSDDetect )
BitField( 9, 1, InternalConfig, RAMLocation ) BitField( 14, 1, InternalConfig, EnableTxLarge ) BitField( 15, 1, InternalConfig, EnableRxLarge ) BitField( 16, 2, InternalConfig, RamPartition ) BitField( 20, 4, InternalConfig, XcvrSelect )
BitField( 24, 1, InternalConfig, AutoSelect )
BitField( 25, 1, InternalConfig, DisableBIOSROM ) };
enum {
BitField( 0, 1, MediaOptions, BaseT4 )
BitField( 1, 1, MediaOptions, BaseTX )
BitField( 2, 1, MediaOptions, BaseFX )
BitField( 3, 1, MediaOptions, Base10BT )
BitField( 4, 1, MediaOptions, BaseCoax )
BitField( 5, 1, MediaOptions, BaseAUI )
BitField( 6, 1, MediaOptions, BaseMII )
BitField( 8, 1, MediaOptions, Base10FL )
};
enum {
BitField( 0, 3, ResetOptions, FeatureSet )
BitField( 3, 1, ResetOptions, D3ResetDisable )
BitField( 4, 1, ResetOptions, DisableAdvFD )
BitField( 5, 1, ResetOptions, DisableAdv100 )
BitField( 6, 1, ResetOptions, DisableAutoNeg )
BitField( 7, 1, ResetOptions, DebugMode )
BitField( 8, 1, ResetOptions, FastAutoNeg )
BitField( 9, 1, ResetOptions, FastEE )
BitField( 10, 1, ResetOptions, ForcedConfig )
BitField( 11, 1, ResetOptions, TestPDTPDR )
BitField( 12, 1, ResetOptions, Test100TX )
BitField( 13, 1, ResetOptions, Test100RX )
};
enum {
BitField( 0, 1, NetworkDiagnostic, TestLowVoltageDetector )
BitField( 1, 5, NetworkDiagnostic, AsicRevision )
BitField( 6, 1, NetworkDiagnostic, UpperByteEnable )
BitField( 7, 1, NetworkDiagnostic, StatisticsEnabled )
BitField( 8, 1, NetworkDiagnostic, TxFatalError )
BitField( 9, 1, NetworkDiagnostic, Transmitting )
BitField( 10, 1, NetworkDiagnostic, RxEnabled )
BitField( 11, 1, NetworkDiagnostic, TxEnabled )
BitField( 12, 1, NetworkDiagnostic, FIFOLoopback )
BitField( 13, 1, NetworkDiagnostic, MACLoopback )
BitField( 14, 1, NetworkDiagnostic, EndecLoopback )
BitField( 15, 1, NetworkDiagnostic, ExternalLoopback )
};
enum {
BitField( 0, 1, MacControl, DeferExtendEnable )
BitField( 1, 4, MacControl, DeferTimerSelect )
BitField( 5, 1, MacControl, FullDuplexEnable )
BitField( 6, 1, MacControl, AllowLargePackets )
BitField( 7, 1, MacControl, ExtendAfterCollision ) BitField( 8, 1, MacControl, FlowControlEnable ) BitField( 9, 1, MacControl, VLTEnable ) };
enum {
BitField( 1, 1, MediaStatus, DataRate100 )
BitField( 2, 1, MediaStatus, CRCStripDisable ) BitField( 3, 1, MediaStatus, EnableSQEStats )
BitField( 4, 1, MediaStatus, CollisionDetect )
BitField( 5, 1, MediaStatus, CarrierSense )
BitField( 6, 1, MediaStatus, JabberGuardEnabled )
BitField( 7, 1, MediaStatus, LinkBeatEnabled )
BitField( 9, 1, MediaStatus, JabberDetect )
BitField( 10, 1, MediaStatus, PolarityReversed )
BitField( 11, 1, MediaStatus, LinkDetect )
BitField( 12, 1, MediaStatus, TxInProg )
BitField( 14, 1, MediaStatus, DCConverterEnabled )
BitField( 15, 1, MediaStatus, AUIDisabled )
};
enum {
BitField( 0, 1, PhysicalMgmt, Clk )
BitField( 1, 1, PhysicalMgmt, Data )
BitField( 2, 1, PhysicalMgmt, Dir )
kPhysicalMgmtDirWrite = SetBitField( PhysicalMgmt, Dir, 1 ),
kPhysicalMgmtDirRead = SetBitField( PhysicalMgmt, Dir, 0 )
};
enum {
BitField( 1, 1, TxStatus, ReclaimError )
BitField( 2, 1, TxStatus, Overflow )
BitField( 3, 1, TxStatus, MaxCollisions )
BitField( 4, 1, TxStatus, Underrun )
BitField( 5, 1, TxStatus, Jabber )
BitField( 6, 1, TxStatus, InterruptRequested )
BitField( 7, 1, TxStatus, Complete )
};
enum {
kTxFreeTreshSizePacket = 6
};
enum {
BitField( 1, 1, DMACtrl, DnCmplReq )
BitField( 2, 1, DMACtrl, DnStalled )
BitField( 3, 1, DMACtrl, UpComplete )
BitField( 4, 1, DMACtrl, DnComplete )
BitField( 5, 1, DMACtrl, UpRxEarlyEnable )
BitField( 6, 1, DMACtrl, ArmCountdown )
BitField( 7, 1, DMACtrl, DnInProg )
BitField( 8, 1, DMACtrl, CounterSpeed )
BitField( 9, 1, DMACtrl, CountdownMode )
BitField( 16, 1, DMACtrl, UpAltSeqDisable ) BitField( 20, 1, DMACtrl, DefeatMWI ) BitField( 21, 1, DMACtrl, DefeatMRL ) BitField( 22, 1, DMACtrl, UpOverDiscDisable ) BitField( 30, 1, DMACtrl, TargetAbort )
BitField( 31, 1, DMACtrl, MasterAbort )
};
enum {
kDnBurstThreshMax = 0x1f
};
enum {
kDnPriorityThreshMax = 0x3f
};
enum {
kTxReclaimThreshMin = 0x04,
kTxReclaimThreshMax = 0xff
};
enum {
kTxStartThreshMin = 64,
kTxStartThreshMax = 0x1fff
};
enum {
kUpBurstThreshMax = 0x1f
};
enum {
kUpPriorityThreshMax = 0x1f
};
enum {
kStationAddressWindow = 2,
kStationAddressOffset = 0,
kStationAddressMaskWindow = 2,
kStationAddressMaskOffset = 6
};
enum {
kTxFragmentCount = 5
};
enum {
BitField( 0, 13, TxDescHeader, Length )
BitField( 13, 1, TxDescHeader, CRCAppendDisable )
BitField( 15, 1, TxDescHeader, TxIndicate )
BitField( 16, 1, TxDescHeader, DnComplete )
BitField( 25, 1, TxDescHeader, AddIPChecksum )
BitField( 26, 1, TxDescHeader, AddTCPChecksum )
BitField( 27, 1, TxDescHeader, AddUDPChecksum )
BitField( 28, 1, TxDescHeader, RoundUpDefeat )
BitField( 29, 1, TxDescHeader, DPDEmpty )
BitField( 31, 1, TxDescHeader, DnIndicate )
BitField( 0, 2, TxDescHeader, RoundUpBoundary )
BitField( 2, 8, TxDescHeader, PacketID )
};
enum {
BitField( 0, 13, TxFragment, Length )
BitField( 31, 1, TxFragment, Last )
};
typedef struct {
UInt32 address;
UInt32 command;
} BufferFragment;
typedef struct _TxDescriptor
{
IOPhysicalAddress nextPtr;
volatile UInt32 header;
BufferFragment fragments[ kTxFragmentCount ];
_TxDescriptor * drvNext;
_TxDescriptor * drvPrevious;
IOPhysicalAddress drvPhysAddr;
mbuf_t drvMbuf;
} TxDescriptor;
enum {
kRxFragmentCount = 2
};
enum {
BitField( 0, 13, RxDescStatus, Length )
BitField( 14, 1, RxDescStatus, UpError )
BitField( 15, 1, RxDescStatus, UpComplete )
BitField( 16, 1, RxDescStatus, UpOverrun )
BitField( 17, 1, RxDescStatus, RuntFrame )
BitField( 18, 1, RxDescStatus, AlignmentError )
BitField( 19, 1, RxDescStatus, CRCError )
BitField( 20, 1, RxDescStatus, OversizedFrame )
BitField( 23, 1, RxDescStatus, DribbleBits )
BitField( 24, 1, RxDescStatus, UpOverflow )
BitField( 25, 1, RxDescStatus, IPChecksumError )
BitField( 26, 1, RxDescStatus, TCPChecksumError )
BitField( 27, 1, RxDescStatus, UDPChecksumError )
BitField( 29, 1, RxDescStatus, IPChecksumChecked )
BitField( 30, 1, RxDescStatus, TCPChecksumChecked )
BitField( 31, 1, RxDescStatus, UDPChecksumChecked )
};
enum {
BitField( 0, 13, RxFragment, Length )
BitField( 31, 1, RxFragment, Last )
};
typedef struct _RxDescriptor
{
IOPhysicalAddress nextPtr;
volatile UInt32 status;
BufferFragment fragments[ kRxFragmentCount ];
_RxDescriptor * drvNext;
mbuf_t drvMbuf;
} RxDescriptor;
enum {
BitField( 0, 16, MIIFrame, Data )
BitField( 16, 2, MIIFrame, TA )
BitField( 18, 5, MIIFrame, RegAddr )
BitField( 23, 5, MIIFrame, PhyAddr )
BitField( 28, 2, MIIFrame, Opcode )
BitField( 30, 2, MIIFrame, ST )
kMIIFrameTAWrite = SetBitField( MIIFrame, TA, 2 ),
kMIIFrameOpcodeWrite = SetBitField( MIIFrame, Opcode, 1 ),
kMIIFrameOpcodeRead = SetBitField( MIIFrame, Opcode, 2 ),
kMIIFrameStart = SetBitField( MIIFrame, ST, 1 )
};
#define kMIIDelay 1
#define kMIIFramePreamble 0xFFFFFFFF
#define kMIIFrameSize 32
enum {
kPHYAddrMin = 0,
kPHYAddrCyclone = 24,
kPHYAddrMax = 31,
kPHYAddressInvalid = 0xff
};
enum {
kPHYIDInvalid = 0x00000000
};
enum {
kMIIRegisterControl = 0,
kMIIRegisterStatus = 1,
kMIIRegisterID0 = 2,
kMIIRegisterID1 = 3,
kMIIRegisterAdvertisement = 4,
kMIIRegisterLinkPartner = 5,
kMIIRegisterExpansion = 6,
kMIIRegisterNextPage = 7,
};
enum {
BitField( 7, 1, MIIControl, CollisionTest )
BitField( 8, 1, MIIControl, FullDuplex )
BitField( 9, 1, MIIControl, RestartNegotiation )
BitField( 10, 1, MIIControl, Isolate )
BitField( 11, 1, MIIControl, PowerDown )
BitField( 12, 1, MIIControl, AutoNegotiation )
BitField( 13, 1, MIIControl, SpeedSelection )
BitField( 14, 1, MIIControl, Loopback )
BitField( 15, 1, MIIControl, Reset )
};
enum {
BitField( 0, 1, MIIStatus, ExtendedCapable )
BitField( 1, 1, MIIStatus, JabberDetect )
BitField( 2, 1, MIIStatus, LinkValid )
BitField( 3, 1, MIIStatus, NegotiationAbility )
BitField( 4, 1, MIIStatus, RemoteFault )
BitField( 5, 1, MIIStatus, NegotiationComplete )
BitField( 11, 5, MIIStatus, Links )
BitField( 11, 1, MIIStatus, 10BASET )
BitField( 12, 1, MIIStatus, 10BASET_FD )
BitField( 13, 1, MIIStatus, 100BASETX )
BitField( 14, 1, MIIStatus, 100BASETX_FD )
BitField( 15, 1, MIIStatus, 100BASET4 )
};
enum {
BitField( 0, 5, MIIAdvertisement, Protocol )
BitField( 5, 5, MIIAdvertisement, Links )
BitField( 5, 1, MIIAdvertisement, 10BASET )
BitField( 6, 1, MIIAdvertisement, 10BASET_FD )
BitField( 7, 1, MIIAdvertisement, 100BASETX )
BitField( 8, 1, MIIAdvertisement, 100BASETX_FD )
BitField( 9, 1, MIIAdvertisement, 100BASET4 )
BitField( 10, 1, MIIAdvertisement, PauseCapable )
BitField( 13, 1, MIIAdvertisement, RemoteFault )
BitField( 14, 1, MIIAdvertisement, Acknowledge )
};
enum {
BitField( 0, 5, MIILinkPartner, Protocol )
BitField( 5, 5, MIILinkPartner, Links )
BitField( 5, 1, MIILinkPartner, 10BASET )
BitField( 6, 1, MIILinkPartner, 10BASET_FD )
BitField( 7, 1, MIILinkPartner, 100BASETX )
BitField( 8, 1, MIILinkPartner, 100BASETX_FD )
BitField( 9, 1, MIILinkPartner, 100BASET4 )
BitField( 13, 1, MIILinkPartner, RemoteFault )
BitField( 14, 1, MIILinkPartner, Acknowledge )
};
enum {
kPHYResetDelay = 10,
kPHYResetTimeout = 100,
kPHYLinkDelay = 20,
kPHYLinkTimeout = 5000,
};
#endif