The Pedigree Project 0.1
Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
EhciHandoff::State Class Reference

#include <EhciHandoff.h>

+ Collaboration diagram for EhciHandoff::State:

Public Member Functions

template<typename Config >
AcquireResult acquire (uint16_t offset, Config &config, size_t pollLimit=DefaultPollLimit)
 
template<typename Config >
ReleaseResult withdrawRequest (Config &config, size_t pollLimit=DefaultPollLimit)
 
template<typename Config >
ReleaseResult release (Config &config, bool callerQuiescedOrNeverTouched, size_t pollLimit=DefaultPollLimit)
 
uint16_t offset () const
 
uint32_t savedSmiEnables () const
 
bool wasBiosOwned () const
 
bool requested () const
 
bool acquired () const
 
bool disabled () const
 

Static Public Attributes

static constexpr uint32_t BiosOwned = 1U << 16
 
static constexpr uint32_t OsOwned = 1U << 24
 
static constexpr uint8_t LegacyCapabilityId = 1
 
static constexpr size_t DefaultPollLimit = 1000
 

Private Member Functions

void reset ()
 
template<typename Config >
bool restoreSmis (Config &config)
 
template<typename Config >
ReleaseResult releaseInternal (Config &config, bool allowUnacquired, size_t pollLimit)
 

Static Private Member Functions

static bool validOffset (uint16_t offset)
 
static uint16_t controlOffset (uint16_t offset)
 

Private Attributes

uint16_t m_Offset
 
uint32_t m_SavedSmiEnables
 
bool m_WasBiosOwned
 
bool m_RequestWritten
 
bool m_Acquired
 
bool m_Disabled
 
bool m_SmiMutationAttempted
 
bool m_SnapshotValid
 

Static Private Attributes

static constexpr uint16_t ControlOffset = 4
 

Detailed Description

Tracks one EHCI legacy ownership exchange.

Config must provide:

bool read32(uint16_t offset, uint32_t& value); bool write32(uint16_t offset, uint32_t value); bool write8(uint16_t offset, uint8_t value); void delay();

The caller owns all controller quiescence ordering. In particular, release may only be called after schedules, callbacks, DMA, and the PCI interrupt source have been detached. The helper never touches controller schedules.

Definition at line 47 of file EhciHandoff.h.

Constructor & Destructor Documentation

◆ State()

EhciHandoff::State::State ( )
inline

Definition at line 54 of file EhciHandoff.h.

Member Function Documentation

◆ acquire()

template<typename Config >
AcquireResult EhciHandoff::State::acquire ( uint16_t  offset,
Config &  config,
size_t  pollLimit = DefaultPollLimit 
)
inline

Request OS ownership, or use the existing BIOS-unowned shortcut.

The semaphore request is a byte write at offset +3. A dword read-modify-write is deliberately not used: the other USBLEGSUP fields are semaphores, capability metadata, or reserved bits.

Definition at line 72 of file EhciHandoff.h.

◆ acquired()

bool EhciHandoff::State::acquired ( ) const
inline

Definition at line 181 of file EhciHandoff.h.

◆ controlOffset()

static uint16_t EhciHandoff::State::controlOffset ( uint16_t  offset)
inlinestaticprivate

Definition at line 196 of file EhciHandoff.h.

◆ disabled()

bool EhciHandoff::State::disabled ( ) const
inline

Definition at line 185 of file EhciHandoff.h.

◆ offset()

uint16_t EhciHandoff::State::offset ( ) const
inline

Definition at line 165 of file EhciHandoff.h.

◆ release()

template<typename Config >
ReleaseResult EhciHandoff::State::release ( Config &  config,
bool  callerQuiescedOrNeverTouched,
size_t  pollLimit = DefaultPollLimit 
)
inline

Return ownership after the caller has quiesced all controller activity.

If the controller started BIOS-unowned, this is a no-op: it never writes either ownership semaphore or re-enables firmware SMIs for a controller that never granted the OS an ownership lease.

Definition at line 158 of file EhciHandoff.h.

◆ releaseInternal()

template<typename Config >
ReleaseResult EhciHandoff::State::releaseInternal ( Config &  config,
bool  allowUnacquired,
size_t  pollLimit 
)
inlineprivate

Definition at line 224 of file EhciHandoff.h.

◆ requested()

bool EhciHandoff::State::requested ( ) const
inline

Definition at line 177 of file EhciHandoff.h.

◆ reset()

void EhciHandoff::State::reset ( )
inlineprivate

Definition at line 200 of file EhciHandoff.h.

◆ restoreSmis()

template<typename Config >
bool EhciHandoff::State::restoreSmis ( Config &  config)
inlineprivate

Definition at line 212 of file EhciHandoff.h.

◆ savedSmiEnables()

uint32_t EhciHandoff::State::savedSmiEnables ( ) const
inline

Definition at line 169 of file EhciHandoff.h.

◆ validOffset()

static bool EhciHandoff::State::validOffset ( uint16_t  offset)
inlinestaticprivate

Definition at line 192 of file EhciHandoff.h.

◆ wasBiosOwned()

bool EhciHandoff::State::wasBiosOwned ( ) const
inline

Definition at line 173 of file EhciHandoff.h.

◆ withdrawRequest()

template<typename Config >
ReleaseResult EhciHandoff::State::withdrawRequest ( Config &  config,
size_t  pollLimit = DefaultPollLimit 
)
inline

Withdraw an ownership request which did not reach acquired state.

This path is intentionally separate from release: no controller schedule or callback has been published yet. It restores the saved SMI enables, clears only the OS-owned byte when a request was written, and does not invent a BIOS-owned semaphore. A successful return means that the OS semaphore was cleared; firmware confirmation is reported separately.

Definition at line 143 of file EhciHandoff.h.

Member Data Documentation

◆ BiosOwned

constexpr uint32_t EhciHandoff::State::BiosOwned = 1U << 16
staticconstexpr

Definition at line 49 of file EhciHandoff.h.

◆ ControlOffset

constexpr uint16_t EhciHandoff::State::ControlOffset = 4
staticconstexprprivate

Definition at line 190 of file EhciHandoff.h.

◆ DefaultPollLimit

constexpr size_t EhciHandoff::State::DefaultPollLimit = 1000
staticconstexpr

Definition at line 52 of file EhciHandoff.h.

◆ LegacyCapabilityId

constexpr uint8_t EhciHandoff::State::LegacyCapabilityId = 1
staticconstexpr

Definition at line 51 of file EhciHandoff.h.

◆ m_Acquired

bool EhciHandoff::State::m_Acquired
private

Definition at line 284 of file EhciHandoff.h.

◆ m_Disabled

bool EhciHandoff::State::m_Disabled
private

Definition at line 285 of file EhciHandoff.h.

◆ m_Offset

uint16_t EhciHandoff::State::m_Offset
private

Definition at line 280 of file EhciHandoff.h.

◆ m_RequestWritten

bool EhciHandoff::State::m_RequestWritten
private

Definition at line 283 of file EhciHandoff.h.

◆ m_SavedSmiEnables

uint32_t EhciHandoff::State::m_SavedSmiEnables
private

Definition at line 281 of file EhciHandoff.h.

◆ m_SmiMutationAttempted

bool EhciHandoff::State::m_SmiMutationAttempted
private

Definition at line 286 of file EhciHandoff.h.

◆ m_SnapshotValid

bool EhciHandoff::State::m_SnapshotValid
private

Definition at line 287 of file EhciHandoff.h.

◆ m_WasBiosOwned

bool EhciHandoff::State::m_WasBiosOwned
private

Definition at line 282 of file EhciHandoff.h.

◆ OsOwned

constexpr uint32_t EhciHandoff::State::OsOwned = 1U << 24
staticconstexpr

Definition at line 50 of file EhciHandoff.h.


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