Skeleton smcCpuOff, fix building, fix smcConfigureCarveout

This commit is contained in:
Michael Scire 2018-02-26 17:41:31 -08:00
parent 23e9a8369a
commit c4789a5a11
5 changed files with 49 additions and 3 deletions

View file

@ -1,5 +1,8 @@
#include <stdbool.h>
#include <stdint.h>
#include "cache.h"
#include "cpu_context.h"
#include "flow.h"
#include "pmc.h"
#include "timers.h"
#include "utils.h"
@ -56,7 +59,34 @@ uint32_t cpu_on(uint32_t core, uint64_t entrypoint_addr, uint64_t argument) {
return 0;
}
void power_down_current_core(void) {
unsigned int current_core = get_core_id();
flow_set_csr(current_core, 0);
flow_set_halt_events(current_core, 0);
flow_set_cc4_ctrl(current_core, 0);
save_current_core_context();
g_cpu_contexts[current_core].is_active = 0;
flush_dcache_all();
/* TODO: wait_for_power_off(), which writes to regs + . */
}
uint32_t cpu_off(void) {
if (get_core_id() == 3) {
power_down_current_core();
} else {
/* TODO: call_with_stack_pointer(get_powerdown_stack(), power_down_current_core); */
}
while (true) {
/* Wait forever. */
}
return 0;
}
void save_current_core_context(void) {
/* TODO */
}
void restore_current_core_context(void) {
/* TODO */
}

View file

@ -44,6 +44,9 @@ typedef struct {
#define NUM_CPU_CORES 4
void save_current_core_context(void);
void restore_current_core_context(void);
void set_core_entrypoint_and_argument(uint32_t core, uint64_t entrypoint_addr, uint64_t argument);
uint32_t cpu_on(uint32_t core, uint64_t entrypoint_addr, uint64_t argument);

View file

@ -5,6 +5,7 @@
#include "utils.h"
#include "bpmp.h"
#include "cache.h"
#include "configitem.h"
#include "flow.h"
#include "fuse.h"

View file

@ -111,6 +111,10 @@ static smc_table_t g_smc_tables[2] = {
static atomic_flag g_is_user_smc_in_progress = ATOMIC_FLAG_INIT;
static atomic_flag g_is_priv_smc_in_progress = ATOMIC_FLAG_INIT;
/* Global for smc_configure_carveout. */
static bool g_configured_carveouts[2] = {false, false};
uintptr_t get_smc_core012_stack_address(void) {
return TZRAM_GET_SEGMENT_ADDRESS(TZRAM_SEGMENT_ID_CORE012_STACK) + 0x1000;
}
@ -546,14 +550,18 @@ uint32_t smc_configure_carveout(smc_args_t *args) {
return 2;
}
/* Ensure validity of carveout index. */
if (carveout_id > 1) {
return 2;
}
/* Configuration is one-shot, and cannot be done multiple times. */
static bool configured_carveouts[2] = {false, false};
if (configured_carveouts[carveout_id]) {
if (g_configured_carveouts[carveout_id]) {
return 2;
}
configure_kernel_carveout(carveout_id + 4, address, size);
configured_carveouts[carveout_id] = true;
g_configured_carveouts[carveout_id] = true;
return 0;
}

View file

@ -14,3 +14,7 @@ void invalidate_icache_all_tzram_pa(void) {
uintptr_t get_warmboot_crt0_stack_address(void) {
return TZRAM_GET_SEGMENT_ADDRESS(TZRAM_SEGMENT_ID_CORE3_STACK) + 0x800;
}
void warmboot_init(void) {
/* TODO: Implement. */
}