|
The Pedigree Project 0.1
|
Inheritance diagram for UsbHub:
Collaboration diagram for UsbHub:Classes | |
| class | ConnectionChangeSuppression |
| struct | RootConnection |
| class | StartupActivity |
| struct | SyncParam |
| Structure used synchronous transactions. More... | |
Public Member Functions | |
| 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 () |
| virtual void | addTransferToTransaction (uintptr_t pTransaction, bool bToggle, UsbPid pid, uintptr_t pBuffer, size_t nBytes)=0 |
| Adds a new transfer to an existent transaction. | |
| virtual uintptr_t | createTransaction (UsbEndpoint endpointInfo)=0 |
| 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)=0 |
| virtual void | cancelAsyncAndDrain (uintptr_t pTransaction, void(*pCallback)(uintptr_t, ssize_t), 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)=0 |
| Adds an owned recurring interrupt-IN transaction. | |
| 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) |
| virtual bool | portReset (uint8_t nPort, bool bErrorResponse=false)=0 |
| Gets a UsbDevice from a given vendor:product pair. | |
Public Member Functions inherited from Device | |
| Device (Device *p) | |
| Device * | getParent () const |
| void | setParent (Device *p) |
| virtual void | getName (String &str) |
| 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 () |
| 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 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 MUST_USE_RESULT bool | cancelInterruptInAndDrain (const UsbInterruptInToken &token, void(*callback)(uintptr_t, ssize_t), uintptr_t parameter, bool producerAlreadyStopped)=0 |
| 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 Member Functions | |
| bool | deviceConnectedAdmitted (uint8_t nPort, UsbSpeed speed) |
| void | deviceDisconnectedLocked (uint8_t nPort) |
| void | retirePortContainersLocked (uint8_t nPort, bool *retiredAddresses, bool *pinnedSubtreeAddresses=nullptr) |
| void | releaseRetiredAddressesLocked (uint8_t nPort, const bool *retiredAddresses) |
| void | retainAddressLocked (size_t address) |
| void | releaseAddressLocked (size_t address) |
| void | retainAddressesLocked (const bool *addresses) |
| void | releaseAddressesLocked (const bool *addresses) |
| void | releaseConnectionChangeSuppression (size_t port) |
Static Private Member Functions | |
| static void | syncCallback (uintptr_t pParam, ssize_t ret) |
| Callback used by synchronous transactions. | |
| static void | collectUsbAddresses (Device *device, bool *addresses) |
| static void | collectImmediateUsbContainers (Device *device, List< UsbDeviceContainer * > &containers) |
| static void | drainSubtreeProbeAdmissions (UsbDeviceContainer *container) |
Private Attributes | |
| ExtensibleBitmap | m_UsedAddresses |
| size_t | m_AddressReferences [128] = {} |
| Mutex | m_EnumerationLock |
| Mutex | m_TopologyLock |
| Atomic< size_t > | m_ConnectionChangeStates [ConnectionChangePortCount] |
| UsbHub * | m_RootHub |
| bool | m_IsRootHub |
| uint8_t | m_RootPort |
| size_t | m_RootPortGeneration |
| bool | m_RetainDisconnectedAddresses = false |
Static Private Attributes | |
| static constexpr size_t | ConnectionChangePortCount = 32 |
| static constexpr size_t | ConnectionChangePending |
| static constexpr size_t | ConnectionChangeCountMask = ~ConnectionChangePending |
Friends | |
| class | UsbInterruptInHandle |
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 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) |
Static Protected Member Functions inherited from Device | |
| static Device & | root () |
Protected Attributes inherited from Device | |
| Vector< Address * > | m_Addresses |
| Vector< Device * > | m_Children |
| Device * | m_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 |
|
pure virtual |
Adds an owned recurring interrupt-IN transaction.
Implemented in Xhci, Ehci, Ohci, Uhci, and UsbHubDevice.
Referenced by UsbHubDevice::addInterruptInHandler().
Here is the caller graph for this function:
|
inlinevirtual |
|
pure virtual |
Adds a new transfer to an existent transaction.
Implemented in Ehci, Ohci, Uhci, UsbHubDevice, and Xhci.
Referenced by UsbHubDevice::addTransferToTransaction(), and UsbDevice::controlRequestResult().
Here is the caller graph for this function:
|
protected |
Associates a downstream hub with its already-initialised parent hub.
Definition at line 249 of file UsbHub.cc.
References m_IsRootHub, m_RootHub, m_RootPort, and m_RootPortGeneration.
|
inlineprotectedvirtual |
|
pure virtual |
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.
Implemented in Ehci, Ohci, Uhci, UsbHubDevice, and Xhci.
Referenced by UsbHubDevice::cancelAsyncAndDrain(), and doSync().
Here is the caller graph for this function:
|
protectedpure virtual |
Stops and drains one exact recurring interrupt-IN subscription.
Implemented in Xhci, Ehci, Ohci, Uhci, and UsbHubDevice.
|
staticprivate |
|
staticprivate |
|
inlinevirtual |
|
pure virtual |
Creates a new transaction with the given endpoint data.
Implemented in Xhci, Ehci, Ohci, Uhci, and UsbHubDevice.
Referenced by UsbDevice::controlRequestResult(), and UsbHubDevice::createTransaction().
Here is the caller graph for this function:
|
inlineprotectedvirtual |
Current observed connection generation for one HCD root port.
Reimplemented in Uhci, and Xhci.
Definition at line 377 of file UsbHub.h.
Referenced by rootConnectionForChild().
Here is the caller graph for this function:
|
protected |
Atomically records an observation only if its suppression scope is still active. False means the caller must process the observation now.
Definition at line 302 of file UsbHub.cc.
References m_ConnectionChangeStates.
Referenced by Ohci::irq(), and Uhci::timer().
Here is the caller graph for this function:| bool UsbHub::deviceConnected | ( | uint8_t | nPort, |
| UsbSpeed | speed | ||
| ) |
Called when a device is connected to a port on the hub.
Definition at line 387 of file UsbHub.cc.
Referenced by Ehci::executeRequest(), Ohci::executeRequest(), Uhci::executeRequest(), Xhci::executeRequest(), and UsbHubDevice::initialiseDriver().
Here is the caller graph for this function:
|
private |
| void UsbHub::deviceDisconnected | ( | uint8_t | nPort | ) |
Called when a device is disconnected from a port on the hub.
Definition at line 545 of file UsbHub.cc.
References m_TopologyLock.
Referenced by disconnectAllDevices(), Ehci::executeRequest(), Ohci::executeRequest(), Uhci::executeRequest(), and Xhci::executeRequest().
Here is the caller graph for this function:
|
private |
|
protected |
Destroys every USB child while the most-derived hub is still live.
Definition at line 216 of file UsbHub.cc.
References Vector< T >::count(), deviceDisconnected(), Device::getType(), Device::m_Children, Device::removeChild(), Device::setParent(), and Device::UsbContainer.
|
pure 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.
Implemented in Ehci, Ohci, Uhci, UsbHubDevice, and Xhci.
Referenced by UsbHubDevice::doAsync(), and doSync().
Here is the caller graph for this function:| ssize_t UsbHub::doSync | ( | uintptr_t | nTransaction, |
| uint32_t | timeout = 5000 |
||
| ) |
Performs a transaction, blocks until it's completed and returns the result
Definition at line 733 of file UsbHub.cc.
References Semaphore::acquireForCompletion(), Semaphore::acquireWithError(), cancelAsyncAndDrain(), doAsync(), and syncCallback().
Referenced by UsbDevice::controlRequestResult().
Here is the caller graph for this function:
|
staticprivate |
|
inlineprotectedvirtual |
|
virtual |
Returns the (abstract) type of the device.
Reimplemented from Device.
Definition at line 245 of file UsbHub.cc.
References Device::UsbController.
|
inlineprotectedvirtual |
|
pure 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. |
Implemented in Ehci, Ohci, Uhci, UsbHubDevice, and Xhci.
|
inlinevirtual |
|
protected |
Publishes a controller token into an empty caller-owned handle.
Definition at line 206 of file UsbHub.cc.
Referenced by Ehci::addInterruptInHandler().
Here is the caller graph for this function:
|
private |
|
private |
|
private |
|
inlineprotectedvirtual |
|
private |
|
protectedvirtual |
|
inlinevirtual |
|
private |
|
private |
|
protected |
Keeps descendant addresses reserved when hardware cannot be reset.
Definition at line 241 of file UsbHub.cc.
References m_RetainDisconnectedAddresses.
Referenced by UsbHubDevice::prepareForDriverRetirement().
Here is the caller graph for this function:
|
private |
| UsbHub::RootConnection UsbHub::rootConnectionForChild | ( | uint8_t | childPort | ) | const |
Resolves a child port to its root-controller connection generation.
Definition at line 200 of file UsbHub.cc.
References currentRootPortGeneration(), m_IsRootHub, m_RootPort, and m_RootPortGeneration.
Referenced by UsbDevice::UsbDevice().
Here is the caller graph for this function:
|
inlineprotected |
|
inlinevirtual |
|
protected |
Begins one nested root-port suppression scope.
Definition at line 263 of file UsbHub.cc.
References Dec, Hex, Scheduler::instance(), m_ConnectionChangeStates, and Scheduler::yield().
|
staticprivate |
Callback used by synchronous transactions.
Definition at line 712 of file UsbHub.cc.
References Semaphore::release().
Referenced by doSync().
Here is the caller graph for this function:
|
friend |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
private |
One atomic publication state per USB 2 root-port slot.
Definition at line 305 of file UsbHub.h.
Referenced by deferConnectionChangeIfSuppressed(), and suppressConnectionChanges().
|
private |
|
private |
Device-taking construction identifies an HCD rather than a USB hub.
Definition at line 311 of file UsbHub.h.
Referenced by attachToUpstreamHub(), and rootConnectionForChild().
|
private |
Driver-only unbind cannot prove downstream devices stopped answering.
Definition at line 320 of file UsbHub.h.
Referenced by retainDisconnectedAddressesUntilControllerTeardown().
|
private |
Shared address-allocation owner for this hub hierarchy.
Definition at line 308 of file UsbHub.h.
Referenced by attachToUpstreamHub().
|
private |
Root-controller port through which this downstream hub is reached.
Definition at line 314 of file UsbHub.h.
Referenced by attachToUpstreamHub(), and rootConnectionForChild().
|
private |
Root connection generation captured by the downstream hub device.
Definition at line 317 of file UsbHub.h.
Referenced by attachToUpstreamHub(), and rootConnectionForChild().
|
private |
Serializes connection generations published by this hub.
Definition at line 297 of file UsbHub.h.
Referenced by deviceDisconnected().
|
private |