ChibiOS 21.11.4
Base API

Detailed Description

Collaboration diagram for Base API:

Kernel types

typedef port_rtcnt_t rtcnt_t
typedef port_syssts_t syssts_t
typedef port_stkalign_t stkalign_t
typedef uint8_t tstate_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

ChibiOS/NIL version identification

#define CH_KERNEL_VERSION   "4.1.3"
 Kernel version string.
#define CH_KERNEL_MAJOR   4
 Kernel version major number.
#define CH_KERNEL_MINOR   1
 Kernel version minor number.
#define CH_KERNEL_PATCH   3
 Kernel version patch number.

Constants for configuration options

#define FALSE   0
 Generic 'false' preprocessor boolean constant.
#define TRUE   1
 Generic 'true' preprocessor boolean constant.

Wakeup messages

#define MSG_OK   (msg_t)0
 OK wakeup message.
#define MSG_TIMEOUT   (msg_t)-1
 Wake-up caused by a timeout condition.
#define MSG_RESET   (msg_t)-2
 Wake-up caused by a reset condition.

Special time constants

#define TIME_IMMEDIATE   ((sysinterval_t)-1)
 Zero time specification for some functions with a timeout specification.
#define TIME_INFINITE   ((sysinterval_t)0)
 Infinite time specification for all functions with a timeout specification.
#define TIME_MAX_INTERVAL   ((sysinterval_t)-2)
 Maximum interval constant usable as timeout.
#define TIME_MAX_SYSTIME   ((systime_t)-1)
 Maximum system of system time before it wraps.

Thread state related macros

#define NIL_STATE_WTSTART   (tstate_t)0
 Thread not yet started or terminated.
#define NIL_STATE_READY   (tstate_t)1
 Thread ready or executing.
#define NIL_STATE_SLEEPING   (tstate_t)2
 Thread sleeping.
#define NIL_STATE_SUSPENDED   (tstate_t)3
 Thread suspended.
#define NIL_STATE_WTEXIT   (tstate_t)4
 Waiting a thread.
#define NIL_STATE_WTQUEUE   (tstate_t)5
 On queue or semaph.
#define NIL_STATE_WTOREVT   (tstate_t)6
 Waiting for events.
#define NIL_STATE_WTANDEVT   (tstate_t)7
 Waiting for events.
#define NIL_STATE_SNDMSGQ   (tstate_t)8
 Sending a message, in queue.
#define NIL_STATE_WTMSG   (tstate_t)1
 Waiting for a message.
#define NIL_STATE_FINAL   (tstate_t)1
 Thread terminated.
#define NIL_THD_IS_WTSTART(tp)
#define NIL_THD_IS_READY(tp)
#define NIL_THD_IS_SLEEPING(tp)
#define NIL_THD_IS_SUSPENDED(tp)
#define NIL_THD_IS_WTEXIT(tp)
#define NIL_THD_IS_WTQUEUE(tp)
#define NIL_THD_IS_WTOREVT(tp)
#define NIL_THD_IS_WTANDEVT(tp)
#define NIL_THD_IS_SNDMSGQ(tp)
#define NIL_THD_IS_WTMSG(tp)
#define NIL_THD_IS_FINAL(tp)
#define CH_STATE_NAMES

RT options not existing in NIL

#define CH_CFG_USE_REGISTRY   FALSE

Threads tables definition macros

#define THD_TABLE_BEGIN    const thread_descriptor_t nil_thd_configs[] = {
 Start of user threads table.
#define THD_TABLE_THREAD(_prio, _name, _wap, _funcp, _arg)
 Entry of user threads table.
#define THD_TABLE_END
 End of user threads table.

Memory alignment support macros

#define MEM_ALIGN_MASK(a)
 Alignment mask constant.
#define MEM_ALIGN_PREV(p, a)
 Aligns to the previous aligned memory address.
#define MEM_ALIGN_NEXT(p, a)
 Aligns to the new aligned memory address.
#define MEM_IS_ALIGNED(p, a)
 Returns whatever a pointer or memory size is aligned.
#define MEM_IS_VALID_ALIGNMENT(a)
 Returns whatever a constant is a valid alignment.

Working Areas

#define THD_WORKING_AREA_SIZE(n)
 Calculates the total Working Area size.
#define THD_WORKING_AREA(s, n)
 Static working area allocation.

Threads abstraction macros

#define THD_FUNCTION(tname, arg)
 Thread declaration macro.

ISRs abstraction macros

#define CH_IRQ_IS_VALID_PRIORITY(prio)
 Priority level validation macro.
#define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio)
 Priority level validation macro.
#define CH_IRQ_PROLOGUE()
 IRQ handler enter code.
#define CH_IRQ_EPILOGUE()
 IRQ handler exit code.
#define CH_IRQ_HANDLER(id)
 Standard normal IRQ handler declaration.

Fast ISRs abstraction macros

#define CH_FAST_IRQ_HANDLER(id)
 Standard fast IRQ handler declaration.

Time conversion utilities

#define TIME_S2I(secs)
 Seconds to time interval.
#define TIME_MS2I(msecs)
 Milliseconds to time interval.
#define TIME_US2I(usecs)
 Microseconds to time interval.
#define TIME_I2S(interval)
 Time interval to seconds.
#define TIME_I2MS(interval)
 Time interval to milliseconds.
#define TIME_I2US(interval)
 Time interval to microseconds.

Threads queues

#define __THREADS_QUEUE_DATA(name)
 Data part of a static threads queue object initializer.
#define THREADS_QUEUE_DECL(name)
 Static threads queue object initializer.

Macro Functions

#define chSysGetRealtimeCounterX()
 Returns the current value of the system real time counter.
#define chSysDisable()
 Raises the system interrupt priority mask to the maximum level.
#define chSysSuspend()
 Raises the system interrupt priority mask to system level.
#define chSysEnable()
 Lowers the system interrupt priority mask to user level.
#define chSysLock()
 Enters the kernel lock state.
#define chSysUnlock()
 Leaves the kernel lock state.
#define chSysLockFromISR()
 Enters the kernel lock state from within an interrupt handler.
#define chSysUnlockFromISR()
 Leaves the kernel lock state from within an interrupt handler.
#define chSchGoSleepS(newstate)
 Puts the current thread to sleep into the specified state.
#define chSchWakeupS(ntp, msg)
 Wakes up a thread.
#define chSchIsRescRequiredI()
 Evaluates if a reschedule is required.
#define chThdGetSelfX()
 Returns a pointer to the current thread_t.
#define chThdGetPriorityX(void)
 Returns the current thread priority.
#define chThdResumeS(trp, msg)
 Wakes up a thread waiting on a thread reference object.
#define chThdSleepSeconds(secs)
 Delays the invoking thread for the specified number of seconds.
#define chThdSleepMilliseconds(msecs)
 Delays the invoking thread for the specified number of milliseconds.
#define chThdSleepMicroseconds(usecs)
 Delays the invoking thread for the specified number of microseconds.
#define chThdSleepS(timeout)
 Suspends the invoking thread for the specified time.
#define chThdSleepUntilS(abstime)
 Suspends the invoking thread until the system time arrives to the specified value.
#define chThdQueueObjectInit(tqp)
 Initializes a threads queue object.
#define chThdQueueIsEmptyI(tqp)
 Evaluates to true if the specified queue is empty.
#define chVTGetSystemTimeX()
 Current system time.
#define chVTTimeElapsedSinceX(start)
 Returns the elapsed time since the specified start time.
#define chVTIsSystemTimeWithinX(start, end)
 Checks if the current system time is within the specified time window.
#define chTimeAddX(systime, interval)
 Adds an interval to a system time returning a system time.
#define chTimeDiffX(start, end)
 Subtracts two system times returning an interval.
#define chDbgCheck(c)
 Function parameters check.
#define chDbgAssert(c, r)
 Condition assertion.

Data Structures

struct  nil_threads_queue
 Structure representing a queue of threads. More...
struct  nil_thread_descriptor
 Structure representing a thread descriptor. More...
struct  nil_thread
 Structure representing a thread. More...
struct  nil_os_instance
 System data structure. More...

Macros

#define __dbg_check_disable()
#define __dbg_check_suspend()
#define __dbg_check_enable()
#define __dbg_check_lock()
#define __dbg_check_unlock()
#define __dbg_check_lock_from_isr()
#define __dbg_check_unlock_from_isr()
#define __dbg_check_enter_isr()
#define __dbg_check_leave_isr()
#define chDbgCheckClassI()
#define chDbgCheckClassS()
#define __CHIBIOS_NIL__
 ChibiOS/NIL identification macro.
#define CH_KERNEL_STABLE   1
 Stable release flag.
#define CH_CFG_ST_TIMEDELTA   0
#define CH_CFG_USE_MESSAGES   FALSE
#define NIL_DBG_ENABLED   TRUE
#define THD_IDLE_BASE   (&__main_thread_stack_base__)
#define THD_IDLE_END   (&__main_thread_stack_end__)
#define CH_PORT_SUPPORTS_RECURSIVE_LOCKS   FALSE
#define __dbg_enter_lock()
#define __dbg_enter_lock()
#define __dbg_leave_lock()
#define __dbg_leave_lock()
#define __CH_STRINGIFY(a)
 Utility to make the parameter a quoted string.
#define THD_WORKING_AREA_END(wa)
 Returns the top address of a working area.

Typedefs

typedef uint32_t systime_t
 Type of system time.
typedef uint32_t sysinterval_t
 Type of time interval.
typedef uint64_t time_conv_t
 Type of time conversion variable.
typedef struct nil_os_instance os_instance_t
 Type of a structure representing the system.
typedef void(* tfunc_t) (void *p)
 Thread function.
typedef struct nil_thread_descriptor thread_descriptor_t
 Type of a thread descriptor.
typedef struct nil_thread thread_t
 Type of a structure representing a thread.
typedef thread_tthread_reference_t
 Type of a thread reference.
typedef struct nil_threads_queue threads_queue_t
 Type of a queue of threads.
