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 From 49d71a01abeefa000a4cd7a556052d826b096d49 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 20 Jul 2013 10:12:44 +0000 Subject: Renamed or added prefix to all hernel configuration options. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6010 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index 5585117b6..e87d0c6c1 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -130,7 +130,7 @@ extern "C" { static inline void chSysSwitch(thread_t *ntp, thread_t *otp) { dbg_trace(otp); - THREAD_CONTEXT_SWITCH_HOOK(ntp, otp); + CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp); port_switch(ntp, otp); } -- cgit v1.2.3 From 40f413d3c97a7694703938cd031ce15912b29ff7 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 24 Jul 2013 14:54:26 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6025 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index e87d0c6c1..5086e0b7f 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -109,6 +109,8 @@ extern "C" { void chSysInit(void); void chSysHalt(void); void chSysTimerHandlerI(void); + syssts_t chSysGetAndLockX(void); + void chSysRestoreLockX(syssts_t sts); #ifdef __cplusplus } #endif @@ -214,7 +216,7 @@ static inline void chSysUnlock(void) { * * @special */ -static inline void chSysLockFromIsr(void) { +static inline void chSysLockFromISR(void) { port_lock_from_isr(); dbg_check_lock_from_isr(); @@ -233,7 +235,7 @@ static inline void chSysLockFromIsr(void) { * * @special */ -static inline void chSysUnlockFromIsr(void) { +static inline void chSysUnlockFromISR(void) { dbg_check_unlock_from_isr(); port_unlock_from_isr(); -- cgit v1.2.3 From 61f841306aaa11b1471db1deb00470ea48f646fd Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 29 Jul 2013 13:28:35 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6037 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index 5086e0b7f..3dc6623e9 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -61,7 +61,8 @@ */ #define CH_IRQ_PROLOGUE() \ PORT_IRQ_PROLOGUE(); \ - dbg_check_enter_isr(); + dbg_check_enter_isr(); \ + _stats_increase_irq() /** * @brief IRQ handler exit code. @@ -73,7 +74,7 @@ */ #define CH_IRQ_EPILOGUE() \ dbg_check_leave_isr(); \ - PORT_IRQ_EPILOGUE(); + PORT_IRQ_EPILOGUE() /** * @brief Standard normal IRQ handler declaration. @@ -99,6 +100,23 @@ #define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id) /** @} */ +/** + * @brief Returns the current value of the system real time counter. + * @note This function can be called from any context. + * @note If the port does not support a realtime counter then this + * function returns the system time. + * + * @return The value of the system realtime counter of + * type rtcnt_t. + * + * @special + */ +#if CH_PORT_SUPPORTS_RT || defined(__DOXYGEN__) +#define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value() +#else +#define chSysGetRealtimeCounterX() (rtcnt_t)chVTGetSystemTimeX() +#endif + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ @@ -132,6 +150,7 @@ extern "C" { static inline void chSysSwitch(thread_t *ntp, thread_t *otp) { dbg_trace(otp); + _stats_increase_ctxswc(); CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp); port_switch(ntp, otp); } -- cgit v1.2.3 From ca4b2f91b7a24abeb6ea7fa43c1816397fb966c4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 29 Jul 2013 14:31:13 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6039 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 89 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 5 deletions(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index 3dc6623e9..0fd07b96b 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -100,21 +100,100 @@ #define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id) /** @} */ +/** + * @name Time conversion utilities for the realtime counter + * @{ + */ +/** + * @brief Seconds to realtime counter. + * @details Converts from seconds to realtime counter cycles. + * @note The result is rounded upward to the next tick boundary. + * + * @param[in] freq realtime counter operating frequency + * @param[in] sec number of seconds + * @return The number of cycles. + * + * @api + */ +#define S2RTV(freq, sec) ((freq) * (sec)) + +/** + * @brief Milliseconds to realtime counter. + * @details Converts from milliseconds to realtime counter cycles. + * @note The result is rounded upward to the next tick boundary. + * + * @param[in] freq realtime counter operating frequency + * @param[in] msec number of milliseconds + * @return The number of cycles. + * + * @api + */ +#define MS2RTC(freq, msec) (rtcnt_t)((((freq) + 999UL) / 1000UL) * (msec)) + +/** + * @brief Microseconds to realtime counter. + * @details Converts from microseconds to realtime counter cycles. + * @note The result is rounded upward to the next tick boundary. + * + * @param[in] freq realtime counter operating frequency + * @param[in] usec number of microseconds + * @return The number of cycles. + * + * @api + */ +#define US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec)) + +/** + * @brief Realtime counter cycles to seconds. + * @details Converts from realtime counter cycles number to seconds. + * + * @param[in] freq realtime counter operating frequency + * @param[in] n number of cycles + * @return The number of seconds. + * + * @api + */ +#define RTC2S(freq, n) (rtcnt_t)((n) / (freq)) + +/** + * @brief Realtime counter cycles to milliseconds. + * @details Converts from realtime counter cycles number to milliseconds. + * + * @param[in] freq realtime counter operating frequency + * @param[in] n number of cycles + * @return The number of milliseconds. + * + * @api + */ +#define RTC2MS(freq, n) ((n) / ((freq) / 1000UL)) + +/** + * @brief Realtime counter cycles to microseconds. + * @details Converts from realtime counter cycles number to microseconds. + * + * @param[in] freq realtime counter operating frequency + * @param[in] n number of cycles + * @return The number of microseconds. + * + * @api + */ +#define RTC2US(freq, n) ((n) / ((freq) / 1000000UL)) +/** @} */ + /** * @brief Returns the current value of the system real time counter. * @note This function can be called from any context. - * @note If the port does not support a realtime counter then this - * function returns the system time. * * @return The value of the system realtime counter of - * type rtcnt_t. + * type rtcnt_t. If the port does not support a + * realtime counter then zero is returned. * - * @special + * @xclass */ #if CH_PORT_SUPPORTS_RT || defined(__DOXYGEN__) #define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value() #else -#define chSysGetRealtimeCounterX() (rtcnt_t)chVTGetSystemTimeX() +#define chSysGetRealtimeCounterX() 0 #endif /*===========================================================================*/ -- cgit v1.2.3 From f569bcec23452c190248aab184a125f3a52e2eb8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 29 Jul 2013 15:13:52 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6040 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index 0fd07b96b..722323d54 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -182,18 +182,16 @@ /** * @brief Returns the current value of the system real time counter. - * @note This function can be called from any context. + * @note This function is only available if the port layer supports the + * option @p CH_PORT_SUPPORTS_RT. * * @return The value of the system realtime counter of - * type rtcnt_t. If the port does not support a - * realtime counter then zero is returned. + * type rtcnt_t. * * @xclass */ #if CH_PORT_SUPPORTS_RT || defined(__DOXYGEN__) #define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value() -#else -#define chSysGetRealtimeCounterX() 0 #endif /*===========================================================================*/ @@ -208,6 +206,10 @@ extern "C" { void chSysTimerHandlerI(void); syssts_t chSysGetAndLockX(void); void chSysRestoreLockX(syssts_t sts); +#if CH_PORT_SUPPORTS_RT + bool chSysIsCounterWithinX(rtcnt_t cnt, rtcnt_t start, rtcnt_t end); + void chSysPolledDelayX(rtcnt_t cycles); +#endif #ifdef __cplusplus } #endif -- cgit v1.2.3 From 9cd24294b8b5c32af4f64762eb99868b1a5c7b75 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 30 Jul 2013 09:19:07 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6045 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index 722323d54..9663e85ac 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -61,8 +61,9 @@ */ #define CH_IRQ_PROLOGUE() \ PORT_IRQ_PROLOGUE(); \ - dbg_check_enter_isr(); \ - _stats_increase_irq() + _stats_start_measure_isr(); \ + _stats_increase_irq(); \ + dbg_check_enter_isr() /** * @brief IRQ handler exit code. @@ -74,6 +75,7 @@ */ #define CH_IRQ_EPILOGUE() \ dbg_check_leave_isr(); \ + _stats_stop_measure_isr(); \ PORT_IRQ_EPILOGUE() /** @@ -290,6 +292,7 @@ static inline void chSysEnable(void) { static inline void chSysLock(void) { port_lock(); + _stats_start_measure_crit_thd(); dbg_check_lock(); } @@ -301,6 +304,7 @@ static inline void chSysLock(void) { static inline void chSysUnlock(void) { dbg_check_unlock(); + _stats_stop_measure_crit_thd(); port_unlock(); } @@ -319,6 +323,7 @@ static inline void chSysUnlock(void) { static inline void chSysLockFromISR(void) { port_lock_from_isr(); + _stats_start_measure_crit_isr(); dbg_check_lock_from_isr(); } @@ -338,6 +343,7 @@ static inline void chSysLockFromISR(void) { static inline void chSysUnlockFromISR(void) { dbg_check_unlock_from_isr(); + _stats_stop_measure_crit_isr(); port_unlock_from_isr(); } -- cgit v1.2.3 From 64403d8f188725bc5814813371382bc148956a83 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 30 Jul 2013 14:23:37 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6048 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index 9663e85ac..bfb521d65 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -61,7 +61,6 @@ */ #define CH_IRQ_PROLOGUE() \ PORT_IRQ_PROLOGUE(); \ - _stats_start_measure_isr(); \ _stats_increase_irq(); \ dbg_check_enter_isr() @@ -75,7 +74,6 @@ */ #define CH_IRQ_EPILOGUE() \ dbg_check_leave_isr(); \ - _stats_stop_measure_isr(); \ PORT_IRQ_EPILOGUE() /** @@ -196,6 +194,24 @@ #define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value() #endif +/** + * @brief Performs a context switch. + * @note Not a user function, it is meant to be invoked by the scheduler + * itself or from within the port layer. + * + * @param[in] ntp the thread to be switched in + * @param[in] otp the thread to be switched out + * + * @special + */ +#define chSysSwitch(ntp, otp) { \ + \ + dbg_trace(otp); \ + _stats_increase_ctxswc(); \ + CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp); \ + port_switch(ntp, otp); \ +} + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ @@ -220,24 +236,6 @@ extern "C" { /* Module inline functions. */ /*===========================================================================*/ -/** - * @brief Performs a context switch. - * @note Not a user function, it is meant to be invoked by the scheduler - * itself or from within the port layer. - * - * @param[in] ntp the thread to be switched in - * @param[in] otp the thread to be switched out - * - * @special - */ -static inline void chSysSwitch(thread_t *ntp, thread_t *otp) { - - dbg_trace(otp); - _stats_increase_ctxswc(); - CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp); - port_switch(ntp, otp); -} - /** * @brief Raises the system interrupt priority mask to the maximum level. * @details All the maskable interrupt sources are disabled regardless their -- cgit v1.2.3 From ceea042aaf3e373b598b3295c256feaef4e4236c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 31 Jul 2013 12:26:02 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6056 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index bfb521d65..9eaf5d8e6 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -207,7 +207,7 @@ #define chSysSwitch(ntp, otp) { \ \ dbg_trace(otp); \ - _stats_increase_ctxswc(); \ + _stats_ctxswc(ntp, otp); \ CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp); \ port_switch(ntp, otp); \ } -- cgit v1.2.3 From 04601b760b4d72a400237c5469a0962a66251507 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 6 Aug 2013 09:19:19 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6084 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index 9eaf5d8e6..2d7cfa430 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -109,75 +109,71 @@ * @details Converts from seconds to realtime counter cycles. * @note The result is rounded upward to the next tick boundary. * - * @param[in] freq realtime counter operating frequency * @param[in] sec number of seconds * @return The number of cycles. * * @api */ -#define S2RTV(freq, sec) ((freq) * (sec)) +#define S2RTV(sec) (CH_CFG_RTC_FREQUENCY * (sec)) /** * @brief Milliseconds to realtime counter. * @details Converts from milliseconds to realtime counter cycles. * @note The result is rounded upward to the next tick boundary. * - * @param[in] freq realtime counter operating frequency * @param[in] msec number of milliseconds * @return The number of cycles. * * @api */ -#define MS2RTC(freq, msec) (rtcnt_t)((((freq) + 999UL) / 1000UL) * (msec)) +#define MS2RTC(msec) (rtcnt_t)(((CH_CFG_RTC_FREQUENCY + 999UL) / \ + 1000UL) * (msec)) /** * @brief Microseconds to realtime counter. * @details Converts from microseconds to realtime counter cycles. * @note The result is rounded upward to the next tick boundary. * - * @param[in] freq realtime counter operating frequency * @param[in] usec number of microseconds * @return The number of cycles. * * @api */ -#define US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec)) +#define US2RTC(usec) (rtcnt_t)(((CH_CFG_RTC_FREQUENCY + 999999UL) / \ + 1000000UL) * (usec)) /** * @brief Realtime counter cycles to seconds. * @details Converts from realtime counter cycles number to seconds. * - * @param[in] freq realtime counter operating frequency * @param[in] n number of cycles * @return The number of seconds. * * @api */ -#define RTC2S(freq, n) (rtcnt_t)((n) / (freq)) +#define RTC2S(n) (rtcnt_t)(CH_CFG_RTC_FREQUENCY / (freq)) /** * @brief Realtime counter cycles to milliseconds. * @details Converts from realtime counter cycles number to milliseconds. * - * @param[in] freq realtime counter operating frequency * @param[in] n number of cycles * @return The number of milliseconds. * * @api */ -#define RTC2MS(freq, n) ((n) / ((freq) / 1000UL)) +#define RTC2MS(n) ((n) / (CH_CFG_RTC_FREQUENCY / 1000UL)) /** * @brief Realtime counter cycles to microseconds. * @details Converts from realtime counter cycles number to microseconds. * - * @param[in] freq realtime counter operating frequency * @param[in] n number of cycles * @return The number of microseconds. * * @api */ -#define RTC2US(freq, n) ((n) / ((freq) / 1000000UL)) +#define RTC2US(n) ((n) / (CH_CFG_RTC_FREQUENCY / 1000000UL)) /** @} */ /** -- cgit v1.2.3 From 649decd10516a30886d05f5afca3d425d836db0e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Aug 2013 10:17:45 +0000 Subject: Cleanup debug module. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6120 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index 2d7cfa430..475e090bd 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -62,7 +62,7 @@ #define CH_IRQ_PROLOGUE() \ PORT_IRQ_PROLOGUE(); \ _stats_increase_irq(); \ - dbg_check_enter_isr() + _dbg_check_enter_isr() /** * @brief IRQ handler exit code. @@ -73,7 +73,7 @@ * @special */ #define CH_IRQ_EPILOGUE() \ - dbg_check_leave_isr(); \ + _dbg_check_leave_isr(); \ PORT_IRQ_EPILOGUE() /** @@ -202,7 +202,7 @@ */ #define chSysSwitch(ntp, otp) { \ \ - dbg_trace(otp); \ + _dbg_trace(otp); \ _stats_ctxswc(ntp, otp); \ CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp); \ port_switch(ntp, otp); \ @@ -243,7 +243,7 @@ extern "C" { static inline void chSysDisable(void) { port_disable(); - dbg_check_disable(); + _dbg_check_disable(); } /** @@ -260,7 +260,7 @@ static inline void chSysDisable(void) { static inline void chSysSuspend(void) { port_suspend(); - dbg_check_suspend(); + _dbg_check_suspend(); } /** @@ -274,7 +274,7 @@ static inline void chSysSuspend(void) { */ static inline void chSysEnable(void) { - dbg_check_enable(); + _dbg_check_enable(); port_enable(); } @@ -287,7 +287,7 @@ static inline void chSysLock(void) { port_lock(); _stats_start_measure_crit_thd(); - dbg_check_lock(); + _dbg_check_lock(); } /** @@ -297,7 +297,7 @@ static inline void chSysLock(void) { */ static inline void chSysUnlock(void) { - dbg_check_unlock(); + _dbg_check_unlock(); _stats_stop_measure_crit_thd(); port_unlock(); } @@ -318,7 +318,7 @@ static inline void chSysLockFromISR(void) { port_lock_from_isr(); _stats_start_measure_crit_isr(); - dbg_check_lock_from_isr(); + _dbg_check_lock_from_isr(); } /** @@ -336,7 +336,7 @@ static inline void chSysLockFromISR(void) { */ static inline void chSysUnlockFromISR(void) { - dbg_check_unlock_from_isr(); + _dbg_check_unlock_from_isr(); _stats_stop_measure_crit_isr(); port_unlock_from_isr(); } -- cgit v1.2.3 From a1435e018bfc9919cb76b1356509ecc883767fb4 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 10 Aug 2013 14:51:16 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6123 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chsys.h | 346 ---------------------------------------------- 1 file changed, 346 deletions(-) delete mode 100644 os/kernel/include/chsys.h (limited to 'os/kernel/include/chsys.h') diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h deleted file mode 100644 index 475e090bd..000000000 --- a/os/kernel/include/chsys.h +++ /dev/null @@ -1,346 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012,2013 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file chsys.h - * @brief System related macros and structures. - * - * @addtogroup system - * @{ - */ - -#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 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(); \ - _stats_increase_irq(); \ - _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) -/** @} */ - -/** - * @name Time conversion utilities for the realtime counter - * @{ - */ -/** - * @brief Seconds to realtime counter. - * @details Converts from seconds to realtime counter cycles. - * @note The result is rounded upward to the next tick boundary. - * - * @param[in] sec number of seconds - * @return The number of cycles. - * - * @api - */ -#define S2RTV(sec) (CH_CFG_RTC_FREQUENCY * (sec)) - -/** - * @brief Milliseconds to realtime counter. - * @details Converts from milliseconds to realtime counter cycles. - * @note The result is rounded upward to the next tick boundary. - * - * @param[in] msec number of milliseconds - * @return The number of cycles. - * - * @api - */ -#define MS2RTC(msec) (rtcnt_t)(((CH_CFG_RTC_FREQUENCY + 999UL) / \ - 1000UL) * (msec)) - -/** - * @brief Microseconds to realtime counter. - * @details Converts from microseconds to realtime counter cycles. - * @note The result is rounded upward to the next tick boundary. - * - * @param[in] usec number of microseconds - * @return The number of cycles. - * - * @api - */ -#define US2RTC(usec) (rtcnt_t)(((CH_CFG_RTC_FREQUENCY + 999999UL) / \ - 1000000UL) * (usec)) - -/** - * @brief Realtime counter cycles to seconds. - * @details Converts from realtime counter cycles number to seconds. - * - * @param[in] n number of cycles - * @return The number of seconds. - * - * @api - */ -#define RTC2S(n) (rtcnt_t)(CH_CFG_RTC_FREQUENCY / (freq)) - -/** - * @brief Realtime counter cycles to milliseconds. - * @details Converts from realtime counter cycles number to milliseconds. - * - * @param[in] n number of cycles - * @return The number of milliseconds. - * - * @api - */ -#define RTC2MS(n) ((n) / (CH_CFG_RTC_FREQUENCY / 1000UL)) - -/** - * @brief Realtime counter cycles to microseconds. - * @details Converts from realtime counter cycles number to microseconds. - * - * @param[in] n number of cycles - * @return The number of microseconds. - * - * @api - */ -#define RTC2US(n) ((n) / (CH_CFG_RTC_FREQUENCY / 1000000UL)) -/** @} */ - -/** - * @brief Returns the current value of the system real time counter. - * @note This function is only available if the port layer supports the - * option @p CH_PORT_SUPPORTS_RT. - * - * @return The value of the system realtime counter of - * type rtcnt_t. - * - * @xclass - */ -#if CH_PORT_SUPPORTS_RT || defined(__DOXYGEN__) -#define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value() -#endif - -/** - * @brief Performs a context switch. - * @note Not a user function, it is meant to be invoked by the scheduler - * itself or from within the port layer. - * - * @param[in] ntp the thread to be switched in - * @param[in] otp the thread to be switched out - * - * @special - */ -#define chSysSwitch(ntp, otp) { \ - \ - _dbg_trace(otp); \ - _stats_ctxswc(ntp, otp); \ - CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp); \ - port_switch(ntp, otp); \ -} - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - void chSysInit(void); - void chSysHalt(void); - void chSysTimerHandlerI(void); - syssts_t chSysGetAndLockX(void); - void chSysRestoreLockX(syssts_t sts); -#if CH_PORT_SUPPORTS_RT - bool chSysIsCounterWithinX(rtcnt_t cnt, rtcnt_t start, rtcnt_t end); - void chSysPolledDelayX(rtcnt_t cycles); -#endif -#ifdef __cplusplus -} -#endif - -/*===========================================================================*/ -/* Module inline functions. */ -/*===========================================================================*/ - -/** - * @brief Raises the system interrupt priority mask to the maximum level. - * @details All the maskable interrupt sources are disabled regardless their - * hardware priority. - * @note Do not invoke this API from within a kernel lock. - * - * @special - */ -static inline void chSysDisable(void) { - - port_disable(); - _dbg_check_disable(); -} - -/** - * @brief Raises the system interrupt priority mask to system level. - * @details The interrupt sources that should not be able to preempt the kernel - * are disabled, interrupt sources with higher priority are still - * enabled. - * @note Do not invoke this API from within a kernel lock. - * @note This API is no replacement for @p chSysLock(), the @p chSysLock() - * could do more than just disable the interrupts. - * - * @special - */ -static inline void chSysSuspend(void) { - - port_suspend(); - _dbg_check_suspend(); -} - -/** - * @brief Lowers the system interrupt priority mask to user level. - * @details All the interrupt sources are enabled. - * @note Do not invoke this API from within a kernel lock. - * @note This API is no replacement for @p chSysUnlock(), the - * @p chSysUnlock() could do more than just enable the interrupts. - * - * @special - */ -static inline void chSysEnable(void) { - - _dbg_check_enable(); - port_enable(); -} - -/** - * @brief Enters the kernel lock mode. - * - * @special - */ -static inline void chSysLock(void) { - - port_lock(); - _stats_start_measure_crit_thd(); - _dbg_check_lock(); -} - -/** - * @brief Leaves the kernel lock mode. - * - * @special - */ -static inline void chSysUnlock(void) { - - _dbg_check_unlock(); - _stats_stop_measure_crit_thd(); - port_unlock(); -} - -/** - * @brief Enters the kernel lock mode 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.
- * 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. - * - * @special - */ -static inline void chSysLockFromISR(void) { - - port_lock_from_isr(); - _stats_start_measure_crit_isr(); - _dbg_check_lock_from_isr(); -} - -/** - * @brief Leaves the kernel lock mode 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.
- * 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. - * - * @special - */ -static inline void chSysUnlockFromISR(void) { - - _dbg_check_unlock_from_isr(); - _stats_stop_measure_crit_isr(); - port_unlock_from_isr(); -} - -#endif /* _CHSYS_H_ */ - -/** @} */ -- cgit v1.2.3