|
ChibiOS/RT
2.5.1 |
|
System related APIs and services:
Functions | |
| void | chSysInit (void) |
| ChibiOS/RT initialization. | |
| void | chSysTimerHandlerI (void) |
| Handles time ticks for round robin preemption and timer increments. | |
| WORKING_AREA (_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE) | |
| Idle thread working area. | |
| void | _idle_thread (void *p) |
| This function implements the idle thread infinite loop. | |
Macro Functions | |
| #define | chSysGetIdleThread() (rlist.r_queue.p_prev) |
| Returns a pointer to the idle thread. | |
| #define | chSysHalt() port_halt() |
| Halts the system. | |
| #define | chSysSwitch(ntp, otp) |
| Performs a context switch. | |
| #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 mode. | |
| #define | chSysUnlock() |
| Leaves the kernel lock mode. | |
| #define | chSysLockFromIsr() |
| Enters the kernel lock mode from within an interrupt handler. | |
| #define | chSysUnlockFromIsr() |
| Leaves the kernel lock mode from within an interrupt handler. | |
ISRs abstraction macros | |
| #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) |
| Standard normal IRQ handler declaration. | |
Fast ISRs abstraction macros | |
| #define | CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id) |
| Standard fast IRQ handler declaration. | |
| void chSysInit | ( | void | ) |
ChibiOS/RT initialization.
After executing this function the current instructions stream becomes the main thread.
chSysInit() is invoked and are internally enabled. NORMALPRIO. Definition at line 77 of file chsys.c.
References _core_init(), _heap_init(), _idle_thread(), _scheduler_init(), _thread_init(), _trace_init(), _vt_init(), chRegSetThreadName, chSysEnable, chThdCreateStatic(), currp, IDLEPRIO, NORMALPRIO, port_init, setcurrp, and THD_STATE_CURRENT.

| 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_TIME_QUANTUM macro, the round robin interval.Definition at line 130 of file chsys.c.
References chDbgCheckClassI(), chVTDoTickI, currp, and SYSTEM_TICK_EVENT_HOOK.

