unified/drivers: adapt timer drivers to unified kernel

They must provide the k_cycles_get_32() API and must not refer to
command packets: the latter do not exist on unified kernels.

Change-Id: Ia354dc060e5ad2595850f97da82d8feb590d16b7
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
Benjamin Walsh 2016-09-02 17:01:52 -04:00
parent 5d23818070
commit 3caec4e95d
3 changed files with 20 additions and 0 deletions

View file

@ -44,6 +44,7 @@
#include <sys_clock.h>
#include <drivers/system_timer.h>
#if !defined(CONFIG_KERNEL_V2)
#ifdef CONFIG_MICROKERNEL
#include <microkernel.h>
@ -51,6 +52,7 @@
extern struct nano_stack _k_command_stack;
#endif /* CONFIG_MICROKERNEL */
#endif
/* running total of timer count */
static uint32_t clock_accumulated_count;
@ -629,7 +631,11 @@ 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.
*/
#ifdef CONFIG_KERNEL_V2
uint32_t k_cycle_get_32(void)
#else
uint32_t sys_cycle_get_32(void)
#endif
{
return clock_accumulated_count + (__scs.systick.strvr - __scs.systick.stcvr);
}

View file

@ -62,6 +62,7 @@
#include <drivers/system_timer.h>
#include <nano_private.h>
#if !defined(CONFIG_KERNEL_V2)
#ifdef CONFIG_MICROKERNEL
#include <microkernel.h>
@ -69,6 +70,7 @@
extern struct nano_stack _k_command_stack;
#endif /* CONFIG_MICROKERNEL */
#endif
#include <board.h>
@ -639,7 +641,11 @@ int _sys_clock_driver_init(struct device *device)
* it will need to call _hpetMainCounterAtomic().
*/
#ifdef CONFIG_KERNEL_V2
uint32_t k_cycle_get_32(void)
#else
uint32_t sys_cycle_get_32(void)
#endif
{
return (uint32_t) *_HPET_MAIN_COUNTER_VALUE;
}

View file

@ -84,9 +84,11 @@
#include <power.h>
#include <device.h>
#if !defined(CONFIG_KERNEL_V2)
#ifdef CONFIG_MICROKERNEL
#include <microkernel.h>
#endif /* CONFIG_MICROKERNEL */
#endif
#include <board.h>
@ -157,9 +159,11 @@ static unsigned char timer_mode = TIMER_MODE_PERIODIC;
/* externs */
#if !defined(CONFIG_KERNEL_V2)
#ifdef CONFIG_MICROKERNEL
extern struct nano_stack _k_command_stack;
#endif /* CONFIG_MICROKERNEL */
#endif
/**
*
@ -619,7 +623,11 @@ int _sys_clock_resume(struct device *dev, int pm_policy)
*
* @return up counter of elapsed clock cycles
*/
#ifdef CONFIG_KERNEL_V2
uint32_t k_cycle_get_32(void)
#else
uint32_t sys_cycle_get_32(void)
#endif
{
uint32_t val; /* system clock value */