The Pedigree Project 0.1
Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Dm9601 Class Reference
+ Inheritance diagram for Dm9601:
+ Collaboration diagram for Dm9601:

Classes

struct  InterruptInPacket
 
struct  Packet
 

Public Member Functions

 Dm9601 (UsbDevice *pDev)
 
virtual void initialiseDriver ()
 Implemented by the driver class, initialises driver-specific stuff.
 
virtual void getName (String &str)
 
virtual bool send (size_t nBytes, uintptr_t buffer)
 
virtual bool setStationInfo (const StationInfo &info)
 
virtual const StationInfo & getStationInfo ()
 
- Public Member Functions inherited from UsbDevice
 UsbDevice (UsbHub *pHub, uint8_t nPort, UsbSpeed speed)
 Default constructor.
 
 UsbDevice (UsbDevice *pDev)
 Copy constructor.
 
virtual ~UsbDevice ()
 Destructor.
 
void initialise (uint8_t nAddress)
 Initialises the device at the given address.
 
virtual void getUsbDeviceName (String &str)
 
uint8_t getAddress ()
 Returns the current address of the device.
 
uint8_t getPort ()
 Returns the number of the port on which the device is connected.
 
UsbHub * getHub () const
 
UsbSpeed getSpeed ()
 Returns the speed at which the device operates.
 
UsbState getUsbState ()
 Returns the current state of the device.
 
DeviceDescriptor * getDescriptor ()
 Returns the device descriptor of the device.
 
ConfigDescriptor * getConfiguration ()
 Returns the configuration in use.
 
Interface * getInterface ()
 Returns the interface in use.
 
void useConfiguration (uint8_t nConfig)
 Switches to the given configuration.
 
void useInterface (uint8_t nInterface)
 Switches to the given interface.
 
UsbDeviceContainer * getContainer () const
 Gets our Device container, for replacing parents on hubs etc.
 
virtual bool hasSubtree () const
 Do we expose our own Device tree?
 
virtual Device * getDevice ()
 
virtual void prepareForDriverRetirement ()
 
virtual void quiesceForRetirement ()
 
virtual void prepareForDisconnection ()
 
- 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)
 

Private Types

enum  VendorRequests {
  ReadRegister = 0 , WriteRegister = 1 , ReadMemory = 2 , WriteRegister1 = 3 ,
  WriteMemory = 5 , WriteMemory1 = 7
}
 
enum  Registers {
  NetworkControl = 0 , NetworkStatus = 1 , TxControl = 2 , TxStatus1 = 3 ,
  TxStatus2 = 4 , RxControl = 5 , RxStatus = 6 , RxOverflowCount = 7 ,
  BackPressThreshold = 8 , FlowControl = 9 , RxFlowControl = 10 , PhyControl = 11 ,
  PhyAddress = 12 , PhyLowByte = 13 , PhyHighByte = 14 , WakeUpControl = 15 ,
  PhysicalAddress = 16 , MulticastAddress = 22 , GeneralPurposeCtl = 30 , GeneralPurpose = 31 ,
  TxWriteAddressLo = 32 , TxWriteAddressHi = 33 , TxReadAddressLo = 34 , TxReadAddressHi = 35 ,
  RxWriteAddressLo = 36 , RxWriteAddressHi = 37 , RxReadAddressLo = 38 , RxReadAddressHi = 39 ,
  Vendor = 40 , Product = 42 , Chip = 44 , UsbAddress = 0xF0 ,
  RxCounter = 0xF1 , TxCount = 0xF2 , UsbStatus = 0xF2 , UsbControl = 0xF4
}
 

Private Member Functions

void receiveThread ()
 
void receiveLoop ()
 
void doReceive ()
 
bool readRegister (uint8_t reg, uintptr_t buffer, size_t nBytes)
 Reads data from a register into a buffer.
 
bool writeRegister (uint8_t reg, uintptr_t buffer, size_t nBytes)
 Writes data from a buffer to a register.
 
bool writeRegister (uint8_t reg, uint8_t data)
 Writes a single 8-bit value to a register.
 
bool readMemory (uint16_t offset, uintptr_t buffer, size_t nBytes)
 Reads data from device memory into a buffer.
 
bool writeMemory (uint16_t offset, uintptr_t buffer, size_t nBytes)
 Writes data from a buffer into device memory.
 
bool writeMemory (uint16_t offset, uint8_t data)
 Writes a single 8-bit value into device memory.
 
bool readEeprom (uint8_t offset, uint16_t &value)
 Reads a 16-bit value from the device EEPROM.
 
bool writeEeprom (uint8_t offset, uint16_t data)
 Writes a 16-bit value to the device EEPROM.
 
bool readMii (uint8_t offset, uint16_t &value)
 Reads a 16-bit value from the external MII.
 
bool writeMii (uint8_t offset, uint16_t data)
 Writes a 16-bit value to the external MII.
 
bool readSharedWord (bool phy, uint8_t offset, uint16_t &value)
 
bool writeSharedWord (bool phy, uint8_t offset, uint16_t value)
 
bool waitForSharedOperation ()
 
bool resetDevice ()
 
bool waitForLink ()
 
bool waitForTxReady ()
 
 Dm9601 (const Dm9601 &)
 
void operator= (const Dm9601 &)
 

Static Private Member Functions

static int recvTrampoline (void *p)
 
static int trampoline (void *p)
 

Private Attributes

struct Dm9601::InterruptInPacket PACKED
 
Endpoint * m_pInEndpoint
 
Endpoint * m_pOutEndpoint
 
Mutex m_TxLock
 
Mutex m_SharedRegisterLock
 
Semaphore m_IncomingPackets
 
Packet * m_RxQueueHead
 
Packet * m_RxQueueTail
 
Spinlock m_RxPacketQueueLock
 
size_t m_TxPacket
 
Atomic< bool > m_Running
 
bool m_Registered
 
OperationBarrier m_Operations
 
OwnedThread m_PacketWorker
 
OwnedThread m_ReceiveWorker
 

Additional Inherited Members

- Public Types inherited from UsbDevice
enum  UsbState {
  Connected = 0 , Addressed , HasDescriptors , Configured ,
  HasInterface , HasDriver
}
 Possible states for an USB device. More...
 
- 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)
 
- Public Attributes inherited from UsbDevice
struct UsbDevice::Setup PACKED
 
struct UsbDevice::DeviceQualifier PACKED
 
- Protected Member Functions inherited from UsbDevice
ssize_t doSync (Endpoint *pEndpoint, UsbPid pid, uintptr_t pBuffer, size_t nBytes, size_t timeout)
 
ssize_t syncIn (Endpoint *pEndpoint, uintptr_t pBuffer, size_t nBytes, size_t timeout=5000)
 
ssize_t syncOut (Endpoint *pEndpoint, uintptr_t pBuffer, size_t nBytes, size_t timeout=5000)
 
MUST_USE_RESULT bool addInterruptInHandler (Endpoint *pEndpoint, uintptr_t pBuffer, uint16_t nBytes, void(*pCallback)(uintptr_t, ssize_t), UsbInterruptInHandle &handle, uintptr_t pParam=0)
 
bool controlRequest (uint8_t nRequestType, uint8_t nRequest, uint16_t nValue, uint16_t nIndex, uint16_t nLength=0, uintptr_t pBuffer=0, uint32_t timeout=5000)
 Performs an USB control request.
 
ssize_t controlRequestResult (uint8_t nRequestType, uint8_t nRequest, uint16_t nValue, uint16_t nIndex, uint16_t nLength=0, uintptr_t pBuffer=0, uint32_t timeout=5000)
 Returns data bytes transferred, or a negative UsbError.
 
uint16_t getStatus ()
 Gets device's current status.
 
bool clearEndpointHalt (Endpoint *pEndpoint)
 Clears a halt on the given endpoint.
 
void * getDescriptor (uint8_t nDescriptorType, uint8_t nDescriptorIndex, uint16_t nBytes, uint8_t requestType=0)
 Gets a descriptor from the device.
 
uint8_t getDescriptorLength (uint8_t nDescriptorType, uint8_t nDescriptorIndex, uint8_t requestType=0)
 Gets a descriptor's length from the device.
 
String getString (uint8_t nString)
 Gets a string.
 
- Protected Member Functions inherited from Device
 NOT_COPYABLE_OR_ASSIGNABLE (Device)
 
- Static Protected Member Functions inherited from Device
static Device & root ()
 
- Protected Attributes inherited from UsbDevice
uint8_t m_nAddress
 The current address of the device.
 
uint16_t m_ControlPacketSize
 
uint8_t m_nPort
 The number of the port on which the device is connected.
 
uint8_t m_nRootPort
 Root-controller connection which owns this device generation.
 
size_t m_nRootPortGeneration
 
UsbSpeed m_Speed
 The speed at which the device operates.
 
UsbState m_UsbState
 The current state of the device.
 
DeviceDescriptor * m_pDescriptor
 Device descriptor for this device.
 
ConfigDescriptor * m_pConfiguration
 Configuration in use.
 
Interface * m_pInterface
 Interface in use.
 
UsbHub * m_pHub
 Parent USB hub.
 
UsbDeviceContainer * m_pContainer
 Our current container.
 
- 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

Definition at line 37 of file Dm9601.h.

Member Enumeration Documentation

◆ Registers

enum Dm9601::Registers
private

Definition at line 75 of file Dm9601.h.

◆ VendorRequests

enum Dm9601::VendorRequests
private

Definition at line 66 of file Dm9601.h.

Constructor & Destructor Documentation

◆ Dm9601()

Dm9601::Dm9601 ( UsbDevice *  pDev)

Definition at line 63 of file Dm9601.cc.

◆ ~Dm9601()

Dm9601::~Dm9601 ( )
virtual

Definition at line 81 of file Dm9601.cc.

Member Function Documentation

◆ doReceive()

void Dm9601::doReceive ( )
private

Definition at line 307 of file Dm9601.cc.

◆ getName()

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

Stores the device's name in str.

Reimplemented from Network.

Definition at line 45 of file Dm9601.h.

◆ getStationInfo()

const StationInfo & Dm9601::getStationInfo ( )
virtual

Gets station information (such as IP addresses)

Reimplemented from Network.

Definition at line 409 of file Dm9601.cc.

◆ initialiseDriver()

void Dm9601::initialiseDriver ( )
virtual

Implemented by the driver class, initialises driver-specific stuff.

Reimplemented from UsbDevice.

Definition at line 116 of file Dm9601.cc.

References ALIGN, Device::getParent(), ProcessorBase::information(), NetworkStack::instance(), m_pInEndpoint, UsbDevice::m_pInterface, m_pOutEndpoint, UsbDevice::m_UsbState, readEeprom(), NetworkStack::registerDevice(), and writeRegister().

◆ readEeprom()

bool Dm9601::readEeprom ( uint8_t  offset,
uint16_t &  value 
)
private

Reads a 16-bit value from the device EEPROM.

Definition at line 457 of file Dm9601.cc.

Referenced by initialiseDriver().

+ Here is the caller graph for this function:

◆ readMemory()

bool Dm9601::readMemory ( uint16_t  offset,
uintptr_t  buffer,
size_t  nBytes 
)
private

Reads data from device memory into a buffer.

Definition at line 435 of file Dm9601.cc.

References UsbDevice::controlRequest().

◆ readMii()

bool Dm9601::readMii ( uint8_t  offset,
uint16_t &  value 
)
private

Reads a 16-bit value from the external MII.

Definition at line 465 of file Dm9601.cc.

◆ readRegister()

bool Dm9601::readRegister ( uint8_t  reg,
uintptr_t  buffer,
size_t  nBytes 
)
private

Reads data from a register into a buffer.

Definition at line 413 of file Dm9601.cc.

References UsbDevice::controlRequest().

Referenced by send().

+ Here is the caller graph for this function:

◆ readSharedWord()

bool Dm9601::readSharedWord ( bool  phy,
uint8_t  offset,
uint16_t &  value 
)
private

Definition at line 473 of file Dm9601.cc.

◆ receiveLoop()

void Dm9601::receiveLoop ( )
private

Definition at line 243 of file Dm9601.cc.

◆ receiveThread()

void Dm9601::receiveThread ( )
private

Definition at line 204 of file Dm9601.cc.

◆ recvTrampoline()

int Dm9601::recvTrampoline ( void *  p)
staticprivate

Definition at line 192 of file Dm9601.cc.

◆ resetDevice()

bool Dm9601::resetDevice ( )
private

Definition at line 528 of file Dm9601.cc.

◆ send()

bool Dm9601::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

Implements Network.

Definition at line 249 of file Dm9601.cc.

References ALIGN, m_pOutEndpoint, m_TxLock, m_TxPacket, readRegister(), and OperationBarrier::tryAcquire().

◆ setStationInfo()

bool Dm9601::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 382 of file Dm9601.cc.

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

◆ trampoline()

int Dm9601::trampoline ( void *  p)
staticprivate

Definition at line 198 of file Dm9601.cc.

◆ waitForLink()

