34#ifndef SKIP_STATIC_ASSERTS
37 "TCB stack_pointer offset mismatch - update context_switch.s");
39 "TCB task_state offset mismatch - update context_switch.s");
40_Static_assert(offsetof(
icarus_task_t, global_tick_paused) == 20,
41 "TCB global_tick_paused offset mismatch - update context_switch.s");
43 "TCB ticks_to_pause offset mismatch - update context_switch.s");
90 __attribute__((aligned(2048)))
91 __attribute__((section(".ram_d2")));
94 __attribute__((aligned(2048)));
177#if ICARUS_ENABLE_HEARTBEAT_VIS
183#if ICARUS_ENABLE_HEARTBEAT_VIS
196#if ICARUS_ENABLE_HEARTBEAT_VIS
239 for (i = 0u; i < 16u; i++) {
302 return (
void*) ret_ptr;
330 name_buffer[i] = src[i];
331 if (src[i] ==
'\0') {
404 uint32_t free_words = 0;
405 for (uint32_t i = 0; i < t->
stack_size; i++) {
412 if (free_words < t->stack_watermark) {
void display_render_banner(uint8_t row, const char *task_name, bool is_on)
Render a simple flashing banner (on/off indicator)
void display_init(void)
Initialize terminal display - clear screen and print header.
#define ICARUS_HEARTBEAT_ON_TICKS
Heartbeat LED on duration in ticks.
#define ICARUS_HEARTBEAT_OFF_TICKS
Heartbeat LED off duration in ticks.
#define ICARUS_MAX_TASK_NAME_LEN
Maximum length of task name string (including null terminator)
#define ICARUS_MAX_SEMAPHORES
Maximum number of semaphores.
#define ICARUS_MAX_TASKS
Maximum number of concurrent tasks.
#define ICARUS_MAX_MESSAGE_BYTES
Maximum bytes per message pipe buffer.
#define ICARUS_TICKS_PER_TASK
Number of SysTick interrupts per task time slice.
#define ICARUS_DATA_WORDS
Data region size per task in 32-bit words.
#define ICARUS_MAX_MESSAGE_QUEUES
Maximum number of message queues (pipes)
#define ICARUS_STACK_WORDS
Stack size per task in 32-bit words.
static uint32_t data_pool[128][512]
void * __kernel_protected_data(uint16_t num_words)
Privileged implementation of kernel_protected_data.
uint8_t num_created_tasks
Total number of created tasks.
volatile uint32_t current_task_ticks_remaining
Ticks remaining in current task's time slice.
void start_cold_task(icarus_task_t *task)
void __exit_critical(void)
Privileged implementation of exit_critical.
uint8_t running_task_count
Count of tasks in active states.
uint8_t current_task_index
Index of currently executing task.
static uint16_t data_pool_word_offsets[128]
uint8_t __os_get_num_created_tasks(void)
Privileged implementation of os_get_num_created_tasks.
icarus_pipe_t * message_pipe_list[64]
Array of pointers to all message pipes.
volatile uint8_t os_running
Flag indicating OS is running.
icarus_task_t * task_list[128]
Array of pointers to all task control blocks.
int8_t current_cleanup_task_idx
Current cleanup queue write index.
void __os_init(void)
Privileged implementation of os_init.
icarus_task_state_t __os_get_task_state(uint8_t task_idx)
Privileged implementation of os_get_task_state.
static void __init_pipe(uint8_t message_pipe_idx, uint16_t max_messages, bool should_engage)
void __enter_critical(void)
Privileged implementation of enter_critical.
static void os_idle_task(void)
volatile uint8_t critical_stack_depth
static icarus_pipe_t message_pipe_pool[64]
static icarus_task_t task_pool[128]
uint8_t __os_is_running(void)
Privileged implementation of os_is_running.
static icarus_semaphore_t semaphore_pool[64]
static void __init_sem(uint8_t semaphore_idx, uint32_t semaphore_count, bool should_engage)
uint32_t * __kernel_get_data(uint8_t task_idx)
Privileged implementation of kernel_get_data.
void __os_start(void)
Privileged implementation of os_start.
uint32_t __os_get_task_dispatch_count(uint8_t task_idx)
Privileged implementation of os_get_task_dispatch_count.
const char * __os_get_task_name(uint8_t task_idx)
Privileged implementation of os_get_task_name.
icarus_semaphore_t * semaphore_list[64]
Array of pointers to all semaphores.
int8_t cleanup_task_idx[128]
Cleanup task index queue.
volatile uint32_t os_tick_count
System tick counter.
uint32_t cpu_vregisters[16]
uint32_t * __kernel_get_stack(uint8_t task_idx)
Privileged implementation of kernel_get_stack.
void __os_update_stack_watermark(uint8_t task_idx)
Scan a task's stack from the base upward for the sentinel pattern (0xDEADC0DE) and update the waterma...
uint32_t __os_get_stack_watermark(uint8_t task_idx)
Privileged implementation of os_get_stack_watermark.
volatile uint32_t ticks_per_task
Configured ticks per time slice.
volatile bool scheduler_enabled
Scheduler enable flag.
static uint32_t stack_pool[128][512]
static void os_heartbeat_task(void)
ICARUS Kernel Core - State and Initialization.
void os_yield(void)
Voluntarily yield CPU to scheduler.
const char * os_get_current_task_name(void)
Get name of currently executing task.
uint32_t task_active_sleep(uint32_t ticks)
Sleep for specified ticks (cooperative, via SVC)
void LED_On(void)
Turn LED on.
void LED_Blink(uint32_t on_ticks, uint32_t off_ticks)
Blink LED with specified timing.
void LED_Off(void)
Turn LED off.
ICARUS Scheduler - Task Scheduling and Timing.
uint8_t os_is_running(void)
Check if OS is running (safe from unprivileged mode)
uint16_t count
Current number of bytes in buffer.
uint16_t dequeue_idx
Read index (circular)
uint16_t max_count
Maximum buffer capacity in bytes.
uint16_t enqueue_idx
Write index (circular)
uint8_t buffer[512]
Circular message buffer.
uint32_t tick_updated_at
Last modification timestamp.
bool engaged
true if pipe is initialized and active
uint32_t tick_updated_at
Last modification timestamp (for debugging)
uint32_t max_count
Maximum count (initial value)
bool engaged
true if semaphore is initialized and active
uint32_t count
Current semaphore count.
char name[32]
Human-readable task name.
icarus_task_state_t task_state
Current task state (offset 16)
uint32_t dispatch_count
Times this task has been dispatched.
uint32_t * stack_base
Base address of task stack.
uint32_t stack_size
Stack size in 32-bit words.
uint32_t stack_watermark
Minimum free stack words observed.
ICARUS Task Management - Creation and Lifecycle.
void __os_register_task(void(*function)(void), const char *name)
Privileged implementation of os_register_task.
icarus_task_state_t
Task state enumeration.
@ TASK_STATE_FINISHED
Task completed execution normally.