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

#include <SplitIrqHandler.h>

+ Inheritance diagram for SplitIrqHandler:
+ Collaboration diagram for SplitIrqHandler:

Classes

struct  Registration
 

Public Types

enum class  HardStageDisposition : size_t { NotHandled , Handled , Deferred }
 

Protected Member Functions

 SplitIrqHandler (const String &name)
 
bool initialiseSplitIrq ()
 
irq_id_t registerIsaSplitIrq (IrqManager &manager, uint8_t irq, const IrqPolicy &policy)
 
irq_id_t registerPciSplitIrq (IrqManager &manager, Device &device, const IrqPolicy &policy)
 
bool shutdownSplitIrq ()
 
virtual HardStageDisposition hardIrq (irq_id_t number, InterruptState &state, size_t &work)=0
 
virtual void threadedIrq (size_t work)=0
 
virtual bool quiesceIrqSources ()=0
 
virtual void rearmIrqSources (size_t work)=0
 

Private Member Functions

::HardIrqDisposition irq (irq_id_t number, InterruptState &state) final
 
void dispatchThreaded ()
 
bool publishWork (size_t work)
 
 SplitIrqHandler (const SplitIrqHandler &)=delete
 
SplitIrqHandleroperator= (const SplitIrqHandler &)=delete
 
virtual ~HardIrqHandler ()
 
- Private Member Functions inherited from IrqHandlerBase
virtual ~IrqHandlerBase ()
 

Static Private Member Functions

static void dispatchThreaded (void *context, uint8_t line, size_t cookie)
 

Private Attributes

Registration m_Registrations [MaxRegistrations]
 
size_t m_RegistrationCount
 
Atomic< size_t > m_LifecycleBusy
 
Atomic< size_t > m_AcceptingRegistrations
 
ThreadedIrqDispatcher m_Dispatcher
 
Spinlock m_StateLock
 
bool m_Quiescing
 
Atomic< size_t > m_Stopping
 
Atomic< size_t > m_PublicationFailures
 
Atomic< size_t > m_DeferredIrqs
 
Atomic< size_t > m_CompletedBatches
 
size_t m_PendingWork
 
bool m_Started
 

Static Private Attributes

static constexpr size_t MaxRegistrations = 16
 

Detailed Description

Owns a coalescing worker for an IRQ handler.

The hard callback is limited to claiming and quiescing the device source, capturing any data which cannot wait, and returning Deferred with a work bitmask. The worker receives only that bitmask: InterruptState never escapes the hard callback. If exact event counts matter, the hard callback must put them in a preallocated device-owned ring and the worker must drain it.

A Deferred result means the device source is already safe for the machine IRQ line to remain enabled. Level-triggered devices must mask or acknowledge their own source in hardIrq(). threadedIrq() drains the source but must not unmask it; the base calls rearmIrqSources() only while rearm is serialised against shutdown.

Definition at line 41 of file SplitIrqHandler.h.

Member Enumeration Documentation

◆ HardStageDisposition

enum class SplitIrqHandler::HardStageDisposition : size_t
strong

Definition at line 43 of file SplitIrqHandler.h.

Constructor & Destructor Documentation

◆ SplitIrqHandler()

SplitIrqHandler::SplitIrqHandler ( const String name)
explicitprotected

Definition at line 41 of file SplitIrqHandler.cc.

◆ ~SplitIrqHandler()

SplitIrqHandler::~SplitIrqHandler ( )
protectedvirtual

Definition at line 63 of file SplitIrqHandler.cc.

Member Function Documentation

◆ dispatchThreaded() [1/2]

void SplitIrqHandler::dispatchThreaded ( )
private

Definition at line 263 of file SplitIrqHandler.cc.

◆ dispatchThreaded() [2/2]

void SplitIrqHandler::dispatchThreaded ( void *  context,
uint8_t  line,
size_t  cookie 
)
staticprivate

Definition at line 259 of file SplitIrqHandler.cc.

◆ hardIrq()

virtual HardStageDisposition SplitIrqHandler::hardIrq ( irq_id_t  number,
InterruptState &  state,
size_t &  work 
)
protectedpure virtual

Runs in hard IRQ context and must be bounded and nonblocking.

Implemented in HostedTimer.

Referenced by irq().

+ Here is the caller graph for this function:

◆ initialiseSplitIrq()

bool SplitIrqHandler::initialiseSplitIrq ( )
protected

Starts the owned worker before any device IRQ source is enabled.

Definition at line 73 of file SplitIrqHandler.cc.

References ThreadedIrqDispatcher::initialise().

Referenced by HostedTimer::initialise3().

+ Here is the caller graph for this function:

◆ irq()

HardIrqDisposition SplitIrqHandler::irq ( irq_id_t  number,
InterruptState &  state 
)
finalprivatevirtual

Handles an IRQ synchronously in hard interrupt context.

Implements HardIrqHandler.

Definition at line 246 of file SplitIrqHandler.cc.

References hardIrq(), and KeepMasked.

