The Pedigree Project 0.1
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Nic3C90x Class Reference

#include <3Com90x.h>

+ Inheritance diagram for Nic3C90x:
+ Collaboration diagram for Nic3C90x:

Classes

struct  RXD
 
struct  TXD
 

Public Member Functions

 Nic3C90x (Network *pDev)
 
virtual void getName (String &str)
 
virtual bool send (size_t nBytes, uintptr_t buffer)
 
virtual bool setStationInfo (const StationInfo &info)
 
virtual const StationInfo & getStationInfo ()
 
bool isInitialised () const
 
virtual IrqDisposition irq (irq_id_t number)
 
- Public Member Functions inherited from Network
 Network (Network *pDev)
 
virtual Type getType ()
 
virtual void dump (String &str)
 
virtual bool isConnected ()
 
virtual void gotPacket ()
 
virtual void droppedPacket ()
 Called when a packet is dropped by the system.
 
virtual void badPacket ()
 
- Public Member Functions inherited from Device
 Device (Device *p)
 
Device * getParent () const
 
void setParent (Device *p)
 
virtual const String & getSpecificType ()
 
virtual void setSpecificType (String str)
 
void setPciPosition (uint32_t bus, uint32_t device, uint32_t func)
 
void setPciIdentifiers (uint8_t classCode, uint8_t subclassCode, uint16_t vendorId, uint16_t deviceId, uint8_t progIf)
 
void setPciConfigHeader (const PciBus::ConfigSpace &space)
 
PciBus::ConfigSpace getPciConfigHeader () const
 
uint8_t getPciClassCode ()
 
uint8_t getPciSubclassCode ()
 
uint16_t getPciVendorId ()
 
uint16_t getPciDeviceId ()
 
uint8_t getPciProgInterface ()
 
uint32_t getPciBusPosition ()
 
uint32_t getPciDevicePosition ()
 
uint32_t getPciFunctionNumber ()
 
Device * getPhysicalFunction () const
 
size_t getVirtualFunctionIndex () const
 
void setVirtualFunction (Device *physicalFunction, size_t index)
 
virtual Vector< Address * > & addresses ()
 
virtual uintptr_t getInterruptNumber ()
 
virtual void setInterruptNumber (uintptr_t n)
 
void addChild (Device *pDevice)
 
Device * getChild (size_t n)
 
size_t getNumChildren ()
 
void removeChild (size_t n)
 
void removeChild (Device *d)
 
void replaceChild (Device *src, Device *dest)
 
- Public Member Functions inherited from IrqHandler
virtual bool acceptsSpuriousInterrupts () const
 

Public Attributes

IoBase * m_pBase
 

Private Member Functions

bool issueCommand (int cmd, int param)
 
int setWindow (int window)
 
bool waitForEepromReady ()
 
bool readEeprom (int address, uint16_t &value)
 
int writeEepromWord (int address, uint16_t value)
 
int writeEeprom (int address, uint16_t value)
 
bool reset ()
 
bool quiesce ()
 
bool stopDeviceLocked ()
 
struct Nic3C90x::TXD __attribute__ ((aligned(8)))
 
struct Nic3C90x::RXD __attribute__ ((aligned(8)))
 
 Nic3C90x (const Nic3C90x &)
 
void operator= (const Nic3C90x &)
 

Private Attributes

uint8_t m_isBrev
 
uint8_t m_CurrentWindow
 
uint8_t * m_pRxBuffVirt
 
uint8_t * m_pTxBuffVirt
 
uintptr_t m_pRxBuffPhys
 
uintptr_t m_pTxBuffPhys
 
MemoryRegion m_RxBuffMR
 
MemoryRegion m_TxBuffMR
 
uintptr_t m_pDPD
 
MemoryRegion m_DPDMR
 
uintptr_t m_pUPD
 
MemoryRegion m_UPDMR
 
TXD * m_TransmitDPD
 
RXD * m_ReceiveUPD
 
uint8_t m_ReceiveStaging [NUM_UPDS *ReceiveSlotSize]
 
Semaphore m_TxMutex
 
Mutex m_DeviceLock
 
Mutex m_SendLock
 
size_t m_RxConsumerIndex
 
irq_id_t m_IrqId
 
bool m_Active
 
bool m_Stopping
 
bool m_TxSuccessful
 
bool m_Initialised
 

Static Private Attributes

static constexpr size_t ReceiveSlotSize = 1536
 

Additional Inherited Members

- Public Types inherited from Device
enum  Type {
  Generic , Root , Disk , Bus ,
  Display , Network , Sound , Console ,
  Mouse , Controller , UsbController , UsbGeneric ,
  UsbContainer
}
 
