ChibiOS/NIL
3.2.2
|
![]() |
Macros | |
#define | _CHIBIOS_NIL_ |
ChibiOS/NIL identification macro. More... | |
#define | CH_KERNEL_STABLE 1 |
Stable release flag. More... | |
#define | CH_CFG_USE_FACTORY TRUE |
Objects Factory APIs. More... | |
#define | CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 |
Maximum length for object names. More... | |
#define | CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE |
Enables the registry of generic objects. More... | |
#define | CH_CFG_FACTORY_GENERIC_BUFFERS TRUE |
Enables factory for generic buffers. More... | |
#define | CH_CFG_FACTORY_SEMAPHORES TRUE |
Enables factory for semaphores. More... | |
#define | CH_CFG_FACTORY_MAILBOXES TRUE |
Enables factory for mailboxes. More... | |
#define | CH_CFG_FACTORY_OBJ_FIFOS TRUE |
Enables factory for objects FIFOs. More... | |
#define | THD_IDLE_BASE (&__main_thread_stack_base__) |
#define | __CH_STRINGIFY(a) #a |
Utility to make the parameter a quoted string. More... | |
ChibiOS/NIL version identification | |
#define | CH_KERNEL_VERSION "3.2.2" |
Kernel version string. More... | |
#define | CH_KERNEL_MAJOR 3 |
Kernel version major number. More... | |
#define | CH_KERNEL_MINOR 2 |
Kernel version minor number. More... | |
#define | CH_KERNEL_PATCH 2 |
Kernel version patch number. More... | |
Constants for configuration options | |
#define | FALSE 0 |
Generic 'false' preprocessor boolean constant. More... | |
#define | TRUE 1 |
Generic 'true' preprocessor boolean constant. More... | |
Wakeup messages | |
#define | MSG_OK (msg_t)0 |
OK wakeup message. More... | |
#define | MSG_TIMEOUT (msg_t)-1 |
Wake-up caused by a timeout condition. More... | |
#define | MSG_RESET (msg_t)-2 |
Wake-up caused by a reset condition. More... | |
Special time constants | |
#define | TIME_IMMEDIATE ((sysinterval_t)-1) |
Zero time specification for some functions with a timeout specification. More... | |
#define | TIME_INFINITE ((sysinterval_t)0) |
Infinite time specification for all functions with a timeout specification. More... | |
#define | TIME_MAX_INTERVAL ((sysinterval_t)-2) |
Maximum interval constant usable as timeout. More... | |
#define | TIME_MAX_SYSTIME ((systime_t)-1) |
Maximum system of system time before it wraps. More... | |
Thread state related macros | |
#define | NIL_STATE_READY (tstate_t)0 |
Thread ready or executing. More... | |
#define | NIL_STATE_SLEEPING (tstate_t)1 |
Thread sleeping. More... | |
#define | NIL_STATE_SUSP (tstate_t)2 |
Thread suspended. More... | |
#define | NIL_STATE_WTQUEUE (tstate_t)3 |
On queue or semaph. More... | |
#define | NIL_STATE_WTOREVT (tstate_t)4 |
Waiting for events. More... | |
#define | NIL_THD_IS_READY(tp) ((tp)->state == NIL_STATE_READY) |
#define | NIL_THD_IS_SLEEPING(tp) ((tp)->state == NIL_STATE_SLEEPING) |
#define | NIL_THD_IS_SUSP(tp) ((tp)->state == NIL_STATE_SUSP) |
#define | NIL_THD_IS_WTQUEUE(tp) ((tp)->state == NIL_STATE_WTQUEUE) |
#define | NIL_THD_IS_WTOREVT(tp) ((tp)->state == NIL_STATE_WTOREVT) |
Events related macros | |
#define | ALL_EVENTS ((eventmask_t)-1) |
All events allowed mask. More... | |
#define | EVENT_MASK(eid) ((eventmask_t)(1 << (eid))) |
Returns an event mask from an event identifier. More... | |
Threads tables definition macros | |
#define | THD_TABLE_BEGIN const thread_config_t nil_thd_configs[CH_CFG_NUM_THREADS + 1] = { |
Start of user threads table. More... | |
#define | THD_TABLE_ENTRY(wap, name, funcp, arg) |
Entry of user threads table. More... | |
#define | THD_TABLE_END |
End of user threads table. More... | |
Memory alignment support macros | |
#define | MEM_ALIGN_MASK(a) ((size_t)(a) - 1U) |
Alignment mask constant. More... | |
#define | MEM_ALIGN_PREV(p, a) ((size_t)(p) & ~MEM_ALIGN_MASK(a)) |
Aligns to the previous aligned memory address. More... | |
#define | MEM_ALIGN_NEXT(p, a) |
Aligns to the new aligned memory address. More... | |
#define | MEM_IS_ALIGNED(p, a) (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U) |
Returns whatever a pointer or memory size is aligned. More... | |
#define | MEM_IS_VALID_ALIGNMENT(a) (((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U)) |
Returns whatever a constant is a valid alignment. More... | |
Working Areas | |
#define | THD_WORKING_AREA_SIZE(n) |
Calculates the total Working Area size. More... | |
#define | THD_WORKING_AREA(s, n) PORT_WORKING_AREA(s, n) |
Static working area allocation. More... | |
Threads abstraction macros | |
#define | THD_FUNCTION(tname, arg) PORT_THD_FUNCTION(tname, arg) |
Thread declaration macro. More... | |
ISRs abstraction macros | |
#define | CH_IRQ_IS_VALID_PRIORITY(prio) PORT_IRQ_IS_VALID_PRIORITY(prio) |
Priority level validation macro. More... | |
#define | CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) PORT_IRQ_IS_VALID_KERNEL_PRIORITY(prio) |
Priority level validation macro. More... | |
#define | CH_IRQ_PROLOGUE() |
IRQ handler enter code. More... | |
#define | CH_IRQ_EPILOGUE() |
IRQ handler exit code. More... | |
#define | CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id) |
Standard normal IRQ handler declaration. More... | |
Fast ISRs abstraction macros | |
#define | CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id) |
Standard fast IRQ handler declaration. More... | |
Time conversion utilities | |
#define | TIME_S2I(secs) ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)CH_CFG_ST_FREQUENCY)) |
Seconds to time interval. More... | |
#define | TIME_MS2I(msecs) |
Milliseconds to time interval. More... | |
#define | TIME_US2I(usecs) |
Microseconds to time interval. More... | |
#define | TIME_I2S(interval) |
Time interval to seconds. More... | |
#define | TIME_I2MS(interval) |
Time interval to milliseconds. More... | |
#define | TIME_I2US(interval) |
Time interval to microseconds. More... | |
Threads queues | |
#define | _THREADS_QUEUE_DATA(name) {(cnt_t)0} |
Data part of a static threads queue object initializer. More... | |
#define | _THREADS_QUEUE_DECL(name) threads_queue_t name = _THREADS_QUEUE_DATA(name) |
Static threads queue object initializer. More... | |
Semaphores macros | |
#define | _SEMAPHORE_DATA(name, n) {n} |
Data part of a static semaphore initializer. More... | |
#define | SEMAPHORE_DECL(name, n) semaphore_t name = _SEMAPHORE_DATA(name, n) |
Static semaphore initializer. More... | |
Macro Functions | |
#define | chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value() |
Returns the current value of the system real time counter. More... | |
#define | chSysDisable() |
Raises the system interrupt priority mask to the maximum level. More... | |
#define | chSysSuspend() |
Raises the system interrupt priority mask to system level. More... | |
#define | chSysEnable() |
Lowers the system interrupt priority mask to user level. More... | |
#define | chSysLock() |
Enters the kernel lock state. More... | |
#define | chSysUnlock() |
Leaves the kernel lock state. More... | |
#define | chSysLockFromISR() |
Enters the kernel lock state from within an interrupt handler. More... | |
#define | chSysUnlockFromISR() |
Leaves the kernel lock state from within an interrupt handler. More... | |
#define | chSchIsRescRequiredI() ((bool)(nil.current != nil.next)) |
Evaluates if a reschedule is required. More... | |
#define | chThdGetSelfX() nil.current |
Returns a pointer to the current thread_t . More... | |
#define | chThdSleepSeconds(secs) chThdSleep(TIME_S2I(secs)) |
Delays the invoking thread for the specified number of seconds. More... | |
#define | chThdSleepMilliseconds(msecs) chThdSleep(TIME_MS2I(msecs)) |
Delays the invoking thread for the specified number of milliseconds. More... | |
#define | chThdSleepMicroseconds(usecs) chThdSleep(TIME_US2I(usecs)) |
Delays the invoking thread for the specified number of microseconds. More... | |
#define | chThdSleepS(timeout) (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout) |
Suspends the invoking thread for the specified time. More... | |
#define | chThdSleepUntilS(abstime) |
Suspends the invoking thread until the system time arrives to the specified value. More... | |
#define | chThdQueueObjectInit(tqp) ((tqp)->cnt = (cnt_t)0) |
Initializes a threads queue object. More... | |
#define | chThdQueueIsEmptyI(tqp) ((bool)(tqp->cnt >= (cnt_t)0)) |
Evaluates to true if the specified queue is empty. More... | |
#define | chSemObjectInit(sp, n) ((sp)->cnt = (n)) |
Initializes a semaphore with the specified counter value. More... | |
#define | chSemWait(sp) chSemWaitTimeout(sp, TIME_INFINITE) |
Performs a wait operation on a semaphore. More... | |
#define | chSemWaitS(sp) chSemWaitTimeoutS(sp, TIME_INFINITE) |
Performs a wait operation on a semaphore. More... | |
#define | chSemFastWaitI(sp) ((sp)->cnt--) |
Decreases the semaphore counter. More... | |
#define | chSemFastSignalI(sp) ((sp)->cnt++) |
Increases the semaphore counter. More... | |
#define | chSemGetCounterI(sp) ((sp)->cnt) |
Returns the semaphore counter current value. More... | |
#define | chVTGetSystemTimeX() (nil.systime) |
Current system time. More... | |
#define | chVTTimeElapsedSinceX(start) chTimeDiffX((start), chVTGetSystemTimeX()) |
Returns the elapsed time since the specified start time. More... | |
#define | chTimeAddX(systime, interval) ((systime_t)(systime) + (systime_t)(interval)) |
Adds an interval to a system time returning a system time. More... | |
#define | chTimeDiffX(start, end) ((sysinterval_t)((systime_t)((systime_t)(end) - (systime_t)(start)))) |
Subtracts two system times returning an interval. More... | |
#define | chTimeIsInRangeX(time, start, end) |
Checks if the specified time is within the specified time range. More... | |
#define | chDbgCheck(c) |
Function parameters check. More... | |
#define | chDbgAssert(c, r) |
Condition assertion. More... | |
Typedefs | |
typedef uint32_t | systime_t |
Type of system time. More... | |
typedef uint32_t | sysinterval_t |
Type of time interval. More... | |
typedef uint64_t | time_conv_t |
Type of time conversion variable. More... | |
typedef struct nil_thread | thread_t |
Type of a structure representing a thread. More... | |
typedef struct nil_threads_queue | threads_queue_t |
Type of a queue of threads. More... | |
typedef threads_queue_t | semaphore_t |
Type of a structure representing a semaphore. More... | |
typedef void(* | tfunc_t) (void *p) |
Thread function. More... | |
typedef struct nil_thread_cfg | thread_config_t |
Type of a structure representing a thread static configuration. More... | |
typedef thread_t * | thread_reference_t |
Type of a thread reference. More... | |
typedef struct nil_system | nil_system_t |
Type of a structure representing the system. More... | |
Data Structures | |
struct | nil_threads_queue |
Structure representing a queue of threads. More... | |
struct | nil_thread_cfg |
Structure representing a thread static configuration. More... | |
struct | nil_thread |
Structure representing a thread. More... | |
struct | nil_system |
System data structure. More... | |
Functions | |
static 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. More... | |
static 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. More... | |
void | _dbg_check_disable (void) |
Guard code for chSysDisable() . More... | |
void | _dbg_check_suspend (void) |
Guard code for chSysSuspend() . More... | |
void | _dbg_check_enable (void) |
Guard code for chSysEnable() . More... | |
void | _dbg_check_lock (void) |
Guard code for chSysLock() . More... | |
void | _dbg_check_unlock (void) |
Guard code for chSysUnlock() . More... | |
void | _dbg_check_lock_from_isr (void) |
Guard code for chSysLockFromIsr() . More... | |
void | _dbg_check_unlock_from_isr (void) |
Guard code for chSysUnlockFromIsr() . More... | |
void | _dbg_check_enter_isr (void) |
Guard code for CH_IRQ_PROLOGUE() . More... | |
void | _dbg_check_leave_isr (void) |
Guard code for CH_IRQ_EPILOGUE() . More... | |
void | chDbgCheckClassI (void) |
I-class functions context check. More... | |
void | chDbgCheckClassS (void) |
S-class functions context check. More... | |
void | chSysInit (void) |
Initializes the kernel. More... | |
void | chSysHalt (const char *reason) |
Halts the system. More... | |
void | chSysTimerHandlerI (void) |
Time management handler. More... | |
void | chSysUnconditionalLock (void) |
Unconditionally enters the kernel lock state. More... | |
void | chSysUnconditionalUnlock (void) |
Unconditionally leaves the kernel lock state. More... | |
syssts_t | chSysGetStatusAndLockX (void) |
Returns the execution status and enters a critical zone. More... | |
void | chSysRestoreStatusX (syssts_t sts) |
Restores the specified execution status and leaves a critical zone. More... | |
bool | chSysIsCounterWithinX (rtcnt_t cnt, rtcnt_t start, rtcnt_t end) |
Realtime window test. More... | |
void | chSysPolledDelayX (rtcnt_t cycles) |
Polled delay. More... | |
thread_t * | chSchReadyI (thread_t *tp, msg_t msg) |
Makes the specified thread ready for execution. More... | |
bool | chSchIsPreemptionRequired (void) |
Evaluates if preemption is required. More... | |
void | chSchDoReschedule (void) |
Switches to the first thread on the runnable queue. More... | |
void | chSchRescheduleS (void) |
Reschedules if needed. More... | |
msg_t | chSchGoSleepTimeoutS (tstate_t newstate, sysinterval_t timeout) |
Puts the current thread to sleep into the specified state with timeout specification. More... | |
msg_t | chThdSuspendTimeoutS (thread_reference_t *trp, sysinterval_t timeout) |
Sends the current thread sleeping and sets a reference variable. More... | |
void | chThdResumeI (thread_reference_t *trp, msg_t msg) |
Wakes up a thread waiting on a thread reference object. More... | |
void | chThdResume (thread_reference_t *trp, msg_t msg) |
Wakes up a thread waiting on a thread reference object. More... | |
void | chThdSleep (sysinterval_t timeout) |
Suspends the invoking thread for the specified time. More... | |
void | chThdSleepUntil (systime_t abstime) |
Suspends the invoking thread until the system time arrives to the specified value. More... | |
msg_t | chThdEnqueueTimeoutS (threads_queue_t *tqp, sysinterval_t timeout) |
Enqueues the caller thread on a threads queue object. More... | |
void | chThdDoDequeueNextI (threads_queue_t *tqp, msg_t msg) |
Dequeues and wakes up one thread from the threads queue object. More... | |
void | chThdDequeueNextI (threads_queue_t *tqp, msg_t msg) |
Dequeues and wakes up one thread from the threads queue object, if any. More... | |
void | chThdDequeueAllI (threads_queue_t *tqp, msg_t msg) |
Dequeues and wakes up all threads from the threads queue object. More... | |
msg_t | chSemWaitTimeout (semaphore_t *sp, sysinterval_t timeout) |
Performs a wait operation on a semaphore with timeout specification. More... | |
msg_t | chSemWaitTimeoutS (semaphore_t *sp, sysinterval_t timeout) |
Performs a wait operation on a semaphore with timeout specification. More... | |
void | chSemSignal (semaphore_t *sp) |
Performs a signal operation on a semaphore. More... | |
void | chSemSignalI (semaphore_t *sp) |
Performs a signal operation on a semaphore. More... | |
void | chSemReset (semaphore_t *sp, cnt_t n) |
Performs a reset operation on the semaphore. More... | |
void | chSemResetI (semaphore_t *sp, cnt_t n) |
Performs a reset operation on the semaphore. More... | |
void | chEvtSignal (thread_t *tp, eventmask_t mask) |
Adds a set of event flags directly to the specified thread_t . More... | |
void | chEvtSignalI (thread_t *tp, eventmask_t mask) |
Adds a set of event flags directly to the specified thread_t . More... | |
eventmask_t | chEvtWaitAnyTimeout (eventmask_t mask, sysinterval_t timeout) |
Waits for any of the specified events. More... | |
Variables | |
nil_system_t | nil |
System data structures. More... | |
#define FALSE 0 |
#define TRUE 1 |
#define MSG_OK (msg_t)0 |
OK wakeup message.
Definition at line 100 of file ch.h.
Referenced by chEvtSignalI(), chEvtWaitAnyTimeout(), chFifoSendObject(), chFifoSendObjectAhead(), chFifoSendObjectAheadI(), chFifoSendObjectAheadS(), chFifoSendObjectI(), chFifoSendObjectS(), chGuardedPoolAllocTimeoutS(), chMBFetchI(), chMBFetchTimeoutS(), chMBPostAheadI(), chMBPostAheadTimeoutS(), chMBPostI(), chMBPostTimeoutS(), chPipeReadTimeout(), chPipeWriteTimeout(), chSemSignalI(), and chSemWaitTimeoutS().
#define MSG_TIMEOUT (msg_t)-1 |
Wake-up caused by a timeout condition.
Definition at line 101 of file ch.h.
Referenced by chMBFetchI(), chMBPostAheadI(), chMBPostI(), chSemWaitTimeoutS(), chSysTimerHandlerI(), chThdEnqueueTimeoutS(), and chThdSuspendTimeoutS().
#define MSG_RESET (msg_t)-2 |
Wake-up caused by a reset condition.
Definition at line 104 of file ch.h.
Referenced by chMBFetchI(), chMBFetchTimeoutS(), chMBPostAheadI(), chMBPostAheadTimeoutS(), chMBPostI(), chMBPostTimeoutS(), chMBResetI(), chPipeReset(), and chSemResetI().
#define TIME_IMMEDIATE ((sysinterval_t)-1) |
Zero time specification for some functions with a timeout specification.
TIME_IMMEDIATE
as timeout parameter, see the specific function documentation. Definition at line 119 of file ch.h.
Referenced by chEvtWaitAnyTimeout(), chFifoSendObject(), chFifoSendObjectAhead(), chFifoSendObjectAheadS(), chFifoSendObjectS(), chSemWaitTimeoutS(), chThdEnqueueTimeoutS(), and chThdSuspendTimeoutS().
#define TIME_INFINITE ((sysinterval_t)0) |
Infinite time specification for all functions with a timeout specification.
Definition at line 125 of file ch.h.
Referenced by chSchGoSleepTimeoutS().
#define TIME_MAX_INTERVAL ((sysinterval_t)-2) |
#define TIME_MAX_SYSTIME ((systime_t)-1) |
#define NIL_STATE_READY (tstate_t)0 |
#define NIL_STATE_SUSP (tstate_t)2 |
#define NIL_STATE_WTQUEUE (tstate_t)3 |
On queue or semaph.
Definition at line 147 of file ch.h.
Referenced by chSemSignalI(), chSemWaitTimeoutS(), chThdDoDequeueNextI(), chThdEnqueueTimeoutS(), and nil_ready_all().
#define NIL_STATE_WTOREVT (tstate_t)4 |
#define EVENT_MASK | ( | eid | ) | ((eventmask_t)(1 << (eid))) |
#define CH_CFG_USE_FACTORY TRUE |
#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 |
#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE |
#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE |
#define CH_CFG_FACTORY_SEMAPHORES TRUE |
#define CH_CFG_FACTORY_MAILBOXES TRUE |
#define CH_CFG_FACTORY_OBJ_FIFOS TRUE |
#define THD_IDLE_BASE (&__main_thread_stack_base__) |
Boundaries of the idle thread boundaries, only required if stack checking is enabled.
Definition at line 531 of file ch.h.
Referenced by chSysInit().
#define __CH_STRINGIFY | ( | a | ) | #a |
#define THD_TABLE_BEGIN const thread_config_t nil_thd_configs[CH_CFG_NUM_THREADS + 1] = { |
#define THD_TABLE_ENTRY | ( | wap, | |
name, | |||
funcp, | |||
arg | |||
) |
#define THD_TABLE_END |
End of user threads table.
#define MEM_ALIGN_MASK | ( | a | ) | ((size_t)(a) - 1U) |
#define MEM_ALIGN_PREV | ( | p, | |
a | |||
) | ((size_t)(p) & ~MEM_ALIGN_MASK(a)) |
#define MEM_ALIGN_NEXT | ( | p, | |
a | |||
) |
Aligns to the new aligned memory address.
[in] | p | variable to be aligned |
[in] | a | alignment, must be a power of two |
Definition at line 781 of file ch.h.
Referenced by chCoreAllocAlignedWithOffsetI(), chHeapAllocAligned(), chHeapFree(), and chHeapObjectInit().
#define MEM_IS_ALIGNED | ( | p, | |
a | |||
) | (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U) |
Returns whatever a pointer or memory size is aligned.
[in] | p | variable to be aligned |
[in] | a | alignment, must be a power of two |
Definition at line 790 of file ch.h.
Referenced by chHeapFree(), chPoolAllocI(), and chPoolFreeI().
#define MEM_IS_VALID_ALIGNMENT | ( | a | ) | (((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.
[in] | a | alignment to be checked, must be a constant |
Definition at line 798 of file ch.h.
Referenced by chCoreAllocAlignedWithOffsetI(), chHeapAllocAligned(), and chPoolObjectInitAligned().
#define THD_WORKING_AREA_SIZE | ( | n | ) |
Calculates the total Working Area size.
[in] | n | the stack size to be assigned to the thread |
#define THD_WORKING_AREA | ( | s, | |
n | |||
) | PORT_WORKING_AREA(s, n) |
Static working area allocation.
This macro is used to allocate a static thread working area aligned as both position and size.
[in] | s | the name to be assigned to the stack array |
[in] | n | the stack size to be assigned to the thread |
#define THD_FUNCTION | ( | tname, | |
arg | |||
) | PORT_THD_FUNCTION(tname, arg) |
#define CH_IRQ_IS_VALID_PRIORITY | ( | prio | ) | PORT_IRQ_IS_VALID_PRIORITY(prio) |
Priority level validation macro.
This macro determines if the passed value is a valid priority level for the underlying architecture.
[in] | prio | the priority level |
false | if the priority is invalid or if the architecture does not support priorities. |
true | if the priority is valid. |
#define CH_IRQ_IS_VALID_KERNEL_PRIORITY | ( | prio | ) | PORT_IRQ_IS_VALID_KERNEL_PRIORITY(prio) |
Priority level validation macro.
This macro determines if the passed value is a valid priority level that cannot preempt the kernel critical zone.
[in] | prio | the priority level |
false | if the priority is invalid or if the architecture does not support priorities. |
true | if the priority is valid. |
#define CH_IRQ_PROLOGUE | ( | ) |
IRQ handler enter code.
#define CH_IRQ_EPILOGUE | ( | ) |
IRQ handler exit code.
#define CH_IRQ_HANDLER | ( | id | ) | PORT_IRQ_HANDLER(id) |
#define CH_FAST_IRQ_HANDLER | ( | id | ) | PORT_FAST_IRQ_HANDLER(id) |
#define TIME_S2I | ( | secs | ) | ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)CH_CFG_ST_FREQUENCY)) |
Seconds to time interval.
Converts from seconds to system ticks number.
[in] | secs | number of seconds |
#define TIME_MS2I | ( | msecs | ) |
Milliseconds to time interval.
Converts from milliseconds to system ticks number.
[in] | msecs | number of milliseconds |
#define TIME_US2I | ( | usecs | ) |
Microseconds to time interval.
Converts from microseconds to system ticks number.
[in] | usecs | number of microseconds |
#define TIME_I2S | ( | interval | ) |
Time interval to seconds.
Converts from system ticks number to seconds.
[in] | interval | interval in ticks |
#define TIME_I2MS | ( | interval | ) |
Time interval to milliseconds.
Converts from system ticks number to milliseconds.
[in] | interval | interval in ticks |
#define TIME_I2US | ( | interval | ) |
Time interval to microseconds.
Converts from system ticks number to microseconds.
[in] | interval | interval in ticks |
#define _THREADS_QUEUE_DATA | ( | name | ) | {(cnt_t)0} |
#define _THREADS_QUEUE_DECL | ( | name | ) | threads_queue_t name = _THREADS_QUEUE_DATA(name) |
#define _SEMAPHORE_DATA | ( | name, | |
n | |||
) | {n} |
Data part of a static semaphore initializer.
This macro should be used when statically initializing a semaphore that is part of a bigger structure.
[in] | name | the name of the semaphore variable |
[in] | n | the counter initial value, this value must be non-negative |
#define SEMAPHORE_DECL | ( | name, | |
n | |||
) | semaphore_t name = _SEMAPHORE_DATA(name, n) |
#define chSysGetRealtimeCounterX | ( | ) | (rtcnt_t)port_rt_get_counter_value() |
Returns the current value of the system real time counter.
PORT_SUPPORTS_RT
.Definition at line 1100 of file ch.h.
Referenced by chSysPolledDelayX().
#define chSysDisable | ( | ) |
Raises the system interrupt priority mask to the maximum level.
All the maskable interrupt sources are disabled regardless their hardware priority.
#define chSysSuspend | ( | ) |
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.
chSysLock()
, the chSysLock()
could do more than just disable the interrupts.Definition at line 1127 of file ch.h.
Referenced by chSysInit().
#define chSysEnable | ( | ) |
Lowers the system interrupt priority mask to user level.
All the interrupt sources are enabled.
chSysUnlock()
, the chSysUnlock()
could do more than just enable the interrupts.#define chSysLock | ( | ) |
Enters the kernel lock state.
Definition at line 1151 of file ch.h.
Referenced by chBSemSignal(), chCoreAllocAligned(), chCoreAllocAlignedWithOffset(), chEvtSignal(), chEvtWaitAnyTimeout(), chGuardedPoolAllocTimeout(), chGuardedPoolFree(), chMBFetchTimeout(), chMBPostAheadTimeout(), chMBPostTimeout(), chMBReset(), chPipeReadTimeout(), chPipeReset(), chPipeWriteTimeout(), chPoolAlloc(), chPoolFree(), chSemReset(), chSemSignal(), chSemWaitTimeout(), chSysGetStatusAndLockX(), chSysUnconditionalLock(), chThdResume(), chThdSleep(), and chThdSleepUntil().
#define chSysUnlock | ( | ) |
Leaves the kernel lock state.
Definition at line 1161 of file ch.h.
Referenced by chBSemSignal(), chCoreAllocAligned(), chCoreAllocAlignedWithOffset(), chEvtSignal(), chEvtWaitAnyTimeout(), chGuardedPoolAllocTimeout(), chGuardedPoolFree(), chMBFetchTimeout(), chMBPostAheadTimeout(), chMBPostTimeout(), chMBReset(), chPipeReadTimeout(), chPipeReset(), chPipeWriteTimeout(), chPoolAlloc(), chPoolFree(), chSemReset(), chSemSignal(), chSemWaitTimeout(), chSysInit(), chSysRestoreStatusX(), chSysUnconditionalUnlock(), chThdResume(), chThdSleep(), and chThdSleepUntil().
#define chSysLockFromISR | ( | ) |
Enters the kernel lock state from within an interrupt handler.
Definition at line 1178 of file ch.h.
Referenced by chSysGetStatusAndLockX(), and chSysTimerHandlerI().
#define chSysUnlockFromISR | ( | ) |
Leaves the kernel lock state from within an interrupt handler.
Definition at line 1196 of file ch.h.
Referenced by chSysRestoreStatusX(), and chSysTimerHandlerI().
#define chSchIsRescRequiredI | ( | ) | ((bool)(nil.current != nil.next)) |
Evaluates if a reschedule is required.
true | if there is a thread that must go in running state immediately. |
false | if preemption is not required. |
Definition at line 1210 of file ch.h.
Referenced by chSchIsPreemptionRequired(), and chSchRescheduleS().
#define chThdGetSelfX | ( | ) | nil.current |
#define chThdSleepSeconds | ( | secs | ) | chThdSleep(TIME_S2I(secs)) |
Delays the invoking thread for the specified number of seconds.
[in] | secs | time in seconds, must be different from zero |
#define chThdSleepMilliseconds | ( | msecs | ) | chThdSleep(TIME_MS2I(msecs)) |
Delays the invoking thread for the specified number of milliseconds.
[in] | msecs | time in milliseconds, must be different from zero |
#define chThdSleepMicroseconds | ( | usecs | ) | chThdSleep(TIME_US2I(usecs)) |
Delays the invoking thread for the specified number of microseconds.
[in] | usecs | time in microseconds, must be different from zero |
#define chThdSleepS | ( | timeout | ) | (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout) |
Suspends the invoking thread for the specified time.
[in] | timeout | the delay in system ticks |
Definition at line 1264 of file ch.h.
Referenced by chThdSleep().
#define chThdSleepUntilS | ( | abstime | ) |
Suspends the invoking thread until the system time arrives to the specified value.
[in] | abstime | absolute system time |
Definition at line 1275 of file ch.h.
Referenced by chThdSleepUntil().
#define chThdQueueObjectInit | ( | tqp | ) | ((tqp)->cnt = (cnt_t)0) |
Initializes a threads queue object.
[out] | tqp | pointer to the threads queue object |
Definition at line 1286 of file ch.h.
Referenced by chMBObjectInit().
#define chThdQueueIsEmptyI | ( | tqp | ) | ((bool)(tqp->cnt >= (cnt_t)0)) |
Evaluates to true
if the specified queue is empty.
[out] | tqp | pointer to the threads queue object |
false | if the queue is not empty. |
true | if the queue is empty. |
#define chSemObjectInit | ( | sp, | |
n | |||
) | ((sp)->cnt = (n)) |
Initializes a semaphore with the specified counter value.
[out] | sp | pointer to a semaphore_t structure |
[in] | n | initial value of the semaphore counter. Must be non-negative. |
Definition at line 1310 of file ch.h.
Referenced by _factory_init(), _heap_init(), chBSemObjectInit(), chFactoryCreateSemaphore(), chGuardedPoolObjectInitAligned(), and chHeapObjectInit().
#define chSemWait | ( | sp | ) | chSemWaitTimeout(sp, TIME_INFINITE) |
Performs a wait operation on a semaphore.
[in] | sp | pointer to a semaphore_t structure |
CH_MSG_OK | if the thread has not stopped on the semaphore or the semaphore has been signaled. |
CH_MSG_RST | if the semaphore has been reset using chSemReset() . |
Definition at line 1324 of file ch.h.
Referenced by chBSemWait().
#define chSemWaitS | ( | sp | ) | chSemWaitTimeoutS(sp, TIME_INFINITE) |
Performs a wait operation on a semaphore.
[in] | sp | pointer to a semaphore_t structure |
CH_MSG_OK | if the thread has not stopped on the semaphore or the semaphore has been signaled. |
CH_MSG_RST | if the semaphore has been reset using chSemReset() . |
Definition at line 1338 of file ch.h.
Referenced by chBSemWaitS().
#define chSemFastWaitI | ( | sp | ) | ((sp)->cnt--) |
Decreases the semaphore counter.
This macro can be used when the counter is known to be positive.
[in] | sp | pointer to a semaphore_t structure |
Definition at line 1348 of file ch.h.
Referenced by chGuardedPoolAllocI().
#define chSemFastSignalI | ( | sp | ) | ((sp)->cnt++) |
Increases the semaphore counter.
This macro can be used when the counter is known to be not negative.
[in] | sp | pointer to a semaphore_t structure |
#define chSemGetCounterI | ( | sp | ) | ((sp)->cnt) |
Returns the semaphore counter current value.
Definition at line 1366 of file ch.h.
Referenced by chGuardedPoolAllocI(), and chGuardedPoolGetCounterI().
#define chVTGetSystemTimeX | ( | ) | (nil.systime) |
Current system time.
Returns the number of system ticks since the chSysInit()
invocation.
systime_t
size.Definition at line 1383 of file ch.h.
Referenced by chSchGoSleepTimeoutS().
#define chVTTimeElapsedSinceX | ( | start | ) | chTimeDiffX((start), chVTGetSystemTimeX()) |
Adds an interval to a system time returning a system time.
[in] | systime | base system time |
[in] | interval | interval to be added |
Definition at line 1408 of file ch.h.
Referenced by chSchGoSleepTimeoutS(), and chSysTimerHandlerI().
#define chTimeDiffX | ( | start, | |
end | |||
) | ((sysinterval_t)((systime_t)((systime_t)(end) - (systime_t)(start)))) |
Subtracts two system times returning an interval.
[in] | start | first system time |
[in] | end | second system time |
Definition at line 1420 of file ch.h.
Referenced by chSysTimerHandlerI().
#define chTimeIsInRangeX | ( | time, | |
start, | |||
end | |||
) |
Checks if the specified time is within the specified time range.
[in] | time | the time to be verified |
[in] | start | the start of the time window (inclusive) |
[in] | end | the end of the time window (non inclusive) |
true | current time within the specified time window. |
false | current time not within the specified time window. |
Definition at line 1436 of file ch.h.
Referenced by chSchGoSleepTimeoutS().
#define chDbgCheck | ( | c | ) |
Function parameters check.
If the condition check fails then the kernel panics and halts.
CH_DBG_ENABLE_CHECKS
switch is specified in chconf.h
else the macro does nothing.[in] | c | the condition to be verified to be true |
Definition at line 1451 of file ch.h.
Referenced by chCoreAllocAlignedWithOffsetI(), chEvtSignalI(), chFifoObjectInitAligned(), chGuardedPoolLoadArray(), chHeapAllocAligned(), chHeapFree(), chHeapObjectInit(), chMBFetchI(), chMBFetchTimeoutS(), chMBObjectInit(), chMBPostAheadI(), chMBPostAheadTimeoutS(), chMBPostI(), chMBPostTimeoutS(), chMBResetI(), chPipeObjectInit(), chPipeReadTimeout(), chPipeReset(), chPipeWriteTimeout(), chPoolAllocI(), chPoolFreeI(), chPoolLoadArray(), chPoolObjectInitAligned(), chSchReadyI(), chSemResetI(), chSemSignalI(), chSemWaitTimeoutS(), chThdDequeueAllI(), chThdDequeueNextI(), and chThdEnqueueTimeoutS().
#define chDbgAssert | ( | c, | |
r | |||
) |
Condition assertion.
If the condition check fails then the kernel panics with a message and halts.
CH_DBG_ENABLE_ASSERTS
switch is specified in chconf.h
else the macro does nothing. [in] | c | the condition to be verified to be true |
[in] | r | a remark string |
Definition at line 1477 of file ch.h.
Referenced by chFifoSendObject(), chFifoSendObjectAhead(), chFifoSendObjectAheadI(), chFifoSendObjectAheadS(), chFifoSendObjectI(), chFifoSendObjectS(), chGuardedPoolAllocI(), chHeapFree(), chPoolAllocI(), chSchGoSleepTimeoutS(), chSchReadyI(), chSysTimerHandlerI(), chThdDoDequeueNextI(), chThdEnqueueTimeoutS(), chThdResumeI(), chThdSuspendTimeoutS(), nil_find_thread(), and nil_ready_all().
typedef uint32_t systime_t |
typedef uint32_t sysinterval_t |
typedef uint64_t time_conv_t |
typedef struct nil_thread thread_t |
typedef struct nil_threads_queue threads_queue_t |
typedef threads_queue_t semaphore_t |
typedef struct nil_thread_cfg thread_config_t |
typedef thread_t* thread_reference_t |
typedef struct nil_system nil_system_t |
|
static |
Retrieves the highest priority thread in the specified state and associated to the specified object.
[in] | state | thread state |
[in] | p | object pointer |
Definition at line 60 of file ch.c.
References CH_CFG_NUM_THREADS, chDbgAssert, nil_thread::p, nil_thread::state, and nil_system::threads.
Referenced by chSemSignalI(), and chThdDoDequeueNextI().
|
static |
Puts in ready state all thread matching the specified status and associated object.
[in] | p | object pointer |
[in] | cnt | number of threads to be readied as a negative number, non negative numbers are ignored |
[in] | msg | the wakeup message |
Definition at line 85 of file ch.c.
References CH_CFG_NUM_THREADS, chDbgAssert, chSchReadyI(), NIL_STATE_WTQUEUE, nil_thread::p, nil_thread::state, and nil_system::threads.
Referenced by chSemResetI(), and chThdDequeueAllI().
void _dbg_check_disable | ( | void | ) |
Guard code for chSysDisable()
.
Definition at line 118 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
void _dbg_check_suspend | ( | void | ) |
Guard code for chSysSuspend()
.
Definition at line 130 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
void _dbg_check_enable | ( | void | ) |
Guard code for chSysEnable()
.
Definition at line 142 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
void _dbg_check_lock | ( | void | ) |
Guard code for chSysLock()
.
Definition at line 154 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
void _dbg_check_unlock | ( | void | ) |
Guard code for chSysUnlock()
.
Definition at line 167 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
void _dbg_check_lock_from_isr | ( | void | ) |
Guard code for chSysLockFromIsr()
.
Definition at line 180 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
void _dbg_check_unlock_from_isr | ( | void | ) |
Guard code for chSysUnlockFromIsr()
.
Definition at line 193 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
void _dbg_check_enter_isr | ( | void | ) |
Guard code for CH_IRQ_PROLOGUE()
.
Definition at line 206 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
void _dbg_check_leave_isr | ( | void | ) |
Guard code for CH_IRQ_EPILOGUE()
.
Definition at line 221 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
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.
Definition at line 239 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
Referenced by chBSemGetStateI(), chBSemResetI(), chBSemSignalI(), chCoreAllocAlignedWithOffsetI(), chEvtSignalI(), chMBFetchI(), chMBGetFreeCountI(), chMBGetUsedCountI(), chMBPeekI(), chMBPostAheadI(), chMBPostI(), chMBResetI(), chPoolAllocI(), chPoolFreeI(), chSchReadyI(), chSemResetI(), chSemSignalI(), chSysTimerHandlerI(), chThdDequeueAllI(), and chThdDequeueNextI().
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.
Definition at line 254 of file ch.c.
References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.
Referenced by chBSemWaitS(), chBSemWaitTimeoutS(), chMBFetchTimeoutS(), chMBPostAheadTimeoutS(), chMBPostTimeoutS(), chSchGoSleepTimeoutS(), chSchRescheduleS(), chSemWaitTimeoutS(), and chThdEnqueueTimeoutS().
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.
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.Definition at line 273 of file ch.c.
References _core_init(), _factory_init(), _heap_init(), nil_thread_cfg::arg, CH_CFG_NUM_THREADS, CH_CFG_SYSTEM_INIT_HOOK, CH_CFG_THREAD_EXT_INIT_HOOK, chSysSuspend, chSysUnlock, nil_system::current, nil_thread_cfg::funcp, nil_system::isr_cnt, nil_system::lock_cnt, nil_system::next, THD_IDLE_BASE, nil_system::threads, nil_thread::wabase, nil_thread_cfg::wbase, and nil_thread_cfg::wend.
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.
[in] | reason | pointer to an error string |
Definition at line 354 of file ch.c.
References CH_CFG_SYSTEM_HALT_HOOK, and nil_system::dbg_panic_msg.
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().
void chSysTimerHandlerI | ( | void | ) |
Time management handler.
Definition at line 379 of file ch.c.
References CH_CFG_NUM_THREADS, chDbgAssert, chDbgCheckClassI(), chSchReadyI(), chSysLockFromISR, chSysUnlockFromISR, chTimeAddX, chTimeDiffX, nil_threads_queue::cnt, nil_system::lasttime, MSG_TIMEOUT, nil_system::nexttime, nil_thread::semp, nil_system::systime, nil_system::threads, nil_thread::timeout, nil_thread::tqp, and nil_thread::trp.
void chSysUnconditionalLock | ( | void | ) |
void chSysUnconditionalUnlock | ( | void | ) |
Unconditionally leaves the kernel lock state.
Definition at line 493 of file ch.c.
References chSysUnlock.
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.
Definition at line 513 of file ch.c.
References chSysLock, and chSysLockFromISR.
void chSysRestoreStatusX | ( | syssts_t | sts | ) |
Restores the specified execution status and leaves a critical zone.
chSchRescheduleS()
is automatically performed if exiting the critical zone and if not in ISR context.[in] | sts | the system status to be restored. |
Definition at line 536 of file ch.c.
References chSchRescheduleS(), chSysUnlock, and chSysUnlockFromISR.
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.
PORT_SUPPORTS_RT
.[in] | cnt | the counter value to be tested |
[in] | start | the start of the time window (inclusive) |
[in] | end | the end of the time window (non inclusive) |
true | current time within the specified time window. |
false | current time not within the specified time window. |
Definition at line 568 of file ch.c.
Referenced by chSysPolledDelayX().
void chSysPolledDelayX | ( | rtcnt_t | cycles | ) |
Polled delay.
PORT_SUPPORTS_RT
.[in] | cycles | number of cycles |
Definition at line 585 of file ch.c.
References chSysGetRealtimeCounterX, and chSysIsCounterWithinX().
Makes the specified thread ready for execution.
[in] | tp | pointer to the thread_t object |
[in] | msg | the wakeup message |
Definition at line 602 of file ch.c.
References CH_CFG_NUM_THREADS, chDbgAssert, chDbgCheck, chDbgCheckClassI(), nil_system::current, nil_thread::msg, nil_system::next, NIL_STATE_READY, nil_thread::state, nil_system::threads, and nil_thread::timeout.
Referenced by chEvtSignalI(), chSemSignalI(), chSysTimerHandlerI(), chThdDoDequeueNextI(), chThdResumeI(), and nil_ready_all().
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.
true | if there is a thread that must go in running state immediately. |
false | if preemption is not required. |
Definition at line 631 of file ch.c.
References chSchIsRescRequiredI.
void chSchDoReschedule | ( | void | ) |
Switches to the first thread on the runnable queue.
Definition at line 643 of file ch.c.
References CH_CFG_IDLE_LEAVE_HOOK, CH_CFG_NUM_THREADS, nil_system::current, nil_system::next, and nil_system::threads.
Referenced by chSchRescheduleS().
void chSchRescheduleS | ( | void | ) |
Reschedules if needed.
Definition at line 658 of file ch.c.
References chDbgCheckClassS(), chSchDoReschedule(), and chSchIsRescRequiredI.
Referenced by chBSemSignal(), chEvtSignal(), chGuardedPoolFree(), chGuardedPoolFreeS(), chMBFetchTimeoutS(), chMBPostAheadTimeoutS(), chMBPostTimeoutS(), chMBReset(), chPipeReset(), chSemReset(), chSemSignal(), chSysRestoreStatusX(), and chThdResume().
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 NIL_MSG_TMO
low level message.
[in] | newstate | the new thread state or a semaphore pointer |
[in] | timeout | the number of ticks before the operation timeouts. the following special values are allowed:
|
NIL_MSG_TMO | if a timeout occurred. |
Definition at line 684 of file ch.c.
References CH_CFG_IDLE_ENTER_HOOK, CH_CFG_NUM_THREADS, CH_CFG_ST_TIMEDELTA, chDbgAssert, chDbgCheckClassS(), chTimeAddX, chTimeIsInRangeX, chVTGetSystemTimeX, nil_system::current, nil_system::lasttime, nil_thread::msg, nil_system::next, nil_system::nexttime, nil_thread::state, nil_system::threads, TIME_INFINITE, and nil_thread::timeout.
Referenced by chEvtWaitAnyTimeout(), chSemWaitTimeoutS(), chThdEnqueueTimeoutS(), and chThdSuspendTimeoutS().
msg_t chThdSuspendTimeoutS | ( | thread_reference_t * | trp, |
sysinterval_t | timeout | ||
) |
Sends the current thread sleeping and sets a reference variable.
[in] | trp | a pointer to a thread reference object |
[in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
|
Definition at line 766 of file ch.c.
References chDbgAssert, chSchGoSleepTimeoutS(), nil_system::current, MSG_TIMEOUT, NIL_STATE_SUSP, TIME_IMMEDIATE, and nil_thread::trp.
Referenced by chPipeReadTimeout(), and chPipeWriteTimeout().
void chThdResumeI | ( | thread_reference_t * | trp, |
msg_t | msg | ||
) |
Wakes up a thread waiting on a thread reference object.
[in] | trp | a pointer to a thread reference object |
[in] | msg | the message code |
Definition at line 789 of file ch.c.
References chDbgAssert, and chSchReadyI().
Referenced by chPipeReset(), and chThdResume().
void chThdResume | ( | thread_reference_t * | trp, |
msg_t | msg | ||
) |
Wakes up a thread waiting on a thread reference object.
[in] | trp | a pointer to a thread reference object |
[in] | msg | the message code |
Definition at line 811 of file ch.c.
References chSchRescheduleS(), chSysLock, chSysUnlock, and chThdResumeI().
Referenced by chPipeReadTimeout(), and chPipeWriteTimeout().
void chThdSleep | ( | sysinterval_t | timeout | ) |
Suspends the invoking thread for the specified time.
[in] | timeout | the delay in system ticks |
Definition at line 826 of file ch.c.
References chSysLock, chSysUnlock, and chThdSleepS.
void chThdSleepUntil | ( | systime_t | abstime | ) |
Suspends the invoking thread until the system time arrives to the specified value.
[in] | abstime | absolute system time |
Definition at line 841 of file ch.c.
References chSysLock, chSysUnlock, and chThdSleepUntilS.
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.
[in] | tqp | pointer to the threads queue object |
[in] | timeout | the timeout in system ticks, the special values are handled as follow:
|
osalQueueWakeupOneI()
or osalQueueWakeupAllI()
functions. MSG_TIMEOUT | if the thread has not been dequeued within the specified timeout or if the function has been invoked with TIME_IMMEDIATE as timeout specification. |
Definition at line 868 of file ch.c.
References chDbgAssert, chDbgCheck, chDbgCheckClassS(), chSchGoSleepTimeoutS(), nil_threads_queue::cnt, nil_system::current, MSG_TIMEOUT, NIL_STATE_WTQUEUE, TIME_IMMEDIATE, and nil_thread::tqp.
Referenced by chMBFetchTimeoutS(), chMBPostAheadTimeoutS(), and chMBPostTimeoutS().
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.
[in] | tqp | pointer to the threads queue object |
[in] | msg | the message code |
Definition at line 895 of file ch.c.
References chDbgAssert, chSchReadyI(), nil_threads_queue::cnt, nil_find_thread(), and NIL_STATE_WTQUEUE.
Referenced by chThdDequeueNextI().
void chThdDequeueNextI | ( | threads_queue_t * | tqp, |
msg_t | msg | ||
) |
Dequeues and wakes up one thread from the threads queue object, if any.
[in] | tqp | pointer to the threads queue object |
[in] | msg | the message code |
Definition at line 914 of file ch.c.
References chDbgCheck, chDbgCheckClassI(), chThdDoDequeueNextI(), and nil_threads_queue::cnt.
Referenced by chMBFetchI(), chMBFetchTimeoutS(), chMBPostAheadI(), chMBPostAheadTimeoutS(), chMBPostI(), and chMBPostTimeoutS().
void chThdDequeueAllI | ( | threads_queue_t * | tqp, |
msg_t | msg | ||
) |
Dequeues and wakes up all threads from the threads queue object.
[in] | tqp | pointer to the threads queue object |
[in] | msg | the message code |
Definition at line 932 of file ch.c.
References chDbgCheck, chDbgCheckClassI(), nil_threads_queue::cnt, and nil_ready_all().
Referenced by chMBResetI().
msg_t chSemWaitTimeout | ( | semaphore_t * | sp, |
sysinterval_t | timeout | ||
) |
Performs a wait operation on a semaphore with timeout specification.
[in] | sp | pointer to a semaphore_t structure |
[in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
|
NIL_MSG_OK | if the thread has not stopped on the semaphore or the semaphore has been signaled. |
NIL_MSG_RST | if the semaphore has been reset using chSemReset() . |
NIL_MSG_TMO | if the semaphore has not been signaled or reset within the specified timeout. |
Definition at line 960 of file ch.c.
References chSemWaitTimeoutS(), chSysLock, and chSysUnlock.
Referenced by chBSemWaitTimeout().
msg_t chSemWaitTimeoutS | ( | semaphore_t * | sp, |
sysinterval_t | timeout | ||
) |
Performs a wait operation on a semaphore with timeout specification.
[in] | sp | pointer to a semaphore_t structure |
[in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
|
NIL_MSG_OK | if the thread has not stopped on the semaphore or the semaphore has been signaled. |
NIL_MSG_RST | if the semaphore has been reset using chSemReset() . |
NIL_MSG_TMO | if the semaphore has not been signaled or reset within the specified timeout. |
Definition at line 989 of file ch.c.
References chDbgCheck, chDbgCheckClassS(), chSchGoSleepTimeoutS(), nil_threads_queue::cnt, nil_system::current, MSG_OK, MSG_TIMEOUT, NIL_STATE_WTQUEUE, nil_thread::semp, and TIME_IMMEDIATE.
Referenced by chBSemWaitTimeoutS(), chGuardedPoolAllocTimeoutS(), and chSemWaitTimeout().
void chSemSignal | ( | semaphore_t * | sp | ) |
Performs a signal operation on a semaphore.
[in] | sp | pointer to a semaphore_t structure |
Definition at line 1019 of file ch.c.
References chSchRescheduleS(), chSemSignalI(), chSysLock, and chSysUnlock.
void chSemSignalI | ( | semaphore_t * | sp | ) |
Performs a signal operation on a semaphore.
[in] | sp | pointer to a semaphore_t structure |
Definition at line 1038 of file ch.c.
References chDbgCheck, chDbgCheckClassI(), chSchReadyI(), nil_threads_queue::cnt, MSG_OK, nil_find_thread(), and NIL_STATE_WTQUEUE.
Referenced by chBSemSignalI(), chGuardedPoolFreeI(), and chSemSignal().
void chSemReset | ( | semaphore_t * | sp, |
cnt_t | n | ||
) |
Performs a reset operation on the semaphore.
[in] | sp | pointer to a semaphore_t structure |
[in] | n | the new value of the semaphore counter. The value must be non-negative. |
Definition at line 1061 of file ch.c.
References chSchRescheduleS(), chSemResetI(), chSysLock, and chSysUnlock.
Referenced by chBSemReset().
void chSemResetI | ( | semaphore_t * | sp, |
cnt_t | n | ||
) |
Performs a reset operation on the semaphore.
[in] | sp | pointer to a semaphore_t structure |
[in] | n | the new value of the semaphore counter. The value must be non-negative. |
Definition at line 1085 of file ch.c.
References chDbgCheck, chDbgCheckClassI(), nil_threads_queue::cnt, MSG_RESET, and nil_ready_all().
Referenced by chBSemResetI(), and chSemReset().
void chEvtSignal | ( | thread_t * | tp, |
eventmask_t | mask | ||
) |
Adds a set of event flags directly to the specified thread_t
.
[in] | tp | the thread to be signaled |
[in] | mask | the event flags set to be ORed |
Definition at line 1108 of file ch.c.
References chEvtSignalI(), chSchRescheduleS(), chSysLock, and chSysUnlock.
void chEvtSignalI | ( | thread_t * | tp, |
eventmask_t | mask | ||
) |
Adds a set of event flags directly to the specified thread_t
.
[in] | tp | the thread to be signaled |
[in] | mask | the event flags set to be ORed |
Definition at line 1128 of file ch.c.
References chDbgCheck, chDbgCheckClassI(), chSchReadyI(), nil_thread::epmask, nil_thread::ewmask, and MSG_OK.
Referenced by chEvtSignal().
eventmask_t chEvtWaitAnyTimeout | ( | eventmask_t | mask, |
sysinterval_t | timeout | ||
) |
Waits for any of the specified events.
The function waits for any event among those specified in mask
to become pending then the events are cleared and returned.
[in] | mask | mask of the event flags that the function should wait for, ALL_EVENTS enables all the events |
[in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
|
0 | if the operation has timed out. |
Definition at line 1158 of file ch.c.
References chSchGoSleepTimeoutS(), chSysLock, chSysUnlock, nil_system::current, nil_thread::epmask, nil_thread::ewmask, MSG_OK, NIL_STATE_WTOREVT, and TIME_IMMEDIATE.
nil_system_t nil |