typedef threads_queue_t semaphore_t
 Type of a structure representing a semaphore.

Functions

thread_tnil_find_thread (tstate_t state, void *p)
 Retrieves the highest priority thread in the specified state and associated to the specified object.
cnt_t nil_ready_all (void *p, cnt_t cnt, msg_t msg)
 Puts in ready state all thread matching the specified status and associated object.
void __dbg_check_disable (void)
 Guard code for chSysDisable().
void __dbg_check_suspend (void)
 Guard code for chSysSuspend().
void __dbg_check_enable (void)
 Guard code for chSysEnable().
void __dbg_check_lock (void)
 Guard code for chSysLock().
void __dbg_check_unlock (void)
 Guard code for chSysUnlock().
void __dbg_check_lock_from_isr (void)
 Guard code for chSysLockFromIsr().
void __dbg_check_unlock_from_isr (void)
 Guard code for chSysUnlockFromIsr().
void __dbg_check_enter_isr (void)
 Guard code for CH_IRQ_PROLOGUE().
void __dbg_check_leave_isr (void)
 Guard code for CH_IRQ_EPILOGUE().
void chDbgCheckClassI (void)
 I-class functions context check.
void chDbgCheckClassS (void)
 S-class functions context check.
void chSysInit (void)
 Initializes the kernel.
void chSysHalt (const char *reason)
 Halts the system.
void chSysTimerHandlerI (void)
 Time management handler.
void chSysUnconditionalLock (void)
 Unconditionally enters the kernel lock state.
void chSysUnconditionalUnlock (void)
 Unconditionally leaves the kernel lock state.
syssts_t chSysGetStatusAndLockX (void)
 Returns the execution status and enters a critical zone.
void chSysRestoreStatusX (syssts_t sts)
 Restores the specified execution status and leaves a critical zone.
bool chSysIsCounterWithinX (rtcnt_t cnt, rtcnt_t start, rtcnt_t end)
 Realtime window test.
void chSysPolledDelayX (rtcnt_t cycles)
 Polled delay.
thread_tchSchReadyI (thread_t *tp, msg_t msg)
 Makes the specified thread ready for execution.
bool chSchIsPreemptionRequired (void)
 Evaluates if preemption is required.
void chSchDoPreemption (void)
 Switches to the first thread on the runnable queue.
void chSchRescheduleS (void)
 Reschedules if needed.
msg_t chSchGoSleepTimeoutS (tstate_t newstate, sysinterval_t timeout)
 Puts the current thread to sleep into the specified state with timeout specification.
bool chTimeIsInRangeX (systime_t time, systime_t start, systime_t end)
 Checks if the specified time is within the specified time range.
thread_tchThdCreateI (const thread_descriptor_t *tdp)
 Creates a new thread into a static memory area.
thread_tchThdCreate (const thread_descriptor_t *tdp)
 Creates a new thread into a static memory area.
void chThdExit (msg_t msg)
 Terminates the current thread.
msg_t chThdWait (thread_t *tp)
 Blocks the execution of the invoking thread until the specified thread terminates then the exit code is returned.
msg_t chThdSuspendTimeoutS (thread_reference_t *trp, sysinterval_t timeout)
 Sends the current thread sleeping and sets a reference variable.
void chThdResumeI (thread_reference_t *trp, msg_t msg)
 Wakes up a thread waiting on a thread reference object.
void chThdResume (thread_reference_t *trp, msg_t msg)
 Wakes up a thread waiting on a thread reference object.
void chThdSleep (sysinterval_t timeout)
 Suspends the invoking thread for the specified time.
void chThdSleepUntil (systime_t abstime)
 Suspends the invoking thread until the system time arrives to the specified value.
msg_t chThdEnqueueTimeoutS (threads_queue_t *tqp, sysinterval_t timeout)
 Enqueues the caller thread on a threads queue object.
void chThdDoDequeueNextI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up one thread from the threads queue object.
void chThdDequeueNextI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up one thread from the threads queue object, if any.
void chThdDequeueAllI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up all threads from the threads queue object.

Variables

os_instance_t nil
 System data structures.

Macro Definition Documentation

◆ __dbg_check_disable

void __dbg_check_disable ( )

Definition at line 1370 of file nil/include/ch.h.

◆ __dbg_check_suspend

void __dbg_check_suspend ( )

Definition at line 1371 of file nil/include/ch.h.

◆ __dbg_check_enable

void __dbg_check_enable ( )

Definition at line 1372 of file nil/include/ch.h.

◆ __dbg_check_lock

void __dbg_check_lock ( )

Definition at line 1373 of file nil/include/ch.h.

◆ __dbg_check_unlock

void __dbg_check_unlock ( )

Definition at line 1374 of file nil/include/ch.h.

◆ __dbg_check_lock_from_isr

void __dbg_check_lock_from_isr ( )

Definition at line 1375 of file nil/include/ch.h.

◆ __dbg_check_unlock_from_isr

void __dbg_check_unlock_from_isr ( )

Definition at line 1376 of file nil/include/ch.h.

◆ __dbg_check_enter_isr

void __dbg_check_enter_isr ( )

Definition at line 1377 of file nil/include/ch.h.

◆ __dbg_check_leave_isr

void __dbg_check_leave_isr ( )

Definition at line 1378 of file nil/include/ch.h.

◆ chDbgCheckClassI

void chDbgCheckClassI ( )

Definition at line 1379 of file nil/include/ch.h.

◆ chDbgCheckClassS

void chDbgCheckClassS ( )

Definition at line 1380 of file nil/include/ch.h.

◆ __CHIBIOS_NIL__

#define __CHIBIOS_NIL__

ChibiOS/NIL identification macro.

Definition at line 42 of file nil/include/ch.h.

◆ CH_KERNEL_STABLE

#define CH_KERNEL_STABLE   1

Stable release flag.

Definition at line 47 of file nil/include/ch.h.

◆ CH_KERNEL_VERSION

#define CH_KERNEL_VERSION   "4.1.3"

Kernel version string.

Definition at line 56 of file nil/include/ch.h.

◆ CH_KERNEL_MAJOR

#define CH_KERNEL_MAJOR   4

Kernel version major number.

Definition at line 61 of file nil/include/ch.h.

◆ CH_KERNEL_MINOR

#define CH_KERNEL_MINOR   1

Kernel version minor number.

Definition at line 66 of file nil/include/ch.h.

◆ CH_KERNEL_PATCH

#define CH_KERNEL_PATCH   3

Kernel version patch number.

Definition at line 71 of file nil/include/ch.h.

◆ FALSE

#define FALSE   0

Generic 'false' preprocessor boolean constant.

Note
It is meant to be used in configuration files as switch.

Definition at line 83 of file nil/include/ch.h.

◆ TRUE

#define TRUE   1

Generic 'true' preprocessor boolean constant.

Note
It is meant to be used in configuration files as switch.

Definition at line 91 of file nil/include/ch.h.

◆ MSG_OK

#define MSG_OK   (msg_t)0

OK wakeup message.

Definition at line 99 of file nil/include/ch.h.

◆ MSG_TIMEOUT

#define MSG_TIMEOUT   (msg_t)-1

Wake-up caused by a timeout condition.

Definition at line 100 of file nil/include/ch.h.

◆ MSG_RESET

#define MSG_RESET   (msg_t)-2

Wake-up caused by a reset condition.

Definition at line 102 of file nil/include/ch.h.

◆ TIME_IMMEDIATE

#define TIME_IMMEDIATE   ((sysinterval_t)-1)

Zero time specification for some functions with a timeout specification.

Note
Not all functions accept TIME_IMMEDIATE as timeout parameter, see the specific function documentation.

Definition at line 116 of file nil/include/ch.h.

◆ TIME_INFINITE

#define TIME_INFINITE   ((sysinterval_t)0)

Infinite time specification for all functions with a timeout specification.

Definition at line 122 of file nil/include/ch.h.

◆ TIME_MAX_INTERVAL

#define TIME_MAX_INTERVAL   ((sysinterval_t)-2)

Maximum interval constant usable as timeout.

Definition at line 127 of file nil/include/ch.h.

◆ TIME_MAX_SYSTIME

#define TIME_MAX_SYSTIME   ((systime_t)-1)

Maximum system of system time before it wraps.

Definition at line 132 of file nil/include/ch.h.

◆ NIL_STATE_WTSTART

#define NIL_STATE_WTSTART   (tstate_t)0

Thread not yet started or terminated.

Definition at line 139 of file nil/include/ch.h.

◆ NIL_STATE_READY

#define NIL_STATE_READY   (tstate_t)1

Thread ready or executing.

Definition at line 141 of file nil/include/ch.h.

Referenced by chSchReadyI(), and chSysInit().

◆ NIL_STATE_SLEEPING

#define NIL_STATE_SLEEPING   (tstate_t)2

Thread sleeping.

Definition at line 143 of file nil/include/ch.h.

◆ NIL_STATE_SUSPENDED

#define NIL_STATE_SUSPENDED   (tstate_t)3

Thread suspended.

Definition at line 144 of file nil/include/ch.h.

Referenced by chThdSuspendTimeoutS().

◆ NIL_STATE_WTEXIT

#define NIL_STATE_WTEXIT   (tstate_t)4

Waiting a thread.

Definition at line 145 of file nil/include/ch.h.

Referenced by chThdExit(), and chThdWait().

◆ NIL_STATE_WTQUEUE

#define NIL_STATE_WTQUEUE   (tstate_t)5

On queue or semaph.

Definition at line 146 of file nil/include/ch.h.

Referenced by chSemSignalI(), chSemWaitTimeoutS(), chThdDoDequeueNextI(), chThdEnqueueTimeoutS(), and nil_ready_all().

◆ NIL_STATE_WTOREVT

#define NIL_STATE_WTOREVT   (tstate_t)6

Waiting for events.

Definition at line 147 of file nil/include/ch.h.

Referenced by chEvtWaitAnyTimeout(), and chEvtWaitOneTimeout().

◆ NIL_STATE_WTANDEVT

#define NIL_STATE_WTANDEVT   (tstate_t)7

Waiting for events.

Definition at line 148 of file nil/include/ch.h.

Referenced by chEvtWaitAllTimeout().

◆ NIL_STATE_SNDMSGQ

#define NIL_STATE_SNDMSGQ   (tstate_t)8

Sending a message, in queue.

Definition at line 149 of file nil/include/ch.h.

Referenced by chMsgRelease(), chMsgSend(), and chMsgWaitTimeoutS().

◆ NIL_STATE_WTMSG

#define NIL_STATE_WTMSG   (tstate_t)1

Waiting for a message.

Definition at line 151 of file nil/include/ch.h.

Referenced by chMsgWaitTimeoutS().

◆ NIL_STATE_FINAL

#define NIL_STATE_FINAL   (tstate_t)1

Thread terminated.

Definition at line 153 of file nil/include/ch.h.

Referenced by chThdExit().

◆ NIL_THD_IS_WTSTART

#define NIL_THD_IS_WTSTART ( tp)
Value:
((tp)->state == NIL_STATE_WTSTART)
#define NIL_STATE_WTSTART
Thread not yet started or terminated.

Definition at line 155 of file nil/include/ch.h.

Referenced by chThdCreateI().

◆ NIL_THD_IS_READY

#define NIL_THD_IS_READY ( tp)
Value:
((tp)->state == NIL_STATE_READY)
#define NIL_STATE_READY
Thread ready or executing.

Definition at line 156 of file nil/include/ch.h.

Referenced by chSchGoSleepTimeoutS(), chSchReadyI(), and chSysTimerHandlerI().

◆ NIL_THD_IS_SLEEPING

#define NIL_THD_IS_SLEEPING ( tp)
Value:
((tp)->state == NIL_STATE_SLEEPING)
#define NIL_STATE_SLEEPING
Thread sleeping.

Definition at line 157 of file nil/include/ch.h.

◆ NIL_THD_IS_SUSPENDED

#define NIL_THD_IS_SUSPENDED ( tp)
Value:
((tp)->state == NIL_STATE_SUSPENDED)
#define NIL_STATE_SUSPENDED
Thread suspended.

Definition at line 158 of file nil/include/ch.h.

Referenced by chSysTimerHandlerI(), and chThdResumeI().

◆ NIL_THD_IS_WTEXIT

#define NIL_THD_IS_WTEXIT ( tp)
Value:
((tp)->state == NIL_STATE_WTEXIT)
#define NIL_STATE_WTEXIT
Waiting a thread.

Definition at line 159 of file nil/include/ch.h.

◆ NIL_THD_IS_WTQUEUE

#define NIL_THD_IS_WTQUEUE ( tp)
Value:
((tp)->state == NIL_STATE_WTQUEUE)
#define NIL_STATE_WTQUEUE
On queue or semaph.

Definition at line 160 of file nil/include/ch.h.

Referenced by chSysTimerHandlerI().

◆ NIL_THD_IS_WTOREVT

#define NIL_THD_IS_WTOREVT ( tp)
Value:
((tp)->state == NIL_STATE_WTOREVT)
#define NIL_STATE_WTOREVT
Waiting for events.

Definition at line 161 of file nil/include/ch.h.

Referenced by chEvtSignalI().

◆ NIL_THD_IS_WTANDEVT

#define NIL_THD_IS_WTANDEVT ( tp)
Value:
((tp)->state == NIL_STATE_WTANDEVT)
#define NIL_STATE_WTANDEVT
Waiting for events.

Definition at line 162 of file nil/include/ch.h.

Referenced by chEvtSignalI().

◆ NIL_THD_IS_SNDMSGQ

#define NIL_THD_IS_SNDMSGQ ( tp)
Value:
((tp)->state == NIL_STATE_SNDMSGQ)
#define NIL_STATE_SNDMSGQ
Sending a message, in queue.

Definition at line 163 of file nil/include/ch.h.

◆ NIL_THD_IS_WTMSG

#define NIL_THD_IS_WTMSG ( tp)
Value:
((tp)->state == NIL_STATE_WTMSG)
#define NIL_STATE_WTMSG
Waiting for a message.

Definition at line 164 of file nil/include/ch.h.

Referenced by chMsgSend().

◆ NIL_THD_IS_FINAL

#define NIL_THD_IS_FINAL ( tp)
Value:
((tp)->state == NIL_STATE_FINAL)
#define NIL_STATE_FINAL
Thread terminated.

Definition at line 165 of file nil/include/ch.h.

Referenced by chThdCreateI(), and chThdWait().

◆ CH_STATE_NAMES

#define CH_STATE_NAMES
Value:
"WTSTART", "READY", "SLEEPING", "SUSPENDED", "WTEXIT", "WTQUEUE", \
"WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "FINAL"

Definition at line 167 of file nil/include/ch.h.

◆ CH_CFG_USE_REGISTRY

#define CH_CFG_USE_REGISTRY   FALSE

Definition at line 176 of file nil/include/ch.h.

◆ CH_CFG_ST_TIMEDELTA

#define CH_CFG_ST_TIMEDELTA   0

Definition at line 312 of file nil/include/ch.h.

◆ CH_CFG_USE_MESSAGES

#define CH_CFG_USE_MESSAGES   FALSE

Definition at line 316 of file nil/include/ch.h.

◆ NIL_DBG_ENABLED

#define NIL_DBG_ENABLED   TRUE

Definition at line 362 of file nil/include/ch.h.

◆ THD_IDLE_BASE

#define THD_IDLE_BASE   (&__main_thread_stack_base__)

Boundaries of the idle thread boundaries, only required if stack checking is enabled.

Definition at line 370 of file nil/include/ch.h.

Referenced by chSysInit().

◆ THD_IDLE_END

#define THD_IDLE_END   (&__main_thread_stack_end__)

Definition at line 371 of file nil/include/ch.h.

◆ CH_PORT_SUPPORTS_RECURSIVE_LOCKS

#define CH_PORT_SUPPORTS_RECURSIVE_LOCKS   FALSE

Definition at line 381 of file nil/include/ch.h.

◆ __dbg_enter_lock [1/2]

#define __dbg_enter_lock ( )
Value:
(nil.lock_cnt = (cnt_t)1)
os_instance_t nil
System data structures.
Definition ch.c:41
int32_t cnt_t
Definition chearly.h:92

Definition at line 618 of file nil/include/ch.h.

Referenced by __dbg_check_lock(), and __dbg_check_lock_from_isr().

◆ __dbg_enter_lock [2/2]

#define __dbg_enter_lock ( )

Definition at line 618 of file nil/include/ch.h.

◆ __dbg_leave_lock [1/2]

#define __dbg_leave_lock ( )
Value:
(nil.lock_cnt = (cnt_t)0)

Definition at line 619 of file nil/include/ch.h.

Referenced by __dbg_check_unlock(), and __dbg_check_unlock_from_isr().

◆ __dbg_leave_lock [2/2]

#define __dbg_leave_lock ( )

Definition at line 619 of file nil/include/ch.h.

◆ __CH_STRINGIFY

#define __CH_STRINGIFY ( a)
Value:
#a

Utility to make the parameter a quoted string.

Definition at line 625 of file nil/include/ch.h.

◆ THD_TABLE_BEGIN

#define THD_TABLE_BEGIN    const thread_descriptor_t nil_thd_configs[] = {

Start of user threads table.

Definition at line 634 of file nil/include/ch.h.

◆ THD_TABLE_THREAD

#define THD_TABLE_THREAD ( _prio,
_name,
_wap,
_funcp,
_arg )
Value:
{ \
.name = (_name), \
.wbase = (_wap), \
.wend = THD_WORKING_AREA_END(_wap), \
.prio = (_prio), \
.funcp = (_funcp), \
.arg = (_arg) \
},
#define THD_WORKING_AREA_END(s)
End of a working area casted to the correct type.
Definition chthreads.h:157

Entry of user threads table.

Definition at line 640 of file nil/include/ch.h.

◆ THD_TABLE_END

#define THD_TABLE_END
Value:
{ \
.name = "idle", \
.wbase = THD_IDLE_BASE, \
.wend = THD_IDLE_END, \
.prio = CH_CFG_MAX_THREADS, \
.funcp = NULL, \
.arg = NULL \
} \
};
#define CH_CFG_MAX_THREADS
Maximum number of user threads in the application.
#define THD_IDLE_BASE
#define THD_IDLE_END

End of user threads table.

Definition at line 653 of file nil/include/ch.h.

◆ MEM_ALIGN_MASK

#define MEM_ALIGN_MASK ( a)
Value:
((size_t)(a) - 1U)

Alignment mask constant.

Parameters
[in]aalignment, must be a power of two

Definition at line 674 of file nil/include/ch.h.

◆ MEM_ALIGN_PREV

#define MEM_ALIGN_PREV ( p,
a )
Value:
((size_t)(p) & ~MEM_ALIGN_MASK(a))
#define MEM_ALIGN_MASK(a)
Alignment mask constant.
Definition chalign.h:61

Aligns to the previous aligned memory address.

Parameters
[in]pvariable to be aligned
[in]aalignment, must be a power of two

Definition at line 682 of file nil/include/ch.h.

◆ MEM_ALIGN_NEXT

#define MEM_ALIGN_NEXT ( p,
a )
Value:
MEM_ALIGN_PREV((size_t)(p) + \
MEM_ALIGN_MASK(a), (a))
#define MEM_ALIGN_PREV(p, a)
Aligns to the previous aligned memory address.
Definition chalign.h:69

Aligns to the new aligned memory address.

Parameters
[in]pvariable to be aligned
[in]aalignment, must be a power of two

Definition at line 690 of file nil/include/ch.h.

◆ MEM_IS_ALIGNED

