2016-04-22 05:47:09 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-04-22 05:47:09 +08:00
|
|
|
*/
|
|
|
|
|
2016-12-23 21:35:34 +08:00
|
|
|
#include <kernel.h>
|
2016-11-08 23:36:50 +08:00
|
|
|
#include <kernel_structs.h>
|
2016-04-22 05:47:09 +08:00
|
|
|
#include <irq_offload.h>
|
|
|
|
|
2016-06-24 04:49:50 +08:00
|
|
|
volatile irq_offload_routine_t _offload_routine;
|
|
|
|
static volatile void *offload_param;
|
|
|
|
|
|
|
|
/* Called by _enter_irq if it was passed 0 for ipending.
|
|
|
|
* Just in case the offload routine itself generates an unhandled
|
|
|
|
* exception, clear the offload_routine global before executing.
|
|
|
|
*/
|
2019-03-14 23:20:46 +08:00
|
|
|
void z_irq_do_offload(void)
|
2016-06-24 04:49:50 +08:00
|
|
|
{
|
|
|
|
irq_offload_routine_t tmp;
|
|
|
|
|
|
|
|
if (!_offload_routine) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = _offload_routine;
|
|
|
|
_offload_routine = NULL;
|
|
|
|
|
|
|
|
tmp((void *)offload_param);
|
|
|
|
}
|
|
|
|
|
2016-04-22 05:47:09 +08:00
|
|
|
void irq_offload(irq_offload_routine_t routine, void *parameter)
|
|
|
|
{
|
2018-08-15 08:57:08 +08:00
|
|
|
unsigned int key;
|
2016-06-24 04:49:50 +08:00
|
|
|
|
|
|
|
key = irq_lock();
|
|
|
|
_offload_routine = routine;
|
|
|
|
offload_param = parameter;
|
|
|
|
|
|
|
|
__asm__ volatile ("trap");
|
|
|
|
|
|
|
|
irq_unlock(key);
|
2016-04-22 05:47:09 +08:00
|
|
|
}
|
|
|
|
|