1.2. sys — System

System level functionality and definitions.


Source code: src/kernel/sys.h, src/kernel/sys.c

Test code: tst/kernel/sys/main.c

Test coverage: src/kernel/sys.c


Defines

VERSION_STR
SYS_TICK_MAX

Typedefs

typedef uint64_t sys_tick_t

Functions

static sys_tick_t t2st(struct time_t *time_p)

Convertion from the time struct to system ticks.

static void st2t(sys_tick_t tick, struct time_t *time_p)

Convertion from system ticks to the time struct.

int sys_module_init(void)

Initialize the sys module. This function must be called before calling any other function in this module.

The module will only be initialized once even if this function is called multiple times.

Return
zero(0) or negative error code.

int sys_start(void)

Start the system and convert this context to the main thread.

This function initializes a bunch of enabled features in the simba platform. Many low level features (scheduling, timers, ...) are always enabled, but higher level features are only enabled if configured.

This function must be the first function call in main().

Return
zero(0) or negative error code.

void sys_stop(int error)

Stop the system.

Return
Never returns.

void sys_set_on_fatal_callback(void(*callback)(int error))

Set the on-fatal-callback function to given callback.

The on-fatal-callback is called when a fatal error occurs. The default on-fatal-callback is sys_stop().

Return
void
Parameters
  • callback -

    Callback called when a fatal error occurs.

void sys_set_stdin(void *chan_p)

Set the standard input channel.

Return
void.
Parameters
  • chan_p -

    New standard input channel.

void *sys_get_stdin(void)

Get the standard input channel.

Return
Standard input channel or NULL.

void sys_set_stdout(void *chan_p)

Set the standard output channel.

Return
void.
Parameters
  • chan_p -

    New standard output channel.

void *sys_get_stdout(void)

Get the standard output channel.

Return
Standard output channel or NULL.

void sys_lock(void)

Take the system lock. Turns off interrupts.

Return
void.

void sys_unlock(void)

Release the system lock. Turn on interrupts.

Return
void.

void sys_lock_isr(void)

Take the system lock from isr. In many ports this has no effect.

Return
void.

void sys_unlock_isr(void)

Release the system lock from isr. In many ports this function has no effect.

Return
void.

far_string_t sys_get_info(void)

Get a pointer to the application information buffer.

The buffer contains various information about the application; for example the application name and the build date.

Return
The pointer to the application information buffer.

far_string_t sys_get_config(void)

Get a pointer to the application configuration buffer.

The buffer contains a string of all configuration variables and their values.

Return
The pointer to the application configuration buffer.

float sys_interrupt_cpu_usage_get(void)

Get the current interrupt cpu usage counter.

Return
cpu usage, 0-100.

void sys_interrupt_cpu_usage_reset(void)

Reset the interrupt cpu usage counter.

Variables

struct sys_t sys
struct sys_t

Public Members

sys_tick_t tick
void(* sys_t::on_fatal_callback)(int error)
void *stdin_p
void *stdout_p
uint32_t start
uint32_t time
struct sys_t::@56 sys_t::interrupt