|
ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
|
ICARUS Kernel Core Implementation. More...
#include "icarus/kernel.h"#include "icarus/task.h"#include "icarus/scheduler.h"#include "bsp/display.h"#include "bsp/led.h"#include <string.h>#include <stddef.h>Go to the source code of this file.
Functions | |
| void | start_cold_task (icarus_task_t *task) |
| void | __enter_critical (void) |
| Privileged implementation of enter_critical. | |
| void | __exit_critical (void) |
| Privileged implementation of exit_critical. | |
| static void | __init_sem (uint8_t semaphore_idx, uint32_t semaphore_count, bool should_engage) |
| static void | __init_pipe (uint8_t message_pipe_idx, uint16_t max_messages, bool should_engage) |
| static void | os_idle_task (void) |
| static void | os_heartbeat_task (void) |
| void | __os_init (void) |
| Privileged implementation of os_init. | |
| void | __os_start (void) |
| Privileged implementation of os_start. | |
| uint32_t * | __kernel_get_stack (uint8_t task_idx) |
| Privileged implementation of kernel_get_stack. | |
| uint32_t * | __kernel_get_data (uint8_t task_idx) |
| Privileged implementation of kernel_get_data. | |
| void * | __kernel_protected_data (uint16_t num_words) |
| Privileged implementation of kernel_protected_data. | |
| const char * | __os_get_task_name (uint8_t task_idx) |
| Privileged implementation of os_get_task_name. | |
| uint8_t | __os_get_num_created_tasks (void) |
| Privileged implementation of os_get_num_created_tasks. | |
| uint8_t | __os_is_running (void) |
| Privileged implementation of os_is_running. | |
| icarus_task_state_t | __os_get_task_state (uint8_t task_idx) |
| Privileged implementation of os_get_task_state. | |
| uint32_t | __os_get_task_dispatch_count (uint8_t task_idx) |
| Privileged implementation of os_get_task_dispatch_count. | |
| uint32_t | __os_get_stack_watermark (uint8_t task_idx) |
| Privileged implementation of os_get_stack_watermark. | |
| 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 watermark. | |
Variables | |
| icarus_task_t * | task_list [128] |
| Array of pointers to all task control blocks. | |
| icarus_semaphore_t * | semaphore_list [64] |
| Array of pointers to all semaphores. | |
| icarus_pipe_t * | message_pipe_list [64] |
| Array of pointers to all message pipes. | |
| static icarus_task_t | task_pool [128] |
| static icarus_semaphore_t | semaphore_pool [64] |
| static icarus_pipe_t | message_pipe_pool [64] |
| int8_t | cleanup_task_idx [128] |
| Cleanup task index queue. | |
| uint8_t | current_task_index |
| Index of currently executing task. | |
| uint8_t | running_task_count |
| Count of tasks in active states. | |
| 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. | |
| volatile uint32_t | ticks_per_task |
| Configured ticks per time slice. | |
| uint32_t | cpu_vregisters [16] |
| volatile uint32_t | os_tick_count |
| System tick counter. | |
| volatile uint8_t | os_running |
| Flag indicating OS is running. | |
| volatile uint8_t | critical_stack_depth |
| volatile bool | scheduler_enabled |
| Scheduler enable flag. | |
| int8_t | current_cleanup_task_idx |
| Current cleanup queue write index. | |
| static uint32_t | stack_pool [128][512] |
| static uint32_t | data_pool [128][512] |
| static uint16_t | data_pool_word_offsets [128] |
ICARUS Kernel Core Implementation.
Core kernel state, data structures, and initialization.
Definition in file kernel.c.
| void __enter_critical | ( | void | ) |
Privileged implementation of enter_critical.
Definition at line 114 of file kernel.c.
References critical_stack_depth, and scheduler_enabled.
Referenced by crc16_ccitt(), enter_critical(), and SVC_Handler_C().
| void __exit_critical | ( | void | ) |
Privileged implementation of exit_critical.
Definition at line 124 of file kernel.c.
References critical_stack_depth, and scheduler_enabled.
Referenced by crc16_ccitt(), exit_critical(), and SVC_Handler_C().
|
inlinestatic |
Definition at line 144 of file kernel.c.
References icarus_pipe_t::buffer, icarus_pipe_t::count, icarus_pipe_t::dequeue_idx, icarus_pipe_t::engaged, icarus_pipe_t::enqueue_idx, ICARUS_MAX_MESSAGE_BYTES, icarus_pipe_t::max_count, message_pipe_list, os_tick_count, and icarus_pipe_t::tick_updated_at.
Referenced by __os_init().
|
inlinestatic |
Definition at line 135 of file kernel.c.
References icarus_semaphore_t::count, icarus_semaphore_t::engaged, icarus_semaphore_t::max_count, os_tick_count, semaphore_list, and icarus_semaphore_t::tick_updated_at.
Referenced by __os_init().
| uint32_t * __kernel_get_data | ( | uint8_t | task_idx | ) |
Privileged implementation of kernel_get_data.
Definition at line 282 of file kernel.c.
References data_pool.
Referenced by __os_register_task(), kernel_get_data(), and SVC_Handler_C().
| uint32_t * __kernel_get_stack | ( | uint8_t | task_idx | ) |
Privileged implementation of kernel_get_stack.
Definition at line 269 of file kernel.c.
References stack_pool.
Referenced by __os_register_task(), kernel_get_stack(), and SVC_Handler_C().
| void * __kernel_protected_data | ( | uint16_t | num_words | ) |
Privileged implementation of kernel_protected_data.
Definition at line 295 of file kernel.c.
References current_task_index, data_pool, data_pool_word_offsets, and ICARUS_DATA_WORDS.
Referenced by kernel_protected_data(), and SVC_Handler_C().
| uint8_t __os_get_num_created_tasks | ( | void | ) |
Privileged implementation of os_get_num_created_tasks.
Definition at line 345 of file kernel.c.
References num_created_tasks.
Referenced by os_get_num_created_tasks(), and SVC_Handler_C().
| uint32_t __os_get_stack_watermark | ( | uint8_t | task_idx | ) |
Privileged implementation of os_get_stack_watermark.
| task_idx | Task index. |
Definition at line 387 of file kernel.c.
References num_created_tasks, icarus_task_t::stack_watermark, and task_list.
Referenced by os_get_stack_watermark(), and SVC_Handler_C().
| uint32_t __os_get_task_dispatch_count | ( | uint8_t | task_idx | ) |
Privileged implementation of os_get_task_dispatch_count.
| task_idx | Task index. |
Definition at line 375 of file kernel.c.
References icarus_task_t::dispatch_count, num_created_tasks, and task_list.
Referenced by os_get_task_dispatch_count(), and SVC_Handler_C().
| const char * __os_get_task_name | ( | uint8_t | task_idx | ) |
Privileged implementation of os_get_task_name.
Definition at line 315 of file kernel.c.
References ICARUS_MAX_TASK_NAME_LEN, icarus_task_t::name, num_created_tasks, and task_list.
Referenced by os_get_task_name(), and SVC_Handler_C().
| icarus_task_state_t __os_get_task_state | ( | uint8_t | task_idx | ) |
Privileged implementation of os_get_task_state.
| task_idx | Task index. |
Definition at line 363 of file kernel.c.
References num_created_tasks, task_list, icarus_task_t::task_state, and TASK_STATE_FINISHED.
Referenced by os_get_task_state(), and SVC_Handler_C().
| void __os_init | ( | void | ) |
Privileged implementation of os_init.
Definition at line 212 of file kernel.c.
References __init_pipe(), __init_sem(), __os_register_task(), cleanup_task_idx, cpu_vregisters, current_cleanup_task_idx, current_task_index, current_task_ticks_remaining, data_pool_word_offsets, ICARUS_MAX_MESSAGE_QUEUES, ICARUS_MAX_SEMAPHORES, ICARUS_MAX_TASKS, ICARUS_TICKS_PER_TASK, message_pipe_list, message_pipe_pool, os_idle_task(), os_running, running_task_count, scheduler_enabled, semaphore_list, semaphore_pool, task_list, task_pool, and ticks_per_task.
Referenced by os_init().
| uint8_t __os_is_running | ( | void | ) |
Privileged implementation of os_is_running.
Definition at line 354 of file kernel.c.
References os_running.
Referenced by os_is_running(), and SVC_Handler_C().
| void __os_start | ( | void | ) |
Privileged implementation of os_start.
Definition at line 253 of file kernel.c.
References current_task_index, ICARUS_MAX_TASKS, num_created_tasks, start_cold_task(), and task_list.
Referenced by os_start().
| 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 watermark.
| task_idx | Task index. |
Definition at line 399 of file kernel.c.
References num_created_tasks, icarus_task_t::stack_base, icarus_task_t::stack_size, icarus_task_t::stack_watermark, and task_list.
Referenced by os_update_stack_watermark(), and SVC_Handler_C().
|
static |
Definition at line 175 of file kernel.c.
References display_render_banner(), ICARUS_HEARTBEAT_OFF_TICKS, ICARUS_HEARTBEAT_ON_TICKS, LED_Blink(), LED_Off(), LED_On(), os_get_current_task_name(), os_is_running(), ROW_HEARTBEAT, and task_active_sleep().
|
static |
Definition at line 163 of file kernel.c.
References display_init(), and os_yield().
Referenced by __os_init().
|
extern |
Referenced by __os_start().
| int8_t cleanup_task_idx[128] |
Cleanup task index queue.
Definition at line 57 of file kernel.c.
Referenced by __os_exit_task(), __os_init(), and __os_kill_process().
| uint32_t cpu_vregisters[16] |
Definition at line 68 of file kernel.c.
Referenced by __os_init().
| volatile uint8_t critical_stack_depth |
Definition at line 71 of file kernel.c.
Referenced by __enter_critical(), and __exit_critical().
| int8_t current_cleanup_task_idx |
Current cleanup queue write index.
Definition at line 73 of file kernel.c.
Referenced by __os_exit_task(), __os_init(), and __os_kill_process().
| uint8_t current_task_index |
Index of currently executing task.
Definition at line 63 of file kernel.c.
Referenced by __kernel_protected_data(), __os_exit_task(), __os_get_current_task_name(), __os_init(), __os_kill_process(), __os_start(), __os_task_suicide(), and __task_active_sleep().
| volatile uint32_t current_task_ticks_remaining |
Ticks remaining in current task's time slice.
Definition at line 66 of file kernel.c.
Referenced by __os_get_task_ticks_remaining(), __os_init(), __os_yield(), and SysTick_Handler().
|
static |
Definition at line 89 of file kernel.c.
Referenced by __kernel_get_data(), and __kernel_protected_data().
|
static |
Definition at line 98 of file kernel.c.
Referenced by __kernel_protected_data(), and __os_init().
| icarus_pipe_t* message_pipe_list[64] |
Array of pointers to all message pipes.
Definition at line 52 of file kernel.c.
Referenced by __init_pipe(), __os_init(), __pipe_can_dequeue(), __pipe_can_enqueue(), __pipe_dequeue(), __pipe_enqueue(), __pipe_get_count(), __pipe_get_max_count(), __pipe_init(), __pipe_read_bytes(), and __pipe_write_bytes().
|
static |
Definition at line 56 of file kernel.c.
Referenced by __os_init().
| uint8_t num_created_tasks |
Total number of created tasks.
Definition at line 65 of file kernel.c.
Referenced by __os_get_current_task_name(), __os_get_num_created_tasks(), __os_get_stack_watermark(), __os_get_task_dispatch_count(), __os_get_task_name(), __os_get_task_state(), __os_kill_process(), __os_register_task(), __os_restart_task(), __os_start(), __os_update_stack_watermark(), and os_create_task().
| volatile uint8_t os_running |
Flag indicating OS is running.
Definition at line 70 of file kernel.c.
Referenced by __os_init(), __os_is_running(), and SysTick_Handler().
| volatile uint32_t os_tick_count |
System tick counter.
Definition at line 69 of file kernel.c.
Referenced by __init_pipe(), __init_sem(), __os_get_tick_count(), __pipe_init(), __pipe_read_bytes(), __pipe_write_bytes(), __sem_decrement(), __sem_increment(), __semaphore_init(), __task_active_sleep(), __task_busy_wait(), and SysTick_Handler().
| uint8_t running_task_count |
Count of tasks in active states.
Definition at line 64 of file kernel.c.
Referenced by __os_exit_task(), __os_get_running_task_count(), __os_init(), __os_kill_process(), __os_restart_task(), and os_create_task().
| volatile bool scheduler_enabled |
Scheduler enable flag.
Definition at line 72 of file kernel.c.
Referenced by __enter_critical(), __exit_critical(), __os_init(), and SysTick_Handler().
| icarus_semaphore_t* semaphore_list[64] |
Array of pointers to all semaphores.
Definition at line 51 of file kernel.c.
Referenced by __init_sem(), __os_init(), __sem_can_consume(), __sem_can_feed(), __sem_decrement(), __sem_increment(), __semaphore_consume(), __semaphore_consume_timeout(), __semaphore_feed(), __semaphore_get_count(), __semaphore_get_max_count(), and __semaphore_init().
|
static |
Definition at line 55 of file kernel.c.
Referenced by __os_init().
|
static |
Definition at line 79 of file kernel.c.
Referenced by __kernel_get_stack().
| icarus_task_t* task_list[128] |
Array of pointers to all task control blocks.
Definition at line 50 of file kernel.c.
Referenced by __os_exit_task(), __os_get_current_task_name(), __os_get_stack_watermark(), __os_get_task_dispatch_count(), __os_get_task_name(), __os_get_task_state(), __os_init(), __os_kill_process(), __os_register_task(), __os_restart_task(), __os_start(), __os_task_suicide(), __os_update_stack_watermark(), and __task_active_sleep().
|
static |
Definition at line 54 of file kernel.c.
Referenced by __os_init().
| volatile uint32_t ticks_per_task |
Configured ticks per time slice.
Definition at line 67 of file kernel.c.
Referenced by __os_init(), and __os_yield().