Referenced by registerIsaSplitIrq().

+ Here is the caller graph for this function:

◆ publishWork()

bool SplitIrqHandler::publishWork ( size_t  work)
private

Definition at line 277 of file SplitIrqHandler.cc.

◆ quiesceIrqSources()

virtual bool SplitIrqHandler::quiesceIrqSources ( )
protectedpure virtual

Prevents new device interrupts before registry admission is closed. This runs in thread context and must be idempotent across failed retries.

Implemented in HostedTimer.

Referenced by shutdownSplitIrq().

+ Here is the caller graph for this function:

◆ rearmIrqSources()

virtual void SplitIrqHandler::rearmIrqSources ( size_t  work)
protectedpure virtual

Rearms drained device sources unless shutdown has begun.

This runs in thread context with interrupts disabled and is serialised against quiesceIrqSources(). It must be bounded and nonblocking.

Implemented in HostedTimer.

◆ registerIsaSplitIrq()

irq_id_t SplitIrqHandler::registerIsaSplitIrq ( IrqManager manager,
uint8_t  irq,
const IrqPolicy policy 
)
protected

Registers this handler after its owned worker is running.

Definition at line 105 of file SplitIrqHandler.cc.

References irq(), and IrqManager::registerHardIsaIrqHandler().

Referenced by HostedTimer::initialise3().

+ Here is the caller graph for this function:

◆ registerPciSplitIrq()

irq_id_t SplitIrqHandler::registerPciSplitIrq ( IrqManager manager,
Device device,
const IrqPolicy policy 
)
protected

Definition at line 131 of file SplitIrqHandler.cc.

◆ shutdownSplitIrq()

bool SplitIrqHandler::shutdownSplitIrq ( )
protected

Quiesces the hardware, closes every hard callback, drains accepted work, then joins the worker.

The derived owner must call this while its fields and the scheduler are alive. Calls from hard/atomic context or the owned worker are rejected before any lifecycle state changes.

Definition at line 157 of file SplitIrqHandler.cc.

References ProcessorBase::getInterrupts(), ProcessorBase::information(), ThreadedIrqDispatcher::isCurrentWorker(), quiesceIrqSources(), ThreadedIrqDispatcher::shutdown(), and IrqManager::unregisterHandler().

Referenced by HostedTimer::initialise3(), and HostedTimer::uninitialise().

+ Here is the caller graph for this function:

◆ threadedIrq()

virtual void SplitIrqHandler::threadedIrq ( size_t  work)
protectedpure virtual

Runs in ordinary thread context and may use blocking APIs. The owned worker normally calls it; teardown may call it synchronously after the worker is joined to drain a rejected publication. It must not re-enable an interrupt source.

Implemented in HostedTimer.

Member Data Documentation

◆ m_AcceptingRegistrations

Atomic<size_t> SplitIrqHandler::m_AcceptingRegistrations
private

Definition at line 125 of file SplitIrqHandler.h.

◆ m_CompletedBatches

Atomic<size_t> SplitIrqHandler::m_CompletedBatches
private

Definition at line 132 of file SplitIrqHandler.h.

◆ m_DeferredIrqs

Atomic<size_t> SplitIrqHandler::m_DeferredIrqs
private

Definition at line 131 of file SplitIrqHandler.h.

◆ m_Dispatcher

ThreadedIrqDispatcher SplitIrqHandler::m_Dispatcher
private

Definition at line 126 of file SplitIrqHandler.h.

◆ m_LifecycleBusy

Atomic<size_t> SplitIrqHandler::m_LifecycleBusy
private

Definition at line 124 of file SplitIrqHandler.h.

◆ m_PendingWork

size_t SplitIrqHandler::m_PendingWork
private

Definition at line 133 of file SplitIrqHandler.h.

◆ m_PublicationFailures

Atomic<size_t> SplitIrqHandler::m_PublicationFailures
private

Definition at line 130 of file SplitIrqHandler.h.

◆ m_Quiescing

bool SplitIrqHandler::m_Quiescing
private

Definition at line 128 of file SplitIrqHandler.h.

◆ m_RegistrationCount

size_t SplitIrqHandler::m_RegistrationCount
private

Definition at line 123 of file SplitIrqHandler.h.

◆ m_Registrations

Registration SplitIrqHandler::m_Registrations[MaxRegistrations]
private

Definition at line 122 of file SplitIrqHandler.h.

◆ m_Started

bool SplitIrqHandler::m_Started
private

Definition at line 134 of file SplitIrqHandler.h.

◆ m_StateLock

Spinlock SplitIrqHandler::m_StateLock
private

Definition at line 127 of file SplitIrqHandler.h.

◆ m_Stopping

Atomic<size_t> SplitIrqHandler::m_Stopping
private

Definition at line 129 of file SplitIrqHandler.h.

◆ MaxRegistrations

constexpr size_t SplitIrqHandler::MaxRegistrations = 16
staticconstexprprivate

Definition at line 109 of file SplitIrqHandler.h.


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