The Pedigree Project 0.1
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Uhci Class Reference

#include <Uhci.h>

+ Inheritance diagram for Uhci:
+ Collaboration diagram for Uhci:

Classes

struct  QH
 
struct  TD
 

Public Member Functions

 Uhci (Device *pDev)
 
bool initialised () const
 
struct Uhci::TD ALIGN (16)
 
struct Uhci::QH ALIGN (16)
 
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 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.
 
IrqDisposition irq (irq_id_t number) override
 IRQ handler.
 
void doDequeue ()
 
void timer (uint64_t delta)
 Timer callback to handle port status changes.
 
virtual bool portReset (uint8_t nPort, bool bErrorResponse=false)
 Gets a UsbDevice from a given vendor:product pair.
 
- 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)
 
- Public Member Functions inherited from IrqHandler
virtual bool acceptsSpuriousInterrupts () const
 
- Public 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 ()
 

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
 
bool inInterruptCallbackContext () const override
 
size_t currentRootPortGeneration (size_t port) const override
 
void replaySuppressedConnectionChange (size_t port) override
 
virtual uint64_t executeRequest (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)
 
void cancelRequest (const Request &request) override
 
- Protected Member Functions inherited from UsbHub
virtual bool portSpeed (uint8_t, UsbSpeed &)
 
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)
 
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)
 
- Protected Member Functions inherited from Device
 NOT_COPYABLE_OR_ASSIGNABLE (Device)
 
- Protected Member Functions inherited from IrqHandler
virtual ~IrqHandler ()
 
- Protected Member Functions inherited from IrqHandlerBase
virtual ~IrqHandlerBase ()
 
- Protected Member Functions inherited from RequestQueue
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 ()
 

Private Types

enum  UhciConstants {
  UHCI_CMD = 0x00 , UHCI_STS = 0x02 , UHCI_INTR = 0x04 , UHCI_FRMN = 0x06 ,
  UHCI_FRLP = 0x08 , UHCI_PORTSC = 0x10 , UHCI_CMD_GRES = 0x04 , UHCI_CMD_HCRES = 0x02 ,
  UHCI_CMD_RUN = 0x01 , UHCI_STS_HALT = 0x20 , UHCI_STS_ERR = 0x02 , UHCI_STS_INT = 0x01 ,
  UHCI_PORTSC_PRES = 0x200 , UHCI_PORTSC_LOSPEED = 0x100 , UHCI_PORTSC_EDCH = 0x8 , UHCI_PORTSC_ENABLE = 0x4 ,
  UHCI_PORTSC_CSCH = 0x2 , UHCI_PORTSC_CONN = 0x1
}
 

Private Member Functions

bool doAsyncOwned (uintptr_t transaction, void(*callback)(uintptr_t, ssize_t), uintptr_t parameter, UsbInterruptInHandle *interruptHandle, size_t interruptGeneration)
 
void rebuildPeriodicScheduleLocked ()
 
void detachQueueHeadLocked (QH *pQH)
 
void reclaimQueueHeadLocked (QH *pQH)
 
void stop ()
 Stops the controller or panics before DMA ownership can be transferred.
 
void start ()
 Starts the controller or panics instead of leaving work silently stuck.
 
bool setLegacySupportControl (uint16_t control)
 
void modifyPortControl (size_t portRegister, uint16_t clearMask, uint16_t setMask)
 Serialises control RMWs with scanning without echoing W1C status bits.
 
 Uhci (const Uhci &)
 
void operator= (const Uhci &)
 

Static Private Member Functions

static void enqueueCompletedTransfer (void *context)
 
static void rearmPeriodicCompletion (void *context)
 
static void destroyPeriodicCompletion (void *context)
 

Private Attributes

enum Uhci::UhciConstants ALIGN
 
IoBase * m_pBase
 
bool m_HardwareOwned = false
 
bool m_Initialised = false
 
OperationBarrier m_SubmissionOperations
 
OperationBarrier m_CancelOperations
 
OperationBarrier m_TransferOperations
 
OperationBarrier m_CallbackOperations
 
irq_id_t m_IrqId
 
bool m_TimerRegistered
 
Atomic< bool > m_InterruptsClosing
 
uint8_t m_nPorts
 
UsbHcd::PortChangeRequest m_PortChanges [UsbHcd::UhciRootPortCount]
 
Atomic< bool > m_PortChangesClosing
 
Spinlock m_PortChangeLock
 
Mutex m_Mutex
 
Mutex m_IrqProcessingLock
 
UsbHcd::CallbackDeliveryQueue m_CompletionDeliveries
 
Mutex m_AsyncQueueListChangeLock
 
uint32_t * m_pFrameList
 
uintptr_t m_pFrameListPhys
 
TD * m_pTDList
 
uintptr_t m_pTDListPhys
 
ExtensibleBitmap m_TDBitmap
 
QH * m_pAsyncQH
 
QH * m_pPeriodicQH
 
QH * m_pQHList
 
uintptr_t m_pQHListPhys
 
ExtensibleBitmap m_QHBitmap
 
MemoryRegion m_UhciMR
 
QH * m_pCurrentAsyncQueueTail
 
QH * m_pCurrentAsyncQueueHead
 
List< QH * > m_AsyncSchedule
 List of QHs in the active asynchronous schedule.
 
List< QH * > m_PeriodicSchedule
 
List< QH * > m_DequeueList
 List of QHs ready for dequeue.
 
Semaphore m_DequeueCount
 Semaphore for the dequeue list.
 
OperationBarrier m_DequeueOperations
 
Thread * m_pDequeueThread
 
uint64_t m_nPortCheckTicks
 The time passed since last port check.
 

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 *)
 
- Public 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 }
 
- 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)
 
- Protected Types inherited from RequestQueue
enum class  NextRequestResult { Item , Empty , Retry }
 
- Static Protected Member Functions inherited from Device
static Device & root ()
 
- Static Protected 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)
 
- 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
 
- Protected Attributes inherited from RequestQueue
IntakeLane m_IntakeLanes [REQUEST_QUEUE_NUM_PRIORITIES]
 
Request * m_pRequestQueue [REQUEST_QUEUE_NUM_PRIORITIES]
 
Request * m_pRequestQueueTail [REQUEST_QUEUE_NUM_PRIORITIES]
 
Request * m_pActiveRequest
 
Atomic< size_t > m_State
 
Mutex m_LifecycleMutex
 
WaitQueue m_RequestQueueWaiters
 
WaitQueue m_WorkerWaiters
 
Thread * m_pThread
 
Atomic< PerProcessorScheduler * > m_pWorkerScheduler
 
SchedulerWorkerWake m_WorkerWake
 
Atomic< size_t > m_bWorkerReady
 
Atomic< size_t > m_bWorkerActive
 
size_t m_WorkerProgressGeneration
 
RequestQueueOverrunChecker m_OverrunChecker
 
Timer * m_pOverrunTimer
 
Atomic< size_t > m_PublicationState
 
size_t m_nMaxAsyncRequests
 
Atomic< size_t > m_nAsyncRequests
 
Atomic< size_t > m_nTotalRequests
 
Atomic< size_t > m_nActiveRequests
 
NormalStaticString m_Name
 
- Static Protected Attributes inherited from Device
static Device m_Root
 
static Mutex m_TreeLock
 
- Static Protected 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
 

Detailed Description

Device driver for the Uhci class

Definition at line 54 of file Uhci.h.

Member Enumeration Documentation

◆ UhciConstants

enum Uhci::UhciConstants
private

Definition at line 231 of file Uhci.h.

Constructor & Destructor Documentation

◆ Uhci()

Uhci::Uhci ( Device *  pDev)

Definition at line 74 of file Uhci.cc.

