From 25ddb1c801f06a3be7171e20dcfd46d11a75f112 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 19 Jul 2013 14:51:35 +0000 Subject: First cleanup pass finished, queues and streams not yet removed. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5999 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 215 +++++++++++++++++++++++----------------------- 1 file changed, 106 insertions(+), 109 deletions(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index a1f59f38e..5585117b6 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -29,45 +29,94 @@ #ifndef _CHSYS_H_ #define _CHSYS_H_ +/*===========================================================================*/ +/* Module constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module data structures and types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module macros. */ +/*===========================================================================*/ + /** - * @name Macro Functions - * @{ + * @name ISRs abstraction macros */ -#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__) /** - * @brief Returns a pointer to the idle thread. - * @pre In order to use this function the option @p CH_NO_IDLE_THREAD - * must be disabled. - * @note The reference counter of the idle thread is not incremented but - * it is not strictly required being the idle thread a static - * object. + * @brief IRQ handler enter code. + * @note Usually IRQ handlers functions are also declared naked. + * @note On some architectures this macro can be empty. * - * @return Pointer to the idle thread. + * @special + */ +#define CH_IRQ_PROLOGUE() \ + PORT_IRQ_PROLOGUE(); \ + dbg_check_enter_isr(); + +/** + * @brief IRQ handler exit code. + * @note Usually IRQ handlers function are also declared naked. + * @note This macro usually performs the final reschedule by using + * @p chSchIsPreemptionRequired() and @p chSchDoReschedule(). * - * @api + * @special */ -#define chSysGetIdleThread() (rlist.r_queue.p_prev) -#endif +#define CH_IRQ_EPILOGUE() \ + dbg_check_leave_isr(); \ + PORT_IRQ_EPILOGUE(); + +/** + * @brief Standard normal IRQ handler declaration. + * @note @p id can be a function name or a vector number depending on the + * port implementation. + * + * @special + */ +#define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id) +/** @} */ /** - * @brief Halts the system. - * @details 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. + * @name Fast ISRs abstraction macros + */ +/** + * @brief Standard fast IRQ handler declaration. + * @note @p id can be a function name or a vector number depending on the + * port implementation. + * @note Not all architectures support fast interrupts. * * @special */ -#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) -#define chSysHalt() port_halt() -#else -#define chSysHalt() { \ - SYSTEM_HALT_HOOK(); \ - port_halt(); \ +#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id) +/** @} */ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + void chSysInit(void); + void chSysHalt(void); + void chSysTimerHandlerI(void); +#ifdef __cplusplus } #endif +/*===========================================================================*/ +/* Module inline functions. */ +/*===========================================================================*/ + /** * @brief Performs a context switch. * @note Not a user function, it is meant to be invoked by the scheduler @@ -78,10 +127,11 @@ * * @special */ -#define chSysSwitch(ntp, otp) { \ - dbg_trace(otp); \ - THREAD_CONTEXT_SWITCH_HOOK(ntp, otp); \ - port_switch(ntp, otp); \ +static inline void chSysSwitch(thread_t *ntp, thread_t *otp) { + + dbg_trace(otp); + THREAD_CONTEXT_SWITCH_HOOK(ntp, otp); + port_switch(ntp, otp); } /** @@ -92,9 +142,10 @@ * * @special */ -#define chSysDisable() { \ - port_disable(); \ - dbg_check_disable(); \ +static inline void chSysDisable(void) { + + port_disable(); + dbg_check_disable(); } /** @@ -108,9 +159,10 @@ * * @special */ -#define chSysSuspend() { \ - port_suspend(); \ - dbg_check_suspend(); \ +static inline void chSysSuspend(void) { + + port_suspend(); + dbg_check_suspend(); } /** @@ -122,9 +174,10 @@ * * @special */ -#define chSysEnable() { \ - dbg_check_enable(); \ - port_enable(); \ +static inline void chSysEnable(void) { + + dbg_check_enable(); + port_enable(); } /** @@ -132,9 +185,10 @@ * * @special */ -#define chSysLock() { \ - port_lock(); \ - dbg_check_lock(); \ +static inline void chSysLock(void) { + + port_lock(); + dbg_check_lock(); } /** @@ -142,9 +196,10 @@ * * @special */ -#define chSysUnlock() { \ - dbg_check_unlock(); \ - port_unlock(); \ +static inline void chSysUnlock(void) { + + dbg_check_unlock(); + port_unlock(); } /** @@ -159,9 +214,10 @@ * * @special */ -#define chSysLockFromIsr() { \ - port_lock_from_isr(); \ - dbg_check_lock_from_isr(); \ +static inline void chSysLockFromIsr(void) { + + port_lock_from_isr(); + dbg_check_lock_from_isr(); } /** @@ -177,70 +233,11 @@ * * @special */ -#define chSysUnlockFromIsr() { \ - dbg_check_unlock_from_isr(); \ - port_unlock_from_isr(); \ -} -/** @} */ - -/** - * @name ISRs abstraction macros - */ -/** - * @brief IRQ handler enter code. - * @note Usually IRQ handlers functions are also declared naked. - * @note On some architectures this macro can be empty. - * - * @special - */ -#define CH_IRQ_PROLOGUE() \ - PORT_IRQ_PROLOGUE(); \ - dbg_check_enter_isr(); - -/** - * @brief IRQ handler exit code. - * @note Usually IRQ handlers function are also declared naked. - * @note This macro usually performs the final reschedule by using - * @p chSchIsPreemptionRequired() and @p chSchDoReschedule(). - * - * @special - */ -#define CH_IRQ_EPILOGUE() \ - dbg_check_leave_isr(); \ - PORT_IRQ_EPILOGUE(); - -/** - * @brief Standard normal IRQ handler declaration. - * @note @p id can be a function name or a vector number depending on the - * port implementation. - * - * @special - */ -#define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id) -/** @} */ - -/** - * @name Fast ISRs abstraction macros - */ -/** - * @brief Standard fast IRQ handler declaration. - * @note @p id can be a function name or a vector number depending on the - * port implementation. - * @note Not all architectures support fast interrupts. - * - * @special - */ -#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id) -/** @} */ +static inline void chSysUnlockFromIsr(void) { -#ifdef __cplusplus -extern "C" { -#endif - void chSysInit(void); - void chSysTimerHandlerI(void); -#ifdef __cplusplus + dbg_check_unlock_from_isr(); + port_unlock_from_isr(); } -#endif #endif /* _CHSYS_H_ */ -- cgit v1.2.3