2014-02-01 07:51:28 +00:00
|
|
|
/*
|
2020-02-03 20:56:42 +00:00
|
|
|
* Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
|
2014-02-01 07:51:28 +00:00
|
|
|
*
|
2017-05-03 09:38:09 +01:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2014-02-01 07:51:28 +00:00
|
|
|
*/
|
|
|
|
|
2015-10-02 17:56:48 +01:00
|
|
|
#include <assert.h>
|
2014-02-01 07:51:28 +00:00
|
|
|
|
2018-12-14 00:18:21 +00:00
|
|
|
#include <bl31/bl31.h>
|
|
|
|
#include <common/bl_common.h>
|
|
|
|
#include <context.h>
|
|
|
|
#include <lib/el3_runtime/context_mgmt.h>
|
|
|
|
#include <lib/el3_runtime/cpu_data.h>
|
2014-06-02 10:00:25 +01:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* This function returns a pointer to the most recent 'cpu_context' structure
|
|
|
|
* for the calling CPU that was set as the context for the specified security
|
|
|
|
* state. NULL is returned if no such structure has been specified.
|
|
|
|
******************************************************************************/
|
|
|
|
void *cm_get_context(uint32_t security_state)
|
|
|
|
{
|
|
|
|
assert(security_state <= NON_SECURE);
|
|
|
|
|
|
|
|
return get_cpu_data(cpu_context[security_state]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* This function sets the pointer to the current 'cpu_context' structure for the
|
|
|
|
* specified security state for the calling CPU
|
|
|
|
******************************************************************************/
|
|
|
|
void cm_set_context(void *context, uint32_t security_state)
|
|
|
|
{
|
|
|
|
assert(security_state <= NON_SECURE);
|
|
|
|
|
|
|
|
set_cpu_data(cpu_context[security_state], context);
|
|
|
|
}
|
|
|
|
|
2015-10-02 17:56:48 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* This function returns a pointer to the most recent 'cpu_context' structure
|
|
|
|
* for the CPU identified by `cpu_idx` that was set as the context for the
|
|
|
|
* specified security state. NULL is returned if no such structure has been
|
|
|
|
* specified.
|
|
|
|
******************************************************************************/
|
|
|
|
void *cm_get_context_by_index(unsigned int cpu_idx,
|
|
|
|
unsigned int security_state)
|
|
|
|
{
|
|
|
|
assert(sec_state_is_valid(security_state));
|
|
|
|
|
|
|
|
return get_cpu_data_by_index(cpu_idx, cpu_context[security_state]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* This function sets the pointer to the current 'cpu_context' structure for the
|
|
|
|
* specified security state for the CPU identified by CPU index.
|
|
|
|
******************************************************************************/
|
|
|
|
void cm_set_context_by_index(unsigned int cpu_idx, void *context,
|
|
|
|
unsigned int security_state)
|
|
|
|
{
|
|
|
|
assert(sec_state_is_valid(security_state));
|
|
|
|
|
|
|
|
set_cpu_data_by_index(cpu_idx, cpu_context[security_state], context);
|
|
|
|
}
|