summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Walsh <benjamin.walsh@windriver.com>2015-06-14 18:12:14 -0400
committerAnas Nashif <anas.nashif@intel.com>2016-02-05 20:14:22 -0500
commit617f9c5b4c2e95d20dbaf6fa0ab8525b45bc5120 (patch)
tree7ad87c64766033497a2830ee616f713b530655c8
parent101fee8dde4cff091fa7eaef7ae61a753478ef8c (diff)
nanokernel: allow nano time tracking to be used in microkernels
The nanokernel time tracking code (ticker) can now exist in microkernel systems. This allows the ticker that drives nano timers and timeouts to advance the tick count for these in a microkernel, thus allow their presence there. Previously, nano timers could not be used in a microkernel. Change-Id: I17f2b659691a081b0f9bf3961ed030533aa02a15 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
-rw-r--r--include/clock_vars.h2
-rw-r--r--include/drivers/system_timer.h9
-rw-r--r--kernel/nanokernel/Makefile3
-rw-r--r--kernel/nanokernel/nano_sys_clock.c10
-rw-r--r--kernel/nanokernel/nano_timer.c4
5 files changed, 15 insertions, 13 deletions
diff --git a/include/clock_vars.h b/include/clock_vars.h
index c79c606c5..ed5728696 100644
--- a/include/clock_vars.h
+++ b/include/clock_vars.h
@@ -77,10 +77,8 @@ extern int sys_clock_hw_cycles_per_tick;
#define SYS_CLOCK_HW_CYCLES_TO_NS(X) (uint32_t)(SYS_CLOCK_HW_CYCLES_TO_NS64(X))
-#ifdef CONFIG_NANOKERNEL
extern int64_t _nano_ticks;
extern struct nano_timer *_nano_timer_list;
-#endif /* CONFIG_NANOKERNEL */
#endif /* !_ASMLANGUAGE */
diff --git a/include/drivers/system_timer.h b/include/drivers/system_timer.h
index 736b789e0..762c2f3f3 100644
--- a/include/drivers/system_timer.h
+++ b/include/drivers/system_timer.h
@@ -64,11 +64,18 @@ extern void _timer_idle_enter(int32_t ticks);
extern void _timer_idle_exit(void);
#endif /* TIMER_SUPPORTS_TICKLESS */
+extern uint32_t _nano_get_earliest_deadline(void);
+
+#if defined(CONFIG_NANO_TIMEOUTS) || defined(CONFIG_NANO_TIMERS)
+ extern void _nano_sys_clock_tick_announce(uint32_t ticks);
+#else
+ #define _nano_sys_clock_tick_announce(ticks) do { } while((0))
+#endif
+
#ifdef CONFIG_MICROKERNEL
#define _sys_clock_tick_announce() \
nano_isr_stack_push(&_k_command_stack, TICK_EVENT)
#else
- extern void _nano_sys_clock_tick_announce(uint32_t ticks);
extern uint32_t _sys_idle_elapsed_ticks;
#define _sys_clock_tick_announce() \
_nano_sys_clock_tick_announce(_sys_idle_elapsed_ticks)
diff --git a/kernel/nanokernel/Makefile b/kernel/nanokernel/Makefile
index b8b11678a..879de3a13 100644
--- a/kernel/nanokernel/Makefile
+++ b/kernel/nanokernel/Makefile
@@ -5,7 +5,7 @@ ccflags-y +=-I$(srctree)/kernel/microkernel/include
asflags-y := ${ccflags-y}
obj-y = nano_fiber.o nano_lifo.o \
- nano_fifo.o nano_stack.o \
+ nano_fifo.o nano_stack.o nano_sys_clock.o \
nano_context.o nano_init.o nano_sema.o \
version.o ctors.o device.o
@@ -13,5 +13,4 @@ obj-$(CONFIG_STACK_CANARIES) += compiler_stack_protect.o
obj-$(CONFIG_INT_LATENCY_BENCHMARK) += int_latency_bench.o
obj-$(CONFIG_PERFORMANCE_METRICS) += nanometrics.o
obj-$(CONFIG_ADVANCED_POWER_MANAGEMENT) += idle.o
-obj-$(CONFIG_NANOKERNEL) += nano_sys_clock.o
obj-$(CONFIG_NANO_TIMERS) += nano_timer.o
diff --git a/kernel/nanokernel/nano_sys_clock.c b/kernel/nanokernel/nano_sys_clock.c
index b02c6b9e1..b6ed2565a 100644
--- a/kernel/nanokernel/nano_sys_clock.c
+++ b/kernel/nanokernel/nano_sys_clock.c
@@ -30,7 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef CONFIG_NANOKERNEL
#include <nanok.h>
#include <toolchain.h>
@@ -38,6 +37,8 @@
#include <wait_q.h>
#include <drivers/system_timer.h>
+#ifdef CONFIG_NANOKERNEL
+
#ifdef CONFIG_SYS_CLOCK_EXISTS
int sys_clock_us_per_tick = 1000000 / sys_clock_ticks_per_sec;
int sys_clock_hw_cycles_per_tick =
@@ -48,7 +49,6 @@ int sys_clock_us_per_tick;
int sys_clock_hw_cycles_per_tick;
#endif
-int64_t _nano_ticks = 0;
/* updated by timer driver for tickless, stays at 1 for non-tickless */
uint32_t _sys_idle_elapsed_ticks = 1;
@@ -68,6 +68,10 @@ void nano_time_init(void)
SYS_PREKERNEL_INIT(nano_time_init, 250);
+#endif /* CONFIG_NANOKERNEL */
+
+int64_t _nano_ticks = 0;
+
/*******************************************************************************
*
* nano_tick_get_32 - return the lower part of the current system tick count
@@ -271,5 +275,3 @@ uint32_t _nano_get_earliest_deadline(void)
return min(_nano_get_earliest_timeouts_deadline(),
_nano_get_earliest_timers_deadline());
}
-
-#endif /* CONFIG_NANOKERNEL */
diff --git a/kernel/nanokernel/nano_timer.c b/kernel/nanokernel/nano_timer.c
index 8892dd1d2..7f711d126 100644
--- a/kernel/nanokernel/nano_timer.c
+++ b/kernel/nanokernel/nano_timer.c
@@ -30,8 +30,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifdef CONFIG_NANOKERNEL
-
#include <nanok.h>
struct nano_timer *_nano_timer_list = NULL;
@@ -295,5 +293,3 @@ void *nano_task_timer_wait(struct nano_timer *timer /* timer to pend on */
{
return nano_task_lifo_get_wait(&timer->lifo);
}
-
-#endif /* CONFIG_NANOKERNEL */