#define MEM_IS_ALIGNED ( p,
a )
Value:
(((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U)

Returns whatever a pointer or memory size is aligned.

Parameters
[in]pvariable to be aligned
[in]aalignment, must be a power of two

Definition at line 699 of file nil/include/ch.h.

◆ MEM_IS_VALID_ALIGNMENT

#define MEM_IS_VALID_ALIGNMENT ( a)
Value:
(((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U))

Returns whatever a constant is a valid alignment.

Valid alignments are powers of two.

Parameters
[in]aalignment to be checked, must be a constant

Definition at line 707 of file nil/include/ch.h.

◆ THD_WORKING_AREA_SIZE

#define THD_WORKING_AREA_SIZE ( n)
Value:
#define MEM_ALIGN_NEXT(p, a)
Aligns to the next aligned memory address.
Definition chalign.h:80
#define PORT_STACK_ALIGN
Stack alignment constant.
Definition chcore.h:56
#define PORT_WA_SIZE(n)
Computes the thread working area global size.
Definition chcore.h:196

Calculates the total Working Area size.

Parameters
[in]nthe stack size to be assigned to the thread
Returns
The total used memory in bytes.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 723 of file nil/include/ch.h.

◆ THD_WORKING_AREA

#define THD_WORKING_AREA ( s,
n )
Value:
#define PORT_WORKING_AREA(s, n)
Static working area allocation.
Definition chcore.h:208

Static working area allocation.

This macro is used to allocate a static thread working area aligned as both position and size.

Parameters
[in]sthe name to be assigned to the stack array
[in]nthe stack size to be assigned to the thread
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 736 of file nil/include/ch.h.

◆ THD_WORKING_AREA_END

#define THD_WORKING_AREA_END ( wa)
Value:
((wa) + ((sizeof wa) / sizeof (stkalign_t)))
port_stkalign_t stkalign_t
Definition chearly.h:80

Returns the top address of a working area.

Note
The parameter is assumed to be an array of stkalign_t. The macros is invalid for anything else.
Parameters
[in]waworking area array
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 748 of file nil/include/ch.h.

◆ THD_FUNCTION

#define THD_FUNCTION ( tname,
arg )
Value:
PORT_THD_FUNCTION(tname, arg)
#define PORT_THD_FUNCTION(tname, arg)
Optimized thread function declaration macro.
Definition chcore.h:182

Thread declaration macro.

Note
Thread declarations should be performed using this macro because the port layer could define optimizations for thread functions.

Definition at line 760 of file nil/include/ch.h.

◆ CH_IRQ_IS_VALID_PRIORITY

#define CH_IRQ_IS_VALID_PRIORITY ( prio)
Value:
#define PORT_IRQ_IS_VALID_PRIORITY(n)
Priority level verification macro.
Definition chcore.h:214

Priority level validation macro.

This macro determines if the passed value is a valid priority level for the underlying architecture.

Parameters
[in]priothe priority level
Returns
Priority range result.
Return values
falseif the priority is invalid or if the architecture does not support priorities.
trueif the priority is valid.

Definition at line 779 of file nil/include/ch.h.

◆ CH_IRQ_IS_VALID_KERNEL_PRIORITY

#define CH_IRQ_IS_VALID_KERNEL_PRIORITY ( prio)
Value:
#define PORT_IRQ_IS_VALID_KERNEL_PRIORITY(n)
Priority level verification macro.
Definition chcore.h:219

Priority level validation macro.

This macro determines if the passed value is a valid priority level that cannot preempt the kernel critical zone.

Parameters
[in]priothe priority level
Returns
Priority range result.
Return values
falseif the priority is invalid or if the architecture does not support priorities.
trueif the priority is valid.

Definition at line 797 of file nil/include/ch.h.

◆ CH_IRQ_PROLOGUE

#define CH_IRQ_PROLOGUE ( )
Value:
__dbg_check_enter_isr()
#define PORT_IRQ_PROLOGUE()
IRQ prologue code.
Definition chcore.h:226

IRQ handler enter code.

Note
Usually IRQ handlers functions are also declared naked.
On some architectures this macro can be empty.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 810 of file nil/include/ch.h.

◆ CH_IRQ_EPILOGUE

#define CH_IRQ_EPILOGUE ( )
Value:
PORT_IRQ_EPILOGUE()
#define __dbg_check_leave_isr()
Definition chdebug.h:98

IRQ handler exit code.

Note
Usually IRQ handlers function are also declared naked.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 820 of file nil/include/ch.h.

◆ CH_IRQ_HANDLER

#define CH_IRQ_HANDLER ( id)
Value:
#define PORT_IRQ_HANDLER(id)
IRQ handler function declaration.
Definition chcore.h:243

Standard normal IRQ handler declaration.

Note
id can be a function name or a vector number depending on the port implementation.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 831 of file nil/include/ch.h.

◆ CH_FAST_IRQ_HANDLER

#define CH_FAST_IRQ_HANDLER ( id)
Value:
#define PORT_FAST_IRQ_HANDLER(id)
Fast IRQ handler function declaration.
Definition chcore.h:254

Standard fast IRQ handler declaration.

Note
id can be a function name or a vector number depending on the port implementation.
Not all architectures support fast interrupts.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 846 of file nil/include/ch.h.

◆ TIME_S2I

#define TIME_S2I ( secs)
Value:
#define CH_CFG_ST_FREQUENCY
System tick frequency.
uint64_t time_conv_t
Type of time conversion variable.
Definition chtime.h:155
uint64_t sysinterval_t
Type of time interval.
Definition chtime.h:119

Seconds to time interval.

Converts from seconds to system ticks number.

Note
The result is rounded upward to the next tick boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]secsnumber of seconds
Returns
The number of ticks.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 866 of file nil/include/ch.h.

◆ TIME_MS2I

#define TIME_MS2I ( msecs)
Value:

Milliseconds to time interval.

Converts from milliseconds to system ticks number.

Note
The result is rounded upward to the next tick boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]msecsnumber of milliseconds
Returns
The number of ticks.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 882 of file nil/include/ch.h.

◆ TIME_US2I

#define TIME_US2I ( usecs)
Value:
((sysinterval_t)((((time_conv_t)(usecs) * \
(time_conv_t)999999) / (time_conv_t)1000000))

Microseconds to time interval.

Converts from microseconds to system ticks number.

Note
The result is rounded upward to the next tick boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]usecsnumber of microseconds
Returns
The number of ticks.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 900 of file nil/include/ch.h.

◆ TIME_I2S

#define TIME_I2S ( interval)
Value:
(time_secs_t)(((time_conv_t)(interval) + \
uint32_t time_secs_t
Type of seconds.
Definition chtime.h:136

Time interval to seconds.

Converts from system ticks number to seconds.

Note
The result is rounded up to the next second boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]intervalinterval in ticks
Returns
The number of seconds.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 918 of file nil/include/ch.h.

◆ TIME_I2MS

#define TIME_I2MS ( interval)
Value:
(time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000) + \
uint32_t time_msecs_t
Type of milliseconds.
Definition chtime.h:142

Time interval to milliseconds.

Converts from system ticks number to milliseconds.

Note
The result is rounded up to the next millisecond boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]intervalinterval in ticks
Returns
The number of milliseconds.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 936 of file nil/include/ch.h.

◆ TIME_I2US