bool Dm9601::waitForLink ( )
private

Definition at line 549 of file Dm9601.cc.

◆ waitForSharedOperation()

bool Dm9601::waitForSharedOperation ( )
private

Definition at line 510 of file Dm9601.cc.

◆ waitForTxReady()

bool Dm9601::waitForTxReady ( )
private

Definition at line 568 of file Dm9601.cc.

◆ writeEeprom()

bool Dm9601::writeEeprom ( uint8_t  offset,
uint16_t  data 
)
private

Writes a 16-bit value to the device EEPROM.

Definition at line 461 of file Dm9601.cc.

◆ writeMemory() [1/2]

bool Dm9601::writeMemory ( uint16_t  offset,
uint8_t  data 
)
private

Writes a single 8-bit value into device memory.

Definition at line 451 of file Dm9601.cc.

References UsbDevice::controlRequest().

◆ writeMemory() [2/2]

bool Dm9601::writeMemory ( uint16_t  offset,
uintptr_t  buffer,
size_t  nBytes 
)
private

Writes data from a buffer into device memory.

Definition at line 443 of file Dm9601.cc.

References UsbDevice::controlRequest().

◆ writeMii()

bool Dm9601::writeMii ( uint8_t  offset,
uint16_t  data 
)
private

Writes a 16-bit value to the external MII.

Definition at line 469 of file Dm9601.cc.

◆ writeRegister() [1/2]

bool Dm9601::writeRegister ( uint8_t  reg,
uint8_t  data 
)
private

Writes a single 8-bit value to a register.

Definition at line 429 of file Dm9601.cc.

References UsbDevice::controlRequest().

◆ writeRegister() [2/2]

bool Dm9601::writeRegister ( uint8_t  reg,
uintptr_t  buffer,
size_t  nBytes 
)
private

Writes data from a buffer to a register.

Definition at line 421 of file Dm9601.cc.

References UsbDevice::controlRequest().

Referenced by initialiseDriver().

+ Here is the caller graph for this function:

◆ writeSharedWord()

bool Dm9601::writeSharedWord ( bool  phy,
uint8_t  offset,
uint16_t  value 
)
private

Definition at line 494 of file Dm9601.cc.

Member Data Documentation

◆ m_IncomingPackets

Semaphore Dm9601::m_IncomingPackets
private

Number of packets in the queue

Definition at line 176 of file Dm9601.h.

◆ m_Operations

OperationBarrier Dm9601::m_Operations
private

Definition at line 194 of file Dm9601.h.

◆ m_PacketWorker

OwnedThread Dm9601::m_PacketWorker
private

Definition at line 195 of file Dm9601.h.

◆ m_pInEndpoint

Endpoint* Dm9601::m_pInEndpoint
private

Bulk IN endpoint

Definition at line 164 of file Dm9601.h.

Referenced by initialiseDriver().

◆ m_pOutEndpoint

Endpoint* Dm9601::m_pOutEndpoint
private

Bulk OUT endpoint

Definition at line 167 of file Dm9601.h.

Referenced by initialiseDriver(), and send().

◆ m_ReceiveWorker

OwnedThread Dm9601::m_ReceiveWorker
private

Definition at line 196 of file Dm9601.h.

◆ m_Registered

bool Dm9601::m_Registered
private

Definition at line 193 of file Dm9601.h.

◆ m_Running

Atomic<bool> Dm9601::m_Running
private

Definition at line 192 of file Dm9601.h.

◆ m_RxPacketQueueLock

Spinlock Dm9601::m_RxPacketQueueLock
private

Definition at line 187 of file Dm9601.h.

◆ m_RxQueueHead

Packet* Dm9601::m_RxQueueHead
private

Definition at line 185 of file Dm9601.h.

◆ m_RxQueueTail

Packet* Dm9601::m_RxQueueTail
private

Definition at line 186 of file Dm9601.h.

◆ m_SharedRegisterLock

Mutex Dm9601::m_SharedRegisterLock
private

Serialises the multi-request EEPROM and PHY register protocol.

Definition at line 173 of file Dm9601.h.

◆ m_TxLock

Mutex Dm9601::m_TxLock
private

Mutex to only allow one TX in progress at a time.

Definition at line 170 of file Dm9601.h.

Referenced by send().

◆ m_TxPacket

size_t Dm9601::m_TxPacket
private

Internal state: which TX packet are we on at the moment

Definition at line 190 of file Dm9601.h.

Referenced by send().


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