diff --git a/os/common/ports/ARM/chcore.h b/os/common/ports/ARM/chcore.h
index c749dbcef..cceb70147 100644
--- a/os/common/ports/ARM/chcore.h
+++ b/os/common/ports/ARM/chcore.h
@@ -600,12 +600,16 @@ static inline void port_wait_for_interrupt(void) {
#endif
}
+#endif /* !defined(_FROM_ASM_) */
+
+/*===========================================================================*/
+/* Module late inclusions. */
+/*===========================================================================*/
+
+#if !defined(_FROM_ASM_)
+
#if CH_CFG_ST_TIMEDELTA > 0
-#if PORT_USE_ALT_TIMER == FALSE
#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER */
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
#endif /* !defined(_FROM_ASM_) */
diff --git a/os/common/ports/ARM/chcore_timer.h b/os/common/ports/ARM/chcore_timer.h
deleted file mode 100644
index 86d94d514..000000000
--- a/os/common/ports/ARM/chcore_timer.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
- 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
-
- This file is part of ChibiOS.
-
- ChibiOS 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 version 3 of the License.
-
- ChibiOS 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 ARM/chcore_timer.h
- * @brief System timer header file.
- *
- * @addtogroup ARM_TIMER
- * @{
- */
-
-#ifndef CHCORE_TIMER_H
-#define CHCORE_TIMER_H
-
-/*===========================================================================*/
-/* Module constants. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module pre-compile time settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Derived constants and error checks. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module data structures and types. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module macros. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module inline functions. */
-/*===========================================================================*/
-
-/**
- * @brief Starts the alarm.
- * @note Makes sure that no spurious alarms are triggered after
- * this call.
- *
- * @param[in] time the time to be set for the first alarm
- *
- * @notapi
- */
-static inline void port_timer_start_alarm(systime_t time) {
- void stStartAlarm(systime_t time);
-
- stStartAlarm(time);
-}
-
-/**
- * @brief Stops the alarm interrupt.
- *
- * @notapi
- */
-static inline void port_timer_stop_alarm(void) {
- void stStopAlarm(void);
-
- stStopAlarm();
-}
-
-/**
- * @brief Sets the alarm time.
- *
- * @param[in] time the time to be set for the next alarm
- *
- * @notapi
- */
-static inline void port_timer_set_alarm(systime_t time) {
- void stSetAlarm(systime_t time);
-
- stSetAlarm(time);
-}
-
-/**
- * @brief Returns the system time.
- *
- * @return The system time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_time(void) {
- systime_t stGetCounter(void);
-
- return stGetCounter();
-}
-
-/**
- * @brief Returns the current alarm time.
- *
- * @return The currently set alarm time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_alarm(void) {
- systime_t stGetAlarm(void);
-
- return stGetAlarm();
-}
-
-#endif /* CHCORE_TIMER_H */
-
-/** @} */
diff --git a/os/common/ports/ARMv6-M-RP2/chcore.h b/os/common/ports/ARMv6-M-RP2/chcore.h
index 2e24df418..0dc7c2e14 100644
--- a/os/common/ports/ARMv6-M-RP2/chcore.h
+++ b/os/common/ports/ARMv6-M-RP2/chcore.h
@@ -489,12 +489,6 @@ extern "C" {
}
#endif
-#if PORT_USE_ALT_TIMER == FALSE
-#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER == TRUE */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER == TRUE */
-
/*===========================================================================*/
/* Module inline functions. */
/*===========================================================================*/
@@ -686,6 +680,18 @@ __STATIC_INLINE core_id_t port_get_core_id(void) {
#endif /* !defined(_FROM_ASM_) */
+/*===========================================================================*/
+/* Module late inclusions. */
+/*===========================================================================*/
+
+#if !defined(_FROM_ASM_)
+
+#if CH_CFG_ST_TIMEDELTA > 0
+#include "chcore_timer.h"
+#endif /* CH_CFG_ST_TIMEDELTA > 0 */
+
+#endif /* !defined(_FROM_ASM_) */
+
#endif /* CHCORE_H */
/** @} */
diff --git a/os/common/ports/ARMv6-M-RP2/chcore_timer.h b/os/common/ports/ARMv6-M-RP2/chcore_timer.h
deleted file mode 100644
index 4f522e6db..000000000
--- a/os/common/ports/ARMv6-M-RP2/chcore_timer.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
- 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
-
- This file is part of ChibiOS.
-
- ChibiOS 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 version 3 of the License.
-
- ChibiOS 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 ARMv6-M-RP2/chcore_timer.h
- * @brief System timer header file.
- *
- * @addtogroup ARMV6M_RP2_TIMER
- * @{
- */
-
-#ifndef CHCORE_TIMER_H
-#define CHCORE_TIMER_H
-
-/*===========================================================================*/
-/* Module constants. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module pre-compile time settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Derived constants and error checks. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module data structures and types. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module macros. */
-/*===========================================================================*/
-
-#if (CH_CFG_ST_TIMEDELTA > 0) || defined(__DOXYGEN__)
-/**
- * @brief Enables the system timer for the specified OS instance.
- */
-#define port_timer_enable(oip) stBindAlarmN((unsigned)(oip)->core_id)
-
-/**
- * @brief Disables the system timer for the specified OS instance.
- */
-#define port_timer_disable(oip)
-
-/**
- * @brief Starts the alarm.
- * @note Makes sure that no spurious alarms are triggered after
- * this call.
- *
- * @param[in] time the time to be set for the first alarm
- *
- * @notapi
- */
-#define port_timer_start_alarm(time) stStartAlarmN((unsigned)currcore->core_id, time)
-
-/**
- * @brief Stops the alarm interrupt.
- *
- * @notapi
- */
-#define port_timer_stop_alarm() stStopAlarmN((unsigned)currcore->core_id)
-
-/**
- * @brief Sets the alarm time.
- *
- * @param[in] time the time to be set for the next alarm
- *
- * @notapi
- */
-#define port_timer_set_alarm(time) stSetAlarmN((unsigned)currcore->core_id, time)
-
-/**
- * @brief Returns the current alarm time.
- *
- * @return The currently set alarm time.
- *
- * @notapi
- */
-#define port_timer_get_alarm() stGetAlarmN((unsigned)currcore->core_id)
-
-/**
- * @brief Returns the system time.
- *
- * @return The system time.
- *
- * @notapi
- */
-#define port_timer_get_time() stGetCounter()
-
-#else
-#define port_timer_enable(oip) stBind()
-#define port_timer_disable(oip)
-#endif
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- void stBind(void);
-#if CH_CFG_ST_TIMEDELTA > 0
- void stBindAlarmN(unsigned alarm);
- void stStartAlarmN(unsigned alarm, systime_t time);
- void stStopAlarmN(unsigned alarm);
- void stSetAlarmN(unsigned alarm, systime_t time);
- systime_t stGetAlarmN(unsigned alarm);
- systime_t stGetCounter(void);
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-/*===========================================================================*/
-/* Module inline functions. */
-/*===========================================================================*/
-
-#endif /* CHCORE_TIMER_H */
-
-/** @} */
diff --git a/os/common/ports/ARMv6-M/chcore.h b/os/common/ports/ARMv6-M/chcore.h
index ebd1af97d..dbc89d04e 100644
--- a/os/common/ports/ARMv6-M/chcore.h
+++ b/os/common/ports/ARMv6-M/chcore.h
@@ -449,14 +449,6 @@ extern "C" {
}
#endif
-#if CH_CFG_ST_TIMEDELTA > 0
-#if PORT_USE_ALT_TIMER == FALSE
-#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER != FALSE */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER != FALSE */
-#endif /* CH_CFG_ST_TIMEDELTA > 0 */
-
/*===========================================================================*/
/* Module inline functions. */
/*===========================================================================*/
@@ -576,6 +568,18 @@ static inline void port_wait_for_interrupt(void) {
#endif /* !defined(_FROM_ASM_) */
+/*===========================================================================*/
+/* Module late inclusions. */
+/*===========================================================================*/
+
+#if !defined(_FROM_ASM_)
+
+#if CH_CFG_ST_TIMEDELTA > 0
+#include "chcore_timer.h"
+#endif /* CH_CFG_ST_TIMEDELTA > 0 */
+
+#endif /* !defined(_FROM_ASM_) */
+
#endif /* CHCORE_H */
/** @} */
diff --git a/os/common/ports/ARMv7-M/chcore.h b/os/common/ports/ARMv7-M/chcore.h
index e4089d813..5f17a71f3 100644
--- a/os/common/ports/ARMv7-M/chcore.h
+++ b/os/common/ports/ARMv7-M/chcore.h
@@ -548,6 +548,11 @@ struct port_context {
#define PORT_IRQ_IS_VALID_KERNEL_PRIORITY(n) \
(((n) >= CORTEX_MAX_KERNEL_PRIORITY) && ((n) < CORTEX_PRIORITY_LEVELS))
+/**
+ * @brief Optimized thread function declaration macro.
+ */
+#define PORT_THD_FUNCTION(tname, arg) void tname(void *arg)
+
/* By default threads have no syscall context information.*/
#if (PORT_USE_SYSCALL == TRUE) || defined(__DOXYGEN__)
#define __PORT_SETUP_CONTEXT_SYSCALL(tp, wtop) \
@@ -597,11 +602,6 @@ struct port_context {
/* Note, checked above.*/
#endif
-/**
- * @brief Optimized thread function declaration macro.
- */
-#define PORT_THD_FUNCTION(tname, arg) void tname(void *arg)
-
/**
* @brief Platform dependent part of the @p chThdCreateI() API.
* @details This code usually setup the context switching frame represented
@@ -749,14 +749,6 @@ extern "C" {
}
#endif
-#if CH_CFG_ST_TIMEDELTA > 0
-#if PORT_USE_ALT_TIMER == FALSE
-#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER != FALSE */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER != FALSE */
-#endif /* CH_CFG_ST_TIMEDELTA > 0 */
-
/*===========================================================================*/
/* Module inline functions. */
/*===========================================================================*/
@@ -931,6 +923,18 @@ __STATIC_FORCEINLINE rtcnt_t port_rt_get_counter_value(void) {
#endif /* !defined(_FROM_ASM_) */
+/*===========================================================================*/
+/* Module late inclusions. */
+/*===========================================================================*/
+
+#if !defined(_FROM_ASM_)
+
+#if CH_CFG_ST_TIMEDELTA > 0
+#include "chcore_timer.h"
+#endif /* CH_CFG_ST_TIMEDELTA > 0 */
+
+#endif /* !defined(_FROM_ASM_) */
+
#endif /* CHCORE_H */
/** @} */
diff --git a/os/common/ports/ARMv7-M/chcore_timer.h b/os/common/ports/ARMv7-M/chcore_timer.h
deleted file mode 100644
index 15be2f951..000000000
--- a/os/common/ports/ARMv7-M/chcore_timer.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
- 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
-
- This file is part of ChibiOS.
-
- ChibiOS 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 version 3 of the License.
-
- ChibiOS 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 ARMv7-M/chcore_timer.h
- * @brief System timer header file.
- *
- * @addtogroup ARMV7M_TIMER
- * @{
- */
-
-#ifndef CHCORE_TIMER_H
-#define CHCORE_TIMER_H
-
-/*===========================================================================*/
-/* Module constants. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module pre-compile time settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Derived constants and error checks. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module data structures and types. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module macros. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- void stStartAlarm(systime_t time);
- void stStopAlarm(void);
- void stSetAlarm(systime_t time);
- systime_t stGetCounter(void);
- systime_t stGetAlarm(void);
-#ifdef __cplusplus
-}
-#endif
-
-/*===========================================================================*/
-/* Module inline functions. */
-/*===========================================================================*/
-
-/**
- * @brief Starts the alarm.
- * @note Makes sure that no spurious alarms are triggered after
- * this call.
- *
- * @param[in] time the time to be set for the first alarm
- *
- * @notapi
- */
-static inline void port_timer_start_alarm(systime_t time) {
-
- stStartAlarm(time);
-}
-
-/**
- * @brief Stops the alarm interrupt.
- *
- * @notapi
- */
-static inline void port_timer_stop_alarm(void) {
-
- stStopAlarm();
-}
-
-/**
- * @brief Sets the alarm time.
- *
- * @param[in] time the time to be set for the next alarm
- *
- * @notapi
- */
-static inline void port_timer_set_alarm(systime_t time) {
-
- stSetAlarm(time);
-}
-
-/**
- * @brief Returns the system time.
- *
- * @return The system time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_time(void) {
-
- return stGetCounter();
-}
-
-/**
- * @brief Returns the current alarm time.
- *
- * @return The currently set alarm time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_alarm(void) {
-
- return stGetAlarm();
-}
-
-#endif /* CHCORE_TIMER_H */
-
-/** @} */
diff --git a/os/common/ports/ARMv8-M-ML-TZ/chcore.h b/os/common/ports/ARMv8-M-ML-TZ/chcore.h
index 6071a73c8..b853f0e85 100644
--- a/os/common/ports/ARMv8-M-ML-TZ/chcore.h
+++ b/os/common/ports/ARMv8-M-ML-TZ/chcore.h
@@ -794,12 +794,16 @@ __STATIC_FORCEINLINE rtcnt_t port_rt_get_counter_value(void) {
return DWT->CYCCNT;
}
+#endif /* !defined(_FROM_ASM_) */
+
+/*===========================================================================*/
+/* Module late inclusions. */
+/*===========================================================================*/
+
+#if !defined(_FROM_ASM_)
+
#if CH_CFG_ST_TIMEDELTA > 0
-#if PORT_USE_ALT_TIMER == FALSE
#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER != FALSE */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER != FALSE */
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
#endif /* !defined(_FROM_ASM_) */
diff --git a/os/common/ports/ARMv8-M-ML-TZ/chcore_timer.h b/os/common/ports/ARMv8-M-ML-TZ/chcore_timer.h
deleted file mode 100644
index a2792759c..000000000
--- a/os/common/ports/ARMv8-M-ML-TZ/chcore_timer.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
- 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
-
- This file is part of ChibiOS.
-
- ChibiOS 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 version 3 of the License.
-
- ChibiOS 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 ARMv8-M-ML/chcore_timer.h
- * @brief System timer header file.
- *
- * @addtogroup ARMV8M_ML_TZ_TIMER
- * @{
- */
-
-#ifndef CHCORE_TIMER_H
-#define CHCORE_TIMER_H
-
-/*===========================================================================*/
-/* Module constants. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module pre-compile time settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Derived constants and error checks. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module data structures and types. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module macros. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- void stStartAlarm(systime_t time);
- void stStopAlarm(void);
- void stSetAlarm(systime_t time);
- systime_t stGetCounter(void);
- systime_t stGetAlarm(void);
-#ifdef __cplusplus
-}
-#endif
-
-/*===========================================================================*/
-/* Module inline functions. */
-/*===========================================================================*/
-
-/**
- * @brief Starts the alarm.
- * @note Makes sure that no spurious alarms are triggered after
- * this call.
- *
- * @param[in] time the time to be set for the first alarm
- *
- * @notapi
- */
-static inline void port_timer_start_alarm(systime_t time) {
-
- stStartAlarm(time);
-}
-
-/**
- * @brief Stops the alarm interrupt.
- *
- * @notapi
- */
-static inline void port_timer_stop_alarm(void) {
-
- stStopAlarm();
-}
-
-/**
- * @brief Sets the alarm time.
- *
- * @param[in] time the time to be set for the next alarm
- *
- * @notapi
- */
-static inline void port_timer_set_alarm(systime_t time) {
-
- stSetAlarm(time);
-}
-
-/**
- * @brief Returns the system time.
- *
- * @return The system time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_time(void) {
-
- return stGetCounter();
-}
-
-/**
- * @brief Returns the current alarm time.
- *
- * @return The currently set alarm time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_alarm(void) {
-
- return stGetAlarm();
-}
-
-#endif /* CHCORE_TIMER_H */
-
-/** @} */
diff --git a/os/common/ports/ARMv8-M-ML/chcore.h b/os/common/ports/ARMv8-M-ML/chcore.h
index 8ef2222d5..b6ad4730d 100644
--- a/os/common/ports/ARMv8-M-ML/chcore.h
+++ b/os/common/ports/ARMv8-M-ML/chcore.h
@@ -548,14 +548,6 @@ extern "C" {
}
#endif
-#if CH_CFG_ST_TIMEDELTA > 0
-#if PORT_USE_ALT_TIMER == FALSE
-#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER != FALSE */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER != FALSE */
-#endif /* CH_CFG_ST_TIMEDELTA > 0 */
-
/*===========================================================================*/
/* Module inline functions. */
/*===========================================================================*/
@@ -730,6 +722,18 @@ extern "C" {
#endif /* !defined(_FROM_ASM_) */
+/*===========================================================================*/
+/* Module late inclusions. */
+/*===========================================================================*/
+
+#if !defined(_FROM_ASM_)
+
+#if CH_CFG_ST_TIMEDELTA > 0
+#include "chcore_timer.h"
+#endif /* CH_CFG_ST_TIMEDELTA > 0 */
+
+#endif /* !defined(_FROM_ASM_) */
+
#endif /* CHCORE_H */
/** @} */
diff --git a/os/common/ports/ARMv8-M-ML/chcore_timer.h b/os/common/ports/ARMv8-M-ML/chcore_timer.h
deleted file mode 100644
index 85b1f7450..000000000
--- a/os/common/ports/ARMv8-M-ML/chcore_timer.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
- 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
-
- This file is part of ChibiOS.
-
- ChibiOS 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 version 3 of the License.
-
- ChibiOS 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 ARMv8-M-ML/chcore_timer.h
- * @brief System timer header file.
- *
- * @addtogroup ARMV8M_ML_TIMER
- * @{
- */
-
-#ifndef CHCORE_TIMER_H
-#define CHCORE_TIMER_H
-
-/*===========================================================================*/
-/* Module constants. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module pre-compile time settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Derived constants and error checks. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module data structures and types. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module macros. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- void stStartAlarm(systime_t time);
- void stStopAlarm(void);
- void stSetAlarm(systime_t time);
- systime_t stGetCounter(void);
- systime_t stGetAlarm(void);
-#ifdef __cplusplus
-}
-#endif
-
-/*===========================================================================*/
-/* Module inline functions. */
-/*===========================================================================*/
-
-/**
- * @brief Starts the alarm.
- * @note Makes sure that no spurious alarms are triggered after
- * this call.
- *
- * @param[in] time the time to be set for the first alarm
- *
- * @notapi
- */
-static inline void port_timer_start_alarm(systime_t time) {
-
- stStartAlarm(time);
-}
-
-/**
- * @brief Stops the alarm interrupt.
- *
- * @notapi
- */
-static inline void port_timer_stop_alarm(void) {
-
- stStopAlarm();
-}
-
-/**
- * @brief Sets the alarm time.
- *
- * @param[in] time the time to be set for the next alarm
- *
- * @notapi
- */
-static inline void port_timer_set_alarm(systime_t time) {
-
- stSetAlarm(time);
-}
-
-/**
- * @brief Returns the system time.
- *
- * @return The system time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_time(void) {
-
- return stGetCounter();
-}
-
-/**
- * @brief Returns the current alarm time.
- *
- * @return The currently set alarm time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_alarm(void) {
-
- return stGetAlarm();
-}
-
-#endif /* CHCORE_TIMER_H */
-
-/** @} */
diff --git a/os/common/ports/AVR/chcore.h b/os/common/ports/AVR/chcore.h
index 66b9b3f02..19952cda8 100644
--- a/os/common/ports/AVR/chcore.h
+++ b/os/common/ports/AVR/chcore.h
@@ -528,16 +528,10 @@ static inline rtcnt_t port_rt_get_counter_value(void) {
/* Module late inclusions. */
/*===========================================================================*/
-/* The following code is not processed when the file is included from an
- asm module.*/
#if !defined(_FROM_ASM_)
#if CH_CFG_ST_TIMEDELTA > 0
-#if !PORT_USE_ALT_TIMER
#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER */
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
#endif /* !defined(_FROM_ASM_) */
diff --git a/os/common/ports/AVR/chcore_timer.h b/os/common/ports/AVR/chcore_timer.h
deleted file mode 100644
index c2e4ab120..000000000
--- a/os/common/ports/AVR/chcore_timer.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
- 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
-
- This file is part of ChibiOS.
-
- ChibiOS 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 version 3 of the License.
-
- ChibiOS 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 AVR/chcore_timer.h
- * @brief System timer header file.
- *
- * @addtogroup AVR_TIMER
- * @{
- */
-
-#ifndef CHCORE_TIMER_H
-#define CHCORE_TIMER_H
-
-/*===========================================================================*/
-/* Module constants. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module pre-compile time settings. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Derived constants and error checks. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module data structures and types. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module macros. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Module inline functions. */
-/*===========================================================================*/
-
-/**
- * @brief Starts the alarm.
- * @note Makes sure that no spurious alarms are triggered after
- * this call.
- *
- * @param[in] time the time to be set for the first alarm
- *
- * @notapi
- */
-static inline void port_timer_start_alarm(systime_t time) {
- void stStartAlarm(systime_t time);
-
- stStartAlarm(time);
-}
-
-/**
- * @brief Stops the alarm interrupt.
- *
- * @notapi
- */
-static inline void port_timer_stop_alarm(void) {
- void stStopAlarm(void);
-
- stStopAlarm();
-}
-
-/**
- * @brief Sets the alarm time.
- *
- * @param[in] time the time to be set for the next alarm
- *
- * @notapi
- */
-static inline void port_timer_set_alarm(systime_t time) {
- void stSetAlarm(systime_t time);
-
- stSetAlarm(time);
-}
-
-/**
- * @brief Returns the system time.
- *
- * @return The system time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_time(void) {
- systime_t stGetCounter(void);
-
- return stGetCounter();
-}
-
-/**
- * @brief Returns the current alarm time.
- *
- * @return The currently set alarm time.
- *
- * @notapi
- */
-static inline systime_t port_timer_get_alarm(void) {
- systime_t stGetAlarm(void);
-
- return stGetAlarm();
-}
-
-#endif /* CHCORE_TIMER_H */
-
-/** @} */
diff --git a/os/common/ports/SIMIA32/chcore.h b/os/common/ports/SIMIA32/chcore.h
index d94bb52d6..286160ddd 100644
--- a/os/common/ports/SIMIA32/chcore.h
+++ b/os/common/ports/SIMIA32/chcore.h
@@ -459,11 +459,7 @@ static inline void port_wait_for_interrupt(void) {
#if !defined(_FROM_ASM_)
#if CH_CFG_ST_TIMEDELTA > 0
-#if !PORT_USE_ALT_TIMER
#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER */
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
#endif /* !defined(_FROM_ASM_) */
diff --git a/os/common/ports/e200/chcore.h b/os/common/ports/e200/chcore.h
index bf57674b3..ddf6eb5b0 100644
--- a/os/common/ports/e200/chcore.h
+++ b/os/common/ports/e200/chcore.h
@@ -708,11 +708,7 @@ static inline rtcnt_t port_rt_get_counter_value(void) {
#if !defined(_FROM_ASM_)
#if CH_CFG_ST_TIMEDELTA > 0
-#if !PORT_USE_ALT_TIMER
#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER */
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
#endif /* !defined(_FROM_ASM_) */
diff --git a/os/common/ports/templates/chcore.c b/os/common/ports/templates/chcore.c
index be97763e1..7ef05c1db 100644
--- a/os/common/ports/templates/chcore.c
+++ b/os/common/ports/templates/chcore.c
@@ -21,7 +21,7 @@
* @file templates/chcore.c
* @brief Port related template code.
*
- * @addtogroup port_core
+ * @addtogroup TEMPLATE_CORE
* @details Non portable code templates.
* @{
*/
diff --git a/os/common/ports/templates/chcore.h b/os/common/ports/templates/chcore.h
index f62fd1b59..7f54c98b7 100644
--- a/os/common/ports/templates/chcore.h
+++ b/os/common/ports/templates/chcore.h
@@ -23,7 +23,7 @@
* @details This file is a template of the system driver macros provided by
* a port.
*
- * @addtogroup port_core
+ * @addtogroup TEMPLATE_CORE
* @{
*/
@@ -149,12 +149,6 @@
asm module.*/
#if !defined(_FROM_ASM_)
-/**
- * @brief Type of stack and memory alignment enforcement.
- * @note In this architecture the stack alignment is enforced to 64 bits.
- */
-typedef uint64_t stkalign_t;
-
/**
* @brief Interrupt saved context.
* @details This structure represents the stack frame saved during a
@@ -192,6 +186,11 @@ struct port_context {
/* Module macros. */
/*===========================================================================*/
+/**
+ * @brief Optimized thread function declaration macro.
+ */
+#define PORT_THD_FUNCTION(tname, arg) void tname(void *arg)
+
/**
* @brief Platform dependent part of the @p chThdCreateI() API.
* @details This code usually setup the context switching frame represented
@@ -441,16 +440,10 @@ static inline rtcnt_t port_rt_get_counter_value(void) {
/* Module late inclusions. */
/*===========================================================================*/
-/* The following code is not processed when the file is included from an
- asm module.*/
#if !defined(_FROM_ASM_)
#if CH_CFG_ST_TIMEDELTA > 0
-#if !PORT_USE_ALT_TIMER
#include "chcore_timer.h"
-#else /* PORT_USE_ALT_TIMER */
-#include "chcore_timer_alt.h"
-#endif /* PORT_USE_ALT_TIMER */
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
#endif /* !defined(_FROM_ASM_) */
diff --git a/os/common/ports/templates/chtypes.h b/os/common/ports/templates/chtypes.h
index 3bd5f75e9..4409e973f 100644
--- a/os/common/ports/templates/chtypes.h
+++ b/os/common/ports/templates/chtypes.h
@@ -19,13 +19,9 @@
/**
* @file templates/chtypes.h
- * @brief System types template.
+ * @brief Template port system types.
*
- * @addtogroup port_types
- * @details The types defined in this file may change depending on the target
- * architecture. You may also try to optimize the size of the various
- * types in order to privilege size or performance, be careful in
- * doing so.
+ * @addtogroup TEMPLATE_CORE
* @{
*/
@@ -36,65 +32,74 @@
#include
#include
+#include "ccportab.h"
+
/**
- * @name Kernel types
+ * @name Architecture data constraints
+ */
+#define PORT_ARCH_SIZEOF_DATA_PTR 4
+#define PORT_ARCH_SIZEOF_CODE_PTR 4
+#define PORT_ARCH_REGISTERS_WIDTH 32
+#define PORT_ARCH_REVERSE_ORDER 1
+/** @} */
+
+/**
+ * @name Port types
* @{
*/
-typedef uint32_t rtcnt_t; /**< Realtime counter. */
-typedef uint64_t rttime_t; /**< Realtime accumulator. */
-typedef uint32_t syssts_t; /**< System status word. */
-typedef uint8_t tmode_t; /**< Thread flags. */
-typedef uint8_t tstate_t; /**< Thread state. */
-typedef uint8_t trefs_t; /**< Thread references counter. */
-typedef uint8_t tslices_t; /**< Thread time slices counter.*/
-typedef uint32_t tprio_t; /**< Thread priority. */
-typedef int32_t msg_t; /**< Inter-thread message. */
-typedef int32_t eventid_t; /**< Numeric event identifier. */
-typedef uint32_t eventmask_t; /**< Mask of event identifiers. */
-typedef uint32_t eventflags_t; /**< Mask of event flags. */
-typedef int32_t cnt_t; /**< Generic signed counter. */
-typedef uint32_t ucnt_t; /**< Generic unsigned counter. */
+/**
+ * @brief Realtime counter.
+ */
+typedef uint32_t port_rtcnt_t;
+
+/**
+ * @brief Realtime accumulator.
+ */
+typedef uint64_t port_rttime_t;
+
+/**
+ * @brief System status word.
+ */
+typedef uint32_t port_syssts_t;
+
+/**
+ * @brief Type of stack and memory alignment enforcement.
+ * @note In this architecture the stack alignment is enforced to 64 bits,
+ * 32 bits alignment is supported by hardware but deprecated by ARM,
+ * the implementation choice is to not offer the option.
+ */
+typedef uint64_t port_stkalign_t;
/** @} */
+/**
+ * @brief This port does not define OS-related types.
+ */
+#define PORT_DOES_NOT_PROVIDE_TYPES
+
/**
* @brief ROM constant modifier.
* @note It is set to use the "const" keyword in this port.
*/
-#define ROMCONST const
+#define ROMCONST CC_ROMCONST
/**
* @brief Makes functions not inlineable.
- * @note If the compiler does not support such attribute then the
- * realtime counter precision could be degraded.
+ * @note If the compiler does not support such attribute then some
+ * time-dependent services could be degraded.
*/
-#define NOINLINE __attribute__((noinline))
-
-/**
- * @brief Optimized thread function declaration macro.
- */
-#define PORT_THD_FUNCTION(tname, arg) void tname(void *arg)
-
-/**
- * @brief Packed variable specifier.
- */
-#define PACKED_VAR __attribute__((packed))
+#define NOINLINE CC_NO_INLINE
/**
* @brief Memory alignment enforcement for variables.
*/
-#define ALIGNED_VAR(n) __attribute__((aligned(n)))
+#define ALIGNED_VAR(n) CC_ALIGN_DATA(n)
/**
* @brief Size of a pointer.
* @note To be used where the sizeof operator cannot be used, preprocessor
* expressions for example.
*/
-#define SIZEOF_PTR 4
-
-/**
- * @brief True if alignment is low-high in current architecture.
- */
-#define REVERSE_ORDER 1
+#define SIZEOF_PTR PORT_ARCH_SIZEOF_DATA_PTR
#endif /* CHTYPES_H */
diff --git a/os/common/ports/ARMv6-M/chcore_timer.h b/os/hal/osal/rt-nil/chcore_timer.h
similarity index 75%
rename from os/common/ports/ARMv6-M/chcore_timer.h
rename to os/hal/osal/rt-nil/chcore_timer.h
index 7a0652102..6ffafa2c3 100644
--- a/os/common/ports/ARMv6-M/chcore_timer.h
+++ b/os/hal/osal/rt-nil/chcore_timer.h
@@ -1,27 +1,24 @@
/*
- ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
- 2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
+ ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
- This file is part of ChibiOS.
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
- ChibiOS 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 version 3 of the License.
+ http://www.apache.org/licenses/LICENSE-2.0
- ChibiOS 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 .
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
/**
- * @file ARMv6-M/chcore_timer.h
- * @brief System timer header file.
+ * @file osal/rt-nil//chcore_timer.h
+ * @brief System Timer bindings header file.
*
- * @addtogroup ARMV6M_TIMER
+ * @addtogroup OSAL_CHCORE_TIMER
* @{
*/