|
The Pedigree Project 0.1
|
#include <Pic.h>
Inheritance diagram for Pic:
Collaboration diagram for Pic:Classes | |
| class | HardStateGuard |
| class | StateGuard |
Public Member Functions | |
| bool | reservePciRoute (uint8_t irq) |
| EXPORTED_PUBLIC bool | hasIoApic () const |
| EXPORTED_PUBLIC bool | reservePciGsi (uint32_t gsi, bool activeLow) |
| virtual irq_id_t | registerIsaIrqHandler (uint8_t irq, IrqHandler *handler, const IrqPolicy &policy) |
| virtual irq_id_t | registerPciIrqHandler (IrqHandler *handler, Device *pDevice, const IrqPolicy &policy) |
| virtual irq_id_t | registerHardIsaIrqHandler (uint8_t irq, HardIrqHandler *handler, const IrqPolicy &policy) |
| virtual irq_id_t | registerHardPciIrqHandler (HardIrqHandler *handler, Device *pDevice, const IrqPolicy &policy) |
| irq_id_t | registerPciMessageIrqHandler (IrqHandler *handler, Device *device, const IrqPolicy &intxFallbackPolicy) override |
| bool | registerPciMsixIrqHandlers (Device *device, IrqHandler *const *handlers, size_t count, irq_id_t *ids, bool &fallbackSafe, const size_t *processors=nullptr) override |
| irq_id_t | registerHardPciMessageIrqHandler (HardIrqHandler *handler, Device *device, const IrqPolicy &intxFallbackPolicy) override |
| virtual irq_id_t | registerSchedulerIrqHandler (uint8_t irq, SchedulerIrqHandler *handler, const IrqPolicy &policy) |
| virtual bool | unregisterSchedulerIrqHandler (irq_id_t Id, SchedulerIrqHandler *handler) |
| virtual bool | unregisterHandler (irq_id_t Id, IrqHandlerBase *handler) |
| virtual size_t | snapshotIrqLines (IrqLineDiagnosticSnapshot *out, size_t capacity) const |
| bool | initialise () INITIALISATION_ONLY |
| bool | initialiseThreaded () |
| bool | shutdownThreaded () |
| virtual void | tick () |
| virtual bool | control (uint8_t irq, ControlCode code, size_t argument) |
Static Public Member Functions | |
| static Pic & | instance () |
Private Types | |
| enum | FailClosedReason : uint8_t { HardHandoffQuarantine = 1U << 0 , ThreadedPublicationQuarantine = 1U << 1 , UnhandledQuarantine = 1U << 2 , ControllerContentionQuarantine = 1U << 3 } |
Static Private Member Functions | |
| static void | dispatchThreadedLine (void *context, uint8_t irq, size_t cookie) |
Static Private Attributes | |
| static constexpr uint8_t | ControllerWorkLine = PicIrqState::LineCount |
| static EXPORTED_PUBLIC Pic | m_Instance |
Additional Inherited Members | |
Public Types inherited from IrqManager | |
| enum | ControlCode { MitigationThreshold } |
Protected Member Functions inherited from IrqManager | |
| IrqManager () | |
| virtual | ~IrqManager () |
The x86/x64 programmable interrupt controller as IrqManager
|
private |
The copy-constructor
|
private |
|
private |
|
private |
|
virtual |
Controls specific elements of a given IRQ
Reimplemented from IrqManager.
Definition at line 144 of file Pic.cc.
References LIKELY, m_IrqState, m_MitigationThreshold, and UNLIKELY.
|
staticprivate |
|
privatevirtual |
Implements IrqManager.
|
private |
|
private |
|
private |
| bool Pic::initialise | ( | ) |
Initialises the PIC hardware and registers the interrupts with the InterruptManager.
Definition at line 648 of file Pic.cc.
References IoPort::allocate(), ProcessorBase::index(), InterruptManager::instance(), m_ControllerContentions, m_DeliveryProcessor, m_IrqCount, m_MasterPort, m_MitigatedIrqs, m_MitigationThreshold, m_SlavePort, m_SpuriousIrqCount, m_UnhandledIrqCount, InterruptManager::registerInterruptHandler(), and IoPort::write8().
Referenced by Pc::initialise().
Here is the caller graph for this function:| bool Pic::initialiseThreaded | ( | ) |
Starts manager-owned bottom-half workers after scheduler startup.
Definition at line 715 of file Pic.cc.
References ProcessorBase::index(), ThreadedIrqDispatcher::initialise(), m_DeliveryApicId, m_DeliveryProcessor, m_ThreadedDispatcher, X86CommonProcessor::readMachineSpecificRegister(), and ThreadedIrqDispatcher::setRemoteWakeCallback().
|
inlinestatic |
Get the Pic class instance
Definition at line 56 of file Pic.h.
References m_Instance.
Referenced by Pc::deinitialise(), Pc::initialise(), and Pc::initialise3().
Here is the caller graph for this function:
|
privatevirtual |
Called when the handler is registered with the interrupt manager and the interrupt occurred
| [in] | nInterruptNumber | the interrupt number |
| [in] | state | reference to the state before the interrupt |
Implements InterruptHandler.
Definition at line 1367 of file Pic.cc.
References PicIrqState::beginThreadedDispatch(), IrqHandlerRegistry::captureAdmissionCutoff(), IrqHandlerRegistry::captureMixedAdmissionCutoffs(), PicIrqState::completeDispatch(), IrqHandlerRegistry::dispatchHard(), ProcessorBase::index(), m_ControllerStateGate, m_DeliveryProcessor, m_FailClosedReasons, m_Handlers, m_HardStageGenerations, m_IrqCount, m_IrqState, m_MasterPort, m_SchedulerIrqHandler, m_SpuriousIrqCount, m_ThreadedDispatchGenerations, m_ThreadedHadHardStage, m_ThreadedPublicationFailures, m_UnhandledIrqCount, IrqHandlerRegistry::publishThreadedDispatch(), spuriousLocked(), UNLIKELY, and IoPort::write8().
Referenced by operator=().
Here is the caller graph for this function:
|
virtual |
Register an ISA handler which must run in hard IRQ context.
Implements IrqManager.
Definition at line 200 of file Pic.cc.
References Dec, m_FailClosedReasons, m_Handlers, m_IrqState, m_ShuttingDown, m_UnregisterReservations, IrqHandlerRegistry::registerHardHandler(), and UNLIKELY.
|
virtual |
Register a PCI handler which must run in hard IRQ context.
Implements IrqManager.
Definition at line 381 of file Pic.cc.
References Dec, Device::getInterruptNumber(), m_FailClosedReasons, m_Handlers, m_IrqState, m_ShuttingDown, m_UnregisterReservations, IrqHandlerRegistry::registerHardHandler(), and UNLIKELY.
Referenced by registerHardPciMessageIrqHandler().
Here is the caller graph for this function:
|
overridevirtual |
Prefer a PCI message interrupt for a hard handler, with an INTx fallback.
Reimplemented from IrqManager.
Definition at line 467 of file Pic.cc.
References registerHardPciIrqHandler().
|
virtual |
Register an ISA irq
| [in] | irq | the ISA irq number (from 0 to 15) |
| [in] | handler | pointer to the IrqHandler class |
| [in] | policy | electrical, acknowledgement, and completion policy |
Implements IrqManager.
Definition at line 167 of file Pic.cc.
References Dec, m_FailClosedReasons, m_Handlers, m_IrqState, m_ShuttingDown, m_ThreadedDispatcher, m_UnregisterReservations, IrqHandlerRegistry::registerThreadedHandler(), and UNLIKELY.
|
virtual |
Register a PCI irq
Implements IrqManager.
Definition at line 329 of file Pic.cc.
References Dec, Device::getInterruptNumber(), m_FailClosedReasons, m_Handlers, m_IrqState, m_ShuttingDown, m_ThreadedDispatcher, m_UnregisterReservations, IrqHandlerRegistry::registerThreadedHandler(), and UNLIKELY.
Referenced by registerPciMessageIrqHandler().
Here is the caller graph for this function:
|
overridevirtual |
Prefer a PCI message interrupt, falling back to INTx with the given policy.
Reimplemented from IrqManager.
Definition at line 433 of file Pic.cc.
References registerPciIrqHandler().
|
overridevirtual |
Register distinct MSI-X entries as one group. Failure permits a fallback only when fallbackSafe is true. Optional dense processor indices are placement hints; platforms without affinity support may retain their default destination.
Reimplemented from IrqManager.
|
virtual |
Install the platform's dedicated scheduler-timer interrupt source.
Unlike a generic hard handler, this callback is the terminal action for an occurrence and is allowed to abandon its interrupt frame. Platforms which do not provide a direct scheduler route reject the request.
Reimplemented from IrqManager.
Definition at line 489 of file Pic.cc.
References m_IrqState, m_SchedulerIrqHandler, m_ShuttingDown, and m_UnregisterReservations.
| bool Pic::reservePciRoute | ( | uint8_t | irq | ) |
Retains a motherboard PCI route's level trigger for the rest of boot.
Definition at line 232 of file Pic.cc.
References m_IrqState, m_ShuttingDown, m_UnregisterReservations, panic(), IoPort::read8(), and PicIrqState::reservePciRoute().
|
private |
| bool Pic::shutdownThreaded | ( | ) |
Masks all lines, cancels queued batches, then joins every worker.
Definition at line 752 of file Pic.cc.
References ThreadedIrqDispatcher::canShutdown(), ProcessorBase::index(), IrqHandlerRegistry::invalidateThreadedLine(), m_DeferredLineTransitions, m_DeliveryProcessor, m_FailClosedReasons, m_Handlers, m_HardStageGenerations, m_IrqState, m_ShuttingDown, m_ThreadedDispatcher, m_ThreadedDispatchGenerations, m_ThreadedHadHardStage, and ThreadedIrqDispatcher::shutdown().
|
virtual |
Copies up to capacity detached line diagnostics without taking an IRQ manager or handler-registry lock. Unsupported managers return zero.
Reimplemented from IrqManager.
Definition at line 928 of file Pic.cc.
References IrqHandlerRegistry::hardDispatchState(), m_ControllerContentions, m_ControllerPromptAttempts, m_Diagnostics, m_Handlers, m_IrqCount, m_SpuriousIrqCount, m_ThreadedDispatcher, m_ThreadedPublicationFailures, m_UnhandledIrqCount, ThreadedIrqDispatcher::pendingCookie(), IrqDiagnosticSnapshotStore< LineCount >::snapshot(), ThreadedIrqDispatcher::snapshotDiagnostics(), and IrqHandlerRegistry::threadedDispatchState().
|
private |
Handle a potentially-spurious IRQ while the PIC lock is held.
Definition at line 1020 of file Pic.cc.
References m_MasterPort, m_SlavePort, IoPort::read8(), and IoPort::write8().
Referenced by interrupt().
Here is the caller graph for this function:
|
virtual |
Called every millisecond, typically handles IRQ mitigation.
Reimplemented from IrqManager.
|
virtual |
Unregister a previously registered IrqHandler.
A successful return is an ownership barrier: no callback can begin or remain active for the handler. A callback cannot synchronously remove itself, and an atomic context cannot wait for an active callback; those requests return false.
| [in] | Id | the irq's identifier |
Implements IrqManager.
Definition at line 592 of file Pic.cc.
References ProcessorBase::executionContext(), m_Handlers, m_IrqState, m_UnregisterReservations, and IrqHandlerRegistry::unregisterHandler().
|
virtual |
Stop admitting future callbacks for the exact scheduler source. The source must be quiesced first unless removal synchronously masks its controller line. Its handler has static machine lifetime because an already-admitted callback may not return.
Reimplemented from IrqManager.
Definition at line 507 of file Pic.cc.
References m_IrqState, and m_SchedulerIrqHandler.
|
staticconstexprprivate |
|
private |
|
private |
Hard entries/tails which could not immediately own controller state.
Definition at line 214 of file Pic.h.
Referenced by initialise(), and snapshotIrqLines().
|
private |
Lock-free controller-worker prompt state for stopped-world diagnosis.
Definition at line 216 of file Pic.h.
Referenced by snapshotIrqLines().
|
private |
Non-blocking hard-entry ownership and terminal-action handoff.
Definition at line 189 of file Pic.h.
Referenced by interrupt().
|
private |
|
private |
|
private |
Lifetimes published by the BSP immediately before physical unmask.
Definition at line 225 of file Pic.h.
Referenced by shutdownThreaded().
|
private |
Physical LAPIC destination captured with the BSP worker scheduler.
Definition at line 229 of file Pic.h.
Referenced by initialiseThreaded().
|
private |
Stable BSP index rebound after processor topology initialisation.
Definition at line 227 of file Pic.h.
Referenced by initialise(), initialiseThreaded(), interrupt(), and shutdownThreaded().
|
private |
Per-line immutable diagnostic publications.
Definition at line 231 of file Pic.h.
Referenced by snapshotIrqLines().
|
private |
Reasons which must remain masked until their owning lifetime ends.
Definition at line 209 of file Pic.h.
Referenced by interrupt(), registerHardIsaIrqHandler(), registerHardPciIrqHandler(), registerIsaIrqHandler(), registerPciIrqHandler(), and shutdownThreaded().
|
private |
IRQ handlers and their callback lifetime state.
Definition at line 177 of file Pic.h.
Referenced by interrupt(), registerHardIsaIrqHandler(), registerHardPciIrqHandler(), registerIsaIrqHandler(), registerPciIrqHandler(), shutdownThreaded(), snapshotIrqLines(), and unregisterHandler().
|
private |
Invalidates an old hard result after its final callback lifetime ends.
Definition at line 201 of file Pic.h.
Referenced by interrupt(), and shutdownThreaded().
|
private |
|
staticprivate |
|
private |
IRQ counts for given handlers
Definition at line 237 of file Pic.h.
Referenced by initialise(), interrupt(), and snapshotIrqLines().
|
private |
Trigger mode, registration ownership and the complete 16-bit mask.
Definition at line 187 of file Pic.h.
Referenced by control(), interrupt(), registerHardIsaIrqHandler(), registerHardPciIrqHandler(), registerIsaIrqHandler(), registerPciIrqHandler(), registerSchedulerIrqHandler(), reservePciRoute(), shutdownThreaded(), unregisterHandler(), and unregisterSchedulerIrqHandler().
|
private |
The master PIC I/O Port range
Definition at line 171 of file Pic.h.
Referenced by initialise(), interrupt(), and spuriousLocked().
|
private |
|
private |
Mitigation thresholds
Definition at line 245 of file Pic.h.
Referenced by control(), and initialise().
|
private |
|
private |
Dedicated IRQ0 callback which may abandon its interrupt frame.
Definition at line 185 of file Pic.h.
Referenced by interrupt(), registerSchedulerIrqHandler(), and unregisterSchedulerIrqHandler().
|
private |
Closes registration and re-enable paths before worker shutdown.
Definition at line 235 of file Pic.h.
Referenced by registerHardIsaIrqHandler(), registerHardPciIrqHandler(), registerIsaIrqHandler(), registerPciIrqHandler(), registerSchedulerIrqHandler(), reservePciRoute(), and shutdownThreaded().
|
private |
The slave PIC I/O Port range
Definition at line 169 of file Pic.h.
Referenced by initialise(), and spuriousLocked().
|
private |
Architecturally spurious or disabled in-flight occurrences.
Definition at line 239 of file Pic.h.
Referenced by initialise(), interrupt(), and snapshotIrqLines().
|
private |
|
private |
Stable per-line workers plus one controller-continuation worker.
Definition at line 195 of file Pic.h.
Referenced by initialiseThreaded(), registerIsaIrqHandler(), registerPciIrqHandler(), shutdownThreaded(), and snapshotIrqLines().
|
private |
PIC dispatch generation associated with each queued cookie.
Definition at line 199 of file Pic.h.
Referenced by interrupt(), and shutdownThreaded().
|
private |
Hard-stage outcome folded into the matching mixed worker batch.
Definition at line 203 of file Pic.h.
Referenced by interrupt(), and shutdownThreaded().
|
private |
|
private |
|
private |
|
private |
|
private |
Atomic diagnostics for work rejected after dispatcher closure.
Definition at line 211 of file Pic.h.
Referenced by interrupt(), and snapshotIrqLines().
|
private |
Occurrences for which no callback accepted ownership.
Definition at line 241 of file Pic.h.
Referenced by initialise(), interrupt(), and snapshotIrqLines().
|
private |
Unregister operations which have not completed line accounting.
Definition at line 233 of file Pic.h.
Referenced by registerHardIsaIrqHandler(), registerHardPciIrqHandler(), registerIsaIrqHandler(), registerPciIrqHandler(), registerSchedulerIrqHandler(), reservePciRoute(), and unregisterHandler().