#define TIME_I2US ( interval)
Value:
(time_usecs_t)((((time_conv_t)(interval) * (time_conv_t)1000000) + \
uint32_t time_usecs_t
Type of microseconds.
Definition chtime.h:148

Time interval to microseconds.

Converts from system ticks number to microseconds.

Note
The result is rounded up to the next microsecond boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]intervalinterval in ticks
Returns
The number of microseconds.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 954 of file nil/include/ch.h.

◆ __THREADS_QUEUE_DATA

#define __THREADS_QUEUE_DATA ( name)
Value:
{(cnt_t)0}

Data part of a static threads queue object initializer.

This macro should be used when statically initializing a threads queue that is part of a bigger structure.

Parameters
[in]namethe name of the threads queue variable

Definition at line 971 of file nil/include/ch.h.

◆ THREADS_QUEUE_DECL

#define THREADS_QUEUE_DECL ( name)
Value:
#define __THREADS_QUEUE_DATA(name)
Data part of a static threads queue object initializer.
Definition chthreads.h:105
Type of a thread queue.
Definition osal.h:238

Static threads queue object initializer.

Statically initialized threads queues require no explicit initialization using queue_init().

Parameters
[in]namethe name of the threads queue variable

Definition at line 980 of file nil/include/ch.h.

◆ chSysGetRealtimeCounterX

#define chSysGetRealtimeCounterX ( )
Value:
port_rtcnt_t rtcnt_t
Definition chearly.h:77
static rtcnt_t port_rt_get_counter_value(void)
Returns the current value of the realtime counter.
Definition chcore.h:413

Returns the current value of the system real time counter.

Note
This function is only available if the port layer supports the option PORT_SUPPORTS_RT.
Returns
The value of the system realtime counter of type rtcnt_t.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 999 of file nil/include/ch.h.

◆ chSysDisable

#define chSysDisable ( void)
Value:
{ \
port_disable(); \
__dbg_check_disable(); \
}

Raises the system interrupt priority mask to the maximum level.

All the maskable interrupt sources are disabled regardless their hardware priority.

Note
Do not invoke this API from within a kernel lock.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 1010 of file nil/include/ch.h.

◆ chSysSuspend

#define chSysSuspend ( void)
Value:
{ \
port_suspend(); \
__dbg_check_suspend(); \
}

Raises the system interrupt priority mask to system level.

The interrupt sources that should not be able to preempt the kernel are disabled, interrupt sources with higher priority are still enabled.

Note
Do not invoke this API from within a kernel lock.
This API is no replacement for chSysLock(), the chSysLock() could do more than just disable the interrupts.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 1026 of file nil/include/ch.h.

Referenced by chSysInit().

◆ chSysEnable

#define chSysEnable ( void)
Value:
{ \
__dbg_check_enable(); \
port_enable(); \
}

Lowers the system interrupt priority mask to user level.

All the interrupt sources are enabled.

Note
Do not invoke this API from within a kernel lock.
This API is no replacement for chSysUnlock(), the chSysUnlock() could do more than just enable the interrupts.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 1040 of file nil/include/ch.h.

◆ chSysLock

#define chSysLock ( void)
Value:
{ \
port_lock(); \
__dbg_check_lock(); \
}

Enters the kernel lock state.

Function Class:
Special function, this function has special requirements see the notes.

Definition at line 1050 of file nil/include/ch.h.

Referenced by chBSemSignal(), chCacheGetObject(), chCacheReleaseObject(), chCondBroadcast(), chCondSignal(), chCondWait(), chCondWaitTimeout(), chCoreAllocFromBase(), chCoreAllocFromTop(), chEvtAddEvents(), chEvtBroadcastFlags(), chEvtGetAndClearEvents(), chEvtGetAndClearFlags(), chEvtRegisterMaskWithFlags(), chEvtSignal(), chEvtUnregister(), chEvtWaitAll(), chEvtWaitAllTimeout(), chEvtWaitAllTimeout(), chEvtWaitAny(), chEvtWaitAnyTimeout(), chEvtWaitAnyTimeout(), chEvtWaitOne(), chEvtWaitOneTimeout(), chGuardedPoolAllocTimeout(), chGuardedPoolFree(), chMBFetchTimeout(), chMBPostAheadTimeout(), chMBPostTimeout(), chMBReset(), chMsgPoll(), chMsgRelease(), chMsgSend(), chMsgWait(), chMsgWait(), chMsgWaitTimeout(), chMsgWaitTimeout(), chMtxLock(), chMtxTryLock(), chMtxUnlock(), chMtxUnlockAll(), chPipeReadTimeout(), chPipeReset(), chPipeWriteTimeout(), chPoolAlloc(), chPoolFree(), chRegFirstThread(), chRegNextThread(), chSemResetWithMessage(), chSemSignal(), chSemSignalWait(), chSemWait(), chSemWaitTimeout(), chSysGetStatusAndLockX(), chSysUnconditionalLock(), chThdAddRef(), chThdCreate(), chThdCreateFromHeap(), chThdCreateFromMemoryPool(), chThdCreateStatic(), chThdCreateSuspended(), chThdExit(), chThdRelease(), chThdResume(), chThdSetPriority(), chThdSleep(), chThdSleep(), chThdSleepUntil(), chThdSleepUntil(), chThdSleepUntilWindowed(), chThdStart(), chThdTerminate(), chThdWait(), chThdYield(), chTraceResume(), chTraceSuspend(), chTraceWrite(), chVTGetSystemTime(), chVTGetTimeStamp(), chVTIsArmed(), chVTReset(), chVTResetTimeStamp(), chVTSet(), chVTSetContinuous(), i2cSlaveMatchAddress(), and lru_get_last_s().

◆ chSysUnlock

#define chSysUnlock ( void)
Value:
{ \
__dbg_check_unlock(); \
port_unlock(); \
}

Leaves the kernel lock state.

Function Class:
Special function, this function has special requirements see the notes.

Definition at line 1060 of file nil/include/ch.h.

Referenced by chBSemSignal(), chCacheGetObject(), chCacheReleaseObject(), chCondBroadcast(), chCondSignal(), chCondWait(), chCondWaitTimeout(), chCoreAllocFromBase(), chCoreAllocFromTop(), chEvtAddEvents(), chEvtBroadcastFlags(), chEvtGetAndClearEvents(), chEvtGetAndClearFlags(), chEvtRegisterMaskWithFlags(), chEvtSignal(), chEvtUnregister(), chEvtWaitAll(), chEvtWaitAllTimeout(), chEvtWaitAllTimeout(), chEvtWaitAny(), chEvtWaitAnyTimeout(), chEvtWaitAnyTimeout(), chEvtWaitOne(), chEvtWaitOneTimeout(), chGuardedPoolAllocTimeout(), chGuardedPoolFree(), chMBFetchTimeout(), chMBPostAheadTimeout(), chMBPostTimeout(), chMBReset(), chMsgPoll(), chMsgRelease(), chMsgSend(), chMsgWait(), chMsgWait(), chMsgWaitTimeout(), chMsgWaitTimeout(), chMtxLock(), chMtxTryLock(), chMtxUnlock(), chMtxUnlockAll(), chPipeReadTimeout(), chPipeReset(), chPipeWriteTimeout(), chPoolAlloc(), chPoolFree(), chRegFirstThread(), chRegNextThread(), chSemResetWithMessage(), chSemSignal(), chSemSignalWait(), chSemWait(), chSemWaitTimeout(), chSysInit(), chSysRestoreStatusX(), chSysUnconditionalUnlock(), chThdAddRef(), chThdCreate(), chThdCreateFromHeap(), chThdCreateFromMemoryPool(), chThdCreateStatic(), chThdCreateSuspended(), chThdRelease(), chThdResume(), chThdSetPriority(), chThdSleep(), chThdSleep(), chThdSleepUntil(), chThdSleepUntil(), chThdSleepUntilWindowed(), chThdStart(), chThdTerminate(), chThdWait(), chThdYield(), chTraceResume(), chTraceSuspend(), chTraceWrite(), chVTGetSystemTime(), chVTGetTimeStamp(), chVTIsArmed(), chVTReset(), chVTResetTimeStamp(), chVTSet(), chVTSetContinuous(), i2cSlaveMatchAddress(), and lru_get_last_s().

◆ chSysLockFromISR

#define chSysLockFromISR ( void)
Value:
{ \
port_lock_from_isr(); \
__dbg_check_lock_from_isr(); \
}

Enters the kernel lock state from within an interrupt handler.

Note
This API may do nothing on some architectures, it is required because on ports that support preemptable interrupt handlers it is required to raise the interrupt mask to the same level of the system mutual exclusion zone.
It is good practice to invoke this API before invoking any I-class syscall from an interrupt handler.
This API must be invoked exclusively from interrupt handlers.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 1077 of file nil/include/ch.h.

Referenced by __sch_wakeup(), chSysGetStatusAndLockX(), chSysTimerHandlerI(), and chVTDoTickI().

◆ chSysUnlockFromISR

#define chSysUnlockFromISR ( void)
Value:
{ \
__dbg_check_unlock_from_isr(); \
port_unlock_from_isr(); \
}

Leaves the kernel lock state from within an interrupt handler.

Note
This API may do nothing on some architectures, it is required because on ports that support preemptable interrupt handlers it is required to raise the interrupt mask to the same level of the system mutual exclusion zone.
It is good practice to invoke this API after invoking any I-class syscall from an interrupt handler.
This API must be invoked exclusively from interrupt handlers.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 1095 of file nil/include/ch.h.

Referenced by __sch_wakeup(), chSysRestoreStatusX(), chSysTimerHandlerI(), and chVTDoTickI().

◆ chSchGoSleepS

#define chSchGoSleepS ( newstate)
Value:
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
Definition chschd.c:359
#define TIME_INFINITE
Infinite interval specification for all functions with a timeout specification.
Definition chtime.h:55

Puts the current thread to sleep into the specified state.

Parameters
[in]newstatethe new thread state or a semaphore pointer
Returns
The wakeup message.
Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 1108 of file nil/include/ch.h.

Referenced by chCondWaitS(), chEvtWaitAll(), chEvtWaitAny(), chEvtWaitOne(), chMsgSend(), chMsgWaitS(), chMtxLockS(), chSchGoSleepTimeoutS(), chSemSignalWait(), chSemWaitS(), chThdExitS(), chThdSuspendS(), and chThdWait().

◆ chSchWakeupS

#define chSchWakeupS ( ntp,
msg )
Value:
do { \
chSchReadyI(ntp, msg); \
chSchRescheduleS(); \
} while (false)

Wakes up a thread.

Parameters
[in]ntpthe thread to be made ready
[in]msgthe wakeup message
Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 1118 of file nil/include/ch.h.

Referenced by chCondSignal(), chMsgReleaseS(), chSemSignal(), chThdCreate(), chThdCreateFromHeap(), chThdCreateFromMemoryPool(), chThdCreateStatic(), chThdResumeS(), and chThdStart().

◆ chSchIsRescRequiredI

#define chSchIsRescRequiredI ( )
Value:
((bool)(nil.current != nil.next))

Evaluates if a reschedule is required.

Return values
trueif there is a thread that must go in running state immediately.
falseif preemption is not required.
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1132 of file nil/include/ch.h.

Referenced by chSchIsPreemptionRequired(), and chSchRescheduleS().

◆ chThdGetSelfX

◆ chThdGetPriorityX

#define chThdGetPriorityX ( void)
Value:
(tprio_t)(nil.current - &nil.threads[0])
uint32_t tprio_t
Definition chearly.h:87

Returns the current thread priority.

Note
Can be invoked in any context.
Returns
The current thread priority.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 1149 of file nil/include/ch.h.

◆ chThdResumeS

#define chThdResumeS ( trp,
msg )
Value:
do { \
chThdResumeI(trp, msg); \
chSchRescheduleS(); \
} while (false)

Wakes up a thread waiting on a thread reference object.

Note
This function must reschedule, it can only be called from thread context.
Parameters
[in]trpa pointer to a thread reference object
[in]msgthe message code
Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 1161 of file nil/include/ch.h.

Referenced by chThdResume().

◆ chThdSleepSeconds

#define chThdSleepSeconds ( secs)
Value:
void chThdSleep(sysinterval_t time)
Suspends the invoking thread for the specified time.
Definition chthreads.c:655
#define TIME_S2I(secs)
Seconds to time interval.
Definition chtime.h:185

Delays the invoking thread for the specified number of seconds.

Note
The specified time is rounded up to a value allowed by the real system clock.
The maximum specified value is implementation dependent.
Parameters
[in]secstime in seconds, must be different from zero
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1176 of file nil/include/ch.h.

◆ chThdSleepMilliseconds

#define chThdSleepMilliseconds ( msecs)
Value:
#define TIME_MS2I(msecs)
Milliseconds to time interval.
Definition chtime.h:201

