ISIX-RTOS - small operating system for ARM microcontrollers 1.2
Data Structures | Typedefs | Enumerations | Functions | Variables

isix Namespace Reference

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_tisix_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_tisix_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_tisix_sem_create_limited (sem_t *sem, int val, int limit_val)
static sem_tisix_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_tisix_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_tisix_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 Documentation

typedef struct fifo_struct isix::fifo_t

Definition at line 13 of file isix/fifo.h.

typedef union ihandle isix::ihandle_t

Definition at line 30 of file ihandle.h.

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

Define tick type.

Definition at line 23 of file types.h.

typedef struct vtimer_struct isix::vtimer_t

Definition at line 25 of file isix/irqtimers.h.


Enumeration Type Documentation

Returned error codes definitions

Enumerator:
ISIX_EOK 
ISIX_ENOMEM 

No Error

ISIX_ETIMEOUT 

No memory

ISIX_EINVARG 

Timeout

ISIX_EFIFOFULL 

Invalid argument

ISIX_EBUSY 

Fifo queue is full

ISIX_ENOPRIO 

Resource already used

Definition at line 12 of file error.h.


Function Documentation

void* isix::isix_alloc ( size_t  size)

Allocate the memory from the global heap

Parameters:
[in]sizeAllocated size
Returns:
Pointer to the allocated area otherwise NULL

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  )
int isix::isix_fifo_count ( fifo_t *  fifo)

Return number of the elements available in the fifo

Parameters:
[in]fifoPointer to the fifo object
Returns:
ISIX_EOK if success else return an error

Referenced by isix::fifo< T >::size().

fifo_t* isix::isix_fifo_create ( int  n_elem,
int  elem_size 
)

Create queue for n elements

Parameters:
[in]n_elemNumber of available elements in the fifo
[in]elem_sizeSize of the element
Returns:
Fifo object

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)

Delete queue

Parameters:
[in]fifoPointer to the fifo object

Referenced by isix::fifo< T >::~fifo().

int isix::isix_fifo_read ( fifo_t *  fifo,
void *  item,
tick_t  timeout 
)

Read element from the queue if available

Parameters:
[in]fifoPointer to the fifo object
[out]itemPointer to the bufer
[in]timeoutMax waiting timeout
Returns:
ISIX_EOK if success else return an error

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

Parameters:
[in]queuePointer to the fifo object
[out]itemPointer to the bufer
Returns:
ISIX_EOK if success else return an error

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

Parameters:
[in]fifoPointer to queue
[in]itemitem The element push in the queue
[in]timeoutTimeout for selected queue
Returns:
0 if success else return error

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

Parameters:
[in]queuePointer to queue
[in]itemThe element push in the queue
Returns:
ISIX_EOK if success else return an error

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

Parameters:
[in]taskTask control block
Returns:
Size of the number of bytes used by the task/thread
tick_t isix::isix_get_jiffies ( void  )

Get current sytem ticks

Returns:
Number of system tick from system startup

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

Returns:
Number of 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

Parameters:
[out]fragments- return number of fragments mem
Returns:
free memory space

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

Parameters:
[in]num_prioritiesNumber of available tasks priorities
bool isix::isix_is_scheduler_active ( void  )

Functtion return scheduling state

Returns:
True if scheduler is running

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

Parameters:
[in]msTime value in the millisecond
Returns:
Sys tick time value

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

Parameters:
[in]semSemaphore object. When it is null semaphore is created on the stack
[in]valInitial value of the semaphore
Returns:
Semaphore object or NULL when semaphore can't be created

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

Parameters:
[in]semSemaphore object. When it is null semaphore is created on the stack
[in]valInitial value of the semaphore
[in]limit_valMaximum value allowed in the sem
Returns:
Semaphore object or NULL when semaphore can't be created

Referenced by isix_sem_create(), and isix::semaphore::semaphore().

int isix::isix_sem_destroy ( sem_t *  sem)

Destroy the semaphore

Parameters:
[in]semSemaphore object
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

Referenced by isix::semaphore::~semaphore().

int isix::isix_sem_get_isr ( sem_t *  sem)

Get semaphore from the ISR context

Parameters:
[in]semSemaphore object
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

Referenced by isix::semaphore::get_isr().

int isix::isix_sem_getval ( sem_t *  sem)

Get value of the semaphore

Parameters:
[in]semSemaphore object
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

Referenced by isix::semaphore::getval().

int isix::isix_sem_setval ( sem_t *  sem,
int  val 
)

Set value of the semaphore

Parameters:
[in]semSemaphore object
[in]valNew semaphore value
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

Referenced by isix::semaphore::setval().

static int isix::isix_sem_signal ( sem_t *  sem) [inline, static]

Semaphore signal V()

Parameters:
[in]semSemaphore object
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

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

Parameters:
[in]semSemaphore object
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

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()

Parameters:
[in]semSemaphore object
[in]timeoutMax wait time
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

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

Parameters:
[in]taskTask pointer structure if NULL change the current prio
[in]new_prioNew task priority
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

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)

Parameters:
[in]task_funcPointer to the thread function
[in]func_paramFunction parameter
[in]stack_depthThread/Task stack depth
[in]priorityThe task priority
Returns:
Task control object, or NULL when task can't be created

Referenced by isix::task_base::task_base().

int isix::isix_task_delete ( task_t *  task)

Delete the task pointed by the task control object

Parameters:
[in]taskTask control object
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

Referenced by isix::task_base::~task_base().

task_t* isix::isix_task_self ( void  )

Get current thread handler

Returns:
Get the task control block of the current task/thread

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

Parameters:
[in]funcFunction to be called in context - cyclic timeout
[in]argFrgument passed to the function
Returns:
NULL if timer create was unsucess, else return vtimer pointer

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

Parameters:
[in]timerPointer to the timer structure
Returns:
success if ISIX_EOK , otherwise error

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

Parameters:
[in]timerPointer to the timer structure
[in]timeoutTimeout for the next start
Returns:
success if ISIX_EOK , otherwise error

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

Parameters:
[in]timerPointer to the timer structure
[in]timeoutin milisec Timeout for the next start
Returns:
success if ISIX_EOK , otherwise error

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

Parameters:
[in]timerPointer to the timer structure
Returns:
success if ISIX_EOK , otherwise error

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

Parameters:
[in]timeoutWait time
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

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.

Parameters:
[in]countNumber of objects for wait
[in]timeoutTimeout in ticks, or
See also:
ISIX_TIME_INFINITE for infinite waiting
Parameters:
[in]hwndArray of objects for waiting.
Returns:
Function return error code if value is <0 for example
See also:
ISIX_ETIMEOUT when timeout reache and any objects is not signalled. On positive value, return an object index which was signaled. For example if 1 is returned it means that first object from hwnd, array was signalled.
static int isix::isix_wait_ms ( unsigned long  ms) [inline, static]

Wait thread for selected number of milliseconds

Parameters:
[in]timeoutWait time
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

Definition at line 129 of file isix/semaphore.h.

References isix_ms2tick(), and isix_wait().

static void isix::isix_yield ( ) [inline, static]
int isix::isixp_sem_signal ( sem_t *  sem,
bool  isr 
)

Semaphore signal V() private

Parameters:
[in]semSemaphore object
[in]isrTrue when it is called from the ISR context
Returns:
ISIX_EOK if the operation is completed successfully otherwise return an error code

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  )
void isix::port_yield ( void  )

Variable Documentation

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().

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines