ChibiOS 21.11.4
OS Types and Structures

Detailed Description

Collaboration diagram for OS Types and Structures:

Kernel types

typedef port_rtcnt_t rtcnt_t
typedef port_rttime_t rttime_t
typedef port_syssts_t syssts_t
typedef port_stkalign_t stkalign_t
typedef uint8_t tmode_t
typedef uint8_t tstate_t
typedef uint8_t trefs_t
typedef uint8_t tslices_t
typedef uint32_t tprio_t
typedef int32_t msg_t
typedef int32_t eventid_t
typedef uint32_t eventmask_t
typedef uint32_t eventflags_t
typedef int32_t cnt_t
typedef uint32_t ucnt_t

Data Structures

struct  ch_virtual_timer
 Structure representing a Virtual Timer. More...
struct  ch_virtual_timers_list
 Type of virtual timers list header. More...
struct  ch_registry
 Type of a registry structure. More...
struct  ch_threads_queue
 Type of a threads queue. More...
struct  ch_thread
 Structure representing a thread. More...
struct  ch_ready_list
 Type of a ready list header. More...
struct  ch_os_instance_config
 Type of an system instance configuration. More...
struct  ch_os_instance
 System instance data structure. More...
struct  ch_system
 Type of system data structure. More...

Macros

#define __CH_STRINGIFY(a)
 Utility to make the parameter a quoted string.
#define __CH_OFFSETOF(st, m)
 Structure field offset utility.
#define __CH_USED(x)
 Marks an expression result as used.
#define likely(x)
 Marks a boolean expression as likely true.
#define unlikely(x)
 Marks a boolean expression as likely false.
#define threadref(p)
 Safe cast of a queue pointer to a thread pointer.

Typedefs

typedef unsigned core_id_t
 Type of a core identifier.
typedef struct ch_thread thread_t
 Type of a thread structure.
typedef struct ch_os_instance os_instance_t
 Type of an OS instance structure.
typedef struct ch_virtual_timer virtual_timer_t
 Type of a Virtual Timer.
typedef void(* vtfunc_t) (virtual_timer_t *vtp, void *p)
 Type of a Virtual Timer callback function.
typedef struct ch_virtual_timers_list virtual_timers_list_t
 Type of virtual timers list header.
typedef struct ch_registry registry_t
 Type of a registry structure.
typedef thread_tthread_reference_t
 Type of a thread reference.
typedef struct ch_threads_queue threads_queue_t
 Type of a threads queue.
typedef struct ch_ready_list ready_list_t
 Type of a ready list header.
typedef struct ch_os_instance_config os_instance_config_t
 Type of an system instance configuration.
typedef struct ch_system ch_system_t
 Type of system data structure.

Enumerations

enum  system_state_t { ch_sys_uninit = 0 , ch_sys_initializing = 1 , ch_sys_running = 2 , ch_sys_halted = 3 }
 Global state of the operating system. More...

Functions

void chSysHalt (const char *reason)
 Halts the system.

Macro Definition Documentation

◆ __CH_STRINGIFY

#define __CH_STRINGIFY ( a)
Value:
#a

Utility to make the parameter a quoted string.

Parameters
[in]aliteral to be string-ified

Definition at line 149 of file chearly.h.

◆ __CH_OFFSETOF

#define __CH_OFFSETOF ( st,
m )
Value:
/*lint -save -e9005 -e9033 -e413 [11.8, 10.8, 1.3] Normal pointers
arithmetic, it is safe.*/ \
((size_t)((char *)&((st *)0)->m - (char *)0)) \
/*lint -restore*/

Structure field offset utility.

Parameters
[in]ststructured type name
[in]mfield name in the structured type
Returns
The offset of the field in the structured type.

Definition at line 158 of file chearly.h.

Referenced by chRegFirstThread(), and chRegNextThread().

◆ __CH_USED

#define __CH_USED ( x)
Value:
(void)(x)

Marks an expression result as used.

Parameters
[in]xa valid expression

Definition at line 168 of file chearly.h.

◆ likely

#define likely ( x)
Value:
PORT_LIKELY(x)

Marks a boolean expression as likely true.

Note
No namespace prefix for this macro because it is commonly defined by operating systems.
Parameters
[in]xa valid expression

Definition at line 178 of file chearly.h.

Referenced by __thd_stackfill(), ch_dlist_insert(), chSchDoYieldS(), chSchPreemption(), chSchRescheduleS(), chThdSleepUntil(), chThdSleepUntilWindowed(), chThdWait(), vt_insert_first(), and vt_set_alarm().

◆ unlikely

#define unlikely ( x)
Value:
PORT_UNLIKELY(x)

Marks a boolean expression as likely false.

Note
No namespace prefix for this macro because it is commonly defined by operating systems.
Parameters
[in]xa valid expression

Definition at line 191 of file chearly.h.

Referenced by __dbg_check_disable(), __dbg_check_enable(), __dbg_check_enter_isr(), __dbg_check_leave_isr(), __dbg_check_lock(), __dbg_check_lock_from_isr(), __dbg_check_suspend(), __dbg_check_unlock(), __dbg_check_unlock_from_isr(), ch_pqueue_insert_ahead(), ch_pqueue_insert_behind(), chDbgCheckClassI(), chDbgCheckClassS(), chSchWakeupS(), chSemWaitTimeoutS(), chThdEnqueueTimeoutS(), chThdExitS(), chThdSuspendTimeoutS(), and chVTDoTickI().

◆ threadref

#define threadref ( p)
Value:
((thread_t *)(void *)(p))
struct ch_thread thread_t
Type of a thread structure.
Definition chearly.h:133

Safe cast of a queue pointer to a thread pointer.

