git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@582 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
a2ebdce0c7
commit
bbabbf4ac2
|
@ -421,6 +421,7 @@
|
|||
/**
|
||||
* @defgroup Kernel Kernel
|
||||
* @{
|
||||
* @file ch.h ChibiOS/RT main header file, it includes everything else.
|
||||
*/
|
||||
/** @} */
|
||||
|
||||
|
@ -462,12 +463,12 @@
|
|||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup Initialization Initialization
|
||||
* @defgroup System System Management
|
||||
* @{
|
||||
* Initialization APIs and procedures.
|
||||
* Initialization and system-related APIs and procedures.
|
||||
* @ingroup Kernel
|
||||
* @file ch.h ChibiOS/RT main include file, it includes everything else.
|
||||
* @file chinit.c ChibiOS/RT Initialization code.
|
||||
* @file sys.h ChibiOS/RT system-related header file.
|
||||
* @file chsys.c ChibiOS/RT system-related code.
|
||||
*/
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -79,8 +79,6 @@ void SysTickVector(void) {
|
|||
chSysIRQExitI();
|
||||
}
|
||||
|
||||
void *retaddr;
|
||||
|
||||
/*
|
||||
* System invoked context switch.
|
||||
*/
|
||||
|
|
20
src/chsys.c
20
src/chsys.c
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Initialization
|
||||
* @addtogroup System
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -82,7 +82,9 @@ void chSysTimerHandlerI(void) {
|
|||
* @note The use of system mutual exclusion zone is not recommended in
|
||||
* the user code, it is a better idea to use the semaphores or mutexes
|
||||
* instead.
|
||||
* @see CH_USE_NESTED_LOCKS
|
||||
* @note The code of this API is may be inlined or not depending on the
|
||||
* @p CH_OPTIMIZE_SPEED setting.
|
||||
* @see CH_USE_NESTED_LOCKS, chSysLockInline()
|
||||
*/
|
||||
void chSysLock(void) {
|
||||
|
||||
|
@ -94,7 +96,9 @@ void chSysLock(void) {
|
|||
* @note The use of system mutual exclusion zone is not recommended in
|
||||
* the user code, it is a better idea to use the semaphores or mutexes
|
||||
* instead.
|
||||
* @see CH_USE_NESTED_LOCKS
|
||||
* @note The code of this API is may be inlined or not depending on the
|
||||
* @p CH_OPTIMIZE_SPEED setting.
|
||||
* @see CH_USE_NESTED_LOCKS, chSysUnlockInline()
|
||||
*/
|
||||
void chSysUnlock(void) {
|
||||
|
||||
|
@ -103,4 +107,14 @@ void chSysUnlock(void) {
|
|||
}
|
||||
#endif /* !CH_OPTIMIZE_SPEED */
|
||||
|
||||
/**
|
||||
* Abonormal system termination handler. Invoked by the ChibiOS/RT when an
|
||||
* abnormal unrecoverable condition is met.
|
||||
*/
|
||||
void chSysHalt(void) {
|
||||
|
||||
chSysDisable();
|
||||
sys_halt();
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -18,14 +18,77 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Core
|
||||
* @addtogroup System
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef _SYS_H_
|
||||
#define _SYS_H_
|
||||
|
||||
#if defined(CH_USE_REENTRANT_LOCKS) || defined(_DOXYGEN_)
|
||||
/**
|
||||
* Prints a message on the system console (if any).
|
||||
* @param msg the message to be printed on the system console
|
||||
*/
|
||||
#define chSysPuts(msg) sys_puts(msg)
|
||||
|
||||
/**
|
||||
* Performs a context switch.
|
||||
* This is the most critical code in any port, this function is responsible
|
||||
* for the context switch between 2 threads.
|
||||
* @param otp the thread to be switched out
|
||||
* @param ntp the thread to be switched in
|
||||
* @note The implementation of this code affects <b>directly</b> the context
|
||||
* switch performance so optimize here as much as you can.
|
||||
*/
|
||||
#define chSysSwitchI(otp, ntp) sys_switch(otp, ntp)
|
||||
|
||||
/**
|
||||
* Lowers the system interrupt priority mask to user level.
|
||||
* @note The implementation is architecture dependent, it may just enable the
|
||||
* interrupts.
|
||||
* @note This API is normally invoked only from within @p chSysInit().
|
||||
* @note The use of this API is <b>not</b> an alternative to @p chSysUnlock().
|
||||
*/
|
||||
#define chSysEnable() sys_enable()
|
||||
|
||||
/**
|
||||
* Raises the system interrupt priority mask to system level.
|
||||
* @note The implementation is architecture dependent, it may just enable the
|
||||
* interrupts.
|
||||
* @note This API should only be invoked from the main thread in order to stop
|
||||
* ChibiOS/RT, hardware de/re-initialization should follow. It would then
|
||||
* be possible to re-initialize ChibiOS/RT using @p chSysInit().
|
||||
* @note The use of this API is <b>not</b> an alternative to @p chSysLock().
|
||||
*/
|
||||
#define chSysDisable() sys_disable()
|
||||
|
||||
/**
|
||||
* Enters the ChibiOS/RT system mutual exclusion zone 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.<br>
|
||||
* It is good practice to invoke this API before invoking any I-class
|
||||
* syscall from an interrupt handler.
|
||||
* @note This API must be invoked exclusively from interrupt handlers.
|
||||
*/
|
||||
#define chSysLockI() sys_disable_from_isr()
|
||||
|
||||
/**
|
||||
* Leaves the ChibiOS/RT system mutual exclusion zone 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.<br>
|
||||
* It is good practice to invoke this API after invoking any I-class
|
||||
* syscall from an interrupt handler.
|
||||
* @note This API must be invoked exclusively from interrupt handlers.
|
||||
*/
|
||||
#define chSysUnlockI() sys_disable_from_isr()
|
||||
|
||||
#if defined(CH_USE_NESTED_LOCKS) || defined(_DOXYGEN_)
|
||||
/**
|
||||
* Enters the ChibiOS/RT system mutual exclusion zone.
|
||||
* @note The use of system mutual exclusion zone is not recommended in
|
||||
|
@ -57,11 +120,37 @@
|
|||
if (--currp->p_locks == 0) \
|
||||
sys_enable(); \
|
||||
}
|
||||
#else /* defined(CH_USE_REENTRANT_LOCKS) || defined(_DOXYGEN_) */
|
||||
|
||||
#else /* defined(CH_USE_NESTED_LOCKS) || defined(_DOXYGEN_) */
|
||||
|
||||
#define chSysLockInline() sys_disable()
|
||||
#define chSysUnlockInline() sys_enable()
|
||||
#endif /* !defined(CH_USE_REENTRANT_LOCKS) && !defined(_DOXYGEN_) */
|
||||
|
||||
#endif /* !defined(CH_USE_NESTED_LOCKS) && !defined(_DOXYGEN_) */
|
||||
|
||||
/**
|
||||
* IRQ handler enter code.
|
||||
* @note Usually IRQ handlers functions are also declared naked.
|
||||
* @note On some architectures this macro can be empty.
|
||||
*/
|
||||
#define chSysIRQEnterI() sys_irq_prologue()
|
||||
|
||||
/**
|
||||
* IRQ handler exit code.
|
||||
* @note Usually IRQ handlers function are also declared naked.
|
||||
* @note This macro usually performs the final reschedulation by using
|
||||
* \p chSchRescRequiredI() and \p chSchDoRescheduleI().
|
||||
*/
|
||||
#define chSysIRQExitI() sys_irq_epilogue()
|
||||
|
||||
/**
|
||||
* Standard modifier for IRQ handler functions.
|
||||
*/
|
||||
#define CH_IRQ_HANDLER SYS_IRQ_HANDLER
|
||||
|
||||
/*
|
||||
* Inlined code when CH_OPTIMIZE_SPEED is defined.
|
||||
*/
|
||||
#if defined(CH_OPTIMIZE_SPEED)
|
||||
#define chSysLock() chSysLockInline()
|
||||
#define chSysUnlock chSysUnlockInline()
|
||||
|
@ -72,6 +161,11 @@ extern "C" {
|
|||
#endif
|
||||
void chSysInit(void);
|
||||
void chSysTimerHandlerI(void);
|
||||
void chSysHalt(void);
|
||||
#if !defined(CH_OPTIMIZE_SPEED)
|
||||
void chSysLock(void);
|
||||
void chSysUnlock(void);
|
||||
#endif /* !defined(CH_OPTIMIZE_SPEED) */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,9 +25,7 @@
|
|||
#include <ch.h>
|
||||
|
||||
/*
|
||||
* This file is just a template, it contains the function prototypes and the
|
||||
* doxigen documentation. The implementation of the following functions is
|
||||
* architecture/compiler specific.
|
||||
* This file is a template of the system driver functions provided by a port.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -45,64 +43,4 @@ void _idle(void *p) {
|
|||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abonormal system termination handler. Invoked by the ChibiOS/RT when an
|
||||
* abnormal unrecoverable condition is met.
|
||||
*/
|
||||
void chSysHalt(void) {
|
||||
|
||||
chSysLock();
|
||||
|
||||
while (TRUE)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the interrupts, it is only invoked once into \p chSysInit().
|
||||
*/
|
||||
void chSysEnable(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enters the ChibiOS/RT system mutual exclusion zone. The implementation is
|
||||
* architecture dependent, on single core systems usually this function usually
|
||||
* just disables the interrupts.
|
||||
* @note The code in the system mutual exclusion zone must be as light and
|
||||
* fast as possible, the system performance is affected by this.
|
||||
* @note The use of system mutual exclusion zones are not recommended in
|
||||
* the user code, it is a better idea to use the Semaphores instead.
|
||||
*/
|
||||
void chSysLock(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Leaves the ChibiOS/RT system mutual exclusion zone. The implementation is
|
||||
* architecture dependent, on single core systems usually this function usually
|
||||
* just enables the interrupts.
|
||||
* @note The code in the system mutual exclusion zone must be as light and
|
||||
* fast as possible, the system performance is affected by this.
|
||||
* @note The use of system mutual exclusion zones are not recommended in
|
||||
* the user code, it is a better idea to use the Semaphores instead.
|
||||
*/
|
||||
void chSysUnlock(void) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a context switch.
|
||||
* This is the most critical code in any port, this function is responsible
|
||||
* for the context switch between 2 threads.
|
||||
* @param otp the thread to be switched out
|
||||
* @param ntp the thread to be switched in
|
||||
* @note The implementation of this code affects <b>directly</b> the context
|
||||
* switch performance so optimize here as much as you can.
|
||||
*/
|
||||
void chSysSwitchI(Thread *otp, Thread *ntp) {}
|
||||
|
||||
/**
|
||||
* Prints a message on the system console (if any).
|
||||
* @param msg the message to be printed on the system console
|
||||
*/
|
||||
void chSysPuts(char *msg) {
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -106,31 +106,10 @@ typedef struct {
|
|||
*/
|
||||
#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)];
|
||||
|
||||
/**
|
||||
* IRQ handler enter code.
|
||||
* @note Usually IRQ handlers functions are also declared naked.
|
||||
* @note On some architectures this macro can be empty.
|
||||
*/
|
||||
#define chSysIRQEnterI()
|
||||
|
||||
/**
|
||||
* IRQ handler exit code.
|
||||
* @note Usually IRQ handlers function are also declared naked.
|
||||
* @note This macro usually performs the final reschedulation by using
|
||||
* \p chSchRescRequiredI() and \p chSchDoRescheduleI().
|
||||
*/
|
||||
#define chSysIRQExitI()
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void _idle(void *p);
|
||||
void chSysHalt(void);
|
||||
void chSysEnable(void);
|
||||
void chSysLock(void);
|
||||
void chSysUnlock(void);
|
||||
void chSysSwitchI(Thread *otp, Thread *ntp);
|
||||
void chSysPuts(char *msg);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue