Skip to content
Snippets Groups Projects
Verified Commit 944578ca authored by rahix's avatar rahix
Browse files

refactor(lifecycle): Split reset into trigger & wait


This change allows cleaner loading of payloads and is a preparation for
the proper implementation/use of hardware_reset().

Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 4f06bf41
No related branches found
No related tags found
No related merge requests found
......@@ -199,11 +199,14 @@ void core1_boot(void)
core1_start(&core1_initial_ivt);
}
void core1_reset(void)
void core1_trigger_reset(void)
{
/* Signal core 1 that we intend to load a new payload. */
api_interrupt_trigger(EPIC_INT_RESET);
}
void core1_wait_ready(void)
{
/* Wait for the core to accept */
while (1) {
while (SEMA_GetSema(_CONTROL_SEMAPHORE) == E_BUSY) {
......
......@@ -37,7 +37,10 @@ void api_prepare_args(char *args);
void core1_boot(void);
/* Reset core 1 into a state where it can accept a new payload */
void core1_reset(void);
void core1_trigger_reset(void);
/* Wait for core 1 to respond that it is ready for a new payload */
void core1_wait_ready(void);
/* Load a payload into core 1 */
void core1_load(void *ivt, char *args);
......
......@@ -2,6 +2,7 @@
#include "modules/log.h"
#include "modules/modules.h"
#include "api/dispatcher.h"
#include "api/interrupt-sender.h"
#include "l0der/l0der.h"
#include "card10.h"
......@@ -87,6 +88,9 @@ static int load_stat(char *name)
*/
static int do_load(struct load_info *info)
{
struct l0dable_info l0dable;
int res;
if (*info->name == '\0') {
LOG_INFO("lifecycle", "Loading Python interpreter ...");
} else {
......@@ -100,11 +104,21 @@ static int do_load(struct load_info *info)
if (info->do_reset) {
LOG_DEBUG("lifecycle", "Triggering core 1 reset.");
core1_reset();
api_dispatcher_init();
core1_trigger_reset();
}
/*
* Wait for the core to become ready to accept a new payload.
*/
core1_wait_ready();
/*
* Reinitialize API
*/
api_dispatcher_init();
api_interrupt_init();
switch (info->type) {
case PL_PYTHON_SCRIPT:
case PL_PYTHON_DIR:
......@@ -112,14 +126,7 @@ static int do_load(struct load_info *info)
core1_load(PYCARDIUM_IVT, info->name);
break;
case PL_L0DABLE:
/*
* Always reset when loading a l0dable to make sure the memory
* space is absolutely free.
*/
core1_reset();
struct l0dable_info l0dable;
int res = l0der_load_path(info->name, &l0dable);
res = l0der_load_path(info->name, &l0dable);
if (res != 0) {
LOG_ERR("lifecycle", "l0der failed: %d\n", res);
xSemaphoreGive(api_mutex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment