timer: cortex_m_systick: use direct interrupt handler instead of C-function

The current driver implements the global defined "systick" interrupt
callback "sys_clock_isr" as a standard C function with an argument.
However, ARM's direct interrupt handlers do not have any arguments;
they must be declared as "void handler(void)".

Additionally, the direct handler should include some missing special
header/footer.

Fixes: #75693

Signed-off-by: Andrey VOLKOV <andrey.volkov@munic.io>
This commit is contained in:
Andrey VOLKOV 2024-07-15 19:16:30 +02:00 committed by Maureen Helm
commit 213da72d06

View file

@ -162,10 +162,13 @@ static uint32_t elapsed(void)
return (last_load - val2) + overflow_cyc; return (last_load - val2) + overflow_cyc;
} }
/* Callout out of platform assembly, not hooked via IRQ_CONNECT... */ /* sys_clock_isr is calling directly from the platform's vectors table.
void sys_clock_isr(void *arg) * However using ISR_DIRECT_DECLARE() is not so suitable due to possible
* tracing overflow, so here is a stripped down version of it.
*/
ARCH_ISR_DIAG_OFF
__attribute__((interrupt("IRQ"))) void sys_clock_isr(void)
{ {
ARG_UNUSED(arg);
uint32_t dcycles; uint32_t dcycles;
uint32_t dticks; uint32_t dticks;
@ -185,6 +188,7 @@ void sys_clock_isr(void *arg)
* sys_clock_idle_exit function. * sys_clock_idle_exit function.
*/ */
if (timeout_idle) { if (timeout_idle) {
ISR_DIRECT_PM();
z_arm_int_exit(); z_arm_int_exit();
return; return;
@ -211,8 +215,11 @@ void sys_clock_isr(void *arg)
} else { } else {
sys_clock_announce(1); sys_clock_announce(1);
} }
ISR_DIRECT_PM();
z_arm_int_exit(); z_arm_int_exit();
} }
ARCH_ISR_DIAG_ON
void sys_clock_set_timeout(int32_t ticks, bool idle) void sys_clock_set_timeout(int32_t ticks, bool idle)
{ {
@ -419,7 +426,15 @@ void sys_clock_idle_exit(void)
#endif /* CONFIG_CORTEX_M_SYSTICK_IDLE_TIMER */ #endif /* CONFIG_CORTEX_M_SYSTICK_IDLE_TIMER */
if (last_load == TIMER_STOPPED) { if (last_load == TIMER_STOPPED) {
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; /* We really dont know here how much time has passed,
* so lets restart the timer from scratch.
*/
K_SPINLOCK(&lock) {
last_load = CYC_PER_TICK;
SysTick->LOAD = last_load - 1;
SysTick->VAL = 0; /* resets timer to last_load */
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
} }
} }