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
Ehci Class Reference

#include <Ehci.h>

+ Inheritance diagram for Ehci:
+ Collaboration diagram for Ehci:

Classes

struct  QH
 
struct  qTD
 

Public Member Functions

 Ehci (Device *pDev)
 
bool initialiseController ()
 
void startFirmwareRecovery ()
 
struct Ehci::qTD ALIGN (4)
 
struct Ehci::QH ALIGN (32)
 
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 ()
 
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
 
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 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)
 
virtual size_t currentRootPortGeneration (size_t port) const
 
- 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  EhciConstants {
  EHCI_CAPLENGTH = 0x00 , EHCI_HCIVERSION = 0x02 , EHCI_HCSPARAMS = 0x04 , EHCI_HCCPARAMS = 0x08 ,
  EHCI_CMD = 0x00 , EHCI_STS = 0x04 , EHCI_INTR = 0x08 , EHCI_CTRLDSEG = 0x10 ,
  EHCI_FRINDEX = 0x0c , EHCI_PERIODICLP = 0x14 , EHCI_ASYNCLP = 0x18 , EHCI_CFGFLAG = 0x40 ,
  EHCI_PORTSC = 0x44 , EHCI_CMD_ASYNCLE = 0x20 , EHCI_CMD_PERIODICLE = 0x10 , EHCI_CMD_HCRES = 0x02 ,
  EHCI_CMD_RUN = 0x01 , EHCI_STS_HALTED = 0x1000 , EHCI_STS_SYSERR = 0x10 , EHCI_STS_ASYNCADVANCE = 0x20 ,
  EHCI_STS_PORTCH = 0x4 , EHCI_STS_ERR = 0x2 , EHCI_STS_INT = 0x1 , EHCI_PORTSC_PPOW = 0x1000 ,
  EHCI_PORTSC_PRES = 0x100 , EHCI_PORTSC_OCCH = 0x20 , EHCI_PORTSC_ENCH = 0x8 , EHCI_PORTSC_EN = 0x4 ,
  EHCI_PORTSC_CSCH = 0x2 , EHCI_PORTSC_CONN = 0x1
}
 
using IrqProcessingLock = Mutex
 

Private Member Functions

void modifyPortControl (size_t portRegister, uint32_t clearMask, uint32_t setMask)
 
uintptr_t createTransactionAdmitted (UsbEndpoint endpointInfo)
 
void addTransferToTransactionAdmitted (uintptr_t pTransaction, bool bToggle, UsbPid pid, uintptr_t pBuffer, size_t nBytes)
 
void releaseQtdChainLocked (QH *qh)
 
void reclaimQhLocked (size_t transaction)
 
void captureCompletionLocked (size_t transaction, QH *qh, const UsbHcd::TransferCompletion::Claim &claim, List< UsbHcd::CallbackDeliveryQueue::Record * > &completions)
 
void rebuildPeriodicScheduleLocked ()
 
bool beginStartupActivity () override
 
void endStartupActivity (UsbStartup::Outcome outcome) override
 
void completeInitialPort (size_t port)
 
void shutdownController ()
 
bool acquireFirmware (uint16_t capability)
 
void returnToFirmware ()
 
 Ehci (const Ehci &)
 
void operator= (const Ehci &)
 

Static Private Member Functions

static uint32_t portControlValue (uint32_t value)
 
static void finishDeferredCompletion (void *context)
 
static void rearmPeriodicCompletion (void *context)
 
static void destroyPeriodicCompletion (void *context)
 
static int recoverFirmware (void *parameter)
 

Private Attributes

enum Ehci::EhciConstants ALIGN
 
EhciHandoff::State m_Handoff
 
uint16_t m_FirmwarePciCommand = 0
 
bool m_ControllerStopped = false
 
bool m_HardwareTouched = false
 
Spinlock m_StartupLock
 
UsbStartup::State m_Startup
 
uint16_t m_InitialPortMask = 0
 
Semaphore m_RecoveryWake {0}
 
Atomic< bool > m_RecoveryStopping {false}
 
OwnedThread m_RecoveryThread
 
IoBase * m_pBase
 
bool m_HardwareOwned = false
 
uint8_t m_nOpRegsOffset
 
uint8_t m_nPorts
 
UsbHcd::PortChangeRequest m_PortChanges [UsbHcd::EhciRootPortCount]
 
UsbHcd::DeferredPortChanges m_DeferredPortChanges
 
Mutex m_Mutex
 
IrqProcessingLock m_IrqProcessingLock
 
UsbHcd::CallbackDeliveryQueue m_CompletionDeliveries
 
Spinlock m_QueueListChangeLock
 
QH * m_pQHList
 
uintptr_t m_pQHListPhys
 
ExtensibleBitmap m_QHBitmap
 
uint32_t * m_pFrameList
 
uintptr_t m_pFrameListPhys
 
ExtensibleBitmap m_FrameBitmap
 
qTD * m_pqTDList
 
uintptr_t m_pqTDListPhys
 
ExtensibleBitmap m_qTDBitmap
 
QH * m_pCurrentQueueTail
 
QH * m_pCurrentQueueHead
 
MemoryRegion m_EhciMR
 
Semaphore m_DequeueCount
 
Atomic< bool > m_DequeueStopping
 
OwnedThread m_DequeueThread
 
OperationBarrier m_SubmissionOperations
 
OperationBarrier m_CancelOperations
 
OperationBarrier m_CallbackOperations
 
irq_id_t m_IrqId
 
bool m_InterruptHandlerRegistered
 
Atomic< size_t > m_InterruptClosure
 

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 Ehci class

Definition at line 51 of file Ehci.h.

Member Typedef Documentation

◆ IrqProcessingLock

using Ehci::IrqProcessingLock = Mutex
private

Definition at line 60 of file Ehci.h.

Member Enumeration Documentation

◆ EhciConstants

enum Ehci::EhciConstants
private

Definition at line 242 of file Ehci.h.

Constructor & Destructor Documentation

◆ Ehci()

Ehci::Ehci ( Device *  pDev)

Definition at line 124 of file Ehci.cc.

◆ ~Ehci()

Ehci::~Ehci ( )
virtual

Definition at line 595 of file Ehci.cc.

Member Function Documentation

◆ acquireFirmware()

bool Ehci::acquireFirmware ( uint16_t  capability)
private

Definition at line 29 of file EhciFirmware.cc.

◆ addInterruptInHandler()

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

◆ addTransferToTransaction()

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

Adds a new transfer to an existent transaction.

Implements UsbHub.

Definition at line 1313 of file Ehci.cc.

References m_SubmissionOperations, and OperationBarrier::tryAcquire().

◆ addTransferToTransactionAdmitted()

void Ehci::addTransferToTransactionAdmitted ( uintptr_t  pTransaction,
bool  bToggle,
UsbPid  pid,
uintptr_t  pBuffer,
size_t  nBytes 
)
private

Definition at line 1321 of file Ehci.cc.

◆ beginStartupActivity()

bool Ehci::beginStartupActivity ( )
overrideprivatevirtual

Reimplemented from UsbHub.

Definition at line 79 of file EhciFirmware.cc.

◆ cancelAsyncAndDrain()

void Ehci::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 1661 of file Ehci.cc.

References UsbHcd::TransferCompletion::claimCancellation(), Ehci::QH::MetaData::completion, List< T, nodePoolSize >::count(), UsbHcd::CallbackDeliveryQueue::deliver(), UsbHcd::CallbackDeliveryQueue::drain(), m_CancelOperations, m_CompletionDeliveries, m_InterruptClosure, m_IrqProcessingLock, panic(), List< T, nodePoolSize >::popFront(), UsbHcd::CallbackDeliveryQueue::publish(), IoBase::read32(), ExtensibleBitmap::test(), OperationBarrier::tryAcquire(), and IoBase::write32().

