diff --git a/epicardium/api/control.c b/epicardium/api/control.c index 102c07e27d325004e4ae584c7cd327ecb67503ce..27b88c2c9a18dd358632f39f504f1f4aa0efa0ad 100644 --- a/epicardium/api/control.c +++ b/epicardium/api/control.c @@ -214,24 +214,32 @@ void core1_trigger_reset(void) interrupt_trigger_sync(EPIC_INT_RESET); } +bool core1_is_ready(void) +{ + bool ready; + + while (SEMA_GetSema(_CONTROL_SEMAPHORE) == E_BUSY) { + } + + /* + * core 1 will set the ready flag once it is spinning in the + * above loop, waiting for a new IVT. + */ + ready = core1_info.ready; + + SEMA_FreeSema(_CONTROL_SEMAPHORE); + + return ready; +} + void core1_wait_ready(void) { /* Wait for the core to accept */ while (1) { - while (SEMA_GetSema(_CONTROL_SEMAPHORE) == E_BUSY) { - } - - /* - * core 1 will set the ready flag once it is spinning in the - * above loop, waiting for a new IVT. - */ - if (core1_info.ready) { - SEMA_FreeSema(_CONTROL_SEMAPHORE); + if (core1_is_ready()) { break; } - SEMA_FreeSema(_CONTROL_SEMAPHORE); - for (int i = 0; i < 10000; i++) { } } diff --git a/epicardium/api/dispatcher.h b/epicardium/api/dispatcher.h index 4b79095ea530aa8b06cd1bf71d5d5b91972eb049..727fe5acd339e1ce2e882b6bf4a73b433daf09c3 100644 --- a/epicardium/api/dispatcher.h +++ b/epicardium/api/dispatcher.h @@ -39,6 +39,9 @@ void core1_boot(void); /* Reset core 1 into a state where it can accept a new payload */ void core1_trigger_reset(void); +/* Check if core 1 is ready for a new payload */ +bool core1_is_ready(void); + /* Wait for core 1 to respond that it is ready for a new payload */ void core1_wait_ready(void);