Provide cm_get/set_context() for current CPU
All callers of cm_get_context() pass the calling CPU MPIDR to the
function. Providing a specialised version for the current
CPU results in a reduction in code size and better readability.
The current function has been renamed to cm_get_context_by_mpidr()
and the existing name is now used for the current-CPU version.
The same treatment has been done to cm_set_context(), although
only both forms are used at present in the PSCI and TSPD code.
Change-Id: I91cb0c2f7bfcb950a045dbd9ff7595751c0c0ffb
diff --git a/services/spd/tspd/tspd_main.c b/services/spd/tspd/tspd_main.c
index 1a6913a..35bc6e2 100644
--- a/services/spd/tspd/tspd_main.c
+++ b/services/spd/tspd/tspd_main.c
@@ -95,7 +95,7 @@
/* Sanity check the pointer to this cpu's context */
mpidr = read_mpidr();
- assert(handle == cm_get_context(mpidr, NON_SECURE));
+ assert(handle == cm_get_context(NON_SECURE));
/* Save the non-secure context before entering the TSP */
cm_el1_sysregs_context_save(NON_SECURE);
@@ -103,7 +103,7 @@
/* Get a reference to this cpu's TSP context */
linear_id = platform_get_core_pos(mpidr);
tsp_ctx = &tspd_sp_context[linear_id];
- assert(&tsp_ctx->cpu_ctx == cm_get_context(mpidr, SECURE));
+ assert(&tsp_ctx->cpu_ctx == cm_get_context(SECURE));
/*
* Determine if the TSP was previously preempted. Its last known
@@ -275,10 +275,10 @@
if (ns)
SMC_RET1(handle, SMC_UNK);
- assert(handle == cm_get_context(mpidr, SECURE));
+ assert(handle == cm_get_context(SECURE));
cm_el1_sysregs_context_save(SECURE);
/* Get a reference to the non-secure context */
- ns_cpu_context = cm_get_context(mpidr, NON_SECURE);
+ ns_cpu_context = cm_get_context(NON_SECURE);
assert(ns_cpu_context);
/*
@@ -300,7 +300,7 @@
if (ns)
SMC_RET1(handle, SMC_UNK);
- assert(handle == cm_get_context(mpidr, SECURE));
+ assert(handle == cm_get_context(SECURE));
/*
* Restore the relevant EL3 state which saved to service
@@ -316,7 +316,7 @@
}
/* Get a reference to the non-secure context */
- ns_cpu_context = cm_get_context(mpidr, NON_SECURE);
+ ns_cpu_context = cm_get_context(NON_SECURE);
assert(ns_cpu_context);
/*
@@ -339,7 +339,7 @@
if (ns)
SMC_RET1(handle, SMC_UNK);
- assert(handle == cm_get_context(mpidr, SECURE));
+ assert(handle == cm_get_context(SECURE));
/* Assert that standard SMC execution has been preempted */
assert(get_std_smc_active_flag(tsp_ctx->state));
@@ -348,7 +348,7 @@
cm_el1_sysregs_context_save(SECURE);
/* Get a reference to the non-secure context */
- ns_cpu_context = cm_get_context(mpidr, NON_SECURE);
+ ns_cpu_context = cm_get_context(NON_SECURE);
assert(ns_cpu_context);
/* Restore non-secure state */
@@ -434,7 +434,7 @@
* registers need to be preserved, save the non-secure
* state and send the request to the secure payload.
*/
- assert(handle == cm_get_context(mpidr, NON_SECURE));
+ assert(handle == cm_get_context(NON_SECURE));
/* Check if we are already preempted */
if (get_std_smc_active_flag(tsp_ctx->state))
@@ -457,7 +457,7 @@
* payload. Entry into S-EL1 will take place upon exit
* from this function.
*/
- assert(&tsp_ctx->cpu_ctx == cm_get_context(mpidr, SECURE));
+ assert(&tsp_ctx->cpu_ctx == cm_get_context(SECURE));
/* Set appropriate entry for SMC.
* We expect the TSP to manage the PSTATE.I and PSTATE.F
@@ -482,11 +482,11 @@
* into the non-secure context, save the secure state
* and return to the non-secure state.
*/
- assert(handle == cm_get_context(mpidr, SECURE));
+ assert(handle == cm_get_context(SECURE));
cm_el1_sysregs_context_save(SECURE);
/* Get a reference to the non-secure context */
- ns_cpu_context = cm_get_context(mpidr, NON_SECURE);
+ ns_cpu_context = cm_get_context(NON_SECURE);
assert(ns_cpu_context);
/* Restore non-secure state */
@@ -515,7 +515,7 @@
* save the non-secure state and send the request to
* the secure payload.
*/
- assert(handle == cm_get_context(mpidr, NON_SECURE));
+ assert(handle == cm_get_context(NON_SECURE));
/* Check if we are already preempted before resume */
if (!get_std_smc_active_flag(tsp_ctx->state))