typedef Device *(* Callback) (Device *)
 
- Static Public Member Functions inherited from Network
static EXPORTED_PUBLIC uint32_t convertToIpv4 (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
 
static EXPORTED_PUBLIC IpAddress convertToIpv6 (uint8_t a, uint8_t b=0, uint8_t c=0, uint8_t d=0, uint8_t e=0, uint8_t f=0, uint8_t g=0, uint8_t h=0, uint8_t i=0, uint8_t j=0, uint8_t k=0, uint8_t l=0, uint8_t m=0, uint8_t n=0, uint8_t o=0, uint8_t p=0)
 
static EXPORTED_PUBLIC uint16_t calculateChecksum (uintptr_t buffer, size_t nBytes)
 
- Static Public Member Functions inherited from Device
static bool treeLockHeldByCurrentThread ()
 
static void foreach (Callback callback, Device *root=0)
 
template<class F , class... Args>
static void foreach (pedigree_std::Callable< F > &callback, Device *root, Args... args)
 
static void addToRoot (Device *device)
 
static void searchByVendorId (uint16_t vendorId, void(*callback)(Device *), Device *root=0)
 
static void searchByVendorIdAndDeviceId (uint16_t vendorId, uint16_t deviceId, void(*callback)(Device *), Device *root=0)
 
static void searchByClass (uint16_t classCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassAndSubclass (uint16_t classCode, uint16_t subclassCode, void(*callback)(Device *), Device *root=0)
 
static void searchByClassSubclassAndProgInterface (uint16_t classCode, uint16_t subclassCode, uint8_t progInterface, void(*callback)(Device *), Device *root=0)
 
- Protected Member Functions inherited from Device
 NOT_COPYABLE_OR_ASSIGNABLE (Device)
 
- Protected Member Functions inherited from IrqHandler
virtual ~IrqHandler ()
 
- Protected Member Functions inherited from IrqHandlerBase
virtual ~IrqHandlerBase ()
 
- Static Protected Member Functions inherited from Device
static Device & root ()
 
- Protected Attributes inherited from Network
StationInfo m_StationInfo
 
- Protected Attributes inherited from Device
Vector< Address * > m_Addresses
 
Vector< Device * > m_Children
 
Device * m_pParent
 
Device * m_PhysicalFunction
 
size_t m_VirtualFunctionIndex
 
uintptr_t m_InterruptNumber
 
String m_SpecificType
 
PciBus::ConfigSpace m_ConfigHeader
 
uint8_t m_ClassCode
 
uint8_t m_SubclassCode
 
uint16_t m_VendorId
 
uint16_t m_DeviceId
 
uint8_t m_ProgInterface
 
uint32_t m_PciBusPos
 
uint32_t m_PciDevicePos
 
uint32_t m_PciFunctionNum
 
- Static Protected Attributes inherited from Device
static Device m_Root
 
static Mutex m_TreeLock
 

Detailed Description

Device driver for the Nic3C90x class of network device

Definition at line 38 of file 3Com90x.h.

Constructor & Destructor Documentation

◆ Nic3C90x()

Nic3C90x::Nic3C90x ( Network *  pDev)

10 Base TPO

10/100 T4

10/100 TPO

10 Base Combo

10 Base TPO

10 Base Combo

10 Base TPO and Base2

10 Base FL

10/100 TPO

10/100 T4

10 Base FX

Load EEPROM contents

Get the hardware address

Program the MAC address into the station address registers

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

mask out VCO bit that is defined as 10 base FL bit on B-rev cards

Determine transceiver type to use, depending on value stored in eeprom 0x16

Enable DC converter for 10-BASE-T

Set the link to the type we just determined

Now that we've set the xcvr type, reset TX and RX, re-enable

reset of the receiver on B-revision cards re-negotiates the link takes several seconds

Set the RX filter = receive only individual packets & multicast & broadcast

Configure indications but leave the physical source gated.

Definition at line 433 of file 3Com90x.cc.

References PhysicalMemoryManager::allocateRegion(), NetworkStack::deRegisterDevice(), NetworkStack::instance(), PhysicalMemoryManager::instance(), issueCommand(), Device::m_Addresses, m_isBrev, MemoryRegion::physicalAddress(), IoBase::read16(), IoBase::read32(), readEeprom(), NetworkStack::registerDevice(), IrqManager::registerPciIrqHandler(), reset(), Device::setSpecificType(), setWindow(), MemoryRegion::virtualAddress(), VirtualAddressSpace::Write, IoBase::write16(), IoBase::write32(), IoBase::write8(), and writeEeprom().

◆ ~Nic3C90x()

Nic3C90x::~Nic3C90x ( )

Definition at line 764 of file 3Com90x.cc.

Member Function Documentation

◆ getName()

virtual void Nic3C90x::getName ( String &  str)
inlinevirtual

Stores the device's name in str.

Reimplemented from Network.

Definition at line 43 of file 3Com90x.h.

◆ getStationInfo()

const StationInfo & Nic3C90x::getStationInfo ( )
virtual

Gets station information (such as IP addresses)

Reimplemented from Network.

Definition at line 974 of file 3Com90x.cc.

◆ irq()

IrqDisposition Nic3C90x::irq ( irq_id_t  number)
virtual

Handles a pending IRQ in thread context.

Implements IrqHandler.

Definition at line 786 of file 3Com90x.cc.

References NetworkStack::instance(), issueCommand(), Quiesced, IoBase::read16(), IoBase::read8(), NetworkStack::receive(), Semaphore::release(), IoBase::write32(), and IoBase::write8().

◆ isInitialised()

bool Nic3C90x::isInitialised ( ) const
inline

Definition at line 53 of file 3Com90x.h.

◆ issueCommand()

bool Nic3C90x::issueCommand ( int  cmd,
int  param 
)
private

Build the cmd.

Send the cmd to the cmd register

Wait for the cmd to complete, if necessary

Definition at line 95 of file 3Com90x.cc.

References Hex, IoBase::read16(), and IoBase::write16().

Referenced by irq(), Nic3C90x(), reset(), send(), and setWindow().

+ Here is the caller graph for this function:

◆ quiesce()

bool Nic3C90x::quiesce ( )
private

Definition at line 314 of file 3Com90x.cc.

◆ readEeprom()

bool Nic3C90x::readEeprom ( int  address,
uint16_t &  value 
)
private

Select correct window

Make sure the eeprom isn't busy

Read the value

Definition at line 158 of file 3Com90x.cc.

References IoBase::read16(), setWindow(), and IoBase::write16().

Referenced by Nic3C90x(), and writeEeprom().

+ Here is the caller graph for this function:

◆ reset()

bool Nic3C90x::reset ( )
private

Send the reset command to the card

Global reset command resets station mask, non-B revision cards require explicit reset of values

Issue transmit reset, wait for command completion

Reset of the receiver on B-revision cards re-negotiates the link Takes several seconds

Configure indications but leave the physical source gated.

Definition at line 242 of file 3Com90x.cc.

References issueCommand(), m_isBrev, IoBase::read32(), setWindow(), IoBase::write16(), IoBase::write32(), and IoBase::write8().

Referenced by Nic3C90x().

+ Here is the caller graph for this function:

◆ send()

bool Nic3C90x::send ( size_t  nBytes,
uintptr_t  buffer 
)
virtual

Sends a given packet through the device.

Parameters
nBytesThe number of bytes to send.
bufferA buffer with the packet to send

Stall the download engine

Setup the DPD (download descriptor)

Set notification for transmission complete (bit 15)

Send the packet

End Stall and Wait for upload to complete.

Implements Network.

Definition at line 347 of file 3Com90x.cc.

References Semaphore::acquireForCompletion(), Dec, Semaphore::drainAvailable(), Hex, issueCommand(), IoBase::read32(), and IoBase::write32().

◆ setStationInfo()

bool Nic3C90x::setStationInfo ( const StationInfo &  info)
virtual

Sets station information (such as IP addresses)

Parameters
infoThe information to set as the station info

Reimplemented from Network.

Definition at line 947 of file 3Com90x.cc.

References Dec, StationInfo::gateway, Hex, and StationInfo::nDnsServers.

◆ setWindow()

int Nic3C90x::setWindow ( int  window)
private

Window already as set?

Issue the window command

Definition at line 132 of file 3Com90x.cc.

References issueCommand().

Referenced by Nic3C90x(), readEeprom(), reset(), and writeEepromWord().

+ Here is the caller graph for this function:

◆ stopDeviceLocked()

bool Nic3C90x::stopDeviceLocked ( )
private

Definition at line 331 of file 3Com90x.cc.

◆ waitForEepromReady()

bool Nic3C90x::waitForEepromReady ( )
private

Definition at line 145 of file 3Com90x.cc.

◆ writeEeprom()

int Nic3C90x::writeEeprom ( int  address,
uint16_t  value 
)
private

Write the value.

Recompute the checksum

Write the checksum to the location in the eeprom

Definition at line 209 of file 3Com90x.cc.

References m_isBrev, readEeprom(), and writeEepromWord().

Referenced by Nic3C90x().

+ Here is the caller graph for this function:

◆ writeEepromWord()

int Nic3C90x::writeEepromWord ( int  address,
uint16_t  value 
)
private

Select register window

Verify Eeprom not busy

Issue WriteEnable, and wait for completion

Issue EraseReigster, and wait for completion

Send the new data to the eeprom, and wait for completion

Burn the new data into the eeprom, and wait for completion

Definition at line 176 of file 3Com90x.cc.

References setWindow(), and IoBase::write16().

Referenced by writeEeprom().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_Active

bool Nic3C90x::m_Active
private

Definition at line 132 of file 3Com90x.h.

◆ m_CurrentWindow

uint8_t Nic3C90x::m_CurrentWindow
private

Definition at line 81 of file 3Com90x.h.

◆ m_DeviceLock

Mutex Nic3C90x::m_DeviceLock
private

Definition at line 127 of file 3Com90x.h.

◆ m_DPDMR

MemoryRegion Nic3C90x::m_DPDMR
private

Definition at line 91 of file 3Com90x.h.

◆ m_Initialised

bool Nic3C90x::m_Initialised
private

Definition at line 135 of file 3Com90x.h.

◆ m_IrqId

irq_id_t Nic3C90x::m_IrqId
private

Definition at line 131 of file 3Com90x.h.

◆ m_isBrev

uint8_t Nic3C90x::m_isBrev
private

Local NIC information

Definition at line 80 of file 3Com90x.h.

Referenced by Nic3C90x(), reset(), and writeEeprom().

◆ m_pBase

IoBase* Nic3C90x::m_pBase

Definition at line 60 of file 3Com90x.h.

◆ m_pDPD

uintptr_t Nic3C90x::m_pDPD
private

Definition at line 90 of file 3Com90x.h.

◆ m_pRxBuffPhys

uintptr_t Nic3C90x::m_pRxBuffPhys
private

Definition at line 85 of file 3Com90x.h.

◆ m_pRxBuffVirt

uint8_t* Nic3C90x::m_pRxBuffVirt
private

Definition at line 83 of file 3Com90x.h.

◆ m_pTxBuffPhys

uintptr_t Nic3C90x::m_pTxBuffPhys
private

Definition at line 86 of file 3Com90x.h.

◆ m_pTxBuffVirt

uint8_t* Nic3C90x::m_pTxBuffVirt
private

Definition at line 84 of file 3Com90x.h.

◆ m_pUPD

uintptr_t Nic3C90x::m_pUPD
private

Definition at line 93 of file 3Com90x.h.

◆ m_ReceiveStaging

uint8_t Nic3C90x::m_ReceiveStaging[NUM_UPDS *ReceiveSlotSize]
private

Definition at line 120 of file 3Com90x.h.

◆ m_ReceiveUPD

RXD* Nic3C90x::m_ReceiveUPD
private

Definition at line 115 of file 3Com90x.h.

◆ m_RxBuffMR

MemoryRegion Nic3C90x::m_RxBuffMR
private

Definition at line 87 of file 3Com90x.h.

◆ m_RxConsumerIndex

size_t Nic3C90x::m_RxConsumerIndex
private

Definition at line 130 of file 3Com90x.h.

◆ m_SendLock

Mutex Nic3C90x::m_SendLock
private

Definition at line 128 of file 3Com90x.h.

◆ m_Stopping

bool Nic3C90x::m_Stopping
private

Definition at line 133 of file 3Com90x.h.

◆ m_TransmitDPD

TXD* Nic3C90x::m_TransmitDPD
private

Definition at line 114 of file 3Com90x.h.

◆ m_TxBuffMR

MemoryRegion Nic3C90x::m_TxBuffMR
private

Definition at line 88 of file 3Com90x.h.

◆ m_TxMutex

Semaphore Nic3C90x::m_TxMutex
private

Definition at line 125 of file 3Com90x.h.

◆ m_TxSuccessful

bool Nic3C90x::m_TxSuccessful
private

Definition at line 134 of file 3Com90x.h.

◆ m_UPDMR

MemoryRegion Nic3C90x::m_UPDMR
private

Definition at line 94 of file 3Com90x.h.

◆ ReceiveSlotSize

constexpr size_t Nic3C90x::ReceiveSlotSize = 1536
staticconstexprprivate

Definition at line 63 of file 3Com90x.h.


The documentation for this class was generated from the following files: