The Pedigree Project  0.1
Classes | Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | 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 StationInfogetStationInfo ()
 
virtual bool irq (irq_id_t number, InterruptState &state)
 
- 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)
 
DevicegetParent () const
 
void setParent (Device *p)
 
virtual 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 ()
 
virtual Vector< Address * > & addresses ()
 
virtual uintptr_t getInterruptNumber ()
 
virtual void setInterruptNumber (uintptr_t n)
 
void addChild (Device *pDevice)
 
DevicegetChild (size_t n)
 
size_t getNumChildren ()
 
void removeChild (size_t n)
 
void removeChild (Device *d)
 
void replaceChild (Device *src, Device *dest)
 

Public Attributes

IoBasem_pBase
 

Private Member Functions

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

Static Private Member Functions

static int trampoline (void *p)
 

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
 
TXDm_TransmitDPD
 
RXDm_ReceiveUPD
 
Semaphore m_RxMutex
 
Semaphore m_TxMutex
 
List< void * > m_PendingPackets
 

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 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 ()
 
- Static Protected Member Functions inherited from Device
static Deviceroot ()
 
- Protected Attributes inherited from Network
StationInfo m_StationInfo
 
- Protected Attributes inherited from Device
Vector< Address * > m_Addresses
 
Vector< Device * > m_Children
 
Devicem_pParent
 
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 36 of file 3Com90x.h.

Constructor & Destructor Documentation

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

Set indication and interrupt flags, ack any IRQs

Definition at line 315 of file 3Com90x.cc.

References Semaphore::acquire(), PhysicalMemoryManager::continuous, Thread::detach(), ERROR, Device::getInterruptNumber(), Device::getParent(), Processor::information(), NetworkStack::instance(), PhysicalMemoryManager::instance(), issueCommand(), Device::m_Addresses, m_isBrev, NOTICE, MemoryRegion::physicalAddress(), List< T, nodePoolSize >::popFront(), IoBase::read16(), IoBase::read32(), readEeprom(), NetworkStack::receive(), NetworkStack::registerDevice(), IrqManager::registerIsaIrqHandler(), reset(), Device::setSpecificType(), setWindow(), MemoryRegion::virtualAddress(), WARNING, VirtualAddressSpace::Write, IoBase::write16(), IoBase::write32(), IoBase::write8(), and writeEeprom().

Member Function Documentation

virtual void Nic3C90x::getName ( String str)
inlinevirtual

Stores the device's name in str.

Reimplemented from Network.

Definition at line 42 of file 3Com90x.h.

References getStationInfo(), irq(), issueCommand(), readEeprom(), reset(), send(), setStationInfo(), setWindow(), writeEeprom(), and writeEepromWord().

const StationInfo & Nic3C90x::getStationInfo ( )
virtual

Gets station information (such as IP addresses)

Reimplemented from Network.

Definition at line 795 of file 3Com90x.cc.

Referenced by getName().

+ Here is the caller graph for this function:

bool Nic3C90x::irq ( irq_id_t  number,
InterruptState &  state 
)
virtual

Called when the handler is registered with the irq manager and the irq occurred

Note
If this function returns false you have to call IrqManager::acknowledgeIrq() when you removed the interrupt reason.
Parameters
[in]numberthe irq number
Returns
should return true, if the interrupt reason was removed, or false otherwise

Implements IrqHandler.

Definition at line 667 of file 3Com90x.cc.

References ERROR, issueCommand(), NOTICE, List< T, nodePoolSize >::pushBack(), IoBase::read16(), IoBase::read32(), IoBase::read8(), Semaphore::release(), reset(), and IoBase::write8().

Referenced by getName().

+ Here is the caller graph for this function:

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

Ported 3c90x driver from Etherboot. I've changed it around to fit into our structure, and to be a little more portable - Matt

Build the cmd.

Send the cmd to the cmd register

Wait for the cmd to complete, if necessary

Definition at line 83 of file 3Com90x.cc.

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

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

+ Here is the caller graph for this function:

uint16_t Nic3C90x::readEeprom ( int  address)
private

Select correct window

Make sure the eeprom isn't busy

Read the value

Definition at line 115 of file 3Com90x.cc.

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

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

+ Here is the caller graph for this function:

void Nic3C90x::reset ( )
private

Send the reset command to the card

Wait for reset command to complete

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

Set indication and interrupt flags, ack any IRQs

Definition at line 204 of file 3Com90x.cc.

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

Referenced by getName(), irq(), and Nic3C90x().

+ Here is the caller graph for this function:

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

Make sure the card is not waiting on us

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 267 of file 3Com90x.cc.

References Semaphore::acquire(), Processor::information(), issueCommand(), IoBase::read16(), IoBase::read32(), and IoBase::write32().

Referenced by getName().

+ Here is the caller graph for this function:

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 761 of file 3Com90x.cc.

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

Referenced by getName().

+ Here is the caller graph for this function:

int Nic3C90x::setWindow ( int  window)
private

Window already as set?

Issue the window command

Definition at line 102 of file 3Com90x.cc.

References issueCommand().

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

+ Here is the caller graph for this function:

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 168 of file 3Com90x.cc.

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

Referenced by getName(), and Nic3C90x().

+ Here is the caller graph for this function:

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 135 of file 3Com90x.cc.

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

Referenced by getName(), and writeEeprom().

+ Here is the caller graph for this function:

Member Data Documentation

uint8_t Nic3C90x::m_isBrev
private

Local NIC information

Definition at line 75 of file 3Com90x.h.

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


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