◆ cancelInterruptInAndDrain()

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

◆ cancelRequest()

void Ehci::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 2105 of file Ehci.cc.

◆ captureCompletionLocked()

void Ehci::captureCompletionLocked ( size_t  transaction,
QH *  qh,
const UsbHcd::TransferCompletion::Claim &  claim,
List< UsbHcd::CallbackDeliveryQueue::Record * > &  completions 
)
private

Definition at line 865 of file Ehci.cc.

◆ completeInitialPort()

void Ehci::completeInitialPort ( size_t  port)
private

Definition at line 90 of file EhciFirmware.cc.

◆ createTransaction()

uintptr_t Ehci::createTransaction ( UsbEndpoint  endpointInfo)
virtual

Creates a new transaction with the given endpoint data.

Implements UsbHub.

Definition at line 1533 of file Ehci.cc.

References m_SubmissionOperations, and OperationBarrier::tryAcquire().

◆ createTransactionAdmitted()

uintptr_t Ehci::createTransactionAdmitted ( UsbEndpoint  endpointInfo)
private

Definition at line 1540 of file Ehci.cc.

◆ destroyPeriodicCompletion()

void Ehci::destroyPeriodicCompletion ( void *  context)
staticprivate

Definition at line 945 of file Ehci.cc.

◆ doAsync()

bool Ehci::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 1587 of file Ehci.cc.

References UsbHcd::TransferCompletion::arm(), Ehci::QH::MetaData::completion, Dec, EMIT_IF, Hex, m_CompletionDeliveries, m_InterruptClosure, m_IrqProcessingLock, m_SubmissionOperations, ExtensibleBitmap::test(), and OperationBarrier::tryAcquire().

◆ doDequeue()

void Ehci::doDequeue ( )

Definition at line 949 of file Ehci.cc.

◆ endStartupActivity()

void Ehci::endStartupActivity ( UsbStartup::Outcome  outcome)
overrideprivatevirtual

Reimplemented from UsbHub.

Definition at line 84 of file EhciFirmware.cc.

◆ executeRequest()

uint64_t Ehci::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 2062 of file Ehci.cc.

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

◆ finishDeferredCompletion()

void Ehci::finishDeferredCompletion ( void *  context)
staticprivate

Definition at line 879 of file Ehci.cc.

◆ getName()

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

Stores the device's name in str.

Reimplemented from Device.

Definition at line 196 of file Ehci.h.

◆ inInterruptCallbackContext()

bool Ehci::inInterruptCallbackContext ( ) const
inlineoverrideprotectedvirtual

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

Reimplemented from UsbHub.

Definition at line 231 of file Ehci.h.

References UsbHcd::CallbackDeliveryQueue::isInCallbackContext().

◆ initialiseController()

bool Ehci::initialiseController ( )

Definition at line 153 of file Ehci.cc.

◆ irq()

IrqDisposition Ehci::irq ( irq_id_t  number)
overridevirtual

◆ modifyPortControl()

void Ehci::modifyPortControl ( size_t  portRegister,
uint32_t  clearMask,
uint32_t  setMask 
)
private

Definition at line 1996 of file Ehci.cc.

◆ portControlValue()

static uint32_t Ehci::portControlValue ( uint32_t  value)
inlinestaticprivate

Keep non-interrupt PORTSC writes from acknowledging W1C changes.

Definition at line 280 of file Ehci.h.

◆ portReset()

bool Ehci::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 2005 of file Ehci.cc.

References Dec, EMIT_IF, Hex, and IoBase::read32().

Referenced by executeRequest().

+ Here is the caller graph for this function:

◆ rearmPeriodicCompletion()

void Ehci::rearmPeriodicCompletion ( void *  context)
staticprivate

Definition at line 924 of file Ehci.cc.

◆ rebuildPeriodicScheduleLocked()

void Ehci::rebuildPeriodicScheduleLocked ( )
private

