|
The Pedigree Project 0.1
|
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) |
| bool | hasSubtree () const override |
| Do we expose our own Device tree? | |
| Device * | getDevice () override |
| void | prepareForDriverRetirement () override |
| void | quiesceForRetirement () override |
| void | prepareForDisconnection () override |
| 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 MUST_USE_RESULT bool | doAsync (uintptr_t pTransaction, void(*pCallback)(uintptr_t, ssize_t)=0, uintptr_t pParam=0) |
| virtual MUST_USE_RESULT bool | addInterruptInHandler (UsbEndpoint endpointInfo, uintptr_t pBuffer, uint16_t nBytes, void(*pCallback)(uintptr_t, ssize_t), UsbInterruptInHandle &handle, uintptr_t pParam=0) |
| Adds an owned recurring interrupt-IN transaction. | |
| virtual bool | portReset (uint8_t nPort, bool bErrorResponse=false) |
| Gets a UsbDevice from a given vendor:product pair. | |
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. | |
Public Member Functions inherited from UsbHub | |
| UsbHub (Device *p) | |
| RootConnection | rootConnectionForChild (uint8_t childPort) const |
| virtual bool | controllerAssignsAddresses () const |
| virtual bool | supportsHubDevices () const |
| virtual bool | prepareDevice (uint8_t, const UsbEndpoint &) |
| virtual bool | addressDevice (uint8_t, const UsbEndpoint &) |
| virtual bool | resetEndpoint (const UsbEndpoint &) |
| 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) |
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 void | dump (String &str) |
| 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) |
Protected Member Functions | |
| virtual void | cancelAsyncAndDrain (uintptr_t pTransaction, void(*pCallback)(uintptr_t, ssize_t), uintptr_t pParam) |
| MUST_USE_RESULT bool | cancelInterruptInAndDrain (const UsbInterruptInToken &token, void(*callback)(uintptr_t, ssize_t), uintptr_t parameter, bool producerAlreadyStopped) override |
| uint64_t | executeRequest (uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, uint64_t p5, uint64_t p6, uint64_t p7, uint64_t p8) override |
| void | cancelRequest (const Request &request) override |
| bool | portSpeed (uint8_t port, UsbSpeed &speed) override |
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 UsbHub | |
| virtual bool | beginStartupActivity () |
| virtual void | endStartupActivity (UsbStartup::Outcome) |
| virtual void | releaseDeviceAddress (uint8_t) |
| MUST_USE_RESULT bool | publishInterruptInHandle (UsbInterruptInHandle &handle, const UsbInterruptInToken &token, void(*callback)(uintptr_t, ssize_t), uintptr_t parameter) |
| virtual bool | inInterruptCallbackContext () const |
| void | disconnectAllDevices () |
| void | retainDisconnectedAddressesUntilControllerTeardown () |
| void | attachToUpstreamHub (UsbHub *upstream, const RootConnection &connection) |
| UsbHub * | rootHub () const |
| MUST_USE_RESULT bool | suppressConnectionChanges (size_t port, ConnectionChangeSuppression &suppression) |
| MUST_USE_RESULT bool | deferConnectionChangeIfSuppressed (size_t port) |
| virtual void | replaySuppressedConnectionChange (size_t port) |
| virtual size_t | currentRootPortGeneration (size_t port) const |
Protected Member Functions inherited from Device | |
| NOT_COPYABLE_OR_ASSIGNABLE (Device) | |
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 { HubRequest = static_cast<uint8_t>(UsbRequestType::Class) , HubPortRequest } |
Private Types inherited from RequestQueue | |
| enum class | OverrunStatus { Clear , Armed , Stalled , Overloaded } |
| enum class | PreallocatedPublishResult { Accepted , TokenBusy , QueueStopped , QueueFull , InvalidPriority } |
| enum | ActionOnDuplicate { Block , NewRequest , ReturnImmediately } |
| enum class | LifecycleState { Stopped , Accepting , Stopping , Destroyed } |
| enum class | NextRequestResult { Item , Empty , Retry } |
Private Member Functions | |
| bool | setPortFeature (size_t port, PortFeatureSelectors feature) |
| bool | clearPortFeature (size_t port, PortFeatureSelectors feature) |
| bool | getPortStatus (size_t port, uint32_t &status) |
| Top 16 bits of status hold the port-change flags. | |
| bool | clearPortChanges (size_t port, uint32_t status) |
| bool | debouncePort (size_t port, uint32_t &status) |
| bool | connectPort (size_t port) |
| void | portChanged (size_t port) |
| void | stopHotplug () |
Private Member Functions inherited from RequestQueue | |
| RequestQueue (const String &name) | |
| virtual void | initialise () |
| virtual void | destroy () |
| MUST_USE_RESULT uint64_t | addRequest (size_t priority, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
| MUST_USE_RESULT uint64_t | addRequest (size_t priority, ActionOnDuplicate action, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
| uint64_t | addAsyncRequest (size_t priority, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
| MUST_USE_RESULT bool | publishAsyncRequest (size_t priority, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
| bool | canWaitForCompletion () |
| MUST_USE_RESULT bool | waitForPreallocated (PreallocatedRequest &request) |
| MUST_USE_RESULT PreallocatedPublishResult | publishPreallocated (PreallocatedRequest &request, size_t priority, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
| MUST_USE_RESULT PreallocatedPublishResult | republishPreallocatedWhileReleasing (PreallocatedRequest &request, size_t priority, uint64_t p1=0, uint64_t p2=0, uint64_t p3=0, uint64_t p4=0, uint64_t p5=0, uint64_t p6=0, uint64_t p7=0, uint64_t p8=0) |
| MUST_USE_RESULT bool | halt () |
| MUST_USE_RESULT bool | resume () |
| LifecycleState | getLifecycleState () |
| bool | drain () |
| virtual bool | workerPlacement (ThreadPlacement &) const |
| RequestQueue (const RequestQueue &) | |
| void | operator= (const RequestQueue &) |
| virtual bool | compareRequests (const Request &a, const Request &b) |
| int | work () |
| NextRequestResult | getNextRequest (Request *&request) |
| bool | drainIntakeLocked (size_t priority) |
| void | publishRequest (Request *request) |
| Request * | findDuplicate (const Request &request) |
| void | discardRequest (Request *request) |
| uint64_t | addAsyncRequestInternal (size_t priority, uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, uint64_t p5, uint64_t p6, uint64_t p7, uint64_t p8) |
| PreallocatedPublishResult | publishPreallocatedRequest (PreallocatedRequest &request, PreallocatedRequest::State availableState, size_t priority, uint64_t p1, uint64_t p2, uint64_t p3, uint64_t p4, uint64_t p5, uint64_t p6, uint64_t p7, uint64_t p8) |
| void | releasePreallocatedRequest (Request *request) |
| void | invokeCancelRequest (const Request &request) |
| bool | callbackActiveOnCurrentThread () const |
| void | releaseRequest (Request *request) |
| uint64_t | waitForRequest (Request *request) |
| bool | startWorker () |
| bool | stopWorker () |
| void | closePreallocatedAdmission () |
| void | waitForPreallocatedPublishers () |
Static Private Member Functions | |
| static void | statusChanged (uintptr_t parameter, ssize_t result) |
Static Private Member Functions inherited from RequestQueue | |
| static int | trampoline (void *p) |
| static void | completeRequest (Request *request, uint64_t returnValue, bool rejected) |
| static void | retainRequest (Request *request) |
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 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 |
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 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 |
Static Private Attributes inherited from RequestQueue | |
| static constexpr size_t | PublicationClosed = static_cast<size_t>(1) << ((sizeof(size_t) * 8) - 1) |
| static constexpr size_t | PublicationCountMask = ~PublicationClosed |
Definition at line 33 of file UsbHubDevice.h.
|
private |
Definition at line 83 of file UsbHubDevice.h.
|
private |
Definition at line 105 of file UsbHubDevice.h.
|
private |
Definition at line 88 of file UsbHubDevice.h.
| UsbHubDevice::UsbHubDevice | ( | UsbDevice * | dev | ) |
Definition at line 35 of file UsbHubDevice.cc.
|
virtual |
Definition at line 48 of file UsbHubDevice.cc.
|
virtual |
Adds an owned recurring interrupt-IN transaction.
Implements UsbHub.
Definition at line 427 of file UsbHubDevice.cc.
References UsbHub::addInterruptInHandler(), UsbDevice::m_nAddress, UsbDevice::m_nPort, UsbDevice::m_pHub, and UsbDevice::m_Speed.
|
virtual |
Adds a new transfer to an existent transaction.
Implements UsbHub.
Definition at line 401 of file UsbHubDevice.cc.
References UsbHub::addTransferToTransaction(), and UsbDevice::m_pHub.
|
protectedvirtual |
Cancels an accepted transaction or drains a completion which won the race. On return, the matching callback has run exactly once and the controller can no longer access any transfer buffer.
The callback and parameter identify the original transaction generation, preventing a stale numeric transaction handle from cancelling a reused controller slot.
Implements UsbHub.
Definition at line 422 of file UsbHubDevice.cc.
References UsbHub::cancelAsyncAndDrain(), and UsbDevice::m_pHub.
|
overrideprotectedvirtual |
Stops and drains one exact recurring interrupt-IN subscription.
Implements UsbHub.
Definition at line 441 of file UsbHubDevice.cc.
References panic().
|
overrideprotectedvirtual |
Releases payload ownership for a request that will not execute.
This runs without the queue guard for rejected candidates (including stopped queues, duplicates and capacity limits) and queued requests cancelled by destroy(). Implementations used by allocation-free producers must not sleep. Derived destructors must call destroy() while their override and member state are still alive. During destroy(), the lifecycle is serialized: halt() and resume() on this queue return false, while recursive destroy() is a fatal contract violation.
Reimplemented from RequestQueue.
Definition at line 245 of file UsbHubDevice.cc.
|
private |
Definition at line 249 of file UsbHubDevice.cc.
|
private |
Definition at line 389 of file UsbHubDevice.cc.
|
private |
Definition at line 283 of file UsbHubDevice.cc.
|
virtual |
Creates a new transaction with the given endpoint data.
Implements UsbHub.
Definition at line 406 of file UsbHubDevice.cc.
References UsbHub::createTransaction(), UsbDevice::m_nAddress, UsbDevice::m_nPort, UsbDevice::m_pHub, and UsbDevice::m_Speed.
|
private |
Definition at line 261 of file UsbHubDevice.cc.
|
virtual |
Performs a transaction asynchronously.
Returning true transfers one completion obligation to the controller: it must call the callback exactly once, and only after it can no longer access any transfer buffer. Returning false guarantees that the callback was not and will not be called, and that the rejected transaction no longer owns controller or transfer-buffer state.
Implements UsbHub.
Definition at line 417 of file UsbHubDevice.cc.
References UsbHub::doAsync(), and UsbDevice::m_pHub.
|
overrideprotectedvirtual |
Callback - classes are expected to inherit and override this function. It's called when a request needs to be executed (by the worker thread).
Implements RequestQueue.
Definition at line 217 of file UsbHubDevice.cc.
References UsbDevice::controlRequest(), Dec, RequestQueue::getLifecycleState(), and Hex.
|
inlineoverridevirtual |
Get a usable Device for this particular UsbDevice, if it has a subtree.
Reimplemented from UsbDevice.
Definition at line 48 of file UsbHubDevice.h.
|
inlinevirtual |
Stores the device's name in str.
Reimplemented from Device.
Definition at line 40 of file UsbHubDevice.h.
|
private |
Top 16 bits of status hold the port-change flags.
Definition at line 393 of file UsbHubDevice.cc.
References UsbDevice::controlRequest().
Referenced by initialiseDriver(), portReset(), and portSpeed().
Here is the caller graph for this function:
|
inlineoverridevirtual |
Do we expose our own Device tree?
Reimplemented from UsbDevice.
Definition at line 44 of file UsbHubDevice.h.
|
virtual |
Implemented by the driver class, initialises driver-specific stuff.
Reimplemented from UsbDevice.
Definition at line 80 of file UsbHubDevice.cc.
References Dec, UsbDevice::getDescriptor(), UsbDevice::getDescriptorLength(), RequestQueue::getLifecycleState(), getPortStatus(), Hex, RequestQueue::initialise(), UsbDevice::m_nAddress, UsbDevice::m_pInterface, and UsbDevice::m_UsbState.
|
private |
Definition at line 306 of file UsbHubDevice.cc.
|
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.
| bErrorResponse | true 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 344 of file UsbHubDevice.cc.
References Dec, RequestQueue::getLifecycleState(), getPortStatus(), and Hex.
|
overrideprotectedvirtual |
Queries negotiated speed after reset while address zero is serialized.
Reimplemented from UsbHub.
Definition at line 291 of file UsbHubDevice.cc.
References getPortStatus().
|
overridevirtual |
Prepares a driver after its physical device has disappeared.
Reimplemented from UsbDevice.
Definition at line 60 of file UsbHubDevice.cc.
|
overridevirtual |
Quiesces driver-specific ownership before replacing this binding.
Reimplemented from UsbDevice.
Definition at line 55 of file UsbHubDevice.cc.
References UsbHub::retainDisconnectedAddressesUntilControllerTeardown().
|
overridevirtual |
Stops producers which can add or replace devices in this subtree.
Reimplemented from UsbDevice.
Definition at line 64 of file UsbHubDevice.cc.
|
private |
Definition at line 385 of file UsbHubDevice.cc.
|
staticprivate |
Definition at line 196 of file UsbHubDevice.cc.
|
private |
Definition at line 68 of file UsbHubDevice.cc.
|
private |
Definition at line 148 of file UsbHubDevice.h.
|
private |
Definition at line 149 of file UsbHubDevice.h.
|
private |
Definition at line 150 of file UsbHubDevice.h.
|
private |
Definition at line 151 of file UsbHubDevice.h.
|
private |
Definition at line 153 of file UsbHubDevice.h.
|
private |
Definition at line 152 of file UsbHubDevice.h.