Delays the invoking thread for the specified number of milliseconds.

Note
The specified time is rounded up to a value allowed by the real system clock.
The maximum specified value is implementation dependent.
Parameters
[in]msecstime in milliseconds, must be different from zero
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1189 of file nil/include/ch.h.

◆ chThdSleepMicroseconds

#define chThdSleepMicroseconds ( usecs)
Value:
#define TIME_US2I(usecs)
Microseconds to time interval.
Definition chtime.h:219

Delays the invoking thread for the specified number of microseconds.

Note
The specified time is rounded up to a value allowed by the real system clock.
The maximum specified value is implementation dependent.
Parameters
[in]usecstime in microseconds, must be different from zero
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1202 of file nil/include/ch.h.

◆ chThdSleepS

#define chThdSleepS ( timeout)
Value:

Suspends the invoking thread for the specified time.

Parameters
[in]timeoutthe delay in system ticks
Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 1211 of file nil/include/ch.h.

Referenced by chThdSleep(), chThdSleep(), chThdSleepUntil(), and chThdSleepUntilWindowed().

◆ chThdSleepUntilS

#define chThdSleepUntilS ( abstime)
Value:
#define chVTGetSystemTimeX()
Current system time.
#define chTimeDiffX(start, end)
Subtracts two system times returning an interval.

Suspends the invoking thread until the system time arrives to the specified value.

Parameters
[in]abstimeabsolute system time
Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 1222 of file nil/include/ch.h.

Referenced by chThdSleepUntil().

◆ chThdQueueObjectInit

#define chThdQueueObjectInit ( tqp)
Value:
((tqp)->cnt = (cnt_t)0)

Initializes a threads queue object.

Parameters
[out]tqppointer to the threads queue object
Function Class:
Object or module nitializer function.

Definition at line 1233 of file nil/include/ch.h.

Referenced by chMBObjectInit().

◆ chThdQueueIsEmptyI

#define chThdQueueIsEmptyI ( tqp)
Value:
((bool)(tqp->cnt >= (cnt_t)0))

Evaluates to true if the specified queue is empty.

Parameters
[out]tqppointer to the threads queue object
Returns
The queue status.
Return values
falseif the queue is not empty.
trueif the queue is empty.
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1245 of file nil/include/ch.h.

◆ chVTGetSystemTimeX

#define chVTGetSystemTimeX ( void)
Value:
(nil.systime)

Current system time.

Returns the number of system ticks since the chSysInit() invocation.

Note
The counter can reach its maximum and then restart from zero.
This function can be called from any context but its atomicity is not guaranteed on architectures whose word size is less than systime_t size.
Returns
The system time in ticks.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 1261 of file nil/include/ch.h.

Referenced by chSchGoSleepTimeoutS(), chThdSleepUntil(), chThdSleepUntilWindowed(), chVTDoResetI(), chVTDoTickI(), chVTGetRemainingIntervalI(), chVTGetTimersStateI(), chVTGetTimeStampI(), chVTResetTimeStampI(), trace_next(), vt_enqueue(), vt_insert_first(), and vt_set_alarm().

◆ chVTTimeElapsedSinceX

#define chVTTimeElapsedSinceX ( start)
Value:

Returns the elapsed time since the specified start time.

Parameters
[in]startstart time
Returns
The elapsed time.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 1274 of file nil/include/ch.h.

◆ chVTIsSystemTimeWithinX

#define chVTIsSystemTimeWithinX ( start,
end )
Value:
static bool chTimeIsInRangeX(systime_t time, systime_t start, systime_t end)
Checks if the specified time is within the specified time range.
Definition chtime.h:484

Checks if the current system time is within the specified time window.

Note
When start==end then the function returns always false because the time window has zero size.
Parameters
[in]startthe start of the time window (inclusive)
[in]endthe end of the time window (non inclusive)
Return values
truecurrent time within the specified time window.
falsecurrent time not within the specified time window.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 1290 of file nil/include/ch.h.

◆ chTimeAddX

#define chTimeAddX ( systime,
interval )
Value:
((systime_t)(systime) + (systime_t)(interval))
uint64_t systime_t
Type of system time.
Definition chtime.h:107

Adds an interval to a system time returning a system time.

Parameters
[in]systimebase system time
[in]intervalinterval to be added
Returns
The new system time.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 1302 of file nil/include/ch.h.

Referenced by chSchGoSleepTimeoutS(), chSysTimerHandlerI(), chVTDoTickI(), vt_insert_first(), and vt_set_alarm().

◆ chTimeDiffX

#define chTimeDiffX ( start,
end )
Value:
((sysinterval_t)((systime_t)((systime_t)(end) - (systime_t)(start))))

Subtracts two system times returning an interval.

Parameters
[in]startfirst system time
[in]endsecond system time
Returns
The interval representing the time difference.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 1314 of file nil/include/ch.h.

Referenced by chSysTimerHandlerI(), chThdSleepUntil(), chThdSleepUntilWindowed(), chVTDoResetI(), chVTDoTickI(), chVTGetRemainingIntervalI(), chVTGetTimersStateI(), chVTGetTimeStampI(), chVTTimeElapsedSinceX(), vt_enqueue(), vt_insert_first(), and vt_set_alarm().

◆ chDbgCheck

#define chDbgCheck ( c)
Value:
do { \
/*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
if (!(c)) { \
/*lint -restore*/ \
chSysHalt(__func__); \
} \
} \
} while (false)
#define CH_DBG_ENABLE_CHECKS
Debug option, parameters checks.
#define FALSE
Generic 'false' preprocessor boolean constant.

Function parameters check.

If the condition check fails then the kernel panics and halts.

Note
The condition is tested only if the CH_DBG_ENABLE_CHECKS switch is specified in chconf.h else the macro does nothing.
Parameters
[in]cthe condition to be verified to be true
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1328 of file nil/include/ch.h.

◆ chDbgAssert

#define chDbgAssert ( c,
r )
Value:
do { \
/*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
if (!(c)) { \
/*lint -restore*/ \
chSysHalt(__func__); \
} \
} \
} while (false)
#define CH_DBG_ENABLE_ASSERTS
Debug option, consistency checks.

Condition assertion.

If the condition check fails then the kernel panics with a message and halts.

Note
The condition is tested only if the CH_DBG_ENABLE_ASSERTS switch is specified in chconf.h else the macro does nothing.
The remark string is not currently used except for putting a comment in the code about the assertion.
Parameters
[in]cthe condition to be verified to be true
[in]ra remark string
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1354 of file nil/include/ch.h.

Typedef Documentation

◆ rtcnt_t

Realtime counter.

Definition at line 393 of file nil/include/ch.h.

◆ syssts_t

System status word.

Definition at line 394 of file nil/include/ch.h.

◆ stkalign_t

Stack alignment type.

Definition at line 395 of file nil/include/ch.h.

◆ tstate_t

typedef uint8_t tstate_t

Thread state.

Definition at line 398 of file nil/include/ch.h.

◆ tprio_t

typedef uint32_t tprio_t

Thread priority.

Definition at line 399 of file nil/include/ch.h.

◆ msg_t

typedef int32_t msg_t

Inter-thread message.

Definition at line 400 of file nil/include/ch.h.

◆ eventid_t

typedef int32_t eventid_t

Numeric event identifier.

Definition at line 401 of file nil/include/ch.h.

◆ eventmask_t

typedef uint32_t eventmask_t

Mask of event identifiers.

Definition at line 402 of file nil/include/ch.h.

◆ eventflags_t

typedef uint32_t eventflags_t

Mask of event flags.

Definition at line 403 of file nil/include/ch.h.

◆ cnt_t

typedef int32_t cnt_t

Generic signed counter.

Definition at line 404 of file nil/include/ch.h.

◆ ucnt_t

typedef uint32_t ucnt_t

Generic unsigned counter.

Definition at line 405 of file nil/include/ch.h.

◆ systime_t

typedef uint32_t systime_t

Type of system time.

Note
It is selectable in configuration between 16 or 32 bits.

Definition at line 435 of file nil/include/ch.h.

◆ sysinterval_t

typedef uint32_t sysinterval_t

Type of time interval.

Note
It is selectable in configuration between 16 or 32 bits.

Definition at line 441 of file nil/include/ch.h.

◆ time_conv_t

typedef uint64_t time_conv_t

Type of time conversion variable.

Note
This type must have double width than other time types, it is only used internally for conversions.

Definition at line 448 of file nil/include/ch.h.

◆ os_instance_t

Type of a structure representing the system.

Definition at line 459 of file nil/include/ch.h.

◆ tfunc_t

typedef void(* tfunc_t) (void *p)

Thread function.

Definition at line 464 of file nil/include/ch.h.

◆ thread_descriptor_t

typedef struct nil_thread_descriptor thread_descriptor_t

Type of a thread descriptor.

Definition at line 469 of file nil/include/ch.h.

◆ thread_t

typedef struct nil_thread thread_t

Type of a structure representing a thread.

Note
It is required as an early definition.

Definition at line 475 of file nil/include/ch.h.

◆ thread_reference_t

Type of a thread reference.

Definition at line 480 of file nil/include/ch.h.

◆ threads_queue_t

typedef struct nil_threads_queue threads_queue_t

Type of a queue of threads.

Definition at line 485 of file nil/include/ch.h.

◆ semaphore_t

Type of a structure representing a semaphore.

Note
Semaphores are implemented on thread queues, the object is the same, the behavior is slightly different.

Definition at line 493 of file nil/include/ch.h.

Function Documentation

◆ nil_find_thread()

thread_t * nil_find_thread ( tstate_t state,
void * p )

Retrieves the highest priority thread in the specified state and associated to the specified object.

Parameters
[in]statethread state
[in]pobject pointer
Returns
The pointer to the found thread.
Return values
NULLif the thread is not found.
Function Class:
Not an API, this function is for internal use only.

Definition at line 70 of file ch.c.

References CH_CFG_MAX_THREADS, nil, and ch_thread::state.

Referenced by chMsgWaitTimeoutS(), chSemSignalI(), and chThdDoDequeueNextI().

◆ nil_ready_all()

cnt_t nil_ready_all ( void * p,
cnt_t cnt,
msg_t msg )

Puts in ready state all thread matching the specified status and associated object.

Parameters
[in]pobject pointer
[in]cntnumber of threads to be readied as a negative number, non negative numbers are ignored
[in]msgthe wakeup message
Returns
The number of readied threads.
Function Class:
Not an API, this function is for internal use only.

Definition at line 95 of file ch.c.

References CH_CFG_MAX_THREADS, chDbgAssert, chSchReadyI(), nil, NIL_STATE_WTQUEUE, and ch_thread::state.

Referenced by chSemResetWithMessageI(), and chThdDequeueAllI().

Here is the call graph for this function:

◆ __dbg_check_disable()

void __dbg_check_disable ( void )

Guard code for chSysDisable().

Function Class:
Not an API, this function is for internal use only.

Definition at line 120 of file ch.c.

References chSysHalt(), and nil.

Here is the call graph for this function:

◆ __dbg_check_suspend()

void __dbg_check_suspend ( void )

Guard code for chSysSuspend().

Function Class:
Not an API, this function is for internal use only.

Definition at line 132 of file ch.c.

References chSysHalt(), and nil.

Here is the call graph for this function:

◆ __dbg_check_enable()

void __dbg_check_enable ( void )

Guard code for chSysEnable().

Function Class:
Not an API, this function is for internal use only.

Definition at line 144 of file ch.c.

References chSysHalt(), and nil.

Here is the call graph for this function:

◆ __dbg_check_lock()

void __dbg_check_lock ( void )

Guard code for chSysLock().

Function Class:
Not an API, this function is for internal use only.

Definition at line 156 of file ch.c.

References __dbg_enter_lock, chSysHalt(), and nil.

Here is the call graph for this function:

◆ __dbg_check_unlock()

void __dbg_check_unlock ( void )

Guard code for chSysUnlock().

Function Class:
Not an API, this function is for internal use only.

Definition at line 169 of file ch.c.

References __dbg_leave_lock, chSysHalt(), and nil.

Here is the call graph for this function:

◆ __dbg_check_lock_from_isr()

void __dbg_check_lock_from_isr ( void )

Guard code for chSysLockFromIsr().

Function Class:
Not an API, this function is for internal use only.

Definition at line 182 of file ch.c.

References __dbg_enter_lock, chSysHalt(), and nil.

Here is the call graph for this function:

◆ __dbg_check_unlock_from_isr()

void __dbg_check_unlock_from_isr ( void )

Guard code for chSysUnlockFromIsr().

Function Class:
Not an API, this function is for internal use only.

Definition at line 195 of file ch.c.

References __dbg_leave_lock, chSysHalt(), and nil.

Here is the call graph for this function:

◆ __dbg_check_enter_isr()

void __dbg_check_enter_isr ( void )

Guard code for CH_IRQ_PROLOGUE().

Function Class:
Not an API, this function is for internal use only.

Definition at line 208 of file ch.c.

References chSysHalt(), nil, port_lock_from_isr(), and port_unlock_from_isr().

Here is the call graph for this function:

◆ __dbg_check_leave_isr()

void __dbg_check_leave_isr ( void )

Guard code for CH_IRQ_EPILOGUE().

Function Class:
Not an API, this function is for internal use only.

Definition at line 223 of file ch.c.

References chSysHalt(), nil, port_lock_from_isr(), and port_unlock_from_isr().

Here is the call graph for this function:

◆ chDbgCheckClassI()

void chDbgCheckClassI ( void )

I-class functions context check.

Verifies that the system is in an appropriate state for invoking an I-class API function. A panic is generated if the state is not compatible.

Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 241 of file ch.c.

References chSysHalt(), and nil.

Referenced by chSchReadyI(), chSysTimerHandlerI(), chThdCreateI(), chThdDequeueAllI(), and chThdDequeueNextI().

Here is the call graph for this function:

◆ chDbgCheckClassS()

void chDbgCheckClassS ( void )

S-class functions context check.

Verifies that the system is in an appropriate state for invoking an S-class API function. A panic is generated if the state is not compatible.

Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 256 of file ch.c.

References chSysHalt(), and nil.

Referenced by chSchGoSleepTimeoutS(), chSchRescheduleS(), and chThdEnqueueTimeoutS().

Here is the call graph for this function:

◆ chSysInit()

void chSysInit ( void )

Initializes the kernel.

Initializes the kernel structures, the current instructions flow becomes the idle thread upon return. The idle thread must not invoke any kernel primitive able to change state to not runnable.

Note
This function assumes that the nil global variable has been zeroed by the runtime environment. If this is not the case then make sure to clear it before calling this function.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 275 of file ch.c.

References __oslib_init(), CH_CFG_MAX_THREADS, CH_CFG_SYSTEM_INIT_HOOK, chSchRescheduleS(), chSysSuspend, chSysUnlock, chThdCreateI(), thread_descriptor_t::funcp, nil, NIL_STATE_READY, and THD_IDLE_BASE.

Here is the call graph for this function:

◆ 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 330 of file ch.c.

References CH_CFG_SYSTEM_HALT_HOOK, nil, and port_disable().

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:

◆ chSysTimerHandlerI()

void chSysTimerHandlerI ( void )

Time management handler.

Note
This handler has to be invoked by a periodic ISR in order to reschedule the waiting threads.
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 355 of file ch.c.

References CH_CFG_MAX_THREADS, chDbgAssert, chDbgCheckClassI(), chSchReadyI(), chSysLockFromISR, chSysUnlockFromISR, chTimeAddX, chTimeDiffX, MSG_TIMEOUT, nil, NIL_THD_IS_READY, NIL_THD_IS_SUSPENDED, and NIL_THD_IS_WTQUEUE.

Here is the call graph for this function:

◆ chSysUnconditionalLock()

void chSysUnconditionalLock ( void )

Unconditionally enters the kernel lock state.

Note
Can be called without previous knowledge of the current lock state. The final state is "s-locked".
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 459 of file ch.c.

References chSysLock, port_get_lock_status, and port_is_locked.

◆ chSysUnconditionalUnlock()

void chSysUnconditionalUnlock ( void )

Unconditionally leaves the kernel lock state.

Note
Can be called without previous knowledge of the current lock state. The final state is "normal".
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 473 of file ch.c.

References chSysUnlock, port_get_lock_status, and port_is_locked.

◆ chSysGetStatusAndLockX()

syssts_t chSysGetStatusAndLockX ( void )

Returns the execution status and enters a critical zone.

This functions enters into a critical zone and can be called from any context. Because its flexibility it is less efficient than chSysLock() which is preferable when the calling context is known.

Postcondition
The system is in a critical zone.
Note
This function is only available if the underlying port supports port_get_lock_status() and port_is_locked().
Returns
The previous system status, the encoding of this status word is architecture-dependent and opaque.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 495 of file ch.c.

References chSysLock, chSysLockFromISR, port_get_lock_status, port_is_isr_context(), and port_is_locked.

Here is the call graph for this function:

◆ chSysRestoreStatusX()

void chSysRestoreStatusX ( syssts_t sts)

Restores the specified execution status and leaves a critical zone.

Note
A call to chSchRescheduleS() is automatically performed if exiting the critical zone and if not in ISR context.
This function is only available if the underlying port supports port_get_lock_status() and port_is_locked().
Parameters
[in]ststhe system status to be restored.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 520 of file ch.c.

References chSchRescheduleS(), chSysUnlock, chSysUnlockFromISR, port_is_isr_context(), and port_is_locked.

Here is the call graph for this function:

◆ chSysIsCounterWithinX()

bool chSysIsCounterWithinX ( rtcnt_t cnt,
rtcnt_t start,
rtcnt_t end )

Realtime window test.

This function verifies if the current realtime counter value lies within the specified range or not. The test takes care of the realtime counter wrapping to zero on overflow.

Note
When start==end then the function returns always false because a null time range is specified.
This function is only available if the port layer supports the option PORT_SUPPORTS_RT.
Parameters
[in]cntthe counter value to be tested
[in]startthe start of the time window (inclusive)
[in]endthe end of the time window (non inclusive)
Return values
truecurrent time within the specified time window.
falsecurrent time not within the specified time window.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 553 of file ch.c.

Referenced by chSysPolledDelayX().

◆ chSysPolledDelayX()

void chSysPolledDelayX ( rtcnt_t cycles)

Polled delay.

Note
The real delay is always few cycles in excess of the specified value.
This function is only available if the port layer supports the option PORT_SUPPORTS_RT.
Parameters
[in]cyclesnumber of cycles
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 570 of file ch.c.

References chSysGetRealtimeCounterX, and chSysIsCounterWithinX().

Here is the call graph for this function:

◆ chSchReadyI()

thread_t * chSchReadyI ( thread_t * tp,
msg_t msg )

Makes the specified thread ready for execution.

Parameters
[in]tppointer to the thread_t object
[in]msgthe wakeup message
Returns
The same reference passed as parameter.

Definition at line 587 of file ch.c.

References CH_CFG_MAX_THREADS, chDbgAssert, chDbgCheck, chDbgCheckClassI(), nil, NIL_STATE_READY, NIL_THD_IS_READY, and ch_thread::state.

Referenced by chSysTimerHandlerI(), chThdCreateI(), chThdDoDequeueNextI(), chThdExit(), chThdResumeI(), and nil_ready_all().

Here is the call graph for this function:

◆ chSchIsPreemptionRequired()

bool chSchIsPreemptionRequired ( void )

Evaluates if preemption is required.

The decision is taken by comparing the relative priorities and depending on the state of the round robin timeout counter.

Note
Not a user function, it is meant to be invoked by the scheduler itself or from within the port layer.
Return values
trueif there is a thread that must go in running state immediately.
falseif preemption is not required.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 616 of file ch.c.

References chSchIsRescRequiredI.