Definition at line 895 of file Ehci.cc.

◆ reclaimQhLocked()

void Ehci::reclaimQhLocked ( size_t  transaction)
private

Definition at line 852 of file Ehci.cc.

◆ recoverFirmware()

int Ehci::recoverFirmware ( void *  parameter)
staticprivate

Definition at line 110 of file EhciFirmware.cc.

◆ releaseQtdChainLocked()

void Ehci::releaseQtdChainLocked ( QH *  qh)
private

Definition at line 811 of file Ehci.cc.

◆ replaySuppressedConnectionChange()

void Ehci::replaySuppressedConnectionChange ( size_t  port)
overrideprotectedvirtual

Re-publishes one coalesced observation in ordinary thread context.

Reimplemented from UsbHub.

Definition at line 1966 of file Ehci.cc.

References Dec, m_InterruptClosure, m_IrqProcessingLock, IoBase::read32(), and IoBase::write32().

◆ returnToFirmware()

void Ehci::returnToFirmware ( )
private

Definition at line 56 of file EhciFirmware.cc.

◆ shutdownController()

void Ehci::shutdownController ( )
private

Definition at line 603 of file Ehci.cc.

◆ startFirmwareRecovery()

void Ehci::startFirmwareRecovery ( )

Definition at line 100 of file EhciFirmware.cc.

Member Data Documentation

◆ m_CallbackOperations

OperationBarrier Ehci::m_CallbackOperations
private

Closes and drains interrupt callbacks before controller teardown.

Definition at line 367 of file Ehci.h.

◆ m_CancelOperations

OperationBarrier Ehci::m_CancelOperations
private

Remains open while teardown callbacks synchronously cancel peers.

Definition at line 365 of file Ehci.h.

Referenced by cancelAsyncAndDrain(), and cancelInterruptInAndDrain().

◆ m_CompletionDeliveries

UsbHcd::CallbackDeliveryQueue Ehci::m_CompletionDeliveries
private

Per-generation callback publication and cancellation drain boundary.

Definition at line 332 of file Ehci.h.

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

◆ m_ControllerStopped

bool Ehci::m_ControllerStopped = false
private

Definition at line 310 of file Ehci.h.

◆ m_DeferredPortChanges

UsbHcd::DeferredPortChanges Ehci::m_DeferredPortChanges
private

Definition at line 325 of file Ehci.h.

◆ m_DequeueCount

Semaphore Ehci::m_DequeueCount
private

Persistent reclaim worker; destruction wakes and joins it.

Definition at line 358 of file Ehci.h.

◆ m_DequeueStopping

Atomic<bool> Ehci::m_DequeueStopping
private

Definition at line 359 of file Ehci.h.

◆ m_DequeueThread

OwnedThread Ehci::m_DequeueThread
private

Definition at line 360 of file Ehci.h.

◆ m_EhciMR

MemoryRegion Ehci::m_EhciMR
private

Definition at line 355 of file Ehci.h.

◆ m_FirmwarePciCommand

uint16_t Ehci::m_FirmwarePciCommand = 0
private

Definition at line 309 of file Ehci.h.

◆ m_FrameBitmap

ExtensibleBitmap Ehci::m_FrameBitmap
private

Definition at line 341 of file Ehci.h.

◆ m_Handoff

EhciHandoff::State Ehci::m_Handoff
private

Definition at line 308 of file Ehci.h.

◆ m_HardwareOwned

bool Ehci::m_HardwareOwned = false
private

Definition at line 320 of file Ehci.h.

◆ m_HardwareTouched

bool Ehci::m_HardwareTouched = false
private

Definition at line 311 of file Ehci.h.

◆ m_InitialPortMask

uint16_t Ehci::m_InitialPortMask = 0
private

Definition at line 314 of file Ehci.h.

◆ m_InterruptClosure

Atomic<size_t> Ehci::m_InterruptClosure
private

0=open, 1=PORTCH closed, 2=all controller IRQs closed.

Definition at line 371 of file Ehci.h.

Referenced by addInterruptInHandler(), cancelAsyncAndDrain(), cancelInterruptInAndDrain(), doAsync(), and replaySuppressedConnectionChange().

◆ m_InterruptHandlerRegistered

bool Ehci::m_InterruptHandlerRegistered
private

Definition at line 369 of file Ehci.h.

◆ m_IrqId

irq_id_t Ehci::m_IrqId
private

Definition at line 368 of file Ehci.h.

◆ m_IrqProcessingLock

IrqProcessingLock Ehci::m_IrqProcessingLock
private

Serialises transaction completion with synchronous cancellation.

Definition at line 330 of file Ehci.h.

Referenced by addInterruptInHandler(), cancelAsyncAndDrain(), cancelInterruptInAndDrain(), doAsync(), and replaySuppressedConnectionChange().

◆ m_Mutex

Mutex Ehci::m_Mutex
private

Definition at line 327 of file Ehci.h.

◆ m_nOpRegsOffset

uint8_t Ehci::m_nOpRegsOffset
private

Definition at line 322 of file Ehci.h.

◆ m_nPorts

uint8_t Ehci::m_nPorts
private

Definition at line 323 of file Ehci.h.

◆ m_pBase

IoBase* Ehci::m_pBase
private

Definition at line 319 of file Ehci.h.

◆ m_pCurrentQueueHead

QH* Ehci::m_pCurrentQueueHead
private

Definition at line 353 of file Ehci.h.

◆ m_pCurrentQueueTail

QH* Ehci::m_pCurrentQueueTail
private

Definition at line 349 of file Ehci.h.

◆ m_pFrameList

uint32_t* Ehci::m_pFrameList
private

Definition at line 339 of file Ehci.h.

◆ m_pFrameListPhys

uintptr_t Ehci::m_pFrameListPhys
private

Definition at line 340 of file Ehci.h.

◆ m_PortChanges

UsbHcd::PortChangeRequest Ehci::m_PortChanges[UsbHcd::EhciRootPortCount]
private

Definition at line 324 of file Ehci.h.

◆ m_pQHList

QH* Ehci::m_pQHList
private

Definition at line 335 of file Ehci.h.

◆ m_pQHListPhys

uintptr_t Ehci::m_pQHListPhys
private

Definition at line 336 of file Ehci.h.

◆ m_pqTDList

qTD* Ehci::m_pqTDList
private

Definition at line 343 of file Ehci.h.

◆ m_pqTDListPhys

uintptr_t Ehci::m_pqTDListPhys
private

Definition at line 344 of file Ehci.h.

◆ m_QHBitmap

ExtensibleBitmap Ehci::m_QHBitmap
private

Definition at line 337 of file Ehci.h.

◆ m_qTDBitmap

ExtensibleBitmap Ehci::m_qTDBitmap
private

Definition at line 345 of file Ehci.h.

◆ m_QueueListChangeLock

Spinlock Ehci::m_QueueListChangeLock
private

Definition at line 333 of file Ehci.h.

◆ m_RecoveryStopping

Atomic<bool> Ehci::m_RecoveryStopping {false}
private

Definition at line 316 of file Ehci.h.

◆ m_RecoveryThread

OwnedThread Ehci::m_RecoveryThread
private

Definition at line 317 of file Ehci.h.

◆ m_RecoveryWake

Semaphore Ehci::m_RecoveryWake {0}
private

Definition at line 315 of file Ehci.h.

◆ m_Startup

UsbStartup::State Ehci::m_Startup
private

Definition at line 313 of file Ehci.h.

◆ m_StartupLock

Spinlock Ehci::m_StartupLock
private

Definition at line 312 of file Ehci.h.

◆ m_SubmissionOperations

OperationBarrier Ehci::m_SubmissionOperations
private

Rejects new transaction construction before the DMA halt boundary.

Definition at line 363 of file Ehci.h.

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


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