summaryrefslogtreecommitdiff
path: root/include/bl31
diff options
context:
space:
mode:
authordanh-arm <dan.handley@arm.com>2014-06-23 13:10:00 +0100
committerdanh-arm <dan.handley@arm.com>2014-06-23 13:10:00 +0100
commit5298f2cb98b9bdc18eb2f25cd28180ba7fd000d8 (patch)
treeecf35dfadb10030a85143cef9b414ce9830deebf /include/bl31
parent92152eecbb636cef93f491411ccca9edba63aaca (diff)
parentaaba4f28278d20912ddcf32a49ba1c42adec3d2e (diff)
Merge pull request #138 from athoelke/at/cpu-context
Move CPU context pointers into cpu_data
Diffstat (limited to 'include/bl31')
-rw-r--r--include/bl31/context.h1
-rw-r--r--include/bl31/context_mgmt.h31
-rw-r--r--include/bl31/cpu_data.h4
3 files changed, 33 insertions, 3 deletions
diff --git a/include/bl31/context.h b/include/bl31/context.h
index b889f681..c0230b86 100644
--- a/include/bl31/context.h
+++ b/include/bl31/context.h
@@ -188,6 +188,7 @@
#ifndef __ASSEMBLY__
#include <cassert.h>
+#include <platform_def.h> /* for CACHE_WRITEBACK_GRANULE */
#include <stdint.h>
/*
diff --git a/include/bl31/context_mgmt.h b/include/bl31/context_mgmt.h
index ca9d9fac..ade2fa1d 100644
--- a/include/bl31/context_mgmt.h
+++ b/include/bl31/context_mgmt.h
@@ -31,6 +31,7 @@
#ifndef __CM_H__
#define __CM_H__
+#include <cpu_data.h>
#include <stdint.h>
/*******************************************************************************
@@ -38,11 +39,11 @@
******************************************************************************/
void cm_init(void);
void *cm_get_context_by_mpidr(uint64_t mpidr, uint32_t security_state);
-void *cm_get_context(uint32_t security_state);
+static inline void *cm_get_context(uint32_t security_state);
void cm_set_context_by_mpidr(uint64_t mpidr,
void *context,
uint32_t security_state);
-void cm_set_context(void *context, uint32_t security_state);
+static inline void cm_set_context(void *context, uint32_t security_state);
void cm_el3_sysregs_context_save(uint32_t security_state);
void cm_el3_sysregs_context_restore(uint32_t security_state);
void cm_el1_sysregs_context_save(uint32_t security_state);
@@ -56,4 +57,30 @@ void cm_write_scr_el3_bit(uint32_t security_state,
void cm_set_next_eret_context(uint32_t security_state);
uint32_t cm_get_scr_el3(uint32_t security_state);
+/* Inline definitions */
+
+/*******************************************************************************
+ * 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);
+}
+
+
#endif /* __CM_H__ */
diff --git a/include/bl31/cpu_data.h b/include/bl31/cpu_data.h
index 2d256e49..5f45f144 100644
--- a/include/bl31/cpu_data.h
+++ b/include/bl31/cpu_data.h
@@ -32,7 +32,7 @@
#define __CPU_DATA_H__
/* Offsets for the cpu_data structure */
-#define CPU_DATA_CRASH_STACK_OFFSET 0x0
+#define CPU_DATA_CRASH_STACK_OFFSET 0x10
#define CPU_DATA_LOG2SIZE 6
#ifndef __ASSEMBLY__
@@ -47,6 +47,7 @@
/*******************************************************************************
* Cache of frequently used per-cpu data:
+ * Pointers to non-secure and secure security state contexts
* Address of the crash stack
* It is aligned to the cache line boundary to allow efficient concurrent
* manipulation of these pointers on different cpus
@@ -59,6 +60,7 @@
******************************************************************************/
typedef struct cpu_data {
+ void *cpu_context[2];
uint64_t crash_stack;
} __aligned(CACHE_WRITEBACK_GRANULE) cpu_data_t;