◆ chSchDoPreemption()

void chSchDoPreemption ( void )

Switches to the first thread on the runnable queue.

Note
Not a user function, it is meant to be invoked by the scheduler itself or from within the port layer.
Function Class:
Special function, this function has special requirements see the notes.

Definition at line 628 of file ch.c.

References CH_CFG_IDLE_LEAVE_HOOK, CH_CFG_MAX_THREADS, nil, and port_switch.

Referenced by chSchRescheduleS().

◆ chSchRescheduleS()

void chSchRescheduleS ( void )

Reschedules if needed.

Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 643 of file ch.c.

References chDbgCheckClassS(), chSchDoPreemption(), and chSchIsRescRequiredI.

Referenced by chSysInit(), chSysRestoreStatusX(), and chThdCreate().

Here is the call graph for this function:

◆ chSchGoSleepTimeoutS()

msg_t chSchGoSleepTimeoutS ( tstate_t newstate,
sysinterval_t timeout )

Puts the current thread to sleep into the specified state with timeout specification.

The thread goes into a sleeping state, if it is not awakened explicitly within the specified system time then it is forcibly awakened with a MSG_TIMEOUT low level message.

Parameters
[in]newstatethe new thread state or a semaphore pointer
[in]timeoutthe number of ticks before the operation timeouts. the following special values are allowed:
  • TIME_INFINITE no timeout.
Returns
The wakeup message.
Return values
MSG_TIMEOUTif a timeout occurred.
Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 669 of file ch.c.

References CH_CFG_IDLE_ENTER_HOOK, CH_CFG_MAX_THREADS, CH_CFG_ST_TIMEDELTA, chDbgAssert, chDbgCheckClassS(), chTimeAddX, chTimeIsInRangeX(), chVTGetSystemTimeX, nil, NIL_THD_IS_READY, port_switch, ch_thread::state, and TIME_INFINITE.

Referenced by chThdEnqueueTimeoutS(), chThdExit(), chThdSuspendTimeoutS(), and chThdWait().

Here is the call graph for this function:

◆ chTimeIsInRangeX()

bool chTimeIsInRangeX ( systime_t time,
systime_t start,
systime_t end )

Checks if the specified time is within the specified time range.

Note
When start==end then the function returns always false because the time window has zero size.
Parameters
[in]timethe time to be verified
[in]startthe start of the time window (inclusive)
[in]endthe end of the time window (non inclusive)
Return values
truecurrent time within the specified time window.
falsecurrent time not within the specified time window.
Function Class:
This is an X-Class API, this function can be invoked from any context.

Definition at line 749 of file ch.c.

Referenced by chSchGoSleepTimeoutS().

◆ chThdCreateI()

thread_t * chThdCreateI ( const thread_descriptor_t * tdp)

Creates a new thread into a static memory area.

The new thread is initialized and make ready to execute.

Note
A thread can terminate by calling chThdExit() or by simply returning from its main function.
Parameters
[out]tdppointer to the thread descriptor structure
Returns
The pointer to the thread_t structure allocated for the thread.
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 767 of file ch.c.

References thread_descriptor_t::arg, CH_CFG_MAX_THREADS, CH_CFG_THREAD_EXT_INIT_HOOK, chDbgAssert, chDbgCheck, chDbgCheckClassI(), chSchReadyI(), thread_descriptor_t::funcp, MEM_IS_ALIGNED, MSG_OK, nil, NIL_THD_IS_FINAL, NIL_THD_IS_WTSTART, PORT_SETUP_CONTEXT, PORT_STACK_ALIGN, PORT_WORKING_AREA_ALIGN, thread_descriptor_t::prio, ch_thread::wabase, thread_descriptor_t::wbase, and thread_descriptor_t::wend.

Referenced by chSysInit(), and chThdCreate().

Here is the call graph for this function:

◆ chThdCreate()

thread_t * chThdCreate ( const thread_descriptor_t * tdp)

Creates a new thread into a static memory area.

The new thread is initialized and make ready to execute.

Note
A thread can terminate by calling chThdExit() or by simply returning from its main function.
Parameters
[out]tdppointer to the thread descriptor structure
Returns
The pointer to the thread_t structure allocated for the thread.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 813 of file ch.c.

References chSchRescheduleS(), chSysLock, chSysUnlock, and chThdCreateI().

Here is the call graph for this function:

◆ chThdExit()

void chThdExit ( msg_t msg)

Terminates the current thread.

The thread goes in the CH_STATE_FINAL state holding the specified exit status code, other threads can retrieve the exit status code by invoking the function chThdWait().

Postcondition
Eventual code after this function will never be executed, this function never returns. The compiler has no way to know this so do not assume that the compiler would remove the dead code.
Parameters
[in]msgthread exit code
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 838 of file ch.c.

References CH_CFG_MAX_THREADS, CH_CFG_THREAD_EXIT_HOOK, chDbgAssert, chSchGoSleepTimeoutS(), chSchReadyI(), chSysLock, nil, NIL_STATE_FINAL, NIL_STATE_WTEXIT, ch_thread::state, and TIME_INFINITE.

Here is the call graph for this function:

◆ chThdWait()

msg_t chThdWait ( thread_t * tp)

Blocks the execution of the invoking thread until the specified thread terminates then the exit code is returned.

Parameters
[in]tppointer to the thread
Returns
The exit code from the terminated thread.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 876 of file ch.c.

References chSchGoSleepTimeoutS(), chSysLock, chSysUnlock, nil, NIL_STATE_WTEXIT, NIL_THD_IS_FINAL, and TIME_INFINITE.

Here is the call graph for this function:

◆ chThdSuspendTimeoutS()

msg_t chThdSuspendTimeoutS ( thread_reference_t * trp,
sysinterval_t timeout )

Sends the current thread sleeping and sets a reference variable.

Note
This function must reschedule, it can only be called from thread context.
Parameters
[in]trpa pointer to a thread reference object
[in]timeoutthe number of ticks before the operation timeouts, the following special values are allowed:
  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns
The wake up message.
Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 907 of file ch.c.

References chDbgAssert, chSchGoSleepTimeoutS(), MSG_TIMEOUT, nil, NIL_STATE_SUSPENDED, and TIME_IMMEDIATE.

Here is the call graph for this function:

◆ chThdResumeI()

void chThdResumeI ( thread_reference_t * trp,
msg_t msg )

Wakes up a thread waiting on a thread reference object.

Note
This function must not reschedule because it can be called from ISR context.
Parameters
[in]trpa pointer to a thread reference object
[in]msgthe message code
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 930 of file ch.c.

References chDbgAssert, chSchReadyI(), and NIL_THD_IS_SUSPENDED.

Here is the call graph for this function:

◆ chThdResume()

void chThdResume ( thread_reference_t * trp,
msg_t msg )

Wakes up a thread waiting on a thread reference object.

Note
This function must reschedule, it can only be called from thread context.
Parameters
[in]trpa pointer to a thread reference object
[in]msgthe message code
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 952 of file ch.c.

References chSysLock, chSysUnlock, and chThdResumeS.

◆ chThdSleep()

void chThdSleep ( sysinterval_t timeout)

Suspends the invoking thread for the specified time.

Parameters
[in]timeoutthe delay in system ticks
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 966 of file ch.c.

References chSysLock, chSysUnlock, and chThdSleepS.

◆ chThdSleepUntil()

void chThdSleepUntil ( systime_t abstime)

Suspends the invoking thread until the system time arrives to the specified value.

Parameters
[in]abstimeabsolute system time
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 981 of file ch.c.

References chSysLock, chSysUnlock, and chThdSleepUntilS.

◆ chThdEnqueueTimeoutS()

msg_t chThdEnqueueTimeoutS ( threads_queue_t * tqp,
sysinterval_t timeout )

Enqueues the caller thread on a threads queue object.

The caller thread is enqueued and put to sleep until it is dequeued or the specified timeouts expires.

Parameters
[in]tqppointer to a threads_queue_t structure
[in]timeoutthe timeout in system ticks, the special values are handled as follow:
  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns
The message from osalQueueWakeupOneI() or osalQueueWakeupAllI() functions.
Return values
MSG_TIMEOUTif the thread has not been dequeued within the specified timeout or if the function has been invoked with TIME_IMMEDIATE as timeout specification.
Function Class:
This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 1008 of file ch.c.

References chDbgAssert, chDbgCheck, chDbgCheckClassS(), chSchGoSleepTimeoutS(), MSG_TIMEOUT, nil, NIL_STATE_WTQUEUE, and TIME_IMMEDIATE.

Here is the call graph for this function:

◆ chThdDoDequeueNextI()

void chThdDoDequeueNextI ( threads_queue_t * tqp,
msg_t msg )

Dequeues and wakes up one thread from the threads queue object.

Dequeues one thread from the queue without checking if the queue is empty.

Precondition
The queue must contain at least an object.
Parameters
[in]tqppointer to a threads_queue_t structure
[in]msgthe message code
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1035 of file ch.c.

References chDbgAssert, chSchReadyI(), nil_find_thread(), and NIL_STATE_WTQUEUE.

Referenced by chThdDequeueNextI().

Here is the call graph for this function:

◆ chThdDequeueNextI()

void chThdDequeueNextI ( threads_queue_t * tqp,
msg_t msg )

Dequeues and wakes up one thread from the threads queue object, if any.

Parameters
[in]tqppointer to a threads_queue_t structure
[in]msgthe message code
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1057 of file ch.c.

References chDbgCheck, chDbgCheckClassI(), and chThdDoDequeueNextI().

Here is the call graph for this function:

◆ chThdDequeueAllI()

void chThdDequeueAllI ( threads_queue_t * tqp,
msg_t msg )

Dequeues and wakes up all threads from the threads queue object.

Parameters
[in]tqppointer to a threads_queue_t structure
[in]msgthe message code
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1075 of file ch.c.

References chDbgCheck, chDbgCheckClassI(), and nil_ready_all().

Here is the call graph for this function:

Variable Documentation

◆ nil