|
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 - State and Initialization. More...
#include <stdint.h>#include <stdbool.h>#include "bsp/retarget_hal.h"#include "icarus/config.h"#include "icarus/types.h"Go to the source code of this file.
Functions | |
| void | os_init (void) |
| Initialize the ICARUS kernel. | |
| void | os_start (void) |
| Start the ICARUS scheduler. | |
| void | os_yield (void) |
| Voluntarily yield CPU to scheduler. | |
| uint32_t | task_active_sleep (uint32_t ticks) |
| Sleep for specified ticks (cooperative, via SVC) | |
| const char * | os_get_current_task_name (void) |
| Get name of currently executing task. | |
| void | enter_critical (void) |
| Enter critical section (disable scheduler) | |
| void | exit_critical (void) |
| Exit critical section (re-enable scheduler if outermost) | |
| uint32_t * | kernel_get_stack (uint8_t task_idx) |
| Get stack pointer for task index (internal use) | |
| uint32_t * | kernel_get_data (uint8_t task_idx) |
| Get data pointer for task index (internal use) | |
| void * | kernel_protected_data (uint16_t num_words) |
| Allocate protected data words for current task. | |
| bool | bkpram_write (const void *src, uint32_t offset, uint32_t len) |
| Copy data into battery-backed RAM (RAM_D3) via SVC. | |
| void | __enter_critical (void) |
| Privileged implementation of enter_critical. | |
| void | __exit_critical (void) |
| Privileged implementation of exit_critical. | |
| void | __os_init (void) |
| Privileged implementation of os_init. | |
| void | __os_start (void) |
| Privileged implementation of os_start. | |
| void * | __kernel_protected_data (uint16_t num_words) |
| Privileged implementation of kernel_protected_data. | |
| 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. | |
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. | |
| 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. | |
| volatile uint32_t | os_tick_count |
| System tick counter. | |
| volatile uint8_t | os_running |
| Flag indicating OS is running. | |
| volatile bool | scheduler_enabled |
| Scheduler enable flag. | |
| int8_t | cleanup_task_idx [128] |
| Cleanup task index queue. | |
| int8_t | current_cleanup_task_idx |
| Current cleanup queue write index. | |
ICARUS Kernel Core - State and Initialization.
Core kernel state variables, data structures, and initialization. This is the foundation layer that other kernel modules depend on.
Definition in file kernel.h.
| 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().
| 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().
| 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().
| 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().
| bool bkpram_write | ( | const void * | src, |
| uint32_t | offset, | ||
| uint32_t | len | ||
| ) |
Copy data into battery-backed RAM (RAM_D3) via SVC.
On target this issues an SVC that runs a validated memcpy in privileged mode, allowing unprivileged tasks to persist data into BKPRAM without an MPU region grant. Under HOST_TEST the call is a no-op that returns true.
| [in] | src | Source buffer (caller-owned, any memory domain). |
| [in] | offset | Byte offset into BKPRAM (0 .. BSP_RAM_D3_SIZE-1). |
| [in] | len | Number of bytes to copy (must be > 0). |
| true | Write completed successfully. |
| false | Validation failed (offset+len exceeds BKPRAM, or len==0). |
Copy data into battery-backed RAM (RAM_D3) via SVC.
On target this issues an SVC that runs a validated memcpy in privileged mode, allowing unprivileged tasks to persist data into BKPRAM without an MPU region grant. Under HOST_TEST the call is a no-op that returns true.
| [in] | src | Source buffer (caller-owned, any memory domain). |
| [in] | offset | Byte offset into BKPRAM (0 .. BSP_RAM_D3_SIZE-1). |
| [in] | len | Number of bytes to copy (must be > 0). |
| true | Write completed successfully. |
| false | Validation failed (offset+len exceeds BKPRAM, or len==0). |
Copy data into battery-backed RAM (RAM_D3) via SVC.
Definition at line 1737 of file svc.c.
References SVC_BKPRAM_WRITE.
| void enter_critical | ( | void | ) |
Enter critical section (disable scheduler)
Definition at line 478 of file svc.c.
References __enter_critical(), and SVC_ENTER_CRITICAL.
Referenced by __task_blocking_sleep().
| void exit_critical | ( | void | ) |
Exit critical section (re-enable scheduler if outermost)
Definition at line 489 of file svc.c.
References __exit_critical(), and SVC_EXIT_CRITICAL.
Referenced by __task_blocking_sleep().
| uint32_t * kernel_get_data | ( | uint8_t | task_idx | ) |
Get data pointer for task index (internal use)
| task_idx | Task index |
Get data pointer for task index (internal use)
Definition at line 734 of file svc.c.
References __kernel_get_data(), and SVC_KERNEL_GET_DATA.
| uint32_t * kernel_get_stack | ( | uint8_t | task_idx | ) |
Get stack pointer for task index (internal use)
| task_idx | Task index |
Get stack pointer for task index (internal use)
Definition at line 714 of file svc.c.
References __kernel_get_stack(), and SVC_KERNEL_GET_STACK.
| void * kernel_protected_data | ( | uint16_t | num_words | ) |
Allocate protected data words for current task.
Definition at line 754 of file svc.c.
References __kernel_protected_data(), and SVC_KERNEL_PROTECTED_DATA.
| const char * os_get_current_task_name | ( | void | ) |
Get name of currently executing task.
Definition at line 575 of file svc.c.
References __os_get_current_task_name(), and SVC_OS_GET_CURRENT_TASK_NAME.
Referenced by os_heartbeat_task().
| void os_init | ( | void | ) |
Initialize the ICARUS kernel.
Must be called before any other kernel function. Initializes:
Definition at line 501 of file svc.c.
References __os_init().
Referenced by main().
| void os_start | ( | void | ) |
Start the ICARUS scheduler.
Begins task execution. This function does not return.
Definition at line 502 of file svc.c.
References __os_start().
Referenced by main().
| void os_yield | ( | void | ) |
Voluntarily yield CPU to scheduler.
Definition at line 511 of file svc.c.
References __os_yield(), and SVC_OS_YIELD.
Referenced by os_idle_task().
| uint32_t task_active_sleep | ( | uint32_t | ticks | ) |
Sleep for specified ticks (cooperative, via SVC)
Definition at line 522 of file svc.c.
References __task_active_sleep(), and SVC_TASK_ACTIVE_SLEEP.
Referenced by __pipe_dequeue(), __pipe_enqueue(), __semaphore_consume(), __semaphore_consume_timeout(), __semaphore_feed(), CDC_Write(), and os_heartbeat_task().
|
extern |
Cleanup task index queue.
Definition at line 57 of file kernel.c.
Referenced by __os_exit_task(), __os_init(), and __os_kill_process().
|
extern |
Current cleanup queue write index.
Definition at line 73 of file kernel.c.
Referenced by __os_exit_task(), __os_init(), and __os_kill_process().
|
extern |
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().
|
extern |
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().
|
extern |
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().
|
extern |
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().
|
extern |
Flag indicating OS is running.
Definition at line 70 of file kernel.c.
Referenced by __os_init(), __os_is_running(), and SysTick_Handler().
|
extern |
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().
|
extern |
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().
|
extern |
Scheduler enable flag.
Definition at line 72 of file kernel.c.
Referenced by __enter_critical(), __exit_critical(), __os_init(), and SysTick_Handler().
|
extern |
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().
|
extern |
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().
|
extern |
Configured ticks per time slice.
Definition at line 67 of file kernel.c.
Referenced by __os_init(), and __os_yield().