ChibiOS/RT 7.0.5
|
System related APIs and services:
Masks of executable integrity checks. | |
#define | CH_INTEGRITY_RLIST 1U |
#define | CH_INTEGRITY_VTLIST 2U |
#define | CH_INTEGRITY_REGISTRY 4U |
#define | CH_INTEGRITY_PORT 8U |
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 for the realtime counter | |
#define | S2RTC(freq, sec) |
Seconds to realtime counter. | |
#define | MS2RTC(freq, msec) |
Milliseconds to realtime counter. | |
#define | US2RTC(freq, usec) |
Microseconds to realtime counter. | |
#define | RTC2S(freq, n) |
Realtime counter cycles to seconds. | |
#define | RTC2MS(freq, n) |
Realtime counter cycles to milliseconds. | |
#define | RTC2US(freq, n) |
Realtime counter cycles to microseconds. |
Macros | |
#define | CH_SYS_CORE0_MEMORY PORT_CORE0_BSS_SECTION |
Core zero memory affinity macro. | |
#define | CH_SYS_CORE1_MEMORY PORT_CORE1_BSS_SECTION |
Core one memory affinity macro. | |
#define | currcore ch_system.instances[port_get_core_id()] |
Access to current core's instance structure. | |
#define | chSysGetRealtimeCounterX() |
Returns the current value of the system real time counter. | |
#define | chSysSwitch(ntp, otp) |
Performs a context switch. |
Functions | |
static CH_SYS_CORE0_MEMORY | THD_WORKING_AREA (ch_c0_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE) |
Working area for core 0 idle thread. | |
static CH_SYS_CORE1_MEMORY | THD_WORKING_AREA (ch_c1_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE) |
Working area for core 1 idle thread. | |
void | chSysWaitSystemState (system_state_t state) |
Waits for the system state to be equal to the specified one. | |
void | chSysInit (void) |
System initialization. | |
void | chSysHalt (const char *reason) |
Halts the system. | |
thread_t * | chSysGetIdleThreadX (void) |
Returns a pointer to the idle thread. | |
bool | chSysIntegrityCheckI (unsigned testmask) |
System integrity check. | |
void | chSysTimerHandlerI (void) |
Handles time ticks for round robin preemption and timer increments. | |
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. | |
static void | chSysDisable (void) |
Raises the system interrupt priority mask to the maximum level. | |
static void | chSysSuspend (void) |
Raises the system interrupt priority mask to system level. | |
static void | chSysEnable (void) |
Lowers the system interrupt priority mask to user level. | |
static void | chSysLock (void) |
Enters the kernel lock state. | |
static void | chSysUnlock (void) |
Leaves the kernel lock state. | |
static void | chSysLockFromISR (void) |
Enters the kernel lock state from within an interrupt handler. | |
static void | chSysUnlockFromISR (void) |
Leaves the kernel lock state from within an interrupt handler. | |
static void | chSysUnconditionalLock (void) |
Unconditionally enters the kernel lock state. | |
static void | chSysUnconditionalUnlock (void) |
Unconditionally leaves the kernel lock state. | |
static void | chSysNotifyInstance (os_instance_t *oip) |
Notifies an OS instance to check for reschedule. |
Variables | |
ch_system_t | ch_system |
System root object. | |
CH_SYS_CORE0_MEMORY os_instance_t | ch0 |
Core 0 OS instance. | |
stkalign_t | __main_thread_stack_base__ |
stkalign_t | __main_thread_stack_end__ |
const os_instance_config_t | ch_core0_cfg |
Core 0 OS instance configuration. | |
CH_SYS_CORE1_MEMORY os_instance_t | ch1 |
Core 1 OS instance. | |
stkalign_t | __c1_main_thread_stack_base__ |
stkalign_t | __c1_main_thread_stack_end__ |
const os_instance_config_t | ch_core1_cfg |
Core 1 OS instance configuration. |
#define CH_INTEGRITY_RLIST 1U |
Definition at line 41 of file chsys.h.
Referenced by chSysIntegrityCheckI().
#define CH_INTEGRITY_VTLIST 2U |
Definition at line 42 of file chsys.h.
Referenced by chSysIntegrityCheckI().
#define CH_INTEGRITY_REGISTRY 4U |
Definition at line 43 of file chsys.h.
Referenced by chSysIntegrityCheckI().
#define CH_INTEGRITY_PORT 8U |
Definition at line 44 of file chsys.h.
Referenced by chSysIntegrityCheckI().
#define CH_SYS_CORE0_MEMORY PORT_CORE0_BSS_SECTION |
Core zero memory affinity macro.
Definition at line 62 of file chsys.h.
Referenced by THD_WORKING_AREA().
#define CH_SYS_CORE1_MEMORY PORT_CORE1_BSS_SECTION |
Core one memory affinity macro.
Definition at line 74 of file chsys.h.
Referenced by THD_WORKING_AREA().
#define currcore ch_system.instances[port_get_core_id()] |
Access to current core's instance structure.
Definition at line 90 of file chsys.h.
Referenced by __dbg_check_disable(), __dbg_check_enable(), __dbg_check_enter_isr(), __dbg_check_leave_isr(), __dbg_check_lock(), __dbg_check_lock_from_isr(), __dbg_check_suspend(), __dbg_check_unlock(), __dbg_check_unlock_from_isr(), __sch_reschedule_ahead(), __sch_reschedule_behind(), __stats_ctxswc(), __stats_increase_irq(), __stats_start_measure_crit_isr(), __stats_start_measure_crit_thd(), __stats_stop_measure_crit_isr(), __stats_stop_measure_crit_thd(), __trace_halt(), __trace_isr_enter(), __trace_isr_leave(), __trace_ready(), __trace_switch(), chDbgCheckClassI(), chDbgCheckClassS(), chRegFirstThread(), chRegNextThread(), chRFCUCollectFaultsI(), chRFCUGetAndClearFaultsI(), chSchDoPreemption(), chSchDoYieldS(), chSchGoSleepS(), chSchGoSleepTimeoutS(), chSchIsPreemptionRequired(), chSchPreemption(), chSchReadyI(), chSchRescheduleS(), chSchSelectFirst(), chSchWakeupS(), chSysGetIdleThreadX(), chSysHalt(), chSysIntegrityCheckI(), chSysUnlock(), chThdCreateStatic(), chThdCreateSuspendedI(), chTraceResumeI(), chTraceSuspendI(), chTraceWriteI(), chVTDoResetI(), chVTDoSetContinuousI(), chVTDoSetI(), chVTDoTickI(), chVTGetRemainingIntervalI(), chVTGetSystemTimeX(), chVTGetTimersStateI(), chVTGetTimeStampI(), and chVTResetTimeStampI().
#define CH_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 | ) |
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.
chSchIsPreemptionRequired()
and chSchDoReschedule()
.#define CH_IRQ_HANDLER | ( | id | ) |
#define CH_FAST_IRQ_HANDLER | ( | id | ) |
Standard fast IRQ handler declaration.
id
can be a function name or a vector number depending on the port implementation. #define S2RTC | ( | freq, | |
sec ) |
Seconds to realtime counter.
Converts from seconds to realtime counter cycles.
freq
>= 1
.[in] | freq | clock frequency, in Hz, of the realtime counter |
[in] | sec | number of seconds |
#define MS2RTC | ( | freq, | |
msec ) |
Milliseconds to realtime counter.
Converts from milliseconds to realtime counter cycles.
freq
>= 1000
.[in] | freq | clock frequency, in Hz, of the realtime counter |
[in] | msec | number of milliseconds |
#define US2RTC | ( | freq, | |
usec ) |
Microseconds to realtime counter.
Converts from microseconds to realtime counter cycles.
freq
>= 1000000
.[in] | freq | clock frequency, in Hz, of the realtime counter |
[in] | usec | number of microseconds |
#define RTC2S | ( | freq, | |
n ) |
Realtime counter cycles to seconds.
Converts from realtime counter cycles number to seconds.
freq
>= 1
.[in] | freq | clock frequency, in Hz, of the realtime counter |
[in] | n | number of cycles |
#define RTC2MS | ( | freq, | |
n ) |
Realtime counter cycles to milliseconds.
Converts from realtime counter cycles number to milliseconds.
freq
>= 1000
.[in] | freq | clock frequency, in Hz, of the realtime counter |
[in] | n | number of cycles |
#define RTC2US | ( | freq, | |
n ) |
Realtime counter cycles to microseconds.
Converts from realtime counter cycles number to microseconds.
freq
>= 1000000
.[in] | freq | clock frequency, in Hz, of the realtime counter |
[in] | n | number of cycles |
#define chSysGetRealtimeCounterX | ( | ) |
Returns the current value of the system real time counter.
PORT_SUPPORTS_RT
.Definition at line 292 of file chsys.h.
Referenced by chSysPolledDelayX(), chTMChainMeasurementToX(), chTMStartMeasurementX(), chTMStopMeasurementX(), and trace_next().
#define chSysSwitch | ( | ntp, | |
otp ) |
Performs a context switch.
[in] | ntp | the thread to be switched in |
[in] | otp | the thread to be switched out |
Definition at line 305 of file chsys.h.
Referenced by __sch_reschedule_ahead(), __sch_reschedule_behind(), chSchDoPreemption(), chSchGoSleepS(), and chSchWakeupS().
|
static |
Working area for core 0 idle thread.
References CH_SYS_CORE0_MEMORY.
|
static |
Working area for core 1 idle thread.
References CH_SYS_CORE1_MEMORY.
void chSysWaitSystemState | ( | system_state_t | state | ) |
Waits for the system state to be equal to the specified one.
chSchObjectInit()
in order to wait for system initialization by another core.Definition at line 142 of file chsys.c.
References ch_system::state.
void chSysInit | ( | void | ) |
System initialization.
After executing this function the current instructions stream becomes the main thread.
NORMALPRIO
and interrupts are enabled. ch_sys_running
state.Definition at line 159 of file chsys.c.
References __oslib_init(), __reg_object_init(), __rfcu_object_init(), __tm_calibration_object_init(), ch0, CH_CFG_SYSTEM_INIT_HOOK, ch_core0_cfg, ch_sys_initializing, ch_sys_running, chInstanceObjectInit(), chSysUnlock(), ch_system::instances, PORT_CORES_NUMBER, ch_system::reglist, ch_system::rfcu, ch_system::state, and ch_system::tmc.
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 209 of file chsys.c.
References __trace_halt, CH_CFG_SYSTEM_HALT_HOOK, ch_sys_halted, currcore, and ch_system::state.
Referenced by __dbg_check_disable(), __dbg_check_enable(), __dbg_check_enter_isr(), __dbg_check_leave_isr(), __dbg_check_lock(), __dbg_check_lock_from_isr(), __dbg_check_suspend(), __dbg_check_unlock(), __dbg_check_unlock_from_isr(), chDbgCheckClassI(), and chDbgCheckClassS().
thread_t * chSysGetIdleThreadX | ( | void | ) |
Returns a pointer to the idle thread.
chThdGetSelfX()
in that case.Definition at line 248 of file chsys.c.
References chDbgAssert, currcore, ch_thread::hdr, IDLEPRIO, ch_thread::pqueue, ch_priority_queue::prio, and threadref.
Referenced by chSchGoSleepS().
bool chSysIntegrityCheckI | ( | unsigned | testmask | ) |
System integrity check.
Performs an integrity check of the important ChibiOS/RT data structures.
NULL
or corrupted pointers in list elements. Exception vectors must be monitored as well. [in] | testmask | Each bit in this mask is associated to a test to be performed. |
false | The test succeeded. |
true | Test failed. |
Definition at line 280 of file chsys.c.
References CH_INTEGRITY_PORT, CH_INTEGRITY_REGISTRY, CH_INTEGRITY_RLIST, CH_INTEGRITY_VTLIST, chDbgCheckClassI, currcore, ch_virtual_timers_list::dlist, ch_delta_list::next, ch_priority_queue::next, ch_queue::next, ch_ready_list::pqueue, ch_delta_list::prev, ch_priority_queue::prev, ch_queue::prev, REG_HEADER, ch_os_instance::rlist, and ch_os_instance::vtlist.
void chSysTimerHandlerI | ( | void | ) |
Handles time ticks for round robin preemption and timer increments.
Decrements the remaining time quantum of the running thread and preempts it when the quantum is used up. Increments system time and manages the timers.
CH_CFG_TIME_QUANTUM
macro, the round robin interval.Definition at line 386 of file chsys.c.
References CH_CFG_SYSTEM_TICK_HOOK, chDbgCheckClassI, chThdGetSelfX(), chVTDoTickI(), ch_thread::ticks, and ch_thread::time.
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.
port_get_lock_status()
and port_is_locked()
.Definition at line 423 of file chsys.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. port_get_lock_status()
and port_is_locked()
.[in] | sts | the system status to be restored. |
Definition at line 448 of file chsys.c.
References chSchRescheduleS(), chSysUnlock(), and chSysUnlockFromISR().
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 481 of file chsys.c.
Referenced by chSysPolledDelayX().
void chSysPolledDelayX | ( | rtcnt_t | cycles | ) |
Polled delay.
PORT_SUPPORTS_RT
.[in] | cycles | number of cycles |
Definition at line 498 of file chsys.c.
References chSysGetRealtimeCounterX, and chSysIsCounterWithinX().
|
inlinestatic |
Raises the system interrupt priority mask to the maximum level.
All the maskable interrupt sources are disabled regardless their hardware priority.
chSysLock()and
chSysUnock()
which could do more than just disable interrupts.Definition at line 362 of file chsys.h.
References __dbg_check_disable.
|
inlinestatic |
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()
which could do more than just disable interrupts.Definition at line 379 of file chsys.h.
References __dbg_check_suspend.
|
inlinestatic |
Lowers the system interrupt priority mask to user level.
All the interrupt sources are enabled.
chSysUnlock()
which could do more than just enable interrupts.Definition at line 394 of file chsys.h.
References __dbg_check_enable.
|
inlinestatic |
Enters the kernel lock state.
Definition at line 407 of file chsys.h.
References __dbg_check_lock, and __stats_start_measure_crit_thd().
Referenced by chBSemSignal(), chCacheGetObject(), chCacheReleaseObject(), chCondBroadcast(), chCondSignal(), chCondWait(), chCondWaitTimeout(), chCoreAllocFromBase(), chCoreAllocFromTop(), chEvtAddEvents(), chEvtBroadcastFlags(), chEvtGetAndClearEvents(), chEvtGetAndClearFlags(), chEvtRegisterMaskWithFlags(), chEvtSignal(), chEvtUnregister(), chEvtWaitAll(), chEvtWaitAllTimeout(), chEvtWaitAny(), chEvtWaitAnyTimeout(), chEvtWaitOne(), chEvtWaitOneTimeout(), chGuardedPoolAllocTimeout(), chGuardedPoolFree(), chMBFetchTimeout(), chMBPostAheadTimeout(), chMBPostTimeout(), chMBReset(), chMsgPoll(), chMsgRelease(), chMsgSend(), chMsgWait(), 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(), chThdSleepUntil(), chThdSleepUntilWindowed(), chThdStart(), chThdTerminate(), chThdWait(), chThdYield(), chTraceResume(), chTraceSuspend(), chTraceWrite(), chVTGetSystemTime(), chVTGetTimeStamp(), chVTIsArmed(), chVTReset(), chVTResetTimeStamp(), chVTSet(), chVTSetContinuous(), and lru_get_last_s().
|
inlinestatic |
Leaves the kernel lock state.
Definition at line 421 of file chsys.h.
References __dbg_check_unlock, __stats_stop_measure_crit_thd(), chDbgAssert, and currcore.
Referenced by chBSemSignal(), chCacheGetObject(), chCacheReleaseObject(), chCondBroadcast(), chCondSignal(), chCondWait(), chCondWaitTimeout(), chCoreAllocFromBase(), chCoreAllocFromTop(), chEvtAddEvents(), chEvtBroadcastFlags(), chEvtGetAndClearEvents(), chEvtGetAndClearFlags(), chEvtRegisterMaskWithFlags(), chEvtSignal(), chEvtUnregister(), chEvtWaitAll(), chEvtWaitAllTimeout(), chEvtWaitAny(), chEvtWaitAnyTimeout(), chEvtWaitOne(), chEvtWaitOneTimeout(), chGuardedPoolAllocTimeout(), chGuardedPoolFree(), chMBFetchTimeout(), chMBPostAheadTimeout(), chMBPostTimeout(), chMBReset(), chMsgPoll(), chMsgRelease(), chMsgSend(), chMsgWait(), 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(), chThdSleepUntil(), chThdSleepUntilWindowed(), chThdStart(), chThdTerminate(), chThdWait(), chThdYield(), chTraceResume(), chTraceSuspend(), chTraceWrite(), chVTGetSystemTime(), chVTGetTimeStamp(), chVTIsArmed(), chVTReset(), chVTResetTimeStamp(), chVTSet(), chVTSetContinuous(), and lru_get_last_s().
|
inlinestatic |
Enters the kernel lock state from within an interrupt handler.
Definition at line 451 of file chsys.h.
References __dbg_check_lock_from_isr, and __stats_start_measure_crit_isr().
Referenced by __sch_wakeup(), chSysGetStatusAndLockX(), and chVTDoTickI().
|
inlinestatic |
Leaves the kernel lock state from within an interrupt handler.
Definition at line 473 of file chsys.h.
References __dbg_check_unlock_from_isr, and __stats_stop_measure_crit_isr().
Referenced by __sch_wakeup(), chSysRestoreStatusX(), and chVTDoTickI().
|
inlinestatic |
Unconditionally enters the kernel lock state.
port_get_lock_status()
and port_is_locked()
.Definition at line 490 of file chsys.h.
References chSysLock().
|
inlinestatic |
Unconditionally leaves the kernel lock state.
port_get_lock_status()
and port_is_locked()
.Definition at line 506 of file chsys.h.
References chSysUnlock().
|
inlinestatic |
Notifies an OS instance to check for reschedule.
An OS instance is notified to check if a reschedule is required, the implementation is port-dependent.
[in] | oip | pointer to the instance to be notified |
Definition at line 522 of file chsys.h.
Referenced by chSchReadyI(), and chSchWakeupS().
ch_system_t ch_system |
|
extern |
stkalign_t __main_thread_stack_end__ |
const os_instance_config_t ch_core0_cfg |
Core 0 OS instance configuration.
Definition at line 67 of file chsys.c.
Referenced by chSysInit().
|
extern |
stkalign_t __c1_main_thread_stack_end__ |
const os_instance_config_t ch_core1_cfg |
Core 1 OS instance configuration.