Kernel function definitions. STMicroelectronics ST200-TOOLSET
Reklāma
Reklāma
OS21 Kernel
kernel_board
Return the name of the board on which the application is running
Definition:
Arguments:
Returns:
Errors:
Context:
Description:
See also:
#include <os21.h> const char* kernel_board(void);
None
Returns a pointer to a string describing the board on which the application is running.
None
Callable from task or system context.
kernel_board()
returns a pointer to a string which gives a readable description of the board on which the application is currently running.
kernel_version
, kernel_cpu
kernel_chip
Definition:
Arguments:
Returns:
Errors:
Context:
Description:
See also:
Return the name of the chip type on which the application is running
#include <os21.h> const char* kernel_chip(void);
None
Returns a pointer to a string describing the chip type on which the application is running.
None.
Callable from task or system context.
kernel_chip()
returns a pointer to a string which gives a readable description of the chip type on which the application is currently running.
kernel_version
, kernel_board, kernel_cpu
7358306 19/226
Kernel OS21
kernel_cpu
Definition:
Arguments:
Returns:
Errors:
Context:
Description:
See also:
Return the name of the CPU type on which the application is running
#include <os21.h> const char* kernel_cpu(void);
None
Returns a pointer to a string describing the CPU type on which the application is running.
None.
Callable from task or system context.
kernel_cpu()
returns a pointer to a string which gives a readable description of the
CPU type on which the application is currently running.
kernel_version
, kernel_board, kernel_chip
kernel_idle
Definition:
Arguments:
Returns:
Errors:
Context:
Description:
See also:
Return the kernel idle time
#include <os21.h> osclock_t kernel_idle(void);
None
This function returns a time value indicating the kernel idle time.
None
Callable from task or system context.
kernel_idle()
passes back a time value indicating the amount of time that the kernel has been idle; that is the time not executing tasks. Idle time occurs when there is no valid task to run, or interrupt pending.
The idle time is measured by recording the accumulation of intervals between the time when the kernel becomes idle and the time when it becomes active again. kernel_time
20/226 7358306
OS21 Kernel
kernel_initialize
Initialize for preemptive scheduling
Definition:
#include <os21.h> int kernel_initialize(
kernel_initialize_t* init);
Arguments:
kernel_initialize_t* init
Address of kernel initialization structure, or
NULL
Returns:
Errors:
Context:
Description:
See also:
Returns OS21_SUCCESS for success, OS21_FAILURE if an error occurs.
Failure is caused by insufficient space to create the necessary data structures.
Callable from task only.
kernel_initialize()
must be called before any tasks are created. It creates and initializes the task and queue data structures. After the structures are created the calling task is initialized as the root task in the system. This function should only be called once. Calling it multiple times has no effect. kernel_initialize() is also responsible for calling bsp_initialize() to initialize the BSP.
The kernel_initialize_t structure passed to this call provides OS21 with its required memory regions. If the system_heap_base is NULL, and the system_heap_size
is 0, OS21 uses the usual ‘C’ runtime heap as its system heap
(managed by C runtime library routines such as malloc(), free()). If a system heap memory region is provided with this structure, OS21 takes over management of it directly.
If the system_stack_base is NULL, and the system_stack_size is 0, OS21 allocates its system stack from the system heap. The size of the system stack in this case is a platform-specific default value.
If NULL is specified for either base pointer, with an associated non-zero size, OS21 allocates the required memory from the ‘C’ runtime heap.
If the init parameter is passed as a NULL pointer, OS21 uses the ‘C’ runtime heap for its system heap, and allocates a default sized system stack.
The definition of a kernel_initialize_t is: typedef struct {
unsigned char* system_stack_base;
size_t system_stack_size;
unsigned char* system_heap_base,
size_t system_heap_size,
} kernel_initialize_t; kernel_start
7358306 21/226
Kernel OS21
kernel_printf
Output a string
Definition:
#include <os21.h> void kernel_printf(const char * fmt, ...);
Arguments:
fmt
The string to output.
Returns:
Errors:
Context:
Description:
None.
None.
Callable from task or system context.
kernel_printf()
outputs a string in a similar manner to the C run-time function printf()
. kernel_printf() can be called from any context and is guaranteed not to block. It is not guaranteed that the message will be output. For example, if some I/O resource is busy at the point at which the call to kernel_printf() is made, the message may not be output.
kernel_printf()
supports some, but not all, of the familiar printf() formats
(%d, %u,%p, %x, %c, %s and %% are supported). Field width specifiers are not supported.
kernel_start
Starts preemptive scheduling regime
Definition:
Arguments:
Returns:
Errors:
Context:
Description:
#include <os21.h> int kernel_start(void);
None
OS21_SUCCESS
or OS21_FAILURE
Failure is caused by insufficient memory, or kernel_initialize() not having been called previously.
Callable from task only.
kernel_start()
must be called before any tasks are created. On return from the function the preemptive scheduler is running. The calling function is installed as the first OS21 task and is running at MAX_USER_PRIORITY.
kernel_start()
is also responsible for calling bsp_start() in the BSP, to allow any BSP specific start actions to be performed.
Note: Before calling this function,
kernel_initialize()
must have been called.
kernel_start()
should only be called once.
22/226 7358306
OS21 Kernel
kernel_time
Definition:
Arguments:
Returns:
Errors:
Context:
Description:
See also:
Return the kernel up-time
#include <os21.h> osclock_t kernel_time(void);
None
A clock value indicating how long has elapsed since the kernel started executing.
None
Callable from task or system context.
kernel_time()
returns the kernel up-time, indicating the elapsed time that the kernel has been running; that is, the time spent executing code or in idle state.
The kernel up-time is the time from when the kernel was successfully started to the time when the kernel_time() call is made. kernel_idle
kernel_timeslice
Turn on or off timeslicing
Definition:
#include <os21.h> void kernel_timeslice(
int on);
Arguments:
int on
Returns:
Errors:
Context:
Description:
See also:
OS21_TRUE
to turn on timeslicing,
OS21_FALSE
to turn off timeslicing
None
None
Callable from task or system context.
kernel_timeslice()
can be called after kernel_start() has been called and turns timeslicing on or off. If an application has distinct priorities for each task, there is no requirement for timeslicing. An application that runs without timeslicing, spends less time executing OS21 kernel code and is therefore more efficient than one that uses timeslicing.
kernel_start
7358306 23/226
Kernel OS21
kernel_version
Return the OS21 version number
Definition:
Arguments:
Returns:
Errors:
Context:
Description:
See also:
#include <os21.h> const char* kernel_version(void);
None
Returns a pointer to the OS21 version string.
None
Callable from task or system context.
kernel_version()
returns a pointer to a string which gives the OS21 version number. This string takes the form:
{major number}.{minor number}.{patch number} [text]
. That is, a major, minor and release number, separated by decimal points, and optionally followed by a space and a printable text string.
kernel_initialize
24/226 7358306
Lejupielādēt
Reklāma