In development. It changes without notice.
Topic
Main Loop & Hooks
The task that runs the firmware, and the hooks through which code calls a module above it without knowing it.
- kleidos::
platform:: startMainLoop() starts the one task of the application, on core 1. - A hook lets a loop that waits keep the serial console of a debug build answering.
- Another lets a wait on a worker paint meanwhile, on the task that waits.
- Switches name the ways an unlock and a write can be made faster, so that one can be measured without another.
Files | |
| file | src/ |
| app_main() helper that spawns the setup()/ | |
| file | src/ |
| Shared app_main() helper that runs the firmware setup()/ | |
| file | src/ |
| Holds the registered console pump, the console's call on the sleep path and the knobs it set for the next deep sleep. | |
| file | src/ |
| Lets the code below the serial debug console reach it without naming it. | |
| file | src/ |
| The build switches that select the unlock and write performance policies, readable from any layer. | |
| file | src/ |
| Holds the pump a task installed for its wait, and runs it for that task only. | |
| file | src/ |
| Lets a task blocked on another task's work keep painting, without the code that waits naming what it paints. | |
Classes | |
| struct | kleidos:: |
| The parks a console command may ask the next deep sleep to skip, for an A/B against the production sleep. Value-initialized, every member is the production behavior. More about kleidos:: | |
| struct | kleidos:: |
| What one pump step did, and when it wants to run again. More about kleidos:: | |
| class | kleidos:: |
| Install a pump for the calling task for the life of this scope. More about kleidos:: | |
| struct | kleidos:: |
| What the pumps of the open scopes painted, for the unlock trace. More about kleidos:: | |
Macros | |
| #define | KLEIDOS_ |
| #define | KLEIDOS_ |
| #define | KLEIDOS_ |
| #define | KLEIDOS_ |
| Read the credential list one index segment per unit (1) or in one walk (0). | |
| #define | KLEIDOS_ |
| #define | KLEIDOS_ |
| Log the duration of every unlock unit. Debug builds only by default. | |
Functions | |
| bool | kleidos:: |
| Spawn the setup()/loop() task pinned to Core 1 (APP_CPU, 8704-byte stack). | |
| void | kleidos:: |
| No console is compiled in, so a blocking loop has nothing to service. | |
| void | kleidos:: |
| No console is compiled in, so it holds nothing the sleep path must wait for. | |
| DebugSleepKnobs | kleidos:: |
| No console is compiled in, so every sleep is the production one. | |
| WaitPumpTally | kleidos:: |
| The frames painted since the innermost open scope was made. | |
| uint32_t | kleidos:: |
| Run the calling task's pump once and return how long it may sleep. | |
| void | kleidos:: |
| Replace how the facade reads the running task's identity. | |
Variables | |
| constexpr uint32_t | kleidos:: |
| constexpr uint32_t | kleidos:: |
| The shortest slice a pump may ask for (ms): one scheduler tick. | |
Macro Definition Documentation
KLEIDOS_ UNLOCK_ CPU_ BOOST #
Hold the unlock CPU boost across the transition into HOME (1) or drop it at the end of the verify callback (0).
KLEIDOS_ UNLOCK_ IDLE_ FLOOR #
Idle the auth screen at kleidos:: (1) or keep it at the 160 MHz the measured baseline used (0).
KLEIDOS_ UNLOCK_ WAIT_ PUMP #
Paint the verify wait from inside the vault dispatch's wait (1), or leave the UI task asleep there as the measured baseline did (0). See wait_pump.h.
KLEIDOS_ WRITE_ CPU_ BOOST #
Boost the heavy vault writes — the credential save and every other write that measured over 100 ms at the base clock — to 240 MHz for the whole vault-worker round-trip (1), or leave them at the calling state's clock (0).
Function Documentation
runWaitPump() #
Run the calling task's pump once and return how long it may sleep.
What a wait calls between slices, and once before the first.
Not re-entrant by design: a pump step that itself waits on the vault worker reaches this again from inside its own frame, and that inner call runs no pump (not even one a scope opened inside the step installed) and answers kWaitIdleSliceMs, so the inner wait sleeps as an unpumped one.
- Returns
- The slice to sleep in, in [kWaitMinSliceMs, kWaitIdleSliceMs]: the pump's own answer, or kWaitIdleSliceMs when the calling task installed none or is already inside a step.
setWaitTaskIdProvider() #
Replace how the facade reads the running task's identity.
For the host tests, which run every "task" on one thread.
- Parameters
-
Name Direction Meaning fn in The reader, or nullptrto restore the default.
startMainLoop() #
Spawn the setup()/loop() task pinned to Core 1 (APP_CPU, 8704-byte stack).
Call once from app_main(). Returns after the task is created so the IDF main task can exit; the scheduler keeps running the spawned task.
- Parameters
-
Name Meaning setupFn One-time bring-up, run once before the loop. loopFn Loop body, called forever after setup completes.
- Returns
- True if the task was created; false on failure (already logged).
- Return values
-
Value Meaning true Task was created and is now scheduled on Core 1 (APP_CPU). false Task creation failed (already logged via KLEIDOS_LOG).
takeDebugSleepKnobs() #
No console is compiled in, so every sleep is the production one.
- Returns
- Value-initialized knobs: every park runs.
waitPumpTally() #
The frames painted since the innermost open scope was made.
A scope that closes folds its frames into the scope it nested in, so an outer scope's tally (and its trace line) counts every frame painted while it was open, an inner scope's included. Its gaps fold the same way: the outer scope's longest gap also covers the interval from its last paint before the inner scope opened to the inner scope's first paint.
- Returns
- The innermost open scope's tally; all zero with no scope open.
Variable Documentation
kWaitIdleSliceMs #
The slice a wait sleeps in when no pump is installed (ms): the dispatch's watchdog slice.