|
The Pedigree Project 0.1
|
#include <ThreadedIrqDispatcher.h>
Collaboration diagram for ThreadedIrqDispatcher:Classes | |
| class | Line |
Public Types | |
| using | DispatchCallback = void(*)(void *, uint8_t, size_t) |
| using | RemoteWakeCallback = bool(*)(void *, uint8_t, size_t) |
Public Member Functions | |
| ThreadedIrqDispatcher (const String &name, size_t lineCount, DispatchCallback callback, void *callbackContext) | |
| bool | initialise () |
| bool | shutdown () |
| bool | canShutdown () const |
| bool | isInitialised () const |
| bool | isCurrentWorker () const |
| bool | publishFromInterrupt (uint8_t line, size_t cookie) |
| bool | hasPending (uint8_t line) const |
| size_t | pendingCookie (uint8_t line) const |
| size_t | activeCookie (uint8_t line) const |
| size_t | completedBatches (uint8_t line) const |
| size_t | completedCookie (uint8_t line) const |
| uintptr_t | workerIdentity (uint8_t line) const |
| bool | callbackActive (uint8_t line) const |
| bool | publicationClosed (uint8_t line) const |
| void | snapshotDiagnostics (uint8_t line, IrqLineDiagnosticSnapshot &snapshot) const |
Static Public Attributes | |
| static constexpr size_t | MaxLines = 17 |
Private Member Functions | |
| MUST_USE_RESULT bool | setRemoteWakeCallback (RemoteWakeCallback callback, void *callbackContext) |
| ThreadedIrqDispatcher (const ThreadedIrqDispatcher &)=delete | |
| ThreadedIrqDispatcher & | operator= (const ThreadedIrqDispatcher &)=delete |
Private Attributes | |
| Line | m_Lines [MaxLines] |
| NormalStaticString | m_Name |
| size_t | m_LineCount |
| DispatchCallback | m_Callback |
| void * | m_CallbackContext |
| Spinlock | m_ConfigurationLock |
| RemoteWakeCallback | m_RemoteWakeCallback |
| void * | m_RemoteWakeCallbackContext |
| size_t | m_ConfigurationClosed |
| size_t | m_Initialised |
| size_t | m_ShutdownClaimed |
Friends | |
| class | Pic |
Owns one coalescing worker for each configured IRQ or controller work lane.
The controller performs the trigger-specific hard-stage work before publishing a monotonically increasing, nonzero cookie. The worker invokes the callback in ordinary thread context. Interrupted machine state is never retained or exposed to the callback. Publication records atomics, rings the worker scheduler's doorbell, and may issue a bounded directed prompt; it never wakes a sleeping thread from hard context.
Definition at line 35 of file ThreadedIrqDispatcher.h.
| using ThreadedIrqDispatcher::DispatchCallback = void (*)(void*, uint8_t, size_t) |
Definition at line 38 of file ThreadedIrqDispatcher.h.
| using ThreadedIrqDispatcher::RemoteWakeCallback = bool (*)(void*, uint8_t, size_t) |
Prompts the worker processor after a remote producer has made a batch visible. The callback must be bounded, hard-IRQ safe, and must not attempt to roll back the already-published cookie on failure.
Definition at line 44 of file ThreadedIrqDispatcher.h.
| ThreadedIrqDispatcher::ThreadedIrqDispatcher | ( | const String & | name, |
| size_t | lineCount, | ||
| DispatchCallback | callback, | ||
| void * | callbackContext | ||
| ) |
Definition at line 521 of file ThreadedIrqDispatcher.cc.
| ThreadedIrqDispatcher::~ThreadedIrqDispatcher | ( | ) |
Definition at line 604 of file ThreadedIrqDispatcher.cc.
| size_t ThreadedIrqDispatcher::activeCookie | ( | uint8_t | line | ) | const |
Definition at line 741 of file ThreadedIrqDispatcher.cc.
| bool ThreadedIrqDispatcher::callbackActive | ( | uint8_t | line | ) | const |
Definition at line 757 of file ThreadedIrqDispatcher.cc.
| bool ThreadedIrqDispatcher::canShutdown | ( | ) | const |
Whether the current context can synchronously join worker threads.
Definition at line 694 of file ThreadedIrqDispatcher.cc.
References ProcessorBase::executionContext(), ProcessorBase::information(), and isCurrentWorker().
Referenced by shutdown(), and Pic::shutdownThreaded().
Here is the caller graph for this function:| size_t ThreadedIrqDispatcher::completedBatches | ( | uint8_t | line | ) | const |
Definition at line 745 of file ThreadedIrqDispatcher.cc.
| size_t ThreadedIrqDispatcher::completedCookie | ( | uint8_t | line | ) | const |
Definition at line 749 of file ThreadedIrqDispatcher.cc.
| bool ThreadedIrqDispatcher::hasPending | ( | uint8_t | line | ) | const |
Whether an occurrence arrived after the worker claimed its batch.
Definition at line 733 of file ThreadedIrqDispatcher.cc.
| bool ThreadedIrqDispatcher::initialise | ( | ) |
Starts every stable per-line worker after scheduler initialisation.
Definition at line 610 of file ThreadedIrqDispatcher.cc.
References Spinlock::acquire(), ProcessorBase::information(), m_ConfigurationClosed, m_ConfigurationLock, m_ShutdownClaimed, and Spinlock::release().
Referenced by SplitIrqHandler::initialiseSplitIrq(), and Pic::initialiseThreaded().
Here is the caller graph for this function:| bool ThreadedIrqDispatcher::isCurrentWorker | ( | ) | const |
True when called by one of this dispatcher's callback workers.
Definition at line 708 of file ThreadedIrqDispatcher.cc.
References ProcessorBase::information().
Referenced by canShutdown(), and SplitIrqHandler::shutdownSplitIrq().
Here is the caller graph for this function:| bool ThreadedIrqDispatcher::isInitialised | ( | ) | const |
Definition at line 704 of file ThreadedIrqDispatcher.cc.
| size_t ThreadedIrqDispatcher::pendingCookie | ( | uint8_t | line | ) | const |
Lock-free diagnostic state; invalid lines return zero/false.
Definition at line 737 of file ThreadedIrqDispatcher.cc.
Referenced by Pic::snapshotIrqLines().
Here is the caller graph for this function:| bool ThreadedIrqDispatcher::publicationClosed | ( | uint8_t | line | ) | const |
Definition at line 761 of file ThreadedIrqDispatcher.cc.
| bool ThreadedIrqDispatcher::publishFromInterrupt | ( | uint8_t | line, |
| size_t | cookie | ||
| ) |
Marks a line and rings its owning scheduler in one bounded operation. Concurrent or nested producers are coalesced by cookie generation. A constant cookie is safe for multi-producer work-bit users. Callers must enter through a hard/atomic source which serialises same-CPU execution; a nested publication can only occur after the outer cookie is stored.
Definition at line 720 of file ThreadedIrqDispatcher.cc.
|
private |
PIC is the sole production client allowed to request a directed worker prompt. Generic dispatchers deliberately remain local-only so an opaque callback cannot smuggle a blocking operation into hard IRQ context.
Definition at line 549 of file ThreadedIrqDispatcher.cc.
References Spinlock::acquire(), m_ConfigurationClosed, m_ConfigurationLock, m_RemoteWakeCallback, and Spinlock::release().
Referenced by Pic::initialiseThreaded().
Here is the caller graph for this function:| bool ThreadedIrqDispatcher::shutdown | ( | ) |
Rejects new publications and joins every worker.
Definition at line 654 of file ThreadedIrqDispatcher.cc.
References canShutdown(), ProcessorBase::information(), m_ConfigurationClosed, and m_ShutdownClaimed.
Referenced by SplitIrqHandler::shutdownSplitIrq(), and Pic::shutdownThreaded().
Here is the caller graph for this function:| void ThreadedIrqDispatcher::snapshotDiagnostics | ( | uint8_t | line, |
| IrqLineDiagnosticSnapshot & | snapshot | ||
| ) | const |
Copies lock-free timing and detached worker state for the debugger. Live fields are sampled independently; stopped-world use is authoritative.
Definition at line 765 of file ThreadedIrqDispatcher.cc.
Referenced by Pic::snapshotIrqLines().
Here is the caller graph for this function:| uintptr_t ThreadedIrqDispatcher::workerIdentity | ( | uint8_t | line | ) | const |
Definition at line 753 of file ThreadedIrqDispatcher.cc.
|
friend |
Definition at line 134 of file ThreadedIrqDispatcher.h.
|
private |
Definition at line 210 of file ThreadedIrqDispatcher.h.
|
private |
Definition at line 211 of file ThreadedIrqDispatcher.h.
|
private |
Closes callback configuration before the first worker is created.
Definition at line 218 of file ThreadedIrqDispatcher.h.
Referenced by initialise(), setRemoteWakeCallback(), and shutdown().
|
private |
Serialises normal-context callback configuration with initialise().
Definition at line 213 of file ThreadedIrqDispatcher.h.
Referenced by initialise(), and setRemoteWakeCallback().
|
private |
Definition at line 219 of file ThreadedIrqDispatcher.h.
|
private |
Definition at line 209 of file ThreadedIrqDispatcher.h.
|
private |
Definition at line 205 of file ThreadedIrqDispatcher.h.
|
private |
Inline so global interrupt-controller constructors cannot enter the heap.
Definition at line 208 of file ThreadedIrqDispatcher.h.
|
private |
Immutable after initialise(): null intentionally means local-only.
Definition at line 215 of file ThreadedIrqDispatcher.h.
Referenced by setRemoteWakeCallback().
|
private |
Definition at line 216 of file ThreadedIrqDispatcher.h.
|
private |
Exactly one normal-context caller may join and release workers.
Definition at line 221 of file ThreadedIrqDispatcher.h.
Referenced by initialise(), and shutdown().
|
staticconstexpr |
Definition at line 37 of file ThreadedIrqDispatcher.h.