Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
5298f2cb
Commit
5298f2cb
authored
Jun 23, 2014
by
danh-arm
Browse files
Merge pull request #138 from athoelke/at/cpu-context
Move CPU context pointers into cpu_data
parents
92152eec
aaba4f28
Changes
4
Hide whitespace changes
Inline
Side-by-side
bl31/context_mgmt.c
View file @
5298f2cb
...
...
@@ -35,21 +35,12 @@
#include <bl31.h>
#include <context.h>
#include <context_mgmt.h>
#include <cpu_data.h>
#include <interrupt_mgmt.h>
#include <platform.h>
#include <platform_def.h>
#include <runtime_svc.h>
/*******************************************************************************
* Data structure which holds the pointers to non-secure and secure security
* state contexts for each cpu. It is aligned to the cache line boundary to
* allow efficient concurrent manipulation of these pointers on different cpus
******************************************************************************/
typedef
struct
{
void
*
ptr
[
2
];
}
__aligned
(
CACHE_WRITEBACK_GRANULE
)
context_info_t
;
static
context_info_t
cm_context_info
[
PLATFORM_CORE_COUNT
];
/*******************************************************************************
* Context management library initialisation routine. This library is used by
...
...
@@ -79,25 +70,9 @@ void cm_init()
******************************************************************************/
void
*
cm_get_context_by_mpidr
(
uint64_t
mpidr
,
uint32_t
security_state
)
{
uint32_t
linear_id
=
platform_get_core_pos
(
mpidr
);
assert
(
security_state
<=
NON_SECURE
);
return
cm_context_info
[
linear_id
].
ptr
[
security_state
];
}
/*******************************************************************************
* 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
)
{
uint32_t
linear_id
=
platform_get_core_pos
(
read_mpidr
());
assert
(
security_state
<=
NON_SECURE
);
return
cm_context_info
[
linear_id
].
ptr
[
security_state
];
return
get_cpu_data_by_mpidr
(
mpidr
,
cpu_context
[
security_state
]
)
;
}
/*******************************************************************************
...
...
@@ -106,20 +81,9 @@ void *cm_get_context(uint32_t security_state)
******************************************************************************/
void
cm_set_context_by_mpidr
(
uint64_t
mpidr
,
void
*
context
,
uint32_t
security_state
)
{
uint32_t
linear_id
=
platform_get_core_pos
(
mpidr
);
assert
(
security_state
<=
NON_SECURE
);
cm_context_info
[
linear_id
].
ptr
[
security_state
]
=
context
;
}
/*******************************************************************************
* 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
)
{
cm_set_context_by_mpidr
(
read_mpidr
(),
context
,
security_state
);
set_cpu_data_by_mpidr
(
mpidr
,
cpu_context
[
security_state
],
context
);
}
/*******************************************************************************
...
...
include/bl31/context.h
View file @
5298f2cb
...
...
@@ -188,6 +188,7 @@
#ifndef __ASSEMBLY__
#include <cassert.h>
#include <platform_def.h>
/* for CACHE_WRITEBACK_GRANULE */
#include <stdint.h>
/*
...
...
include/bl31/context_mgmt.h
View file @
5298f2cb
...
...
@@ -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__ */
include/bl31/cpu_data.h
View file @
5298f2cb
...
...
@@ -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 0x
1
0
#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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment