|
HomeCore 0.1.3 (07b5544)
Bare-metal personal computer firmware for Cortex-M
|
Kernel startup, the millisecond uptime clock, and heap usage. More...
Data Structures | |
| struct | k_heap_stats_t |
| Heap usage snapshot filled by k_heap_stats(). More... | |
| struct | k_stack_stats_t |
| Main-stack usage filled by k_stack_stats(). More... | |
Functions | |
| void | k_init (void) |
| Initialize kernel services and the standard streams. | |
Uptime | |
| void | k_uptime_init (void) |
Start the 1 kHz system timer and register /dev/uptime. | |
| uint64_t | k_uptime_ms (void) |
| Read the uptime clock. | |
| void | k_tick (void) |
| Advance the uptime clock by one millisecond. | |
Heap statistics | |
| void | k_heap_stats (k_heap_stats_t *stats) |
| Capture current heap usage. | |
Stack statistics | |
| void | k_stack_stats (k_stack_stats_t *stats) |
| Measure the main stack's high-water mark. | |
| #define | K_STACK_FILL_WORD 0xA5A5A5A5U |
| Word written over the unused main stack at reset. | |
Kernel startup, the millisecond uptime clock, and heap usage.
| #define K_STACK_FILL_WORD 0xA5A5A5A5U |
Word written over the unused main stack at reset.
The reset handler fills the main-stack reservation below its own frame with this value. k_stack_stats() finds the deepest word that no longer holds it.
| void k_init | ( | void | ) |
Initialize kernel services and the standard streams.
Starts the uptime clock (see k_uptime_init()) and opens /dev/uart0 as descriptors 0, 1, and 2 for stdin, stdout, and stderr. Calls board_panic() if any step fails. main() calls it once, after soc_init() and board_init().
| void k_uptime_init | ( | void | ) |
Start the 1 kHz system timer and register /dev/uptime.
Called by k_init(). Calls board_panic() if the timer cannot produce 1 kHz from board_cpu_clock_hz().
| uint64_t k_uptime_ms | ( | void | ) |
Read the uptime clock.
Masks interrupts briefly to read the 64-bit counter consistently. Masking interrupts for longer than one tick elsewhere loses time.
| void k_tick | ( | void | ) |
Advance the uptime clock by one millisecond.
Call only from the 1 kHz system timer interrupt.
| void k_heap_stats | ( | k_heap_stats_t * | stats | ) |
Capture current heap usage.
Available memory is reusable + unclaimed, which is not necessarily one contiguous block.
| [out] | stats | Destination. Must not be NULL; this is not checked. |
| void k_stack_stats | ( | k_stack_stats_t * | stats | ) |
Measure the main stack's high-water mark.
Scans the reservation from its lowest address for the first word that was overwritten since reset. used == size means the whole reservation was used and the stack may have overflowed into the heap, which is not detected otherwise. The scan reads up to size bytes; call it from foreground code.
| [out] | stats | Destination. Must not be NULL; this is not checked. |