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. More...
 
virtual void getName (String &str)
 
virtual bool send (size_t nBytes, uintptr_t buffer)
 
virtual bool setStationInfo (const StationInfo &info)
 
virtual const StationInfogetStationInfo ()
 
- 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. More...
 
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.
 
UsbSpeed getSpeed ()
 Returns the speed at which the device operates.
 
UsbState getUsbState ()
 Returns the current state of the device.
 
DeviceDescriptorgetDescriptor ()
 Returns the device descriptor of the device.
 
ConfigDescriptorgetConfiguration ()
 Returns the configuration in use.
 
InterfacegetInterface ()
 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.
 
UsbDeviceContainergetContainer () const
 Gets our Device container, for replacing parents on hubs etc.
 
virtual bool hasSubtree () const
 Do we expose our own Device tree?
 
virtual DevicegetDevice ()
 
- 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)
 

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 () NORETURN
 
void receiveLoop () NORETURN
 
void doReceive ()
 
ssize_t readRegister (uint8_t reg, uintptr_t buffer, size_t nBytes)
 Reads data from a register into a buffer.
 
ssize_t writeRegister (uint8_t reg, uintptr_t buffer, size_t nBytes)
 Writes data from a buffer to a register.
 
ssize_t writeRegister (uint8_t reg, uint8_t data)
 Writes a single 8-bit value to a register.
 
ssize_t readMemory (uint16_t offset, uintptr_t buffer, size_t nBytes)
 Reads data from device memory into a buffer.
 
ssize_t writeMemory (uint16_t offset, uintptr_t buffer, size_t nBytes)
 Writes data from a buffer into device memory.
 
ssize_t writeMemory (uint16_t offset, uint8_t data)
 Writes a single 8-bit value into device memory.
 
uint16_t readEeprom (uint8_t offset)
 Reads a 16-bit value from the device EEPROM. More...
 
void writeEeprom (uint8_t offset, uint16_t data)
 Writes a 16-bit value to the device EEPROM. More...
 
uint16_t readMii (uint8_t offset)
 Reads a 16-bit value from the external MII. More...
 
void writeMii (uint8_t offset, uint16_t data)
 Writes a 16-bit value to the external MII. More...
 
 Dm9601 (const Dm9601 &)
 
void operator= (const Dm9601 &)
 

Static Private Member Functions

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

Private Attributes

struct Dm9601::InterruptInPacket PACKED
 
Endpointm_pInEndpoint
 
Endpointm_pOutEndpoint
 
Mutex m_TxLock
 
Semaphore m_IncomingPackets
 
List< Packet * > m_RxPacketQueue
 
Spinlock m_RxPacketQueueLock
 
size_t m_TxPacket
 

Additional Inherited Members

- Public Types inherited from UsbDevice
enum  UsbState {
  Connected = 0, Addressed, HasDescriptors, Configured,
  HasInterface, HasDriver
}
 Possible states for an USB device.
 
- 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)
 
- 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)
 
void addInterruptInHandler (Endpoint *pEndpoint, uintptr_t pBuffer, uint16_t nBytes, void(*pCallback)(uintptr_t, ssize_t), 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)
 Performs an USB control request.
 
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. More...
 
uint8_t getDescriptorLength (uint8_t nDescriptorType, uint8_t nDescriptorIndex, uint8_t requestType=0)
 Gets a descriptor's length from the device. More...
 
String getString (uint8_t nString)
 Gets a string. More...
 
- Protected Member Functions inherited from Device
 NOT_COPYABLE_OR_ASSIGNABLE (Device)
 
- Static Protected Member Functions inherited from Device
static Deviceroot ()
 
- Protected Attributes inherited from UsbDevice
uint8_t m_nAddress
 The current address of the device.
 
uint8_t m_nPort
 The number of the port on which the device is connected.
 
UsbSpeed m_Speed
 The speed at which the device operates.
 
UsbState m_UsbState
 The current state of the device.
 
DeviceDescriptorm_pDescriptor
 Device descriptor for this device.
 
ConfigDescriptorm_pConfiguration
 Configuration in use.
 
Interfacem_pInterface
 Interface in use.
 
UsbHubm_pHub
 Parent USB hub.
 
UsbDeviceContainerm_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
 
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

Definition at line 34 of file Dm9601.h.

Member Function Documentation

virtual void Dm9601::getName ( String str)
inlinevirtual

Stores the device's name in str.

Reimplemented from Network.

Definition at line 43 of file Dm9601.h.

References getStationInfo(), NORETURN, send(), and setStationInfo().

const StationInfo & Dm9601::getStationInfo ( )
virtual

Gets station information (such as IP addresses)

Reimplemented from Network.

Definition at line 304 of file Dm9601.cc.

Referenced by getName().

+ Here is the caller graph for this function:

void Dm9601::initialiseDriver ( )
virtual

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

Todo:
Timeout

Reimplemented from UsbDevice.

Definition at line 47 of file Dm9601.cc.

References Thread::detach(), ERROR, MemoryPool::free(), NetworkStack::getMemPool(), Device::getParent(), Processor::information(), NetworkStack::instance(), NOTICE, NetworkStack::receive(), and NetworkStack::registerDevice().

uint16_t Dm9601::readEeprom ( uint8_t  offset)
private

Reads a 16-bit value from the device EEPROM.

Todo:
Locking

Definition at line 359 of file Dm9601.cc.

uint16_t Dm9601::readMii ( uint8_t  offset)
private

Reads a 16-bit value from the external MII.

Todo:
Locking

Definition at line 389 of file Dm9601.cc.

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 182 of file Dm9601.cc.

References MemoryPool::allocate(), MemoryPool::free(), NetworkStack::getMemPool(), NetworkStack::instance(), and WARNING.

Referenced by getName().

+ Here is the caller graph for this function:

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 270 of file Dm9601.cc.

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

Referenced by getName().

+ Here is the caller graph for this function:

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

Writes a 16-bit value to the device EEPROM.

Todo:
Locking

Definition at line 375 of file Dm9601.cc.

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

Writes a 16-bit value to the external MII.

Todo:
Locking

Definition at line 405 of file Dm9601.cc.

Member Data Documentation

Semaphore Dm9601::m_IncomingPackets
private

Number of packets in the queue

Definition at line 168 of file Dm9601.h.

Endpoint* Dm9601::m_pInEndpoint
private

Bulk IN endpoint

Definition at line 159 of file Dm9601.h.

Endpoint* Dm9601::m_pOutEndpoint
private

Bulk OUT endpoint

Definition at line 162 of file Dm9601.h.

Mutex Dm9601::m_TxLock
private

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

Definition at line 165 of file Dm9601.h.

size_t Dm9601::m_TxPacket
private

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

Definition at line 181 of file Dm9601.h.


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