ISIX-RTOS - small operating system for ARM microcontrollers 1.2
|
Data Structures | |
class | fifo_base |
The base class for fifo contains only data. More... | |
class | fifo |
The C++ class wrapper for the queue. More... | |
union | ihandle |
class | virtual_timer |
C++ wrapper for the vtime. More... | |
class | semaphore |
Semaphore C++ class wrapper. More... | |
class | task_base |
C++ wrapper for the task/thread. More... | |
Typedefs | |
typedef struct fifo_struct | fifo_t |
typedef union ihandle | ihandle_t |
typedef struct vtimer_struct | vtimer_t |
typedef void(* | task_func_ptr_t )(void *) |
Pointer to task function. | |
typedef uint8_t | prio_t |
Priority type. | |
typedef struct task_struct | task_t |
typedef struct sem_struct | sem_t |
typedef unsigned int | tick_t |
Define tick type. | |
Enumerations | |
enum | isix_error { ISIX_EOK = 0, ISIX_ENOMEM = -1, ISIX_ETIMEOUT = -2, ISIX_EINVARG = -3, ISIX_EFIFOFULL = -4, ISIX_EBUSY = -5, ISIX_ENOPRIO = -6 } |
Functions | |
void | port_yield (void) |
void | port_start_first_task (void) |
void | port_set_interrupt_mask (void) |
void | port_clear_interrupt_mask (void) |
static void | port_cleanup_task (void *) |
static void | port_idle_cpu (void) |
fifo_t * | isix_fifo_create (int n_elem, int elem_size) |
int | isix_fifo_write (fifo_t *fifo, const void *item, tick_t timeout) |
int | isix_fifo_write_isr (fifo_t *queue, const void *item) |
int | isix_fifo_destroy (fifo_t *fifo) |
int | isix_fifo_count (fifo_t *fifo) |
int | isix_fifo_read (fifo_t *fifo, void *item, tick_t timeout) |
int | isix_fifo_read_isr (fifo_t *queue, void *item) |
vtimer_t * | isix_vtimer_create (void(*func)(void *), void *arg) |
int | isix_vtimer_start (vtimer_t *timer, tick_t timeout) |
static int | isix_vtimer_stop (vtimer_t *timer) |
int | isix_vtimer_destroy (vtimer_t *timer) |
static int | isix_vtimer_start_ms (vtimer_t *timer, tick_t timeout) |
void * | isix_alloc (size_t size) |
void | isix_free (void *mem) |
void | isix_alloc_init (void) |
Initialize global heap. | |
size_t | isix_heap_free (int *fragments) |
int | isix_wait_for_multiple_objects (size_t count, tick_t timeout, const ihandle_t *hwnd) |
static void | isix_yield () |
Yield the current process. | |
void | isix_bug (void) |
Halt system when critical error is found. | |
tick_t | isix_get_jiffies (void) |
void | isix_start_scheduler (void) __attribute__((noreturn)) |
Start the scheduler. | |
void | isix_init (prio_t num_priorities) |
prio_t | isix_get_min_priority (void) |
bool | isix_is_scheduler_active (void) |
sem_t * | isix_sem_create_limited (sem_t *sem, int val, int limit_val) |
static sem_t * | isix_sem_create (sem_t *sem, int val) |
int | isix_sem_wait (sem_t *sem, tick_t timeout) |
int | isix_sem_get_isr (sem_t *sem) |
int | isixp_sem_signal (sem_t *sem, bool isr) |
static int | isix_sem_signal (sem_t *sem) |
static int | isix_sem_signal_isr (sem_t *sem) |
int | isix_sem_setval (sem_t *sem, int val) |
int | isix_sem_getval (sem_t *sem) |
int | isix_sem_destroy (sem_t *sem) |
tick_t | isix_ms2tick (unsigned long ms) |
Convert ms to ticks. | |
int | isix_wait (tick_t timeout) |
static int | isix_wait_ms (unsigned long ms) |
task_t * | isix_task_create (task_func_ptr_t task_func, void *func_param, unsigned long stack_depth, prio_t priority) |
int | isixp_task_change_prio (task_t *task, prio_t new_prio, bool yield) |
Private version of change prio function. | |
static int | isix_task_change_prio (task_t *task, prio_t new_prio) |
int | isix_task_delete (task_t *task) |
task_t * | isix_task_self (void) |
size_t | isix_free_stack_space (const task_t *task) |
Variables | |
static const unsigned | ISIX_PORT_SCHED_MIN_STACK_DEPTH = 112 |
static const unsigned | ISIX_HZ = ISIX_CONFIG_HZ |
static const unsigned | ISIX_TIME_INFINITE = 0 |
static const unsigned | ISIX_SEM_ULIMITED = 0 |
typedef struct fifo_struct isix::fifo_t |
Definition at line 13 of file isix/fifo.h.
typedef union ihandle isix::ihandle_t |
typedef uint8_t isix::prio_t |
Priority type.
Definition at line 20 of file isix/scheduler.h.
typedef struct sem_struct isix::sem_t |
Definition at line 15 of file isix/semaphore.h.
typedef void(* isix::task_func_ptr_t)(void *) |
Pointer to task function.
Definition at line 16 of file isix/scheduler.h.
typedef struct task_struct isix::task_t |
Definition at line 38 of file isix/scheduler.h.
typedef unsigned int isix::tick_t |
typedef struct vtimer_struct isix::vtimer_t |
Definition at line 25 of file isix/irqtimers.h.
enum isix::isix_error |
void* isix::isix_alloc | ( | size_t | size | ) |
Allocate the memory from the global heap
[in] | size | Allocated size |
Definition at line 99 of file memory.c.
References ALIGN_SIZE, header::h, header::h_magic, header::h_next, header::h_size, heap, MAGIC, mem_lock(), mem_unlock(), and NULL.
Referenced by isix_fifo_create(), isix_init(), isix_sem_create_limited(), isix_task_create(), and isix_vtimer_create().
void isix::isix_alloc_init | ( | void | ) |
Initialize global heap.
Definition at line 80 of file memory.c.
References header::h, header::h_next, header::h_size, heap, mem_lock_init(), and NULL.
Referenced by isix_init().
void isix::isix_bug | ( | void | ) |
Halt system when critical error is found.
Definition at line 62 of file scheduler.c.
References isix_printk, isixp_enter_critical(), list_for_each_entry, and task_ready_struct::prio.
Referenced by alloc_task_ready_t(), isix_sem_wait(), isix_wait_for_multiple_objects(), isixp_schedule(), isixp_schedule_time(), and isixp_sem_signal().
int isix::isix_fifo_count | ( | fifo_t * | fifo | ) |
Return number of the elements available in the fifo
[in] | fifo | Pointer to the fifo object |
Referenced by isix::fifo< T >::size().
fifo_t* isix::isix_fifo_create | ( | int | n_elem, |
int | elem_size | ||
) |
Create queue for n elements
[in] | n_elem | Number of available elements in the fifo |
[in] | elem_size | Size of the element |
Definition at line 28 of file fifo.c.
References IHANDLE_T_FIFO, isix_alloc(), isix_free(), isix_printk, isix_sem_create(), and NULL.
int isix::isix_fifo_destroy | ( | fifo_t * | fifo | ) |
int isix::isix_fifo_read | ( | fifo_t * | fifo, |
void * | item, | ||
tick_t | timeout | ||
) |
Read element from the queue if available
[in] | fifo | Pointer to the fifo object |
[out] | item | Pointer to the bufer |
[in] | timeout | Max waiting timeout |
Referenced by isix::fifo< T >::pop().
int isix::isix_fifo_read_isr | ( | fifo_t * | queue, |
void * | item | ||
) |
Read element from the queue if available. ISR version
[in] | queue | Pointer to the fifo object |
[out] | item | Pointer to the bufer |
Referenced by isix::fifo< T >::pop_isr().
int isix::isix_fifo_write | ( | fifo_t * | fifo, |
const void * | item, | ||
tick_t | timeout | ||
) |
Push element in the queue
[in] | fifo | Pointer to queue |
[in] | item | item The element push in the queue |
[in] | timeout | Timeout for selected queue |
Referenced by isix::fifo< T >::push().
int isix::isix_fifo_write_isr | ( | fifo_t * | queue, |
const void * | item | ||
) |
Push element in the queue from a ISR
[in] | queue | Pointer to queue |
[in] | item | The element push in the queue |
Referenced by isix::fifo< T >::push_isr().
void isix::isix_free | ( | void * | mem | ) |
Free alocated earlier memory area param[in] mem Pointer to the allocated memory
Definition at line 142 of file memory.c.
References header::h, header::h_next, header::h_size, heap, LIMIT, mem_lock(), mem_unlock(), and NULL.
Referenced by cleanup_tasks(), isix_fifo_create(), isix_fifo_destroy(), isix_sem_destroy(), isix_task_create(), and isix_vtimer_destroy().
size_t isix::isix_free_stack_space | ( | const task_t * | task | ) |
Check of the available stack space
[in] | task | Task control block |
tick_t isix::isix_get_jiffies | ( | void | ) |
Get current sytem ticks
Definition at line 401 of file scheduler.c.
References jiffies.
Referenced by add_vtimer_to_list(), and isix_wait().
prio_t isix::isix_get_min_priority | ( | void | ) |
Function return the minimal available priority
Definition at line 461 of file scheduler.c.
References number_of_priorities.
Referenced by isix_task_create(), isixp_task_change_prio(), and isixp_wakeup_multiple_waiting_tasks().
size_t isix::isix_heap_free | ( | int * | fragments | ) |
Function display current memory usage
[out] | fragments | - return number of fragments mem |
Definition at line 185 of file memory.c.
References heap, mem_lock(), and mem_unlock().
void isix::isix_init | ( | prio_t | num_priorities | ) |
Initialize base OS structure before call main
[in] | num_priorities | Number of available tasks priorities |
bool isix::isix_is_scheduler_active | ( | void | ) |
Functtion return scheduling state
Definition at line 467 of file scheduler.c.
References isix_scheduler_running.
tick_t isix::isix_ms2tick | ( | unsigned long | ms | ) |
Convert ms to ticks.
Convert ms value to the system tick value
[in] | ms | Time value in the millisecond |
Definition at line 285 of file semaphore.c.
References ISIX_CONFIG_HZ.
Referenced by isix_vtimer_start_ms(), and isix_wait_ms().
static sem_t* isix::isix_sem_create | ( | sem_t * | sem, |
int | val | ||
) | [inline, static] |
Function create the semaphore
[in] | sem | Semaphore object. When it is null semaphore is created on the stack |
[in] | val | Initial value of the semaphore |
Definition at line 39 of file isix/semaphore.h.
References isix_sem_create_limited(), and ISIX_SEM_ULIMITED.
Referenced by isix_fifo_create(), and mem_lock_init().
sem_t* isix::isix_sem_create_limited | ( | sem_t * | sem, |
int | val, | ||
int | limit_val | ||
) |
Function create the semaphore
[in] | sem | Semaphore object. When it is null semaphore is created on the stack |
[in] | val | Initial value of the semaphore |
[in] | limit_val | Maximum value allowed in the sem |
Referenced by isix_sem_create(), and isix::semaphore::semaphore().
int isix::isix_sem_destroy | ( | sem_t * | sem | ) |
Destroy the semaphore
[in] | sem | Semaphore object |
Referenced by isix::semaphore::~semaphore().
int isix::isix_sem_get_isr | ( | sem_t * | sem | ) |
Get semaphore from the ISR context
[in] | sem | Semaphore object |
Referenced by isix::semaphore::get_isr().
int isix::isix_sem_getval | ( | sem_t * | sem | ) |
Get value of the semaphore
[in] | sem | Semaphore object |
Referenced by isix::semaphore::getval().
int isix::isix_sem_setval | ( | sem_t * | sem, |
int | val | ||
) |
Set value of the semaphore
[in] | sem | Semaphore object |
[in] | val | New semaphore value |
Referenced by isix::semaphore::setval().
static int isix::isix_sem_signal | ( | sem_t * | sem | ) | [inline, static] |
Semaphore signal V()
[in] | sem | Semaphore object |
Definition at line 72 of file isix/semaphore.h.
References isixp_sem_signal().
Referenced by isix_fifo_read(), isix_fifo_write(), mem_unlock(), and isix::semaphore::signal().
static int isix::isix_sem_signal_isr | ( | sem_t * | sem | ) | [inline, static] |
Semaphore signal V() from the ISR context
[in] | sem | Semaphore object |
Definition at line 82 of file isix/semaphore.h.
References isixp_sem_signal().
Referenced by isix_fifo_read_isr(), isix_fifo_write_isr(), and isix::semaphore::signal_isr().
int isix::isix_sem_wait | ( | sem_t * | sem, |
tick_t | timeout | ||
) |
Wait on the semaphore P()
[in] | sem | Semaphore object |
[in] | timeout | Max wait time |
Referenced by isix::semaphore::wait().
void isix::isix_start_scheduler | ( | void | ) |
Start the scheduler.
Definition at line 449 of file scheduler.c.
References isix_scheduler_running, jiffies, and port_start_first_task().
static int isix::isix_task_change_prio | ( | task_t * | task, |
prio_t | new_prio | ||
) | [inline, static] |
Change the task/thread priority
[in] | task | Task pointer structure if NULL change the current prio |
[in] | new_prio | New task priority |
Definition at line 40 of file task.h.
References isixp_task_change_prio().
task_t* isix::isix_task_create | ( | task_func_ptr_t | task_func, |
void * | func_param, | ||
unsigned long | stack_depth, | ||
prio_t | priority | ||
) |
Create the task function (System thread)
[in] | task_func | Pointer to the thread function |
[in] | func_param | Function parameter |
[in] | stack_depth | Thread/Task stack depth |
[in] | priority | The task priority |
Referenced by isix::task_base::task_base().
int isix::isix_task_delete | ( | task_t * | task | ) |
Delete the task pointed by the task control object
[in] | task | Task control object |
Referenced by isix::task_base::~task_base().
task_t* isix::isix_task_self | ( | void | ) |
Get current thread handler
Definition at line 208 of file task.c.
References isix_current_task.
vtimer_t* isix::isix_vtimer_create | ( | void(*)(void *) | func, |
void * | arg | ||
) |
Create virtual timer called from interrupt context for light events consume much power cyclic tasks
[in] | func | Function to be called in context - cyclic timeout |
[in] | arg | Frgument passed to the function |
Definition at line 88 of file irqtimers.c.
References isix_alloc(), and NULL.
Referenced by isix::virtual_timer::virtual_timer().
int isix::isix_vtimer_destroy | ( | vtimer_t * | timer | ) |
Destroy the vtimer on the selected period
[in] | timer | Pointer to the timer structure |
Referenced by isix::virtual_timer::~virtual_timer().
int isix::isix_vtimer_start | ( | vtimer_t * | timer, |
tick_t | timeout | ||
) |
Start the vtimer on the selected period
[in] | timer | Pointer to the timer structure |
[in] | timeout | Timeout for the next start |
Referenced by isix_vtimer_start_ms(), isix_vtimer_stop(), isix::virtual_timer::start(), and isix::virtual_timer::start_ms().
static int isix::isix_vtimer_start_ms | ( | vtimer_t * | timer, |
tick_t | timeout | ||
) | [inline, static] |
Start the timer on the selected period
[in] | timer | Pointer to the timer structure |
[in] | timeout | in milisec Timeout for the next start |
Definition at line 63 of file isix/irqtimers.h.
References isix_ms2tick(), and isix_vtimer_start().
static int isix::isix_vtimer_stop | ( | vtimer_t * | timer | ) | [inline, static] |
Stop the vtimer on the selected period
[in] | timer | Pointer to the timer structure |
Definition at line 47 of file isix/irqtimers.h.
References isix_vtimer_start().
Referenced by isix::virtual_timer::stop().
int isix::isix_wait | ( | tick_t | timeout | ) |
Wait thread for selected number of ticks
[in] | timeout | Wait time |
Referenced by isix::task_base::__attribute__(), and isix_wait_ms().
int isix::isix_wait_for_multiple_objects | ( | size_t | count, |
tick_t | timeout, | ||
const ihandle_t * | hwnd | ||
) |
Waits until any of objects in array is signaled (sem is signaled or fifo has data in queue.) Function doesn't wait for no space in fifo, so the fifo can block, when user tried to push data into fifo when space in fifo is not available. After call this function user must call sem_wait, or fifo_get , on object which was signalled.
[in] | count | Number of objects for wait |
[in] | timeout | Timeout in ticks, or |
[in] | hwnd | Array of objects for waiting. |
static int isix::isix_wait_ms | ( | unsigned long | ms | ) | [inline, static] |
Wait thread for selected number of milliseconds
[in] | timeout | Wait time |
Definition at line 129 of file isix/semaphore.h.
References isix_ms2tick(), and isix_wait().
static void isix::isix_yield | ( | ) | [inline, static] |
Yield the current process.
Definition at line 24 of file isix/scheduler.h.
References port_yield().
Referenced by isix_sem_wait(), isix_task_create(), isix_task_delete(), ISIX_TASK_FUNC(), isix_wait_for_multiple_objects(), isixp_sem_signal(), and isixp_task_change_prio().
int isix::isixp_sem_signal | ( | sem_t * | sem, |
bool | isr | ||
) |
Semaphore signal V() private
[in] | sem | Semaphore object |
[in] | isr | True when it is called from the ISR context |
Referenced by isix_sem_signal(), and isix_sem_signal_isr().
int isix::isixp_task_change_prio | ( | task_t * | task, |
prio_t | new_prio, | ||
bool | yield | ||
) |
Private version of change prio function.
Referenced by isix_task_change_prio().
static void isix::port_cleanup_task | ( | void * | ) | [inline, static] |
Definition at line 31 of file arm-cm3/include/isix/port_scheduler.h.
void isix::port_clear_interrupt_mask | ( | void | ) |
Definition at line 148 of file arm-cm3/port_scheduler.c.
References NULL, and sigblock_mask.
Referenced by isixp_exit_critical().
static void isix::port_idle_cpu | ( | void | ) | [inline, static] |
Definition at line 37 of file arm-cm3/include/isix/port_scheduler.h.
Referenced by ISIX_TASK_FUNC(), and isix_wait().
void isix::port_set_interrupt_mask | ( | void | ) |
Definition at line 139 of file arm-cm3/port_scheduler.c.
References ISIX_MAX_SYSCALL_INTERRUPT_PRIORITY, NULL, and sigblock_mask.
Referenced by isixp_enter_critical().
void isix::port_start_first_task | ( | void | ) |
Definition at line 163 of file arm-cm3/port_scheduler.c.
References isix_current_task, isixp_schedule(), NULL, setup_signals(), sigblock_mask, signal_stack, STACK_SIZE, and task_struct::top_stack.
Referenced by isix_start_scheduler().
void isix::port_yield | ( | void | ) |
Definition at line 155 of file arm-cm3/port_scheduler.c.
References isix_current_task, isixp_schedule(), portNVIC_INT_CTRL, portNVIC_PENDSVSET, and task_struct::top_stack.
Referenced by isix_systime_handler(), and isix_yield().
const unsigned isix::ISIX_HZ = ISIX_CONFIG_HZ [static] |
Definition at line 28 of file isix/scheduler.h.
static const unsigned isix::ISIX_PORT_SCHED_MIN_STACK_DEPTH = 112 [static] |
Definition at line 11 of file arm-cm3/include/isix/port_scheduler.h.
Referenced by isix_init(), and isix_task_create().
const unsigned isix::ISIX_SEM_ULIMITED = 0 [static] |
Definition at line 19 of file isix/semaphore.h.
Referenced by isix_sem_create(), isix_sem_setval(), and isixp_sem_signal().
const unsigned isix::ISIX_TIME_INFINITE = 0 [static] |
Definition at line 18 of file isix/semaphore.h.
Referenced by mem_lock().