|
|
@ -9,14 +9,6 @@ |
|
|
|
#include <lib/el3_runtime/context_mgmt.h> |
|
|
|
#include "spmd_private.h" |
|
|
|
|
|
|
|
struct spmd_pm_secondary_ep_t { |
|
|
|
uintptr_t entry_point; |
|
|
|
uintptr_t context; |
|
|
|
bool locked; |
|
|
|
}; |
|
|
|
|
|
|
|
static struct spmd_pm_secondary_ep_t spmd_pm_secondary_ep[PLATFORM_CORE_COUNT]; |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* spmd_build_spmc_message |
|
|
|
* |
|
|
@ -45,11 +37,6 @@ int spmd_pm_secondary_core_set_ep(unsigned long long mpidr, |
|
|
|
return -EINVAL; |
|
|
|
} |
|
|
|
|
|
|
|
if (spmd_pm_secondary_ep[id].locked) { |
|
|
|
ERROR("%s entry locked (%llx)\n", __func__, mpidr); |
|
|
|
return -EINVAL; |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
|
* Check entry_point address is a PA within |
|
|
|
* load_address <= entry_point < load_address + binary_size |
|
|
@ -60,10 +47,17 @@ int spmd_pm_secondary_core_set_ep(unsigned long long mpidr, |
|
|
|
return -EINVAL; |
|
|
|
} |
|
|
|
|
|
|
|
spmd_spm_core_context_t *ctx = spmd_get_context_by_mpidr(mpidr); |
|
|
|
spmd_pm_secondary_ep_t *secondary_ep = &ctx->secondary_ep; |
|
|
|
if (secondary_ep->locked) { |
|
|
|
ERROR("%s entry locked (%llx)\n", __func__, mpidr); |
|
|
|
return -EINVAL; |
|
|
|
} |
|
|
|
|
|
|
|
/* Fill new entry to corresponding secondary core id and lock it */ |
|
|
|
spmd_pm_secondary_ep[id].entry_point = entry_point; |
|
|
|
spmd_pm_secondary_ep[id].context = context; |
|
|
|
spmd_pm_secondary_ep[id].locked = true; |
|
|
|
secondary_ep->entry_point = entry_point; |
|
|
|
secondary_ep->context = context; |
|
|
|
secondary_ep->locked = true; |
|
|
|
|
|
|
|
VERBOSE("%s %d %llx %lx %llx\n", |
|
|
|
__func__, id, mpidr, entry_point, context); |
|
|
@ -82,7 +76,7 @@ static void spmd_cpu_on_finish_handler(u_register_t unused) |
|
|
|
entry_point_info_t *spmc_ep_info = spmd_spmc_ep_info_get(); |
|
|
|
spmd_spm_core_context_t *ctx = spmd_get_context(); |
|
|
|
unsigned int linear_id = plat_my_core_pos(); |
|
|
|
int rc; |
|
|
|
uint64_t rc; |
|
|
|
|
|
|
|
assert(ctx != NULL); |
|
|
|
assert(ctx->state != SPMC_STATE_ON); |
|
|
@ -92,21 +86,21 @@ static void spmd_cpu_on_finish_handler(u_register_t unused) |
|
|
|
* TODO: this might require locking the spmc_ep_info structure, |
|
|
|
* or provisioning one structure per cpu |
|
|
|
*/ |
|
|
|
if (spmd_pm_secondary_ep[linear_id].entry_point == 0) { |
|
|
|
if (ctx->secondary_ep.entry_point == 0UL) { |
|
|
|
goto exit; |
|
|
|
} |
|
|
|
|
|
|
|
spmc_ep_info->pc = spmd_pm_secondary_ep[linear_id].entry_point; |
|
|
|
spmc_ep_info->pc = ctx->secondary_ep.entry_point; |
|
|
|
cm_setup_context(&ctx->cpu_ctx, spmc_ep_info); |
|
|
|
write_ctx_reg(get_gpregs_ctx(&ctx->cpu_ctx), CTX_GPREG_X0, |
|
|
|
spmd_pm_secondary_ep[linear_id].context); |
|
|
|
ctx->secondary_ep.context); |
|
|
|
|
|
|
|
/* Mark CPU as initiating ON operation */ |
|
|
|
ctx->state = SPMC_STATE_ON_PENDING; |
|
|
|
|
|
|
|
rc = spmd_spm_core_sync_entry(ctx); |
|
|
|
if (rc != 0) { |
|
|
|
ERROR("%s failed failed (%d) on CPU%u\n", __func__, rc, |
|
|
|
if (rc != 0ULL) { |
|
|
|
ERROR("%s failed (%llu) on CPU%u\n", __func__, rc, |
|
|
|
linear_id); |
|
|
|
ctx->state = SPMC_STATE_OFF; |
|
|
|
return; |
|
|
@ -125,12 +119,12 @@ static int32_t spmd_cpu_off_handler(u_register_t unused) |
|
|
|
{ |
|
|
|
spmd_spm_core_context_t *ctx = spmd_get_context(); |
|
|
|
unsigned int linear_id = plat_my_core_pos(); |
|
|
|
int32_t rc; |
|
|
|
int64_t rc; |
|
|
|
|
|
|
|
assert(ctx != NULL); |
|
|
|
assert(ctx->state != SPMC_STATE_OFF); |
|
|
|
|
|
|
|
if (spmd_pm_secondary_ep[linear_id].entry_point == 0) { |
|
|
|
if (ctx->secondary_ep.entry_point == 0UL) { |
|
|
|
goto exit; |
|
|
|
} |
|
|
|
|
|
|
@ -138,8 +132,8 @@ static int32_t spmd_cpu_off_handler(u_register_t unused) |
|
|
|
spmd_build_spmc_message(get_gpregs_ctx(&ctx->cpu_ctx), PSCI_CPU_OFF); |
|
|
|
|
|
|
|
rc = spmd_spm_core_sync_entry(ctx); |
|
|
|
if (rc != 0) { |
|
|
|
ERROR("%s failed (%d) on CPU%u\n", __func__, rc, linear_id); |
|
|
|
if (rc != 0ULL) { |
|
|
|
ERROR("%s failed (%llu) on CPU%u\n", __func__, rc, linear_id); |
|
|
|
} |
|
|
|
|
|
|
|
/* TODO expect FFA_DIRECT_MSG_RESP returned from SPMC */ |
|
|
|