Note
Casting to a thread pointer should always be performed using this macro. Casting to threads pointer is allowed by design and this is the single check point for this operation.
Parameters
[in]ppointer to a queue/list structure
Returns
The pointer to the thread containing the queue/list element.

Definition at line 206 of file chearly.h.

Referenced by __sch_ready_ahead(), __sch_ready_behind(), __sch_reschedule_ahead(), __sch_reschedule_behind(), __sch_wakeup(), ch_sch_prio_insert(), chCondBroadcastI(), chCondSignal(), chCondSignalI(), chMsgPollS(), chMsgWaitS(), chMsgWaitTimeoutS(), chMtxLockS(), chMtxUnlock(), chMtxUnlockAllS(), chMtxUnlockS(), chRegFirstThread(), chRegNextThread(), chSchDoPreemption(), chSchGoSleepS(), chSchSelectFirst(), chSemAddCounterI(), chSemResetWithMessageI(), chSemSignal(), chSemSignalI(), chSemSignalWait(), chSysGetIdleThreadX(), chThdCreateStatic(), chThdCreateSuspendedI(), chThdDoDequeueNextI(), and chThdExitS().

Typedef Documentation

◆ rtcnt_t

Realtime counter.

Definition at line 77 of file chearly.h.

◆ rttime_t

Realtime accumulator.

Definition at line 78 of file chearly.h.

◆ syssts_t

System status word.

Definition at line 79 of file chearly.h.

◆ stkalign_t

Stack alignment type.

Definition at line 80 of file chearly.h.

◆ tmode_t

typedef uint8_t tmode_t

Thread flags.

Definition at line 83 of file chearly.h.

◆ tstate_t

typedef uint8_t tstate_t

Thread state.

Definition at line 84 of file chearly.h.

◆ trefs_t

typedef uint8_t trefs_t

Thread references counter.

Definition at line 85 of file chearly.h.

◆ tslices_t

typedef uint8_t tslices_t

Thread time slices counter.

Definition at line 86 of file chearly.h.

◆ tprio_t

typedef uint32_t tprio_t

Thread priority.

Definition at line 87 of file chearly.h.

◆ msg_t

typedef int32_t msg_t

Inter-thread message.

Definition at line 88 of file chearly.h.

◆ eventid_t

typedef int32_t eventid_t

Numeric event identifier.

Definition at line 89 of file chearly.h.

◆ eventmask_t

typedef uint32_t eventmask_t

Mask of event identifiers.

Definition at line 90 of file chearly.h.

◆ eventflags_t

typedef uint32_t eventflags_t

Mask of event flags.

Definition at line 91 of file chearly.h.

◆ cnt_t

typedef int32_t cnt_t

Generic signed counter.

Definition at line 92 of file chearly.h.

◆ ucnt_t

typedef uint32_t ucnt_t

Generic unsigned counter.

Definition at line 93 of file chearly.h.

◆ core_id_t

typedef unsigned core_id_t

Type of a core identifier.

Note
Core identifiers have ranges from 0 to PORT_CORES_NUMBER - 1.

Definition at line 128 of file chearly.h.

◆ thread_t

typedef struct ch_thread thread_t

Type of a thread structure.

Definition at line 133 of file chearly.h.

◆ os_instance_t

typedef struct ch_os_instance os_instance_t

Type of an OS instance structure.

Definition at line 138 of file chearly.h.

◆ virtual_timer_t

Type of a Virtual Timer.

Definition at line 60 of file chobjects.h.

◆ vtfunc_t

typedef void(* vtfunc_t) (virtual_timer_t *vtp, void *p)

Type of a Virtual Timer callback function.

Parameters
[in]vtppointer to the virtual_timer_t calling this callback
[in]poptional argument to the callback
Returns
The interval to be reloaded into the timer or zero.
Return values
0if the timer must not be reloaded.

Definition at line 70 of file chobjects.h.

◆ virtual_timers_list_t

Type of virtual timers list header.

Note
The timers list is implemented as a double link bidirectional list in order to make the unlink time constant, the reset of a virtual timer is often used in the code.

◆ registry_t

typedef struct ch_registry registry_t

Type of a registry structure.

◆ thread_reference_t

Type of a thread reference.

Definition at line 138 of file chobjects.h.

◆ threads_queue_t

typedef struct ch_threads_queue threads_queue_t

Type of a threads queue.

◆ ready_list_t

typedef struct ch_ready_list ready_list_t

Type of a ready list header.

◆ os_instance_config_t

Type of an system instance configuration.

◆ ch_system_t

typedef struct ch_system ch_system_t

Type of system data structure.

Enumeration Type Documentation

◆ system_state_t

Global state of the operating system.

Enumerator
ch_sys_uninit 
ch_sys_initializing 
ch_sys_running 
ch_sys_halted 

Definition at line 50 of file chobjects.h.

Function Documentation

◆ chSysHalt()

void chSysHalt ( const char * reason)

Halts the system.

This function is invoked by the operating system when an unrecoverable error is detected, for example because a programming error in the application code that triggers an assertion while in debug mode.

Note
Can be invoked from any system state.
Parameters
[in]reasonpointer to an error string
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 209 of file chsys.c.

References __trace_halt, CH_CFG_SYSTEM_HALT_HOOK, ch_sys_halted, currcore, nil, port_disable(), and ch_system::state.

Referenced by __dbg_check_disable(), __dbg_check_enable(), __dbg_check_enter_isr(), __dbg_check_leave_isr(), __dbg_check_lock(), __dbg_check_lock_from_isr(), __dbg_check_suspend(), __dbg_check_unlock(), __dbg_check_unlock_from_isr(), chDbgCheckClassI(), and chDbgCheckClassS().

Here is the call graph for this function: