sys_clock: Fix up tick announce API
There were three separate "announce ticks" entry points exposed for use by drivers. Unify them to just a single z_clock_announce() function, making the "final" tick announcement the business of the driver only, not the kernel. Note the oddness with "_sys_idle_elapsed_ticks": this was a global variable exposed by the kernel. But it was never actually used by the kernel. It was updated and inspected only within the timer drivers, and only so that it could be passed back to the kernel as the default (actually hidden) argument to the announce function. Break this false dependency by putting this variable into each timer driver individually. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
47644c2015
commit
fa99ad66d0
12 changed files with 71 additions and 76 deletions
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
static u32_t accumulated_cycle_count;
|
static u32_t accumulated_cycle_count;
|
||||||
|
|
||||||
|
static s32_t _sys_idle_elapsed_ticks = 1;
|
||||||
|
|
||||||
static void timer_irq_handler(void *unused)
|
static void timer_irq_handler(void *unused)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(unused);
|
ARG_UNUSED(unused);
|
||||||
|
@ -29,7 +31,7 @@ static void timer_irq_handler(void *unused)
|
||||||
/* Clear the interrupt */
|
/* Clear the interrupt */
|
||||||
alt_handle_irq((void *)TIMER_0_BASE, TIMER_0_IRQ);
|
alt_handle_irq((void *)TIMER_0_BASE, TIMER_0_IRQ);
|
||||||
|
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
#ifdef CONFIG_EXECUTION_BENCHMARKING
|
#ifdef CONFIG_EXECUTION_BENCHMARKING
|
||||||
extern void read_timer_end_of_tick_handler(void);
|
extern void read_timer_end_of_tick_handler(void);
|
||||||
|
|
|
@ -67,11 +67,11 @@
|
||||||
/* running total of timer count */
|
/* running total of timer count */
|
||||||
static u32_t __noinit cycles_per_tick;
|
static u32_t __noinit cycles_per_tick;
|
||||||
static volatile u32_t accumulated_cycle_count;
|
static volatile u32_t accumulated_cycle_count;
|
||||||
|
static s32_t _sys_idle_elapsed_ticks = 1;
|
||||||
|
|
||||||
#ifdef CONFIG_TICKLESS_IDLE
|
#ifdef CONFIG_TICKLESS_IDLE
|
||||||
static u32_t __noinit max_system_ticks;
|
static u32_t __noinit max_system_ticks;
|
||||||
static u32_t __noinit programmed_ticks;
|
static u32_t __noinit programmed_ticks;
|
||||||
extern s32_t _sys_idle_elapsed_ticks;
|
|
||||||
#ifndef CONFIG_TICKLESS_KERNEL
|
#ifndef CONFIG_TICKLESS_KERNEL
|
||||||
static u32_t __noinit programmed_limit;
|
static u32_t __noinit programmed_limit;
|
||||||
static int straddled_tick_on_idle_enter;
|
static int straddled_tick_on_idle_enter;
|
||||||
|
@ -212,9 +212,9 @@ void _timer_int_handler(void *unused)
|
||||||
programmed_ticks = 0;
|
programmed_ticks = 0;
|
||||||
timer_expired = 1;
|
timer_expired = 1;
|
||||||
|
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
/* _sys_clock_tick_announce() could cause new programming */
|
/* z_clock_announce(_sys_idle_elapsed_ticks) could cause new programming */
|
||||||
if (!programmed_ticks && _sys_clock_always_on) {
|
if (!programmed_ticks && _sys_clock_always_on) {
|
||||||
z_tick_set(_get_elapsed_clock_time());
|
z_tick_set(_get_elapsed_clock_time());
|
||||||
program_max_cycles();
|
program_max_cycles();
|
||||||
|
@ -227,9 +227,10 @@ void _timer_int_handler(void *unused)
|
||||||
timer_count <= (cycles_per_tick - 1),
|
timer_count <= (cycles_per_tick - 1),
|
||||||
"timer_count: %d, limit %d\n", timer_count, cycles_per_tick - 1);
|
"timer_count: %d, limit %d\n", timer_count, cycles_per_tick - 1);
|
||||||
|
|
||||||
_sys_clock_final_tick_announce();
|
_sys_idle_elapsed_ticks = 1;
|
||||||
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
#else
|
#else
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
update_accumulated_count();
|
update_accumulated_count();
|
||||||
|
@ -433,7 +434,7 @@ void _timer_idle_exit(void)
|
||||||
|
|
||||||
_sys_idle_elapsed_ticks = programmed_ticks - 1;
|
_sys_idle_elapsed_ticks = programmed_ticks - 1;
|
||||||
update_accumulated_count();
|
update_accumulated_count();
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
__ASSERT_EVAL({},
|
__ASSERT_EVAL({},
|
||||||
u32_t timer_count = timer0_count_register_get(),
|
u32_t timer_count = timer0_count_register_get(),
|
||||||
|
@ -449,7 +450,7 @@ void _timer_idle_exit(void)
|
||||||
_sys_idle_elapsed_ticks = current_count / cycles_per_tick;
|
_sys_idle_elapsed_ticks = current_count / cycles_per_tick;
|
||||||
if (_sys_idle_elapsed_ticks > 0) {
|
if (_sys_idle_elapsed_ticks > 0) {
|
||||||
update_accumulated_count();
|
update_accumulated_count();
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -57,9 +57,7 @@ extern void _NanoIdleValClear(void);
|
||||||
extern void _sys_power_save_idle_exit(s32_t ticks);
|
extern void _sys_power_save_idle_exit(s32_t ticks);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_TICKLESS_IDLE
|
static s32_t _sys_idle_elapsed_ticks = 1;
|
||||||
extern s32_t _sys_idle_elapsed_ticks;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_TICKLESS_IDLE
|
#ifdef CONFIG_TICKLESS_IDLE
|
||||||
static u32_t __noinit default_load_value; /* default count */
|
static u32_t __noinit default_load_value; /* default count */
|
||||||
|
@ -268,9 +266,9 @@ void _timer_int_handler(void *unused)
|
||||||
*/
|
*/
|
||||||
idle_original_ticks = 0;
|
idle_original_ticks = 0;
|
||||||
|
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
/* _sys_clock_tick_announce() could cause new programming */
|
/* z_clock_announce(_sys_idle_elapsed_ticks) could cause new programming */
|
||||||
if (!idle_original_ticks && _sys_clock_always_on) {
|
if (!idle_original_ticks && _sys_clock_always_on) {
|
||||||
z_tick_set(_get_elapsed_clock_time());
|
z_tick_set(_get_elapsed_clock_time());
|
||||||
/* clear overflow tracking flag as it is accounted */
|
/* clear overflow tracking flag as it is accounted */
|
||||||
|
@ -300,9 +298,10 @@ void _timer_int_handler(void *unused)
|
||||||
idle_mode = IDLE_NOT_TICKLESS;
|
idle_mode = IDLE_NOT_TICKLESS;
|
||||||
_sys_idle_elapsed_ticks =
|
_sys_idle_elapsed_ticks =
|
||||||
idle_original_ticks + 1; /* actual # of idle ticks */
|
idle_original_ticks + 1; /* actual # of idle ticks */
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
} else {
|
} else {
|
||||||
_sys_clock_final_tick_announce();
|
_sys_idle_elapsed_ticks = 1;
|
||||||
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* accumulate total counter value */
|
/* accumulate total counter value */
|
||||||
|
@ -315,7 +314,7 @@ void _timer_int_handler(void *unused)
|
||||||
*/
|
*/
|
||||||
clock_accumulated_count += sys_clock_hw_cycles_per_tick();
|
clock_accumulated_count += sys_clock_hw_cycles_per_tick();
|
||||||
|
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
#endif /* CONFIG_TICKLESS_IDLE */
|
#endif /* CONFIG_TICKLESS_IDLE */
|
||||||
|
|
||||||
numIdleTicks = _NanoIdleValGet(); /* get # of idle ticks requested */
|
numIdleTicks = _NanoIdleValGet(); /* get # of idle ticks requested */
|
||||||
|
@ -342,7 +341,7 @@ void _timer_int_handler(void *unused)
|
||||||
* one more tick has occurred -- don't need to do anything special since
|
* one more tick has occurred -- don't need to do anything special since
|
||||||
* timer is already configured to interrupt on the following tick
|
* timer is already configured to interrupt on the following tick
|
||||||
*/
|
*/
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
#endif /* CONFIG_SYS_POWER_MANAGEMENT */
|
#endif /* CONFIG_SYS_POWER_MANAGEMENT */
|
||||||
|
|
||||||
|
@ -644,7 +643,7 @@ void _timer_idle_exit(void)
|
||||||
* for it.
|
* for it.
|
||||||
*/
|
*/
|
||||||
_sys_idle_elapsed_ticks = idle_original_ticks - 1;
|
_sys_idle_elapsed_ticks = idle_original_ticks - 1;
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
} else {
|
} else {
|
||||||
u32_t elapsed; /* elapsed "counter time" */
|
u32_t elapsed; /* elapsed "counter time" */
|
||||||
u32_t remaining; /* remaining "counter time" */
|
u32_t remaining; /* remaining "counter time" */
|
||||||
|
@ -674,7 +673,7 @@ void _timer_idle_exit(void)
|
||||||
_sys_idle_elapsed_ticks = elapsed / default_load_value;
|
_sys_idle_elapsed_ticks = elapsed / default_load_value;
|
||||||
|
|
||||||
if (_sys_idle_elapsed_ticks) {
|
if (_sys_idle_elapsed_ticks) {
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,12 +174,12 @@ extern u32_t _hw_irq_to_c_handler_latency;
|
||||||
#define DBG(...)
|
#define DBG(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static s32_t _sys_idle_elapsed_ticks = 1;
|
||||||
|
|
||||||
#ifdef CONFIG_TICKLESS_IDLE
|
#ifdef CONFIG_TICKLESS_IDLE
|
||||||
|
|
||||||
/* additional globals, locals, and forward declarations */
|
/* additional globals, locals, and forward declarations */
|
||||||
|
|
||||||
extern s32_t _sys_idle_elapsed_ticks;
|
|
||||||
|
|
||||||
/* main counter units per system tick */
|
/* main counter units per system tick */
|
||||||
static u32_t __noinit counter_load_value;
|
static u32_t __noinit counter_load_value;
|
||||||
/* counter value for most recent tick */
|
/* counter value for most recent tick */
|
||||||
|
@ -262,7 +262,7 @@ void _timer_int_handler(void *unused)
|
||||||
* timer is already configured to interrupt on the following tick
|
* timer is already configured to interrupt on the following tick
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -297,9 +297,9 @@ void _timer_int_handler(void *unused)
|
||||||
* announce already consumed elapsed time
|
* announce already consumed elapsed time
|
||||||
*/
|
*/
|
||||||
programmed_ticks = 0;
|
programmed_ticks = 0;
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
/* _sys_clock_tick_announce() could cause new programming */
|
/* z_clock_announce(_sys_idle_elapsed_ticks) could cause new programming */
|
||||||
if (!programmed_ticks && _sys_clock_always_on) {
|
if (!programmed_ticks && _sys_clock_always_on) {
|
||||||
z_tick_set(_get_elapsed_clock_time());
|
z_tick_set(_get_elapsed_clock_time());
|
||||||
program_max_cycles();
|
program_max_cycles();
|
||||||
|
@ -309,7 +309,8 @@ void _timer_int_handler(void *unused)
|
||||||
*_HPET_TIMER0_CONFIG_CAPS |= HPET_Tn_VAL_SET_CNF;
|
*_HPET_TIMER0_CONFIG_CAPS |= HPET_Tn_VAL_SET_CNF;
|
||||||
*_HPET_TIMER0_COMPARATOR = counter_last_value + counter_load_value;
|
*_HPET_TIMER0_COMPARATOR = counter_last_value + counter_load_value;
|
||||||
programmed_ticks = 1;
|
programmed_ticks = 1;
|
||||||
_sys_clock_final_tick_announce();
|
_sys_idle_elapsed_ticks = 1;
|
||||||
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
#endif
|
#endif
|
||||||
#endif /* !CONFIG_TICKLESS_IDLE */
|
#endif /* !CONFIG_TICKLESS_IDLE */
|
||||||
|
|
||||||
|
@ -481,7 +482,7 @@ void _timer_idle_exit(void)
|
||||||
* that the timer ISR will execute first before the tick event
|
* that the timer ISR will execute first before the tick event
|
||||||
* is serviced.
|
* is serviced.
|
||||||
*/
|
*/
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
/* timer interrupt handler reprograms the timer for the next
|
/* timer interrupt handler reprograms the timer for the next
|
||||||
* tick
|
* tick
|
||||||
|
@ -532,7 +533,7 @@ void _timer_idle_exit(void)
|
||||||
|
|
||||||
if (_sys_idle_elapsed_ticks) {
|
if (_sys_idle_elapsed_ticks) {
|
||||||
/* Announce elapsed ticks to the kernel */
|
/* Announce elapsed ticks to the kernel */
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -124,9 +124,8 @@
|
||||||
do {/* nothing */ \
|
do {/* nothing */ \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif /* !CONFIG_TICKLESS_IDLE */
|
#endif /* !CONFIG_TICKLESS_IDLE */
|
||||||
#if defined(CONFIG_TICKLESS_IDLE)
|
|
||||||
extern s32_t _sys_idle_elapsed_ticks;
|
static s32_t _sys_idle_elapsed_ticks = 1;
|
||||||
#endif /* CONFIG_TICKLESS_IDLE */
|
|
||||||
|
|
||||||
/* computed counter 0 initial count value */
|
/* computed counter 0 initial count value */
|
||||||
static u32_t __noinit cycles_per_tick;
|
static u32_t __noinit cycles_per_tick;
|
||||||
|
@ -317,9 +316,9 @@ void _timer_int_handler(void *unused /* parameter is not used */
|
||||||
*/
|
*/
|
||||||
programmed_full_ticks = 0;
|
programmed_full_ticks = 0;
|
||||||
|
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
/* _sys_clock_tick_announce() could cause new programming */
|
/* z_clock_announce(_sys_idle_elapsed_ticks) could cause new programming */
|
||||||
if (!programmed_full_ticks && _sys_clock_always_on) {
|
if (!programmed_full_ticks && _sys_clock_always_on) {
|
||||||
z_tick_set(_get_elapsed_clock_time());
|
z_tick_set(_get_elapsed_clock_time());
|
||||||
program_max_cycles();
|
program_max_cycles();
|
||||||
|
@ -357,9 +356,10 @@ void _timer_int_handler(void *unused /* parameter is not used */
|
||||||
timer_mode = TIMER_MODE_PERIODIC;
|
timer_mode = TIMER_MODE_PERIODIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
_sys_clock_final_tick_announce();
|
_sys_idle_elapsed_ticks = 1;
|
||||||
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
#else
|
#else
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
#endif /*CONFIG_TICKLESS_IDLE*/
|
#endif /*CONFIG_TICKLESS_IDLE*/
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_EXECUTION_BENCHMARKING
|
#ifdef CONFIG_EXECUTION_BENCHMARKING
|
||||||
|
@ -584,7 +584,7 @@ void _timer_idle_exit(void)
|
||||||
* (The timer ISR reprograms the timer for the next tick.)
|
* (The timer ISR reprograms the timer for the next tick.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
timer_known_to_have_expired = true;
|
timer_known_to_have_expired = true;
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ void _timer_idle_exit(void)
|
||||||
*
|
*
|
||||||
* NOTE #1: In the case of a straddled tick, the '_sys_idle_elapsed_ticks'
|
* NOTE #1: In the case of a straddled tick, the '_sys_idle_elapsed_ticks'
|
||||||
* calculation below may result in either 0 or 1. If 1, then this may
|
* calculation below may result in either 0 or 1. If 1, then this may
|
||||||
* result in a harmless extra call to _sys_clock_tick_announce().
|
* result in a harmless extra call to z_clock_announce(_sys_idle_elapsed_ticks).
|
||||||
*
|
*
|
||||||
* NOTE #2: In the case of a straddled tick, it is assumed that when the
|
* NOTE #2: In the case of a straddled tick, it is assumed that when the
|
||||||
* timer is reprogrammed, it will be reprogrammed with a cycle count
|
* timer is reprogrammed, it will be reprogrammed with a cycle count
|
||||||
|
@ -615,7 +615,7 @@ void _timer_idle_exit(void)
|
||||||
_sys_idle_elapsed_ticks = programmed_full_ticks - remaining_full_ticks;
|
_sys_idle_elapsed_ticks = programmed_full_ticks - remaining_full_ticks;
|
||||||
|
|
||||||
if (_sys_idle_elapsed_ticks > 0) {
|
if (_sys_idle_elapsed_ticks > 0) {
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remaining_full_ticks > 0) {
|
if (remaining_full_ticks > 0) {
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
static u64_t tick_period; /* System tick period in number of hw cycles */
|
static u64_t tick_period; /* System tick period in number of hw cycles */
|
||||||
static s64_t silent_ticks;
|
static s64_t silent_ticks;
|
||||||
|
static s32_t _sys_idle_elapsed_ticks = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current HW cycle counter
|
* Return the current HW cycle counter
|
||||||
|
@ -77,7 +78,7 @@ void _timer_idle_exit(void)
|
||||||
silent_ticks -= hwtimer_get_pending_silent_ticks();
|
silent_ticks -= hwtimer_get_pending_silent_ticks();
|
||||||
if (silent_ticks > 0) {
|
if (silent_ticks > 0) {
|
||||||
_sys_idle_elapsed_ticks = silent_ticks;
|
_sys_idle_elapsed_ticks = silent_ticks;
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
}
|
}
|
||||||
silent_ticks = 0;
|
silent_ticks = 0;
|
||||||
hwtimer_set_silent_ticks(0);
|
hwtimer_set_silent_ticks(0);
|
||||||
|
@ -93,7 +94,7 @@ static void sp_timer_isr(void *arg)
|
||||||
ARG_UNUSED(arg);
|
ARG_UNUSED(arg);
|
||||||
_sys_idle_elapsed_ticks = silent_ticks + 1;
|
_sys_idle_elapsed_ticks = silent_ticks + 1;
|
||||||
silent_ticks = 0;
|
silent_ticks = 0;
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -42,10 +42,12 @@
|
||||||
*/
|
*/
|
||||||
static u32_t rtc_past;
|
static u32_t rtc_past;
|
||||||
|
|
||||||
|
static s32_t _sys_idle_elapsed_ticks = 1;
|
||||||
|
|
||||||
#ifdef CONFIG_TICKLESS_IDLE
|
#ifdef CONFIG_TICKLESS_IDLE
|
||||||
/*
|
/*
|
||||||
* Holds the maximum sys ticks the kernel expects to see in the next
|
* Holds the maximum sys ticks the kernel expects to see in the next
|
||||||
* _sys_clock_tick_announce().
|
* z_clock_announce(_sys_idle_elapsed_ticks).
|
||||||
*/
|
*/
|
||||||
static u32_t expected_sys_ticks;
|
static u32_t expected_sys_ticks;
|
||||||
#endif /* CONFIG_TICKLESS_IDLE */
|
#endif /* CONFIG_TICKLESS_IDLE */
|
||||||
|
@ -145,7 +147,7 @@ static void rtc_announce_set_next(void)
|
||||||
) & RTC_MASK;
|
) & RTC_MASK;
|
||||||
|
|
||||||
_sys_idle_elapsed_ticks = sys_elapsed;
|
_sys_idle_elapsed_ticks = sys_elapsed;
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the RTC to the next sys tick */
|
/* Set the RTC to the next sys tick */
|
||||||
|
@ -431,7 +433,7 @@ void _timer_idle_exit(void)
|
||||||
rtc_announce_set_next();
|
rtc_announce_set_next();
|
||||||
|
|
||||||
/* After exiting idle, the kernel no longer expects more than one sys
|
/* After exiting idle, the kernel no longer expects more than one sys
|
||||||
* ticks to have passed when _sys_clock_tick_announce() is called.
|
* ticks to have passed when z_clock_announce(_sys_idle_elapsed_ticks) is called.
|
||||||
*/
|
*/
|
||||||
expected_sys_ticks = 1;
|
expected_sys_ticks = 1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -487,9 +489,9 @@ void rtc1_nrf5_isr(void *arg)
|
||||||
*/
|
*/
|
||||||
expected_sys_ticks = 0;
|
expected_sys_ticks = 0;
|
||||||
/* Anounce elapsed of _sys_idle_elapsed_ticks systicks*/
|
/* Anounce elapsed of _sys_idle_elapsed_ticks systicks*/
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
/* _sys_clock_tick_announce() could cause new programming */
|
/* z_clock_announce(_sys_idle_elapsed_ticks) could cause new programming */
|
||||||
if (!expected_sys_ticks && _sys_clock_always_on) {
|
if (!expected_sys_ticks && _sys_clock_always_on) {
|
||||||
program_max_cycles();
|
program_max_cycles();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ static void pulpino_timer_irq_handler(void *unused)
|
||||||
|
|
||||||
accumulated_cycle_count += sys_clock_hw_cycles_per_tick();
|
accumulated_cycle_count += sys_clock_hw_cycles_per_tick();
|
||||||
|
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_TICKLESS_IDLE
|
#ifdef CONFIG_TICKLESS_IDLE
|
||||||
|
|
|
@ -69,7 +69,7 @@ static void riscv_machine_timer_irq_handler(void *unused)
|
||||||
read_timer_start_of_tick_handler();
|
read_timer_start_of_tick_handler();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(1);
|
||||||
|
|
||||||
/* Rearm timer */
|
/* Rearm timer */
|
||||||
riscv_machine_rearm_timer();
|
riscv_machine_rearm_timer();
|
||||||
|
|
|
@ -96,6 +96,8 @@
|
||||||
#define MIN_TIMER_PROG_DELAY 50 /* TODO: Update this value */
|
#define MIN_TIMER_PROG_DELAY 50 /* TODO: Update this value */
|
||||||
#endif /* CONFIG_XTENSA_INTERNAL_TIMER || (CONFIG_XTENSA_TIMER_IRQ < 0) */
|
#endif /* CONFIG_XTENSA_INTERNAL_TIMER || (CONFIG_XTENSA_TIMER_IRQ < 0) */
|
||||||
|
|
||||||
|
static s32_t _sys_idle_elapsed_ticks = 1;
|
||||||
|
|
||||||
#ifdef CONFIG_TICKLESS_IDLE
|
#ifdef CONFIG_TICKLESS_IDLE
|
||||||
#define TIMER_MODE_PERIODIC 0 /* normal running mode */
|
#define TIMER_MODE_PERIODIC 0 /* normal running mode */
|
||||||
#define TIMER_MODE_ONE_SHOT 1 /* emulated, since sysTick has 1 mode */
|
#define TIMER_MODE_ONE_SHOT 1 /* emulated, since sysTick has 1 mode */
|
||||||
|
@ -103,8 +105,6 @@
|
||||||
#define IDLE_NOT_TICKLESS 0 /* non-tickless idle mode */
|
#define IDLE_NOT_TICKLESS 0 /* non-tickless idle mode */
|
||||||
#define IDLE_TICKLESS 1 /* tickless idle mode */
|
#define IDLE_TICKLESS 1 /* tickless idle mode */
|
||||||
|
|
||||||
extern s32_t _sys_idle_elapsed_ticks;
|
|
||||||
|
|
||||||
static u32_t __noinit cycles_per_tick;
|
static u32_t __noinit cycles_per_tick;
|
||||||
static u32_t __noinit max_system_ticks;
|
static u32_t __noinit max_system_ticks;
|
||||||
static u32_t idle_original_ticks;
|
static u32_t idle_original_ticks;
|
||||||
|
@ -409,7 +409,7 @@ void _timer_idle_exit(void)
|
||||||
SET_TIMER_FIRE_TIME(F);
|
SET_TIMER_FIRE_TIME(F);
|
||||||
}
|
}
|
||||||
if (_sys_idle_elapsed_ticks) {
|
if (_sys_idle_elapsed_ticks) {
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Exit timer idle mode */
|
/* Exit timer idle mode */
|
||||||
|
@ -527,7 +527,7 @@ void _timer_int_handler(void *params)
|
||||||
_sys_idle_elapsed_ticks = idle_original_ticks;
|
_sys_idle_elapsed_ticks = idle_original_ticks;
|
||||||
idle_original_ticks = 0;
|
idle_original_ticks = 0;
|
||||||
/* Anounce elapsed of _sys_idle_elapsed_ticks systicks */
|
/* Anounce elapsed of _sys_idle_elapsed_ticks systicks */
|
||||||
_sys_clock_tick_announce();
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
|
|
||||||
/* Program timer incase it is not Prgrammed */
|
/* Program timer incase it is not Prgrammed */
|
||||||
if (!idle_original_ticks) {
|
if (!idle_original_ticks) {
|
||||||
|
@ -536,7 +536,8 @@ void _timer_int_handler(void *params)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Announce the tick event to the kernel. */
|
/* Announce the tick event to the kernel. */
|
||||||
_sys_clock_final_tick_announce();
|
_sys_idle_elapsed_ticks = 1;
|
||||||
|
z_clock_announce(_sys_idle_elapsed_ticks);
|
||||||
#endif /* CONFIG_TICKLESS_KERNEL */
|
#endif /* CONFIG_TICKLESS_KERNEL */
|
||||||
|
|
||||||
#ifdef CONFIG_EXECUTION_BENCHMARKING
|
#ifdef CONFIG_EXECUTION_BENCHMARKING
|
||||||
|
|
|
@ -38,7 +38,17 @@ extern void _timer_idle_exit(void);
|
||||||
#define _timer_idle_exit() do { } while (false)
|
#define _timer_idle_exit() do { } while (false)
|
||||||
#endif /* CONFIG_TICKLESS_IDLE */
|
#endif /* CONFIG_TICKLESS_IDLE */
|
||||||
|
|
||||||
extern void _nano_sys_clock_tick_announce(s32_t ticks);
|
/**
|
||||||
|
* @brief Announce time progress to the kernel
|
||||||
|
*
|
||||||
|
* Informs the kernel that the specified number of ticks have elapsed
|
||||||
|
* since the last call to z_clock_announce() (or system startup for
|
||||||
|
* the first call).
|
||||||
|
*
|
||||||
|
* @param ticks Elapsed time, in ticks
|
||||||
|
*/
|
||||||
|
extern void z_clock_announce(s32_t ticks);
|
||||||
|
|
||||||
#ifdef CONFIG_TICKLESS_KERNEL
|
#ifdef CONFIG_TICKLESS_KERNEL
|
||||||
extern void _set_time(u32_t time);
|
extern void _set_time(u32_t time);
|
||||||
extern u32_t _get_program_time(void);
|
extern u32_t _get_program_time(void);
|
||||||
|
@ -59,25 +69,6 @@ extern int sys_clock_device_ctrl(struct device *device,
|
||||||
#define sys_clock_device_ctrl device_pm_control_nop
|
#define sys_clock_device_ctrl device_pm_control_nop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern s32_t _sys_idle_elapsed_ticks;
|
|
||||||
#define _sys_clock_tick_announce() \
|
|
||||||
_nano_sys_clock_tick_announce(_sys_idle_elapsed_ticks)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Account for the tick due to the timer interrupt
|
|
||||||
*
|
|
||||||
* @return N/A
|
|
||||||
*/
|
|
||||||
static inline void _sys_clock_final_tick_announce(void)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Ticks are both announced and immediately processed at interrupt
|
|
||||||
* level. Thus there is only one tick left to announce (and process).
|
|
||||||
*/
|
|
||||||
_sys_idle_elapsed_ticks = 1;
|
|
||||||
_sys_clock_tick_announce();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,9 +30,6 @@ int z_clock_hw_cycles_per_sec;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* updated by timer driver for tickless, stays at 1 for non-tickless */
|
|
||||||
s32_t _sys_idle_elapsed_ticks = 1;
|
|
||||||
|
|
||||||
/* Note that this value is 64 bits, and thus non-atomic on almost all
|
/* Note that this value is 64 bits, and thus non-atomic on almost all
|
||||||
* Zephyr archtictures. And of course it's routinely updated inside
|
* Zephyr archtictures. And of course it's routinely updated inside
|
||||||
* timer interrupts. Access to it must be locked.
|
* timer interrupts. Access to it must be locked.
|
||||||
|
@ -284,7 +281,7 @@ static void handle_time_slicing(s32_t ticks)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Announce a tick to the kernel
|
* @brief Announce ticks to the kernel
|
||||||
*
|
*
|
||||||
* This function is only to be called by the system clock timer driver when a
|
* This function is only to be called by the system clock timer driver when a
|
||||||
* tick is to be announced to the kernel. It takes care of dequeuing the
|
* tick is to be announced to the kernel. It takes care of dequeuing the
|
||||||
|
@ -292,7 +289,7 @@ static void handle_time_slicing(s32_t ticks)
|
||||||
*
|
*
|
||||||
* @return N/A
|
* @return N/A
|
||||||
*/
|
*/
|
||||||
void _nano_sys_clock_tick_announce(s32_t ticks)
|
void z_clock_announce(s32_t ticks)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
/* sys_clock timekeeping happens only on the main CPU */
|
/* sys_clock timekeeping happens only on the main CPU */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue