summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Boie <andrew.p.boie@intel.com>2017-02-15 13:40:17 -0800
committerAnas Nashif <nashif@linux.intel.com>2017-02-28 11:57:40 +0000
commit19ccf8300627a460ff1bdfb31c1dc91bed5540cd (patch)
tree9912251be70bd94c15f63adc3e5ab7fbe6103402
parentc1acfd049bc9ac4934082d74380fcb1633fee140 (diff)
kernel: add flexibility to k_cycle_get_32() definition
Some arches may want to define this as an inline function, or define in core arch code instead of timer driver code. Unfortunately, this means we need to remove from the footprint tests, but this is not typically a large function. Issue: ZEP-1546 Change-Id: Ic0d7a33507da855995838f4703d872cd613a2ca2 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
-rw-r--r--drivers/timer/altera_avalon_timer.c2
-rw-r--r--drivers/timer/arcv2_timer0.c2
-rw-r--r--drivers/timer/cortex_m_systick.c2
-rw-r--r--drivers/timer/hpet.c2
-rw-r--r--drivers/timer/loapic_timer.c2
-rw-r--r--drivers/timer/nrf_rtc_timer.c2
-rw-r--r--drivers/timer/pulpino_timer.c2
-rw-r--r--drivers/timer/riscv_machine_timer.c2
-rw-r--r--drivers/timer/xtensa_sys_timer.c2
-rw-r--r--include/arch/arc/v2/misc.h3
-rw-r--r--include/arch/arm/cortex_m/misc.h3
-rw-r--r--include/arch/nios2/arch.h3
-rw-r--r--include/arch/riscv32/arch.h3
-rw-r--r--include/arch/x86/arch.h3
-rw-r--r--include/arch/xtensa/arch.h3
-rw-r--r--include/kernel.h2
-rw-r--r--tests/legacy/benchmark/footprint/microkernel/src/microkernel_footprint.c1
-rw-r--r--tests/legacy/benchmark/footprint/nanokernel/src/nanokernel_footprint.c1
18 files changed, 28 insertions, 12 deletions
diff --git a/drivers/timer/altera_avalon_timer.c b/drivers/timer/altera_avalon_timer.c
index 2dec24506..80a78b167 100644
--- a/drivers/timer/altera_avalon_timer.c
+++ b/drivers/timer/altera_avalon_timer.c
@@ -96,7 +96,7 @@ int _sys_clock_driver_init(struct device *device)
}
-uint32_t k_cycle_get_32(void)
+uint32_t _timer_cycle_get_32(void)
{
/* XXX Per the Altera Embedded IP Peripherals guide, you cannot
* use a timer instance for both the system clock and timestamps
diff --git a/drivers/timer/arcv2_timer0.c b/drivers/timer/arcv2_timer0.c
index 6416a7aa6..3a681fb2f 100644
--- a/drivers/timer/arcv2_timer0.c
+++ b/drivers/timer/arcv2_timer0.c
@@ -413,7 +413,7 @@ int sys_clock_device_ctrl(struct device *port, uint32_t ctrl_command,
}
#endif /* CONFIG_DEVICE_POWER_MANAGEMENT */
-uint32_t k_cycle_get_32(void)
+uint32_t _timer_cycle_get_32(void)
{
return (accumulated_cycle_count + timer0_count_register_get());
}
diff --git a/drivers/timer/cortex_m_systick.c b/drivers/timer/cortex_m_systick.c
index 77d0a338b..450cdac6b 100644
--- a/drivers/timer/cortex_m_systick.c
+++ b/drivers/timer/cortex_m_systick.c
@@ -557,7 +557,7 @@ int _sys_clock_driver_init(struct device *device)
* systick counter is a 24-bit down counter which is reset to "reload" value
* once it reaches 0.
*/
-uint32_t k_cycle_get_32(void)
+uint32_t _timer_cycle_get_32(void)
{
return clock_accumulated_count + (SysTick->LOAD - SysTick->VAL);
}
diff --git a/drivers/timer/hpet.c b/drivers/timer/hpet.c
index 628b29645..8df0126a4 100644
--- a/drivers/timer/hpet.c
+++ b/drivers/timer/hpet.c
@@ -593,7 +593,7 @@ int _sys_clock_driver_init(struct device *device)
* it will need to call _hpetMainCounterAtomic().
*/
-uint32_t k_cycle_get_32(void)
+uint32_t _timer_cycle_get_32(void)
{
return (uint32_t) *_HPET_MAIN_COUNTER_VALUE;
}
diff --git a/drivers/timer/loapic_timer.c b/drivers/timer/loapic_timer.c
index db52f6d3c..b2400502b 100644
--- a/drivers/timer/loapic_timer.c
+++ b/drivers/timer/loapic_timer.c
@@ -588,7 +588,7 @@ int sys_clock_device_ctrl(struct device *port, uint32_t ctrl_command,
*
* @return up counter of elapsed clock cycles
*/
-uint32_t k_cycle_get_32(void)
+uint32_t _timer_cycle_get_32(void)
{
uint32_t val; /* system clock value */
diff --git a/drivers/timer/nrf_rtc_timer.c b/drivers/timer/nrf_rtc_timer.c
index 7917b1427..76c704d4c 100644
--- a/drivers/timer/nrf_rtc_timer.c
+++ b/drivers/timer/nrf_rtc_timer.c
@@ -301,7 +301,7 @@ int _sys_clock_driver_init(struct device *device)
return 0;
}
-uint32_t k_cycle_get_32(void)
+uint32_t _timer_cycle_get_32(void)
{
uint32_t elapsed_cycles;
diff --git a/drivers/timer/pulpino_timer.c b/drivers/timer/pulpino_timer.c
index 154e2c30c..9de8243e0 100644
--- a/drivers/timer/pulpino_timer.c
+++ b/drivers/timer/pulpino_timer.c
@@ -68,7 +68,7 @@ int _sys_clock_driver_init(struct device *device)
*
* @return up counter of elapsed clock cycles
*/
-uint32_t k_cycle_get_32(void)
+uint32_t _timer_cycle_get_32(void)
{
return accumulated_cycle_count + timer->val;
}
diff --git a/drivers/timer/riscv_machine_timer.c b/drivers/timer/riscv_machine_timer.c
index d94420390..b799138ce 100644
--- a/drivers/timer/riscv_machine_timer.c
+++ b/drivers/timer/riscv_machine_timer.c
@@ -89,7 +89,7 @@ int _sys_clock_driver_init(struct device *device)
*
* @return up counter of elapsed clock cycles
*/
-uint32_t k_cycle_get_32(void)
+uint32_t _timer_cycle_get_32(void)
{
/* We just want a cycle count so just post what's in the low 32
* bits of the mtime real-time counter
diff --git a/drivers/timer/xtensa_sys_timer.c b/drivers/timer/xtensa_sys_timer.c
index 321bab87f..3be5bcc07 100644
--- a/drivers/timer/xtensa_sys_timer.c
+++ b/drivers/timer/xtensa_sys_timer.c
@@ -345,7 +345,7 @@ int _sys_clock_driver_init(struct device *device)
*
* @return up counter of elapsed clock cycles
*/
-uint32_t k_cycle_get_32(void)
+uint32_t _timer_cycle_get_32(void)
{
return GET_TIMER_CURRENT_TIME();
}
diff --git a/include/arch/arc/v2/misc.h b/include/arch/arc/v2/misc.h
index fc45ddf59..14c711942 100644
--- a/include/arch/arc/v2/misc.h
+++ b/include/arch/arc/v2/misc.h
@@ -22,6 +22,9 @@ extern "C" {
extern unsigned int k_cpu_sleep_mode;
extern void k_cpu_idle(void);
extern void k_cpu_atomic_idle(unsigned int key);
+
+extern uint32_t _timer_cycle_get_32(void);
+#define _arch_k_cycle_get_32() _timer_cycle_get_32()
#endif
#ifdef __cplusplus
diff --git a/include/arch/arm/cortex_m/misc.h b/include/arch/arm/cortex_m/misc.h
index 76b3d931c..86567e1ea 100644
--- a/include/arch/arm/cortex_m/misc.h
+++ b/include/arch/arm/cortex_m/misc.h
@@ -20,6 +20,9 @@ extern "C" {
#ifndef _ASMLANGUAGE
extern void k_cpu_idle(void);
+
+extern uint32_t _timer_cycle_get_32(void);
+#define _arch_k_cycle_get_32() _timer_cycle_get_32()
#endif
#ifdef __cplusplus
diff --git a/include/arch/nios2/arch.h b/include/arch/nios2/arch.h
index dbc912bf8..eb28c9c3c 100644
--- a/include/arch/nios2/arch.h
+++ b/include/arch/nios2/arch.h
@@ -199,6 +199,9 @@ enum nios2_exception_cause {
BIT(NIOS2_EXCEPTION_ECC_DATA_ERR))
+extern uint32_t _timer_cycle_get_32(void);
+#define _arch_k_cycle_get_32() _timer_cycle_get_32()
+
#endif /* _ASMLANGUAGE */
#ifdef __cplusplus
diff --git a/include/arch/riscv32/arch.h b/include/arch/riscv32/arch.h
index 6624dc55a..198c4f429 100644
--- a/include/arch/riscv32/arch.h
+++ b/include/arch/riscv32/arch.h
@@ -109,6 +109,9 @@ static ALWAYS_INLINE void _arch_irq_unlock(unsigned int key)
: "memory");
}
+extern uint32_t _timer_cycle_get_32(void);
+#define _arch_k_cycle_get_32() _timer_cycle_get_32()
+
#endif /*_ASMLANGUAGE */
#if defined(CONFIG_SOC_RISCV32_PULPINO)
diff --git a/include/arch/x86/arch.h b/include/arch/x86/arch.h
index 16d8a0482..6a6a697ef 100644
--- a/include/arch/x86/arch.h
+++ b/include/arch/x86/arch.h
@@ -488,6 +488,9 @@ extern void k_float_disable(k_tid_t thread);
extern void k_cpu_idle(void);
+extern uint32_t _timer_cycle_get_32(void);
+#define _arch_k_cycle_get_32() _timer_cycle_get_32()
+
/** Nanokernel provided routine to report any detected fatal error. */
extern FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
const NANO_ESF * pEsf);
diff --git a/include/arch/xtensa/arch.h b/include/arch/xtensa/arch.h
index e650fef22..acd1ed1b8 100644
--- a/include/arch/xtensa/arch.h
+++ b/include/arch/xtensa/arch.h
@@ -136,6 +136,9 @@ extern void _irq_priority_set(uint32_t irq, uint32_t prio, uint32_t flags);
FUNC_NORETURN void _SysFatalErrorHandler(unsigned int reason,
const NANO_ESF *esf);
+extern uint32_t _timer_cycle_get_32(void);
+#define _arch_k_cycle_get_32() _timer_cycle_get_32()
+
#endif /* !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__) */
#ifdef __cplusplus
}
diff --git a/include/kernel.h b/include/kernel.h
index 50972ad57..1f79343c8 100644
--- a/include/kernel.h
+++ b/include/kernel.h
@@ -1094,7 +1094,7 @@ extern uint32_t k_uptime_delta_32(int64_t *reftime);
*
* @return Current hardware clock up-counter (in cycles).
*/
-extern uint32_t k_cycle_get_32(void);
+#define k_cycle_get_32() _arch_k_cycle_get_32()
/**
* @} end addtogroup clock_apis
diff --git a/tests/legacy/benchmark/footprint/microkernel/src/microkernel_footprint.c b/tests/legacy/benchmark/footprint/microkernel/src/microkernel_footprint.c
index 6eade5832..de3b168d0 100644
--- a/tests/legacy/benchmark/footprint/microkernel/src/microkernel_footprint.c
+++ b/tests/legacy/benchmark/footprint/microkernel/src/microkernel_footprint.c
@@ -132,7 +132,6 @@ static pfunc func_array[] = {
(pfunc)k_uptime_get_32,
(pfunc)k_uptime_delta,
(pfunc)k_uptime_delta_32,
- (pfunc)k_cycle_get_32,
/* thread stuff */
(pfunc)k_thread_spawn,
diff --git a/tests/legacy/benchmark/footprint/nanokernel/src/nanokernel_footprint.c b/tests/legacy/benchmark/footprint/nanokernel/src/nanokernel_footprint.c
index 0c4d8da5a..6a704f945 100644
--- a/tests/legacy/benchmark/footprint/nanokernel/src/nanokernel_footprint.c
+++ b/tests/legacy/benchmark/footprint/nanokernel/src/nanokernel_footprint.c
@@ -48,7 +48,6 @@ static pfunc func_array[] = {
(pfunc)k_uptime_get_32,
(pfunc)k_uptime_delta,
(pfunc)k_uptime_delta_32,
- (pfunc)k_cycle_get_32,
/* semaphores */
(pfunc)k_sem_init,