Commit fd650ff6 authored by Soby Mathew's avatar Soby Mathew Committed by Achin Gupta
Browse files

PSCI: Migrate SPDs and TSP to the new platform and framework API

The new PSCI frameworks mandates that the platform APIs and the various
frameworks in Trusted Firmware migrate away from MPIDR based core
identification to one based on core index. Deprecated versions of the old
APIs are still present to provide compatibility but their implementations
are not optimal. This patch migrates the various SPDs exisiting within
Trusted Firmware tree and TSP to the new APIs.

Change-Id: Ifc37e7071c5769b5ded21d0b6a071c8c4cab7836
parent a6bd5ffb
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -122,8 +122,7 @@ func tsp_entrypoint ...@@ -122,8 +122,7 @@ func tsp_entrypoint
* primary cpu is running at the moment. * primary cpu is running at the moment.
* -------------------------------------------- * --------------------------------------------
*/ */
mrs x0, mpidr_el1 bl plat_set_my_stack
bl platform_set_stack
/* --------------------------------------------- /* ---------------------------------------------
* Perform early platform setup & platform * Perform early platform setup & platform
...@@ -248,8 +247,7 @@ func tsp_cpu_on_entry ...@@ -248,8 +247,7 @@ func tsp_cpu_on_entry
* enabled. * enabled.
* -------------------------------------------- * --------------------------------------------
*/ */
mrs x0, mpidr_el1 bl plat_set_my_stack
bl platform_set_stack
/* -------------------------------------------- /* --------------------------------------------
* Enable the MMU with the DCache disabled. It * Enable the MMU with the DCache disabled. It
......
...@@ -49,8 +49,7 @@ ...@@ -49,8 +49,7 @@
******************************************************************************/ ******************************************************************************/
void tsp_update_sync_fiq_stats(uint32_t type, uint64_t elr_el3) void tsp_update_sync_fiq_stats(uint32_t type, uint64_t elr_el3)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_stats[linear_id].sync_fiq_count++; tsp_stats[linear_id].sync_fiq_count++;
if (type == TSP_HANDLE_FIQ_AND_RETURN) if (type == TSP_HANDLE_FIQ_AND_RETURN)
...@@ -59,9 +58,9 @@ void tsp_update_sync_fiq_stats(uint32_t type, uint64_t elr_el3) ...@@ -59,9 +58,9 @@ void tsp_update_sync_fiq_stats(uint32_t type, uint64_t elr_el3)
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE #if LOG_LEVEL >= LOG_LEVEL_VERBOSE
spin_lock(&console_lock); spin_lock(&console_lock);
VERBOSE("TSP: cpu 0x%lx sync fiq request from 0x%lx\n", VERBOSE("TSP: cpu 0x%lx sync fiq request from 0x%lx\n",
mpidr, elr_el3); read_mpidr(), elr_el3);
VERBOSE("TSP: cpu 0x%lx: %d sync fiq requests, %d sync fiq returns\n", VERBOSE("TSP: cpu 0x%lx: %d sync fiq requests, %d sync fiq returns\n",
mpidr, read_mpidr(),
tsp_stats[linear_id].sync_fiq_count, tsp_stats[linear_id].sync_fiq_count,
tsp_stats[linear_id].sync_fiq_ret_count); tsp_stats[linear_id].sync_fiq_ret_count);
spin_unlock(&console_lock); spin_unlock(&console_lock);
...@@ -77,8 +76,7 @@ void tsp_update_sync_fiq_stats(uint32_t type, uint64_t elr_el3) ...@@ -77,8 +76,7 @@ void tsp_update_sync_fiq_stats(uint32_t type, uint64_t elr_el3)
******************************************************************************/ ******************************************************************************/
int32_t tsp_fiq_handler(void) int32_t tsp_fiq_handler(void)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos(), id;
uint32_t linear_id = platform_get_core_pos(mpidr), id;
/* /*
* Get the highest priority pending interrupt id and see if it is the * Get the highest priority pending interrupt id and see if it is the
...@@ -105,9 +103,9 @@ int32_t tsp_fiq_handler(void) ...@@ -105,9 +103,9 @@ int32_t tsp_fiq_handler(void)
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE #if LOG_LEVEL >= LOG_LEVEL_VERBOSE
spin_lock(&console_lock); spin_lock(&console_lock);
VERBOSE("TSP: cpu 0x%lx handled fiq %d\n", VERBOSE("TSP: cpu 0x%lx handled fiq %d\n",
mpidr, id); read_mpidr(), id);
VERBOSE("TSP: cpu 0x%lx: %d fiq requests\n", VERBOSE("TSP: cpu 0x%lx: %d fiq requests\n",
mpidr, tsp_stats[linear_id].fiq_count); read_mpidr(), tsp_stats[linear_id].fiq_count);
spin_unlock(&console_lock); spin_unlock(&console_lock);
#endif #endif
return 0; return 0;
...@@ -115,15 +113,14 @@ int32_t tsp_fiq_handler(void) ...@@ -115,15 +113,14 @@ int32_t tsp_fiq_handler(void)
int32_t tsp_irq_received(void) int32_t tsp_irq_received(void)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_stats[linear_id].irq_count++; tsp_stats[linear_id].irq_count++;
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE #if LOG_LEVEL >= LOG_LEVEL_VERBOSE
spin_lock(&console_lock); spin_lock(&console_lock);
VERBOSE("TSP: cpu 0x%lx received irq\n", mpidr); VERBOSE("TSP: cpu 0x%lx received irq\n", read_mpidr());
VERBOSE("TSP: cpu 0x%lx: %d irq requests\n", VERBOSE("TSP: cpu 0x%lx: %d irq requests\n",
mpidr, tsp_stats[linear_id].irq_count); read_mpidr(), tsp_stats[linear_id].irq_count);
spin_unlock(&console_lock); spin_unlock(&console_lock);
#endif #endif
return TSP_PREEMPTED; return TSP_PREEMPTED;
......
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -72,7 +72,6 @@ static tsp_args_t *set_smc_args(uint64_t arg0, ...@@ -72,7 +72,6 @@ static tsp_args_t *set_smc_args(uint64_t arg0,
uint64_t arg6, uint64_t arg6,
uint64_t arg7) uint64_t arg7)
{ {
uint64_t mpidr = read_mpidr();
uint32_t linear_id; uint32_t linear_id;
tsp_args_t *pcpu_smc_args; tsp_args_t *pcpu_smc_args;
...@@ -80,7 +79,7 @@ static tsp_args_t *set_smc_args(uint64_t arg0, ...@@ -80,7 +79,7 @@ static tsp_args_t *set_smc_args(uint64_t arg0,
* Return to Secure Monitor by raising an SMC. The results of the * Return to Secure Monitor by raising an SMC. The results of the
* service are passed as an arguments to the SMC * service are passed as an arguments to the SMC
*/ */
linear_id = platform_get_core_pos(mpidr); linear_id = plat_my_core_pos();
pcpu_smc_args = &tsp_smc_args[linear_id]; pcpu_smc_args = &tsp_smc_args[linear_id];
write_sp_arg(pcpu_smc_args, TSP_ARG0, arg0); write_sp_arg(pcpu_smc_args, TSP_ARG0, arg0);
write_sp_arg(pcpu_smc_args, TSP_ARG1, arg1); write_sp_arg(pcpu_smc_args, TSP_ARG1, arg1);
...@@ -107,8 +106,7 @@ uint64_t tsp_main(void) ...@@ -107,8 +106,7 @@ uint64_t tsp_main(void)
INFO("TSP: Total memory size : 0x%lx bytes\n", INFO("TSP: Total memory size : 0x%lx bytes\n",
BL32_TOTAL_LIMIT - BL32_TOTAL_BASE); BL32_TOTAL_LIMIT - BL32_TOTAL_BASE);
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
/* Initialize the platform */ /* Initialize the platform */
tsp_platform_setup(); tsp_platform_setup();
...@@ -123,7 +121,8 @@ uint64_t tsp_main(void) ...@@ -123,7 +121,8 @@ uint64_t tsp_main(void)
#if LOG_LEVEL >= LOG_LEVEL_INFO #if LOG_LEVEL >= LOG_LEVEL_INFO
spin_lock(&console_lock); spin_lock(&console_lock);
INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu on requests\n", mpidr, INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu on requests\n",
read_mpidr(),
tsp_stats[linear_id].smc_count, tsp_stats[linear_id].smc_count,
tsp_stats[linear_id].eret_count, tsp_stats[linear_id].eret_count,
tsp_stats[linear_id].cpu_on_count); tsp_stats[linear_id].cpu_on_count);
...@@ -139,8 +138,7 @@ uint64_t tsp_main(void) ...@@ -139,8 +138,7 @@ uint64_t tsp_main(void)
******************************************************************************/ ******************************************************************************/
tsp_args_t *tsp_cpu_on_main(void) tsp_args_t *tsp_cpu_on_main(void)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
/* Initialize secure/applications state here */ /* Initialize secure/applications state here */
tsp_generic_timer_start(); tsp_generic_timer_start();
...@@ -152,8 +150,9 @@ tsp_args_t *tsp_cpu_on_main(void) ...@@ -152,8 +150,9 @@ tsp_args_t *tsp_cpu_on_main(void)
#if LOG_LEVEL >= LOG_LEVEL_INFO #if LOG_LEVEL >= LOG_LEVEL_INFO
spin_lock(&console_lock); spin_lock(&console_lock);
INFO("TSP: cpu 0x%lx turned on\n", mpidr); INFO("TSP: cpu 0x%lx turned on\n", read_mpidr());
INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu on requests\n", mpidr, INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu on requests\n",
read_mpidr(),
tsp_stats[linear_id].smc_count, tsp_stats[linear_id].smc_count,
tsp_stats[linear_id].eret_count, tsp_stats[linear_id].eret_count,
tsp_stats[linear_id].cpu_on_count); tsp_stats[linear_id].cpu_on_count);
...@@ -176,8 +175,7 @@ tsp_args_t *tsp_cpu_off_main(uint64_t arg0, ...@@ -176,8 +175,7 @@ tsp_args_t *tsp_cpu_off_main(uint64_t arg0,
uint64_t arg6, uint64_t arg6,
uint64_t arg7) uint64_t arg7)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
/* /*
* This cpu is being turned off, so disable the timer to prevent the * This cpu is being turned off, so disable the timer to prevent the
...@@ -193,8 +191,9 @@ tsp_args_t *tsp_cpu_off_main(uint64_t arg0, ...@@ -193,8 +191,9 @@ tsp_args_t *tsp_cpu_off_main(uint64_t arg0,
#if LOG_LEVEL >= LOG_LEVEL_INFO #if LOG_LEVEL >= LOG_LEVEL_INFO
spin_lock(&console_lock); spin_lock(&console_lock);
INFO("TSP: cpu 0x%lx off request\n", mpidr); INFO("TSP: cpu 0x%lx off request\n", read_mpidr());
INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu off requests\n", mpidr, INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu off requests\n",
read_mpidr(),
tsp_stats[linear_id].smc_count, tsp_stats[linear_id].smc_count,
tsp_stats[linear_id].eret_count, tsp_stats[linear_id].eret_count,
tsp_stats[linear_id].cpu_off_count); tsp_stats[linear_id].cpu_off_count);
...@@ -219,8 +218,7 @@ tsp_args_t *tsp_cpu_suspend_main(uint64_t arg0, ...@@ -219,8 +218,7 @@ tsp_args_t *tsp_cpu_suspend_main(uint64_t arg0,
uint64_t arg6, uint64_t arg6,
uint64_t arg7) uint64_t arg7)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
/* /*
* Save the time context and disable it to prevent the secure timer * Save the time context and disable it to prevent the secure timer
...@@ -237,7 +235,7 @@ tsp_args_t *tsp_cpu_suspend_main(uint64_t arg0, ...@@ -237,7 +235,7 @@ tsp_args_t *tsp_cpu_suspend_main(uint64_t arg0,
#if LOG_LEVEL >= LOG_LEVEL_INFO #if LOG_LEVEL >= LOG_LEVEL_INFO
spin_lock(&console_lock); spin_lock(&console_lock);
INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu suspend requests\n", INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu suspend requests\n",
mpidr, read_mpidr(),
tsp_stats[linear_id].smc_count, tsp_stats[linear_id].smc_count,
tsp_stats[linear_id].eret_count, tsp_stats[linear_id].eret_count,
tsp_stats[linear_id].cpu_suspend_count); tsp_stats[linear_id].cpu_suspend_count);
...@@ -262,8 +260,7 @@ tsp_args_t *tsp_cpu_resume_main(uint64_t suspend_level, ...@@ -262,8 +260,7 @@ tsp_args_t *tsp_cpu_resume_main(uint64_t suspend_level,
uint64_t arg6, uint64_t arg6,
uint64_t arg7) uint64_t arg7)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
/* Restore the generic timer context */ /* Restore the generic timer context */
tsp_generic_timer_restore(); tsp_generic_timer_restore();
...@@ -276,9 +273,9 @@ tsp_args_t *tsp_cpu_resume_main(uint64_t suspend_level, ...@@ -276,9 +273,9 @@ tsp_args_t *tsp_cpu_resume_main(uint64_t suspend_level,
#if LOG_LEVEL >= LOG_LEVEL_INFO #if LOG_LEVEL >= LOG_LEVEL_INFO
spin_lock(&console_lock); spin_lock(&console_lock);
INFO("TSP: cpu 0x%lx resumed. suspend level %ld\n", INFO("TSP: cpu 0x%lx resumed. suspend level %ld\n",
mpidr, suspend_level); read_mpidr(), suspend_level);
INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu suspend requests\n", INFO("TSP: cpu 0x%lx: %d smcs, %d erets %d cpu suspend requests\n",
mpidr, read_mpidr(),
tsp_stats[linear_id].smc_count, tsp_stats[linear_id].smc_count,
tsp_stats[linear_id].eret_count, tsp_stats[linear_id].eret_count,
tsp_stats[linear_id].cpu_suspend_count); tsp_stats[linear_id].cpu_suspend_count);
...@@ -301,8 +298,7 @@ tsp_args_t *tsp_system_off_main(uint64_t arg0, ...@@ -301,8 +298,7 @@ tsp_args_t *tsp_system_off_main(uint64_t arg0,
uint64_t arg6, uint64_t arg6,
uint64_t arg7) uint64_t arg7)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
/* Update this cpu's statistics */ /* Update this cpu's statistics */
tsp_stats[linear_id].smc_count++; tsp_stats[linear_id].smc_count++;
...@@ -310,8 +306,8 @@ tsp_args_t *tsp_system_off_main(uint64_t arg0, ...@@ -310,8 +306,8 @@ tsp_args_t *tsp_system_off_main(uint64_t arg0,
#if LOG_LEVEL >= LOG_LEVEL_INFO #if LOG_LEVEL >= LOG_LEVEL_INFO
spin_lock(&console_lock); spin_lock(&console_lock);
INFO("TSP: cpu 0x%lx SYSTEM_OFF request\n", mpidr); INFO("TSP: cpu 0x%lx SYSTEM_OFF request\n", read_mpidr());
INFO("TSP: cpu 0x%lx: %d smcs, %d erets requests\n", mpidr, INFO("TSP: cpu 0x%lx: %d smcs, %d erets requests\n", read_mpidr(),
tsp_stats[linear_id].smc_count, tsp_stats[linear_id].smc_count,
tsp_stats[linear_id].eret_count); tsp_stats[linear_id].eret_count);
spin_unlock(&console_lock); spin_unlock(&console_lock);
...@@ -334,8 +330,7 @@ tsp_args_t *tsp_system_reset_main(uint64_t arg0, ...@@ -334,8 +330,7 @@ tsp_args_t *tsp_system_reset_main(uint64_t arg0,
uint64_t arg6, uint64_t arg6,
uint64_t arg7) uint64_t arg7)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
/* Update this cpu's statistics */ /* Update this cpu's statistics */
tsp_stats[linear_id].smc_count++; tsp_stats[linear_id].smc_count++;
...@@ -343,8 +338,8 @@ tsp_args_t *tsp_system_reset_main(uint64_t arg0, ...@@ -343,8 +338,8 @@ tsp_args_t *tsp_system_reset_main(uint64_t arg0,
#if LOG_LEVEL >= LOG_LEVEL_INFO #if LOG_LEVEL >= LOG_LEVEL_INFO
spin_lock(&console_lock); spin_lock(&console_lock);
INFO("TSP: cpu 0x%lx SYSTEM_RESET request\n", mpidr); INFO("TSP: cpu 0x%lx SYSTEM_RESET request\n", read_mpidr());
INFO("TSP: cpu 0x%lx: %d smcs, %d erets requests\n", mpidr, INFO("TSP: cpu 0x%lx: %d smcs, %d erets requests\n", read_mpidr(),
tsp_stats[linear_id].smc_count, tsp_stats[linear_id].smc_count,
tsp_stats[linear_id].eret_count); tsp_stats[linear_id].eret_count);
spin_unlock(&console_lock); spin_unlock(&console_lock);
...@@ -371,17 +366,16 @@ tsp_args_t *tsp_smc_handler(uint64_t func, ...@@ -371,17 +366,16 @@ tsp_args_t *tsp_smc_handler(uint64_t func,
{ {
uint64_t results[2]; uint64_t results[2];
uint64_t service_args[2]; uint64_t service_args[2];
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
/* Update this cpu's statistics */ /* Update this cpu's statistics */
tsp_stats[linear_id].smc_count++; tsp_stats[linear_id].smc_count++;
tsp_stats[linear_id].eret_count++; tsp_stats[linear_id].eret_count++;
INFO("TSP: cpu 0x%lx received %s smc 0x%lx\n", mpidr, INFO("TSP: cpu 0x%lx received %s smc 0x%lx\n", read_mpidr(),
((func >> 31) & 1) == 1 ? "fast" : "standard", ((func >> 31) & 1) == 1 ? "fast" : "standard",
func); func);
INFO("TSP: cpu 0x%lx: %d smcs, %d erets\n", mpidr, INFO("TSP: cpu 0x%lx: %d smcs, %d erets\n", read_mpidr(),
tsp_stats[linear_id].smc_count, tsp_stats[linear_id].smc_count,
tsp_stats[linear_id].eret_count); tsp_stats[linear_id].eret_count);
......
/* /*
* Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2014-2015, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -92,7 +92,7 @@ void tsp_generic_timer_stop(void) ...@@ -92,7 +92,7 @@ void tsp_generic_timer_stop(void)
******************************************************************************/ ******************************************************************************/
void tsp_generic_timer_save(void) void tsp_generic_timer_save(void)
{ {
uint32_t linear_id = platform_get_core_pos(read_mpidr()); uint32_t linear_id = plat_my_core_pos();
pcpu_timer_context[linear_id].cval = read_cntps_cval_el1(); pcpu_timer_context[linear_id].cval = read_cntps_cval_el1();
pcpu_timer_context[linear_id].ctl = read_cntps_ctl_el1(); pcpu_timer_context[linear_id].ctl = read_cntps_ctl_el1();
...@@ -105,7 +105,7 @@ void tsp_generic_timer_save(void) ...@@ -105,7 +105,7 @@ void tsp_generic_timer_save(void)
******************************************************************************/ ******************************************************************************/
void tsp_generic_timer_restore(void) void tsp_generic_timer_restore(void)
{ {
uint32_t linear_id = platform_get_core_pos(read_mpidr()); uint32_t linear_id = plat_my_core_pos();
write_cntps_cval_el1(pcpu_timer_context[linear_id].cval); write_cntps_cval_el1(pcpu_timer_context[linear_id].cval);
write_cntps_ctl_el1(pcpu_timer_context[linear_id].ctl); write_cntps_ctl_el1(pcpu_timer_context[linear_id].ctl);
......
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -80,7 +80,6 @@ static uint64_t opteed_sel1_interrupt_handler(uint32_t id, ...@@ -80,7 +80,6 @@ static uint64_t opteed_sel1_interrupt_handler(uint32_t id,
void *cookie) void *cookie)
{ {
uint32_t linear_id; uint32_t linear_id;
uint64_t mpidr;
optee_context_t *optee_ctx; optee_context_t *optee_ctx;
/* Check the security state when the exception was generated */ /* Check the security state when the exception was generated */
...@@ -92,14 +91,13 @@ static uint64_t opteed_sel1_interrupt_handler(uint32_t id, ...@@ -92,14 +91,13 @@ static uint64_t opteed_sel1_interrupt_handler(uint32_t id,
#endif #endif
/* Sanity check the pointer to this cpu's context */ /* Sanity check the pointer to this cpu's context */
mpidr = read_mpidr();
assert(handle == cm_get_context(NON_SECURE)); assert(handle == cm_get_context(NON_SECURE));
/* Save the non-secure context before entering the OPTEE */ /* Save the non-secure context before entering the OPTEE */
cm_el1_sysregs_context_save(NON_SECURE); cm_el1_sysregs_context_save(NON_SECURE);
/* Get a reference to this cpu's OPTEE context */ /* Get a reference to this cpu's OPTEE context */
linear_id = platform_get_core_pos(mpidr); linear_id = plat_my_core_pos();
optee_ctx = &opteed_sp_context[linear_id]; optee_ctx = &opteed_sp_context[linear_id];
assert(&optee_ctx->cpu_ctx == cm_get_context(SECURE)); assert(&optee_ctx->cpu_ctx == cm_get_context(SECURE));
...@@ -125,10 +123,9 @@ static uint64_t opteed_sel1_interrupt_handler(uint32_t id, ...@@ -125,10 +123,9 @@ static uint64_t opteed_sel1_interrupt_handler(uint32_t id,
int32_t opteed_setup(void) int32_t opteed_setup(void)
{ {
entry_point_info_t *optee_ep_info; entry_point_info_t *optee_ep_info;
uint64_t mpidr = read_mpidr();
uint32_t linear_id; uint32_t linear_id;
linear_id = platform_get_core_pos(mpidr); linear_id = plat_my_core_pos();
/* /*
* Get information about the Secure Payload (BL32) image. Its * Get information about the Secure Payload (BL32) image. Its
...@@ -182,8 +179,7 @@ int32_t opteed_setup(void) ...@@ -182,8 +179,7 @@ int32_t opteed_setup(void)
******************************************************************************/ ******************************************************************************/
static int32_t opteed_init(void) static int32_t opteed_init(void)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
entry_point_info_t *optee_entry_point; entry_point_info_t *optee_entry_point;
uint64_t rc; uint64_t rc;
...@@ -195,7 +191,7 @@ static int32_t opteed_init(void) ...@@ -195,7 +191,7 @@ static int32_t opteed_init(void)
optee_entry_point = bl31_plat_get_next_image_ep_info(SECURE); optee_entry_point = bl31_plat_get_next_image_ep_info(SECURE);
assert(optee_entry_point); assert(optee_entry_point);
cm_init_context(mpidr, optee_entry_point); cm_init_my_context(optee_entry_point);
/* /*
* Arrange for an entry into OPTEE. It will be returned via * Arrange for an entry into OPTEE. It will be returned via
...@@ -226,8 +222,7 @@ uint64_t opteed_smc_handler(uint32_t smc_fid, ...@@ -226,8 +222,7 @@ uint64_t opteed_smc_handler(uint32_t smc_fid,
uint64_t flags) uint64_t flags)
{ {
cpu_context_t *ns_cpu_context; cpu_context_t *ns_cpu_context;
unsigned long mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
uint64_t rc; uint64_t rc;
......
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -51,8 +51,7 @@ static void opteed_cpu_on_handler(uint64_t target_cpu) ...@@ -51,8 +51,7 @@ static void opteed_cpu_on_handler(uint64_t target_cpu)
static int32_t opteed_cpu_off_handler(uint64_t unused) static int32_t opteed_cpu_off_handler(uint64_t unused)
{ {
int32_t rc = 0; int32_t rc = 0;
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vectors);
...@@ -85,8 +84,7 @@ static int32_t opteed_cpu_off_handler(uint64_t unused) ...@@ -85,8 +84,7 @@ static int32_t opteed_cpu_off_handler(uint64_t unused)
static void opteed_cpu_suspend_handler(uint64_t unused) static void opteed_cpu_suspend_handler(uint64_t unused)
{ {
int32_t rc = 0; int32_t rc = 0;
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vectors);
...@@ -116,8 +114,7 @@ static void opteed_cpu_suspend_handler(uint64_t unused) ...@@ -116,8 +114,7 @@ static void opteed_cpu_suspend_handler(uint64_t unused)
static void opteed_cpu_on_finish_handler(uint64_t unused) static void opteed_cpu_on_finish_handler(uint64_t unused)
{ {
int32_t rc = 0; int32_t rc = 0;
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
entry_point_info_t optee_on_entrypoint; entry_point_info_t optee_on_entrypoint;
...@@ -129,7 +126,7 @@ static void opteed_cpu_on_finish_handler(uint64_t unused) ...@@ -129,7 +126,7 @@ static void opteed_cpu_on_finish_handler(uint64_t unused)
optee_ctx); optee_ctx);
/* Initialise this cpu's secure context */ /* Initialise this cpu's secure context */
cm_init_context(mpidr, &optee_on_entrypoint); cm_init_my_context(&optee_on_entrypoint);
/* Enter OPTEE */ /* Enter OPTEE */
rc = opteed_synchronous_sp_entry(optee_ctx); rc = opteed_synchronous_sp_entry(optee_ctx);
...@@ -153,8 +150,7 @@ static void opteed_cpu_on_finish_handler(uint64_t unused) ...@@ -153,8 +150,7 @@ static void opteed_cpu_on_finish_handler(uint64_t unused)
static void opteed_cpu_suspend_finish_handler(uint64_t suspend_level) static void opteed_cpu_suspend_finish_handler(uint64_t suspend_level)
{ {
int32_t rc = 0; int32_t rc = 0;
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vectors);
...@@ -193,8 +189,7 @@ static int32_t opteed_cpu_migrate_info(uint64_t *resident_cpu) ...@@ -193,8 +189,7 @@ static int32_t opteed_cpu_migrate_info(uint64_t *resident_cpu)
******************************************************************************/ ******************************************************************************/
static void opteed_system_off(void) static void opteed_system_off(void)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vectors);
...@@ -214,8 +209,7 @@ static void opteed_system_off(void) ...@@ -214,8 +209,7 @@ static void opteed_system_off(void)
******************************************************************************/ ******************************************************************************/
static void opteed_system_reset(void) static void opteed_system_reset(void)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vectors);
......
...@@ -121,7 +121,6 @@ int32_t tlkd_setup(void) ...@@ -121,7 +121,6 @@ int32_t tlkd_setup(void)
******************************************************************************/ ******************************************************************************/
int32_t tlkd_init(void) int32_t tlkd_init(void)
{ {
uint64_t mpidr = read_mpidr();
entry_point_info_t *tlk_entry_point; entry_point_info_t *tlk_entry_point;
/* /*
...@@ -131,7 +130,7 @@ int32_t tlkd_init(void) ...@@ -131,7 +130,7 @@ int32_t tlkd_init(void)
tlk_entry_point = bl31_plat_get_next_image_ep_info(SECURE); tlk_entry_point = bl31_plat_get_next_image_ep_info(SECURE);
assert(tlk_entry_point); assert(tlk_entry_point);
cm_init_context(mpidr, tlk_entry_point); cm_init_my_context(tlk_entry_point);
/* /*
* Arrange for an entry into the test secure payload. * Arrange for an entry into the test secure payload.
......
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -101,7 +101,6 @@ static uint64_t tspd_sel1_interrupt_handler(uint32_t id, ...@@ -101,7 +101,6 @@ static uint64_t tspd_sel1_interrupt_handler(uint32_t id,
void *cookie) void *cookie)
{ {
uint32_t linear_id; uint32_t linear_id;
uint64_t mpidr;
tsp_context_t *tsp_ctx; tsp_context_t *tsp_ctx;
/* Check the security state when the exception was generated */ /* Check the security state when the exception was generated */
...@@ -113,14 +112,13 @@ static uint64_t tspd_sel1_interrupt_handler(uint32_t id, ...@@ -113,14 +112,13 @@ static uint64_t tspd_sel1_interrupt_handler(uint32_t id,
#endif #endif
/* Sanity check the pointer to this cpu's context */ /* Sanity check the pointer to this cpu's context */
mpidr = read_mpidr();
assert(handle == cm_get_context(NON_SECURE)); assert(handle == cm_get_context(NON_SECURE));
/* Save the non-secure context before entering the TSP */ /* Save the non-secure context before entering the TSP */
cm_el1_sysregs_context_save(NON_SECURE); cm_el1_sysregs_context_save(NON_SECURE);
/* Get a reference to this cpu's TSP context */ /* Get a reference to this cpu's TSP context */
linear_id = platform_get_core_pos(mpidr); linear_id = plat_my_core_pos();
tsp_ctx = &tspd_sp_context[linear_id]; tsp_ctx = &tspd_sp_context[linear_id];
assert(&tsp_ctx->cpu_ctx == cm_get_context(SECURE)); assert(&tsp_ctx->cpu_ctx == cm_get_context(SECURE));
...@@ -197,10 +195,9 @@ static uint64_t tspd_ns_interrupt_handler(uint32_t id, ...@@ -197,10 +195,9 @@ static uint64_t tspd_ns_interrupt_handler(uint32_t id,
int32_t tspd_setup(void) int32_t tspd_setup(void)
{ {
entry_point_info_t *tsp_ep_info; entry_point_info_t *tsp_ep_info;
uint64_t mpidr = read_mpidr();
uint32_t linear_id; uint32_t linear_id;
linear_id = platform_get_core_pos(mpidr); linear_id = plat_my_core_pos();
/* /*
* Get information about the Secure Payload (BL32) image. Its * Get information about the Secure Payload (BL32) image. Its
...@@ -256,8 +253,7 @@ int32_t tspd_setup(void) ...@@ -256,8 +253,7 @@ int32_t tspd_setup(void)
******************************************************************************/ ******************************************************************************/
int32_t tspd_init(void) int32_t tspd_init(void)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
entry_point_info_t *tsp_entry_point; entry_point_info_t *tsp_entry_point;
uint64_t rc; uint64_t rc;
...@@ -269,7 +265,7 @@ int32_t tspd_init(void) ...@@ -269,7 +265,7 @@ int32_t tspd_init(void)
tsp_entry_point = bl31_plat_get_next_image_ep_info(SECURE); tsp_entry_point = bl31_plat_get_next_image_ep_info(SECURE);
assert(tsp_entry_point); assert(tsp_entry_point);
cm_init_context(mpidr, tsp_entry_point); cm_init_my_context(tsp_entry_point);
/* /*
* Arrange for an entry into the test secure payload. It will be * Arrange for an entry into the test secure payload. It will be
...@@ -300,8 +296,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid, ...@@ -300,8 +296,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid,
uint64_t flags) uint64_t flags)
{ {
cpu_context_t *ns_cpu_context; cpu_context_t *ns_cpu_context;
unsigned long mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos(), ns;
uint32_t linear_id = platform_get_core_pos(mpidr), ns;
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
uint64_t rc; uint64_t rc;
#if TSP_INIT_ASYNC #if TSP_INIT_ASYNC
...@@ -453,7 +448,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid, ...@@ -453,7 +448,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid,
/* /*
* Disable the interrupt NS locally since it will be enabled globally * Disable the interrupt NS locally since it will be enabled globally
* within cm_init_context. * within cm_init_my_context.
*/ */
disable_intr_rm_local(INTR_TYPE_NS, SECURE); disable_intr_rm_local(INTR_TYPE_NS, SECURE);
#endif #endif
...@@ -471,7 +466,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid, ...@@ -471,7 +466,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid,
assert(NON_SECURE == assert(NON_SECURE ==
GET_SECURITY_STATE(next_image_info->h.attr)); GET_SECURITY_STATE(next_image_info->h.attr));
cm_init_context(read_mpidr_el1(), next_image_info); cm_init_my_context(next_image_info);
cm_prepare_el3_exit(NON_SECURE); cm_prepare_el3_exit(NON_SECURE);
SMC_RET0(cm_get_context(NON_SECURE)); SMC_RET0(cm_get_context(NON_SECURE));
#else #else
......
/* /*
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2013-2015, ARM Limited and Contributors. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
...@@ -52,8 +52,7 @@ static void tspd_cpu_on_handler(uint64_t target_cpu) ...@@ -52,8 +52,7 @@ static void tspd_cpu_on_handler(uint64_t target_cpu)
static int32_t tspd_cpu_off_handler(uint64_t unused) static int32_t tspd_cpu_off_handler(uint64_t unused)
{ {
int32_t rc = 0; int32_t rc = 0;
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_vectors); assert(tsp_vectors);
...@@ -86,8 +85,7 @@ static int32_t tspd_cpu_off_handler(uint64_t unused) ...@@ -86,8 +85,7 @@ static int32_t tspd_cpu_off_handler(uint64_t unused)
static void tspd_cpu_suspend_handler(uint64_t unused) static void tspd_cpu_suspend_handler(uint64_t unused)
{ {
int32_t rc = 0; int32_t rc = 0;
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_vectors); assert(tsp_vectors);
...@@ -117,8 +115,7 @@ static void tspd_cpu_suspend_handler(uint64_t unused) ...@@ -117,8 +115,7 @@ static void tspd_cpu_suspend_handler(uint64_t unused)
static void tspd_cpu_on_finish_handler(uint64_t unused) static void tspd_cpu_on_finish_handler(uint64_t unused)
{ {
int32_t rc = 0; int32_t rc = 0;
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
entry_point_info_t tsp_on_entrypoint; entry_point_info_t tsp_on_entrypoint;
...@@ -131,12 +128,12 @@ static void tspd_cpu_on_finish_handler(uint64_t unused) ...@@ -131,12 +128,12 @@ static void tspd_cpu_on_finish_handler(uint64_t unused)
tsp_ctx); tsp_ctx);
/* Initialise this cpu's secure context */ /* Initialise this cpu's secure context */
cm_init_context(mpidr, &tsp_on_entrypoint); cm_init_my_context(&tsp_on_entrypoint);
#if TSPD_ROUTE_IRQ_TO_EL3 #if TSPD_ROUTE_IRQ_TO_EL3
/* /*
* Disable the NS interrupt locally since it will be enabled globally * Disable the NS interrupt locally since it will be enabled globally
* within cm_init_context. * within cm_init_my_context.
*/ */
disable_intr_rm_local(INTR_TYPE_NS, SECURE); disable_intr_rm_local(INTR_TYPE_NS, SECURE);
#endif #endif
...@@ -163,8 +160,7 @@ static void tspd_cpu_on_finish_handler(uint64_t unused) ...@@ -163,8 +160,7 @@ static void tspd_cpu_on_finish_handler(uint64_t unused)
static void tspd_cpu_suspend_finish_handler(uint64_t suspend_level) static void tspd_cpu_suspend_finish_handler(uint64_t suspend_level)
{ {
int32_t rc = 0; int32_t rc = 0;
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_vectors); assert(tsp_vectors);
...@@ -203,8 +199,7 @@ static int32_t tspd_cpu_migrate_info(uint64_t *resident_cpu) ...@@ -203,8 +199,7 @@ static int32_t tspd_cpu_migrate_info(uint64_t *resident_cpu)
******************************************************************************/ ******************************************************************************/
static void tspd_system_off(void) static void tspd_system_off(void)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_vectors); assert(tsp_vectors);
...@@ -224,8 +219,7 @@ static void tspd_system_off(void) ...@@ -224,8 +219,7 @@ static void tspd_system_off(void)
******************************************************************************/ ******************************************************************************/
static void tspd_system_reset(void) static void tspd_system_reset(void)
{ {
uint64_t mpidr = read_mpidr(); uint32_t linear_id = plat_my_core_pos();
uint32_t linear_id = platform_get_core_pos(mpidr);
tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id]; tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_vectors); assert(tsp_vectors);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment