Commit 92741109 authored by Rahix's avatar Rahix
Browse files

feat(api-caller): Hard-disable all IRQs during API calls

Disable all maskable interrupts on core 1 during API calls.  This brings
two main advantages:

1. It means API calls are now always ISR-safe and can be used everywhere
   in core 1 code.  This is mostly interesting to l0dables as Pycardium
   should not need to do this.

2. It allows Epicardium to halt the clock for core 1 without fear as we
   have observed problems with doing this when core 1 is currently
   executing instructions that touch memory.  Now a synchronous call
   from core 1 will guarantee that it is currently waiting in a WFE and
   no other ISRs could be potentially running.
parent 7fb48178
Pipeline #5223 passed with stages
in 30 seconds
......@@ -5,8 +5,17 @@
#define MXC_ASSERT_ENABLE
#include "mxc_assert.h"
static uint32_t irq_save = 0;
void *_api_call_start(api_id_t id, uintptr_t size)
{
/*
* Disable all maskable interrupts here, to be turned on again at the
* end of _api_call_transact().
*/
irq_save = __get_PRIMASK();
__set_PRIMASK(1);
while (SEMA_GetSema(_API_SEMAPHORE) == E_BUSY) {
}
......@@ -51,6 +60,12 @@ void *_api_call_transact(void *buffer)
API_CALL_MEM->call_flag = _API_FLAG_IDLE;
SEMA_FreeSema(_API_SEMAPHORE);
/*
* Re-enable interrupts (if previously enabled) after completing the API
* call.
*/
__set_PRIMASK(irq_save);
return API_CALL_MEM->buffer;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment