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

Classes

struct  HubDescriptor
 

Public Member Functions

 UsbHubDevice (UsbDevice *dev)
 
virtual void initialiseDriver ()
 Implemented by the driver class, initialises driver-specific stuff.
 
virtual void getName (String &str)
 
virtual void addTransferToTransaction (uintptr_t pTransaction, bool bToggle, UsbPid pid, uintptr_t pBuffer, size_t nBytes)
 Adds a new transfer to an existent transaction.
 
virtual uintptr_t createTransaction (UsbEndpoint endpointInfo)
 Creates a new transaction with the given endpoint data.
 
virtual void doAsync (uintptr_t pTransaction, void(*pCallback)(uintptr_t, ssize_t)=0, uintptr_t pParam=0)
 
virtual void addInterruptInHandler (UsbEndpoint endpointInfo, uintptr_t pBuffer, uint16_t nBytes, void(*pCallback)(uintptr_t, ssize_t), uintptr_t pParam=0)
 Adds a new handler for an interrupt IN transaction.
 
virtual bool portReset (uint8_t nPort, bool bErrorResponse=false)
 Gets a UsbDevice from a given vendor:product pair. More...
 
- 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 UsbHub
 UsbHub (Device *p)
 
virtual Type getType ()
 
bool deviceConnected (uint8_t nPort, UsbSpeed speed)
 Called when a device is connected to a port on the hub.
 
void deviceDisconnected (uint8_t nPort)
 Called when a device is disconnected from a port on the hub.
 
ssize_t doSync (uintptr_t nTransaction, uint32_t timeout=5000)
 
void ignoreConnectionChanges (uint8_t nPort, bool bIgnore=true)
 
- 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 void dump (String &str)
 
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  HubFeatureSelectors { HubLocalPower = 0, HubOverCurrent = 1 }
 
enum  PortFeatureSelectors {
  PortConnection = 0, PortEnable = 1, PortSuspend = 2, PortOverCurrent = 3,
  PortReset = 4, PortPower = 8, PortLowSpeed = 9, CPortConnection = 16,
  CPortEnable = 17, CPortSuspend = 18, CPortOverCurrent = 19, CPortReset = 20,
  PortTest = 21, PortIndicator = 22
}
 
enum  HubRequests { HubPortRequest = UsbRequestType::Class | UsbRequestRecipient::Other }
 

Private Member Functions

bool setPortFeature (size_t port, PortFeatureSelectors feature)
 
bool clearPortFeature (size_t port, PortFeatureSelectors feature)
 
uint32_t getPortStatus (size_t port)
 Top 32 bits hold change status.
 

Private Attributes

size_t m_nPorts
 

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 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 UsbHub
ExtensibleBitmap m_IgnoredPorts
 Bitmap of ports to ignore connection changes on.
 
- 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 31 of file UsbHubDevice.h.

Member Function Documentation

void UsbHubDevice::doAsync ( uintptr_t  pTransaction,
void(*)(uintptr_t, ssize_t)  pCallback = 0,
uintptr_t  pParam = 0 
)
virtual

Performs a transaction asynchronously, calling the given callback on completion

Implements UsbHub.

Definition at line 189 of file UsbHubDevice.cc.

Referenced by getName().

+ Here is the caller graph for this function:

virtual void UsbHubDevice::getName ( String str)
inlinevirtual

Stores the device's name in str.

Reimplemented from Device.

Definition at line 39 of file UsbHubDevice.h.

References addInterruptInHandler(), addTransferToTransaction(), createTransaction(), doAsync(), getPortStatus(), and portReset().

bool UsbHubDevice::portReset ( uint8_t  nPort,
bool  bErrorResponse = false 
)
virtual

Gets a UsbDevice from a given vendor:product pair.

Performs a port reset for the given port. Should only be used in situations where a device cannot recover from an error without a complete reset.

Note
Assumes the port is at CONNECTED with a VALID DEVICE attached.
Parameters
bErrorResponsetrue if this is a reset as a response to an error. Error responses are allowed to use significantly longer delays in their reset logic.

Implements UsbHub.

Definition at line 127 of file UsbHubDevice.cc.

Referenced by getName().

+ Here is the caller graph for this function:


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