| WORKING_AREA | ( | _idle_thread_wa | , |
| PORT_IDLE_THREAD_STACK_SIZE | |||
| ) |
Idle thread working area.
| void _idle_thread | ( | void * | p | ) |
This function implements the idle thread infinite loop.
The function puts the processor in the lowest power mode capable to serve interrupts.
The priority is internally set to the minimum system value so that this thread is executed only if there are no other ready threads in the system.
| [in] | p | the thread parameter, unused in this scenario |
Definition at line 54 of file chsys.c.
References chRegSetThreadName, IDLE_LOOP_HOOK, port_wait_for_interrupt, and TRUE.
Referenced by chSysInit().
| #define chSysGetIdleThread | ( | ) | (rlist.r_queue.p_prev) |
Returns a pointer to the idle thread.
CH_NO_IDLE_THREAD must be disabled. | #define chSysHalt | ( | ) | port_halt() |
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.
Definition at line 63 of file chsys.h.
Referenced by chDbgPanic().
| #define chSysSwitch | ( | ntp, | |
| otp | |||
| ) |
{ \
dbg_trace(otp); \
THREAD_CONTEXT_SWITCH_HOOK(ntp, otp); \
port_switch(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 81 of file chsys.h.
Referenced by chSchDoRescheduleBehind(), chSchGoSleepS(), and chSchWakeupS().
| #define chSysDisable | ( | ) |
{ \
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.
| #define chSysSuspend | ( | ) |
{ \
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.
chSysLock(), the chSysLock() could do more than just disable the interrupts.| #define chSysEnable | ( | ) |
{ \
dbg_check_enable(); \
port_enable(); \
}
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.Definition at line 125 of file chsys.h.
Referenced by chSysInit().
| #define chSysLock | ( | ) |
{ \
port_lock(); \
dbg_check_lock(); \
}
Enters the kernel lock mode.
Definition at line 135 of file chsys.h.
Referenced by chCondBroadcast(), chCondSignal(), chCondWait(), chCondWaitTimeout(), chCoreAlloc(), chEvtAddEvents(), chEvtBroadcastFlags(), chEvtGetAndClearEvents(), chEvtGetAndClearFlags(), chEvtRegisterMask(), chEvtSignal(), chEvtUnregister(), chEvtWaitAll(), chEvtWaitAllTimeout(), chEvtWaitAny(), chEvtWaitAnyTimeout(), chEvtWaitOne(), chEvtWaitOneTimeout(), chIQGetTimeout(), chIQReadTimeout(), chMBFetch(), chMBPost(), chMBPostAhead(), chMBReset(), chMsgRelease(), chMsgSend(), chMsgWait(), chMtxLock(), chMtxTryLock(), chMtxUnlock(), chMtxUnlockAll(), chOQPutTimeout(), chOQWriteTimeout(), chPoolAlloc(), chPoolFree(), chRegFirstThread(), chRegNextThread(), chSemReset(), chSemSignal(), chSemSignalWait(), chSemWait(), chSemWaitTimeout(), chThdAddRef(), chThdCreateFromHeap(), chThdCreateFromMemoryPool(), chThdCreateStatic(), chThdExit(), chThdRelease(), chThdResume(), chThdSetPriority(), chThdSleep(), chThdSleepUntil(), chThdTerminate(), chThdWait(), and chThdYield().
| #define chSysUnlock | ( | ) |
{ \
dbg_check_unlock(); \
port_unlock(); \
}
Leaves the kernel lock mode.
Definition at line 145 of file chsys.h.
Referenced by chCondBroadcast(), chCondSignal(), chCondWait(), chCondWaitTimeout(), chCoreAlloc(), chEvtAddEvents(), chEvtBroadcastFlags(), chEvtGetAndClearEvents(), chEvtGetAndClearFlags(), chEvtRegisterMask(), chEvtSignal(), chEvtUnregister(), chEvtWaitAll(), chEvtWaitAllTimeout(), chEvtWaitAny(), chEvtWaitAnyTimeout(), chEvtWaitOne(), chEvtWaitOneTimeout(), chIQGetTimeout(), chIQReadTimeout(), chMBFetch(), chMBPost(), chMBPostAhead(), chMBReset(), chMsgRelease(), chMsgSend(), chMsgWait(), chMtxLock(), chMtxTryLock(), chMtxUnlock(), chMtxUnlockAll(), chOQPutTimeout(), chOQWriteTimeout(), chPoolAlloc(), chPoolFree(), chRegFirstThread(), chRegNextThread(), chSemReset(), chSemSignal(), chSemSignalWait(), chSemWait(), chSemWaitTimeout(), chThdAddRef(), chThdCreateFromHeap(), chThdCreateFromMemoryPool(), chThdCreateStatic(), chThdRelease(), chThdResume(), chThdSetPriority(), chThdSleep(), chThdSleepUntil(), chThdTerminate(), chThdWait(), and chThdYield().
| #define chSysLockFromIsr | ( | ) |
{ \
port_lock_from_isr(); \
dbg_check_lock_from_isr(); \
}
Enters the kernel lock mode from within an interrupt handler.
| #define chSysUnlockFromIsr | ( | ) |
{ \
dbg_check_unlock_from_isr(); \
port_unlock_from_isr(); \
}
Leaves the kernel lock mode from within an interrupt handler.
| #define CH_IRQ_PROLOGUE | ( | ) |
PORT_IRQ_PROLOGUE(); \ dbg_check_enter_isr();
IRQ handler enter code.
| #define CH_IRQ_EPILOGUE | ( | ) |
dbg_check_leave_isr(); \ PORT_IRQ_EPILOGUE();
IRQ handler exit code.
chSchIsPreemptionRequired() and chSchDoReschedule().| #define CH_IRQ_HANDLER | ( | id | ) | PORT_IRQ_HANDLER(id) |
| #define CH_FAST_IRQ_HANDLER | ( | id | ) | PORT_FAST_IRQ_HANDLER(id) |
Standard fast IRQ handler declaration.
id can be a function name or a vector number depending on the port implementation.