◆ ~Uhci()

Uhci::~Uhci ( )
virtual

Definition at line 496 of file Uhci.cc.

Member Function Documentation

◆ addInterruptInHandler()

bool Uhci::addInterruptInHandler ( UsbEndpoint  endpointInfo,
uintptr_t  pBuffer,
uint16_t  nBytes,
void(*)(uintptr_t, ssize_t)  pCallback,
UsbInterruptInHandle &  handle,
uintptr_t  pParam = 0 
)
virtual

Adds an owned recurring interrupt-IN transaction.

Implements UsbHub.

Definition at line 1346 of file Uhci.cc.

References addTransferToTransaction(), createTransaction(), m_CompletionDeliveries, m_SubmissionOperations, reclaimQueueHeadLocked(), ExtensibleBitmap::test(), and OperationBarrier::tryAcquire().

◆ addTransferToTransaction()

void Uhci::addTransferToTransaction ( uintptr_t  pTransaction,
bool  bToggle,
UsbPid  pid,
uintptr_t  pBuffer,
size_t  nBytes 
)
virtual

◆ cancelAsyncAndDrain()

void Uhci::cancelAsyncAndDrain ( uintptr_t  pTransaction,
void(*)(uintptr_t, ssize_t)  pCallback,
uintptr_t  pParam 
)
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 1230 of file Uhci.cc.

References UsbHcd::TransferCompletion::claimCancellation(), Uhci::QH::MetaData::completion, List< T, nodePoolSize >::count(), UsbHcd::CallbackDeliveryQueue::deliver(), detachQueueHeadLocked(), UsbHcd::CallbackDeliveryQueue::drain(), enqueueCompletedTransfer(), m_CancelOperations, m_CompletionDeliveries, m_DequeueOperations, m_IrqProcessingLock, List< T, nodePoolSize >::popFront(), UsbHcd::CallbackDeliveryQueue::publish(), List< T, nodePoolSize >::pushBack(), IoBase::read16(), start(), stop(), ExtensibleBitmap::test(), OperationBarrier::tryAcquire(), OperationBarrier::tryEnter(), and IoBase::write16().

◆ cancelInterruptInAndDrain()

bool Uhci::cancelInterruptInAndDrain ( const UsbInterruptInToken &  token,
void(*)(uintptr_t, ssize_t)  callback,
uintptr_t  parameter,
bool  producerAlreadyStopped 
)
overrideprotectedvirtual

◆ cancelRequest()

void Uhci::cancelRequest ( const Request &  request)
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 1521 of file Uhci.cc.

◆ createTransaction()

uintptr_t Uhci::createTransaction ( UsbEndpoint  endpointInfo)
virtual

Creates a new transaction with the given endpoint data.

Implements UsbHub.

Definition at line 1073 of file Uhci.cc.

References ExtensibleBitmap::getFirstClear(), m_SubmissionOperations, ExtensibleBitmap::set(), and OperationBarrier::tryAcquire().

Referenced by addInterruptInHandler().

+ Here is the caller graph for this function:

◆ currentRootPortGeneration()

size_t Uhci::currentRootPortGeneration ( size_t  port) const
overrideprotectedvirtual

Current observed connection generation for one HCD root port.

Reimplemented from UsbHub.

Definition at line 1617 of file Uhci.cc.

Referenced by irq().

+ Here is the caller graph for this function:

◆ destroyPeriodicCompletion()

void Uhci::destroyPeriodicCompletion ( void *  context)
staticprivate

Definition at line 469 of file Uhci.cc.

◆ detachQueueHeadLocked()

void Uhci::detachQueueHeadLocked ( QH *  pQH)
private

Requires IRQ then queue-list ownership and an established DMA halt.

Definition at line 370 of file Uhci.cc.

References m_AsyncSchedule, m_pCurrentAsyncQueueTail, and rebuildPeriodicScheduleLocked().

Referenced by cancelAsyncAndDrain(), cancelInterruptInAndDrain(), and irq().

+ Here is the caller graph for this function:

◆ doAsync()

bool Uhci::doAsync ( uintptr_t  pTransaction,
void(*)(uintptr_t, ssize_t)  pCallback = 0,
uintptr_t  pParam = 0 
)
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 1115 of file Uhci.cc.

◆ doAsyncOwned()

bool Uhci::doAsyncOwned ( uintptr_t  transaction,
void(*)(uintptr_t, ssize_t)  callback,
uintptr_t  parameter,
UsbInterruptInHandle *  interruptHandle,
size_t  interruptGeneration 
)
private

Definition at line 1120 of file Uhci.cc.

◆ doDequeue()

void Uhci::doDequeue ( )

Definition at line 704 of file Uhci.cc.

◆ enqueueCompletedTransfer()

void Uhci::enqueueCompletedTransfer ( void *  context)
staticprivate

Runs after callback delivery and hands the QH to the reclaim worker.

Definition at line 359 of file Uhci.cc.

References m_DequeueCount, m_DequeueList, and Semaphore::release().

Referenced by cancelAsyncAndDrain(), and irq().

+ Here is the caller graph for this function:

◆ executeRequest()

uint64_t Uhci::executeRequest ( 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 
)
protectedvirtual

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 1485 of file Uhci.cc.

References Dec, UsbHub::deviceConnected(), UsbHub::deviceDisconnected(), Hex, and IoBase::read16().

◆ getName()

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

Stores the device's name in str.

Reimplemented from Device.

Definition at line 154 of file Uhci.h.

◆ inInterruptCallbackContext()

bool Uhci::inInterruptCallbackContext ( ) const
inlineoverrideprotectedvirtual

True when this execution context must not wait for a USB callback.

Reimplemented from UsbHub.

Definition at line 188 of file Uhci.h.

References UsbHcd::CallbackDeliveryQueue::isInCallbackContext().

◆ initialised()

bool Uhci::initialised ( ) const
inline

Definition at line 58 of file Uhci.h.

◆ irq()

IrqDisposition Uhci::irq ( irq_id_t  number)
overridevirtual

◆ modifyPortControl()

void Uhci::modifyPortControl ( size_t  portRegister,
uint16_t  clearMask,
uint16_t  setMask 
)
private

Serialises control RMWs with scanning without echoing W1C status bits.

Definition at line 1404 of file Uhci.cc.

References IoBase::read16(), and IoBase::write16().

Referenced by portReset().

+ Here is the caller graph for this function:

◆ portReset()

bool Uhci::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 1414 of file Uhci.cc.

References Dec, EMIT_IF, Hex, modifyPortControl(), IoBase::read16(), and IoBase::write16().

◆ rearmPeriodicCompletion()

void Uhci::rearmPeriodicCompletion ( void *  context)
staticprivate

Definition at line 427 of file Uhci.cc.

◆ rebuildPeriodicScheduleLocked()

void Uhci::rebuildPeriodicScheduleLocked ( )
private

Requires the IRQ and queue-list locks, with DMA halted.

Definition at line 407 of file Uhci.cc.

Referenced by detachQueueHeadLocked().

+ Here is the caller graph for this function:

◆ reclaimQueueHeadLocked()

void Uhci::reclaimQueueHeadLocked ( QH *  pQH)
private

Reclaims a detached or never-published QH while m_Mutex is held.

Definition at line 473 of file Uhci.cc.

References ExtensibleBitmap::clear(), List< T, nodePoolSize >::count(), and List< T, nodePoolSize >::popFront().

Referenced by addInterruptInHandler(), and cancelInterruptInAndDrain().

+ Here is the caller graph for this function:

◆ replaySuppressedConnectionChange()

void Uhci::replaySuppressedConnectionChange ( size_t  port)
overrideprotectedvirtual

Re-publishes one coalesced observation in ordinary thread context.

Reimplemented from UsbHub.

Definition at line 1590 of file Uhci.cc.

References Dec.

◆ setLegacySupportControl()

bool Uhci::setLegacySupportControl ( uint16_t  control)
private

Updates the lower USBLEGSUP control word without clobbering its upper word.

Definition at line 1641 of file Uhci.cc.

◆ start()

void Uhci::start ( )
private

Starts the controller or panics instead of leaving work silently stuck.

Definition at line 1631 of file Uhci.cc.

References panic(), IoBase::read16(), and IoBase::write16().

Referenced by cancelAsyncAndDrain(), cancelInterruptInAndDrain(), and irq().

+ Here is the caller graph for this function:

◆ stop()

void Uhci::stop ( )
private

Stops the controller or panics before DMA ownership can be transferred.

Definition at line 1621 of file Uhci.cc.

References panic(), IoBase::read16(), and IoBase::write16().

Referenced by cancelAsyncAndDrain(), cancelInterruptInAndDrain(), and irq().

+ Here is the caller graph for this function:

◆ timer()

void Uhci::timer ( uint64_t  delta)
virtual

Member Data Documentation

◆ m_AsyncQueueListChangeLock

Mutex Uhci::m_AsyncQueueListChangeLock
private

Definition at line 280 of file Uhci.h.

◆ m_AsyncSchedule

List<QH*> Uhci::m_AsyncSchedule
private

List of QHs in the active asynchronous schedule.

Definition at line 307 of file Uhci.h.

Referenced by detachQueueHeadLocked(), and irq().

◆ m_CallbackOperations

OperationBarrier Uhci::m_CallbackOperations
private

Definition at line 264 of file Uhci.h.

◆ m_CancelOperations

OperationBarrier Uhci::m_CancelOperations
private

Drains cancellation callers before their callback state is reclaimed.

Definition at line 261 of file Uhci.h.

Referenced by cancelAsyncAndDrain(), and cancelInterruptInAndDrain().

◆ m_CompletionDeliveries

UsbHcd::CallbackDeliveryQueue Uhci::m_CompletionDeliveries
private

Per-generation callback publication and cancellation drain boundary.

Definition at line 279 of file Uhci.h.

Referenced by addInterruptInHandler(), cancelAsyncAndDrain(), cancelInterruptInAndDrain(), and irq().

◆ m_DequeueCount

Semaphore Uhci::m_DequeueCount
private

Semaphore for the dequeue list.

Definition at line 314 of file Uhci.h.

Referenced by enqueueCompletedTransfer().

◆ m_DequeueList

List<QH*> Uhci::m_DequeueList
private

List of QHs ready for dequeue.

Definition at line 311 of file Uhci.h.

Referenced by enqueueCompletedTransfer().

◆ m_DequeueOperations

OperationBarrier Uhci::m_DequeueOperations
private

Protects queue-head admission from racing controller teardown. The persistent worker is joined separately after admitted work drains.

Definition at line 320 of file Uhci.h.

Referenced by cancelAsyncAndDrain(), and irq().

◆ m_HardwareOwned

bool Uhci::m_HardwareOwned = false
private

Definition at line 256 of file Uhci.h.

◆ m_Initialised

bool Uhci::m_Initialised = false
private

Definition at line 257 of file Uhci.h.

◆ m_InterruptsClosing

Atomic<bool> Uhci::m_InterruptsClosing
private

Definition at line 267 of file Uhci.h.

◆ m_IrqId

irq_id_t Uhci::m_IrqId
private

Definition at line 265 of file Uhci.h.

◆ m_IrqProcessingLock

Mutex Uhci::m_IrqProcessingLock
private

Serialises transaction completion with synchronous cancellation.

Definition at line 277 of file Uhci.h.

Referenced by cancelAsyncAndDrain(), cancelInterruptInAndDrain(), and irq().

◆ m_Mutex

Mutex Uhci::m_Mutex
private

Definition at line 274 of file Uhci.h.

◆ m_nPortCheckTicks

uint64_t Uhci::m_nPortCheckTicks
private

The time passed since last port check.

Definition at line 324 of file Uhci.h.

Referenced by timer().

◆ m_nPorts

uint8_t Uhci::m_nPorts
private

Definition at line 269 of file Uhci.h.

◆ m_pAsyncQH

QH* Uhci::m_pAsyncQH
private

Definition at line 289 of file Uhci.h.

◆ m_pBase

IoBase* Uhci::m_pBase
private

Definition at line 255 of file Uhci.h.

◆ m_pCurrentAsyncQueueHead

QH* Uhci::m_pCurrentAsyncQueueHead
private

Pointer to the current queue head. Used to fill pNext automatically for new queue heads inserted to the asynchronous schedule.

Definition at line 304 of file Uhci.h.

◆ m_pCurrentAsyncQueueTail

QH* Uhci::m_pCurrentAsyncQueueTail
private

Pointer to the current queue tail, which allows insertion of new queue heads to the asynchronous schedule.

Definition at line 300 of file Uhci.h.

Referenced by detachQueueHeadLocked().

◆ m_pDequeueThread

Thread* Uhci::m_pDequeueThread
private

Definition at line 321 of file Uhci.h.

◆ m_PeriodicSchedule

List<QH*> Uhci::m_PeriodicSchedule
private

Definition at line 308 of file Uhci.h.

◆ m_pFrameList

uint32_t* Uhci::m_pFrameList
private

Definition at line 282 of file Uhci.h.

◆ m_pFrameListPhys

uintptr_t Uhci::m_pFrameListPhys
private

Definition at line 283 of file Uhci.h.

◆ m_PortChangeLock

Spinlock Uhci::m_PortChangeLock
private

Definition at line 272 of file Uhci.h.

◆ m_PortChanges

UsbHcd::PortChangeRequest Uhci::m_PortChanges[UsbHcd::UhciRootPortCount]
private

Definition at line 270 of file Uhci.h.

◆ m_PortChangesClosing

Atomic<bool> Uhci::m_PortChangesClosing
private

Definition at line 271 of file Uhci.h.

◆ m_pPeriodicQH

QH* Uhci::m_pPeriodicQH
private

Definition at line 290 of file Uhci.h.

◆ m_pQHList

QH* Uhci::m_pQHList
private

Definition at line 292 of file Uhci.h.

◆ m_pQHListPhys

uintptr_t Uhci::m_pQHListPhys
private

Definition at line 293 of file Uhci.h.

◆ m_pTDList

TD* Uhci::m_pTDList
private

Definition at line 285 of file Uhci.h.

◆ m_pTDListPhys

uintptr_t Uhci::m_pTDListPhys
private

Definition at line 286 of file Uhci.h.

◆ m_QHBitmap

ExtensibleBitmap Uhci::m_QHBitmap
private

Definition at line 294 of file Uhci.h.

◆ m_SubmissionOperations

OperationBarrier Uhci::m_SubmissionOperations
private

Rejects submissions which race transfer teardown.

Definition at line 259 of file Uhci.h.

Referenced by addInterruptInHandler(), addTransferToTransaction(), and createTransaction().

◆ m_TDBitmap

ExtensibleBitmap Uhci::m_TDBitmap
private

Definition at line 287 of file Uhci.h.

◆ m_TimerRegistered

bool Uhci::m_TimerRegistered
private

Definition at line 266 of file Uhci.h.

◆ m_TransferOperations

OperationBarrier Uhci::m_TransferOperations
private

Retained from accepted publication through worker reclamation.

Definition at line 263 of file Uhci.h.

Referenced by cancelInterruptInAndDrain().

◆ m_UhciMR

MemoryRegion Uhci::m_UhciMR
private

Definition at line 296 of file Uhci.h.


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