diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bl31/bl31.h | 2 | ||||
-rw-r--r-- | include/bl31/context.h | 17 | ||||
-rw-r--r-- | include/bl31/context_mgmt.h | 46 | ||||
-rw-r--r-- | include/bl31/cpu_data.h | 92 | ||||
-rw-r--r-- | include/bl31/runtime_svc.h | 6 | ||||
-rw-r--r-- | include/bl31/services/psci.h | 3 | ||||
-rw-r--r-- | include/common/bl_common.h | 14 | ||||
-rw-r--r-- | include/lib/aarch64/arch.h | 1 | ||||
-rw-r--r-- | include/lib/aarch64/arch_helpers.h | 7 | ||||
-rw-r--r-- | include/lib/bakery_lock.h | 6 | ||||
-rw-r--r-- | include/lib/mmio.h | 33 | ||||
-rw-r--r-- | include/plat/common/platform.h | 4 |
12 files changed, 187 insertions, 44 deletions
diff --git a/include/bl31/bl31.h b/include/bl31/bl31.h index 33e4ecee..96867b07 100644 --- a/include/bl31/bl31.h +++ b/include/bl31/bl31.h @@ -40,7 +40,7 @@ void bl31_arch_setup(void); void bl31_next_el_arch_setup(uint32_t security_state); void bl31_set_next_image_type(uint32_t type); uint32_t bl31_get_next_image_type(void); -void bl31_prepare_next_image_entry(); +void bl31_prepare_next_image_entry(void); void bl31_register_bl32_init(int32_t (*)(void)); #endif /* __BL31_H__ */ diff --git a/include/bl31/context.h b/include/bl31/context.h index 16cc744d..c0230b86 100644 --- a/include/bl31/context.h +++ b/include/bl31/context.h @@ -185,14 +185,10 @@ #define CTX_FP_FPCR 0x208 #define CTX_FPREGS_END 0x210 -/****************************************************************************** - * Offsets for the per cpu cache implementation - ******************************************************************************/ -#define PTR_CACHE_CRASH_STACK_OFFSET 0x0 - #ifndef __ASSEMBLY__ #include <cassert.h> +#include <platform_def.h> /* for CACHE_WRITEBACK_GRANULE */ #include <stdint.h> /* @@ -331,17 +327,6 @@ void fpregs_context_save(fp_regs_t *regs); void fpregs_context_restore(fp_regs_t *regs); -/* Per-CPU pointer cache of recently used pointers and also the crash stack - * TODO: Add other commonly used variables to this (tf_issues#90) - */ -typedef struct per_cpu_ptr_cache { - uint64_t crash_stack; -} per_cpu_ptr_cache_t; - -CASSERT(PTR_CACHE_CRASH_STACK_OFFSET == __builtin_offsetof\ - (per_cpu_ptr_cache_t, crash_stack), \ - assert_per_cpu_ptr_cache_crash_stack_offset_mismatch); - #undef CTX_SYSREG_ALL #undef CTX_FP_ALL #undef CTX_GPREG_ALL diff --git a/include/bl31/context_mgmt.h b/include/bl31/context_mgmt.h index 86bbc58b..6127b74b 100644 --- a/include/bl31/context_mgmt.h +++ b/include/bl31/context_mgmt.h @@ -31,31 +31,63 @@ #ifndef __CM_H__ #define __CM_H__ +#include <cpu_data.h> #include <stdint.h> /******************************************************************************* + * Forward declarations + ******************************************************************************/ +struct entry_point_info; + +/******************************************************************************* * Function & variable prototypes ******************************************************************************/ 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_init_context(uint64_t mpidr, const struct entry_point_info *ep); +void cm_prepare_el3_exit(uint32_t security_state); void cm_el3_sysregs_context_restore(uint32_t security_state); void cm_el1_sysregs_context_save(uint32_t security_state); void cm_el1_sysregs_context_restore(uint32_t security_state); -void cm_set_el3_eret_context(uint32_t security_state, uint64_t entrypoint, - uint32_t spsr, uint32_t scr); void cm_set_elr_el3(uint32_t security_state, uint64_t entrypoint); +void cm_set_elr_spsr_el3(uint32_t security_state, + uint64_t entrypoint, uint32_t spsr); void cm_write_scr_el3_bit(uint32_t security_state, uint32_t bit_pos, uint32_t value); void cm_set_next_eret_context(uint32_t security_state); -void cm_init_pcpu_ptr_cache(); -void cm_set_pcpu_ptr_cache(const void *pcpu_ptr); -void *cm_get_pcpu_ptr_cache(void); 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 new file mode 100644 index 00000000..5f45f144 --- /dev/null +++ b/include/bl31/cpu_data.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of ARM nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __CPU_DATA_H__ +#define __CPU_DATA_H__ + +/* Offsets for the cpu_data structure */ +#define CPU_DATA_CRASH_STACK_OFFSET 0x10 +#define CPU_DATA_LOG2SIZE 6 + +#ifndef __ASSEMBLY__ + +#include <arch_helpers.h> +#include <platform_def.h> +#include <stdint.h> + +/******************************************************************************* + * Function & variable prototypes + ******************************************************************************/ + +/******************************************************************************* + * 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 + * + * TODO: Add other commonly used variables to this (tf_issues#90) + * + * The data structure and the _cpu_data accessors should not be used directly + * by components that have per-cpu members. The member access macros should be + * used for this. + ******************************************************************************/ + +typedef struct cpu_data { + void *cpu_context[2]; + uint64_t crash_stack; +} __aligned(CACHE_WRITEBACK_GRANULE) cpu_data_t; + +struct cpu_data *_cpu_data_by_index(uint32_t cpu_index); +struct cpu_data *_cpu_data_by_mpidr(uint64_t mpidr); + +/* Return the cpu_data structure for the current CPU. */ +static inline struct cpu_data *_cpu_data(void) +{ + return (cpu_data_t *)read_tpidr_el3(); +} + + +/************************************************************************** + * APIs for initialising and accessing per-cpu data + *************************************************************************/ + +void init_cpu_data_ptr(void); + +#define get_cpu_data(_m) _cpu_data()->_m +#define set_cpu_data(_m, _v) _cpu_data()->_m = _v +#define get_cpu_data_by_index(_ix, _m) _cpu_data_by_index(_ix)->_m +#define set_cpu_data_by_index(_ix, _m, _v) _cpu_data_by_index(_ix)->_m = _v +#define get_cpu_data_by_mpidr(_id, _m) _cpu_data_by_mpidr(_id)->_m +#define set_cpu_data_by_mpidr(_id, _m, _v) _cpu_data_by_mpidr(_id)->_m = _v + + +#endif /* __ASSEMBLY__ */ +#endif /* __CPU_DATA_H__ */ diff --git a/include/bl31/runtime_svc.h b/include/bl31/runtime_svc.h index d7d88d4c..2d849863 100644 --- a/include/bl31/runtime_svc.h +++ b/include/bl31/runtime_svc.h @@ -264,10 +264,10 @@ CASSERT(RT_SVC_DESC_HANDLE == __builtin_offsetof(rt_svc_desc_t, handle), \ /******************************************************************************* * Function & variable prototypes ******************************************************************************/ -void runtime_svc_init(); +void runtime_svc_init(void); extern uint64_t __RT_SVC_DESCS_START__; extern uint64_t __RT_SVC_DESCS_END__; -uint64_t get_crash_stack(uint64_t mpidr); -void runtime_exceptions(void); +void init_crash_reporting(void); + #endif /*__ASSEMBLY__*/ #endif /* __RUNTIME_SVC_H__ */ diff --git a/include/bl31/services/psci.h b/include/bl31/services/psci.h index 887c4cea..77f406d2 100644 --- a/include/bl31/services/psci.h +++ b/include/bl31/services/psci.h @@ -128,9 +128,6 @@ #define psci_validate_power_state(pstate) (pstate & PSTATE_VALID_MASK) -/* Number of affinity instances whose state this psci imp. can track */ -#define PSCI_NUM_AFFS 32ull - #ifndef __ASSEMBLY__ #include <stdint.h> diff --git a/include/common/bl_common.h b/include/common/bl_common.h index 2f3bade1..f5e2a9a2 100644 --- a/include/common/bl_common.h +++ b/include/common/bl_common.h @@ -33,7 +33,6 @@ #define SECURE 0x0 #define NON_SECURE 0x1 -#define PARAM_EP_SECURITY_MASK 0x1 #define UP 1 #define DOWN 0 @@ -64,10 +63,23 @@ #define ENTRY_POINT_INFO_PC_OFFSET 0x08 #define ENTRY_POINT_INFO_ARGS_OFFSET 0x18 +#define PARAM_EP_SECURITY_MASK 0x1 #define GET_SECURITY_STATE(x) (x & PARAM_EP_SECURITY_MASK) #define SET_SECURITY_STATE(x, security) \ ((x) = ((x) & ~PARAM_EP_SECURITY_MASK) | (security)) +#define EP_EE_MASK 0x2 +#define EP_EE_LITTLE 0x0 +#define EP_EE_BIG 0x2 +#define EP_GET_EE(x) (x & EP_EE_MASK) +#define EP_SET_EE(x, ee) ((x) = ((x) & ~EP_EE_MASK) | (ee)) + +#define EP_ST_MASK 0x4 +#define EP_ST_DISABLE 0x0 +#define EP_ST_ENABLE 0x4 +#define EP_GET_ST(x) (x & EP_ST_MASK) +#define EP_SET_ST(x, ee) ((x) = ((x) & ~EP_ST_MASK) | (ee)) + #define PARAM_EP 0x01 #define PARAM_IMAGE_BINARY 0x02 #define PARAM_BL31 0x03 diff --git a/include/lib/aarch64/arch.h b/include/lib/aarch64/arch.h index 0bfbd66c..5dc488bb 100644 --- a/include/lib/aarch64/arch.h +++ b/include/lib/aarch64/arch.h @@ -167,6 +167,7 @@ #define HCR_FMO_BIT (1 << 3) /* CNTHCTL_EL2 definitions */ +#define EVNTEN_BIT (1 << 2) #define EL1PCEN_BIT (1 << 1) #define EL1PCTEN_BIT (1 << 0) diff --git a/include/lib/aarch64/arch_helpers.h b/include/lib/aarch64/arch_helpers.h index 1ca33502..6ba37c23 100644 --- a/include/lib/aarch64/arch_helpers.h +++ b/include/lib/aarch64/arch_helpers.h @@ -85,14 +85,14 @@ static inline void write_ ## _name(const uint64_t v) \ /* Define function for simple system instruction */ #define DEFINE_SYSOP_FUNC(_op) \ -static inline void _op() \ +static inline void _op(void) \ { \ __asm__ (#_op); \ } /* Define function for system instruction with type specifier */ #define DEFINE_SYSOP_TYPE_FUNC(_op, _type) \ -static inline void _op ## _type() \ +static inline void _op ## _type(void) \ { \ __asm__ (#_op " " #_type); \ } @@ -262,6 +262,9 @@ DEFINE_SYSREG_RW_FUNCS(cnthctl_el2) DEFINE_SYSREG_RW_FUNCS(tpidr_el3) +DEFINE_SYSREG_RW_FUNCS(vpidr_el2) +DEFINE_SYSREG_RW_FUNCS(vmpidr_el2) + /* Implementation specific registers */ DEFINE_RENAME_SYSREG_RW_FUNCS(cpuectlr_el1, CPUECTLR_EL1) diff --git a/include/lib/bakery_lock.h b/include/lib/bakery_lock.h index 037fa7d1..95634cf5 100644 --- a/include/lib/bakery_lock.h +++ b/include/lib/bakery_lock.h @@ -44,8 +44,8 @@ typedef struct bakery_lock { #define NO_OWNER (-1) void bakery_lock_init(bakery_lock_t *bakery); -void bakery_lock_get(unsigned long mpidr, bakery_lock_t *bakery); -void bakery_lock_release(unsigned long mpidr, bakery_lock_t *bakery); -int bakery_lock_try(unsigned long mpidr, bakery_lock_t *bakery); +void bakery_lock_get(bakery_lock_t *bakery); +void bakery_lock_release(bakery_lock_t *bakery); +int bakery_lock_try(bakery_lock_t *bakery); #endif /* __BAKERY_LOCK_H__ */ diff --git a/include/lib/mmio.h b/include/lib/mmio.h index 5d33c597..cb37a1c8 100644 --- a/include/lib/mmio.h +++ b/include/lib/mmio.h @@ -33,13 +33,34 @@ #include <stdint.h> -void mmio_write_8(uintptr_t addr, uint8_t value); -uint8_t mmio_read_8(uintptr_t addr); +static inline void mmio_write_8(uintptr_t addr, uint8_t value) +{ + *(volatile uint8_t*)addr = value; +} -void mmio_write_32(uintptr_t addr, uint32_t value); -uint32_t mmio_read_32(uintptr_t addr); +static inline uint8_t mmio_read_8(uintptr_t addr) +{ + return *(volatile uint8_t*)addr; +} -void mmio_write_64(uintptr_t addr, uint64_t value); -uint64_t mmio_read_64(uintptr_t addr); +static inline void mmio_write_32(uintptr_t addr, uint32_t value) +{ + *(volatile uint32_t*)addr = value; +} + +static inline uint32_t mmio_read_32(uintptr_t addr) +{ + return *(volatile uint32_t*)addr; +} + +static inline void mmio_write_64(uintptr_t addr, uint64_t value) +{ + *(volatile uint64_t*)addr = value; +} + +static inline uint64_t mmio_read_64(uintptr_t addr) +{ + return *(volatile uint64_t*)addr; +} #endif /* __MMIO_H__ */ diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h index 714f6e07..c087dc69 100644 --- a/include/plat/common/platform.h +++ b/include/plat/common/platform.h @@ -165,7 +165,7 @@ unsigned int plat_get_aff_state(unsigned int, unsigned long); /******************************************************************************* * Optional BL3-1 functions (may be overridden) ******************************************************************************/ -void bl31_plat_enable_mmu(); +void bl31_plat_enable_mmu(void); /******************************************************************************* * Mandatory BL3-2 functions (only if platform contains a BL3-2) @@ -175,6 +175,6 @@ void bl32_platform_setup(void); /******************************************************************************* * Optional BL3-2 functions (may be overridden) ******************************************************************************/ -void bl32_plat_enable_mmu(); +void bl32_plat_enable_mmu(void); #endif /* __PLATFORM_H__ */ |