Skip to content
Snippets Groups Projects
  • rahix's avatar
    3b9393fe
    feat(epicardium): Implement basic core 1 lifecycle · 3b9393fe
    rahix authored
    
    This commit introduces a way to control core 1.  This is archieved by a
    predefined API-Interrupt:  The reset interrupt.  When triggered, it will
    bring the core back into its default state and wait for a new vector
    address from Epicardium.  Once this vector address is transferred, it
    will start the new payload.
    
    This method only works as long as core 1 is responsive to the API
    interrupts.  Cases where this might not be the case:
    
      - During times where core 1 has interrupts disabled
      - When in a higher priority exception handler
      - When core 1 has corrupted its IVT
    
    Signed-off-by: default avatarRahix <rahix@rahix.de>
    Verified
    3b9393fe
    History
    feat(epicardium): Implement basic core 1 lifecycle
    rahix authored
    
    This commit introduces a way to control core 1.  This is archieved by a
    predefined API-Interrupt:  The reset interrupt.  When triggered, it will
    bring the core back into its default state and wait for a new vector
    address from Epicardium.  Once this vector address is transferred, it
    will start the new payload.
    
    This method only works as long as core 1 is responsive to the API
    interrupts.  Cases where this might not be the case:
    
      - During times where core 1 has interrupts disabled
      - When in a higher priority exception handler
      - When core 1 has corrupted its IVT
    
    Signed-off-by: default avatarRahix <rahix@rahix.de>
common.h 1.28 KiB
#pragma once
#include "epicardium.h"

#include <stdint.h>
#include <stdbool.h>

/*
 * Semaphore used for API synchronization.
 * TODO: Replace this with a LDREX/STREX based implementation
 */
#define _API_SEMAPHORE        0
#define _CONTROL_SEMAPHORE    1

/* Type of API IDs */
typedef uint32_t api_id_t;

#define _API_FLAG_IDLE        0
#define _API_FLAG_CALLING     1
#define _API_FLAG_RETURNED    2

/* Layout of the shared memory for API calls */
struct api_call_mem {
	/*
	 * Reset stub.  The reset stub is a small function provided by
	 * epicardium that should be called by a payload when receiving the
	 * reset interrupt.
	 */
	void (*reset_stub)();

	/*
	 * Flag for synchronization of API calls.  When this flag
	 * is set, the caller has issued a call and is waiting for
	 * the dispatcher to reset the flag.
	 */
	uint8_t call_flag;

	/* ID if the ongoing API call */
	api_id_t id;

	/* ID of the current interrupt */
	api_int_id_t int_id;

	/*
	 * Buffer for arguments/return value.  This buffer will be
	 * *overflown*, because there is guaranteed space behind it.
	 *
	 * TODO: Add a maximum bounds check
	 */
	uint8_t buffer[1];
};

/* TODO: Make this address part of the linker script */
static __attribute__((unused)) struct api_call_mem* API_CALL_MEM =
	(struct api_call_mem*)0x20080000;