2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
15 #include <lib/utils_def.h>
17 /* Valid priorities set bit 0 of the priority handler. */
18 #define EHF_PRI_VALID_ BIT(0)
20 /* Marker for no handler registered for a valid priority */
21 #define EHF_NO_HANDLER_ (0U | EHF_PRI_VALID_)
23 /* Extract the specified number of top bits from 7 lower bits of priority */
24 #define EHF_PRI_TO_IDX(pri, plat_bits) \
25 ((((unsigned) (pri)) & 0x7fu) >> (7u - (plat_bits)))
27 /* Install exception priority descriptor at a suitable index */
28 #define EHF_PRI_DESC(plat_bits, priority) \
29 [EHF_PRI_TO_IDX(priority, plat_bits)] = { \
30 .ehf_handler = EHF_NO_HANDLER_, \
33 /* Macro for platforms to regiter its exception priorities */
34 #define EHF_REGISTER_PRIORITIES(priorities, num, bits) \
35 const ehf_priorities_t exception_data = { \
36 .num_priorities = (num), \
37 .ehf_priorities = (priorities), \
42 * Priority stack, managed as a bitmap.
44 * Currently only supports 32 priority levels, allowing platforms to use up to 5
45 * top bits of priority. But the type can be changed to uint64_t should need
46 * arise to support 64 priority levels, allowing platforms to use up to 6 top
49 typedef uint32_t ehf_pri_bits_t
;
52 * Per-PE exception data. The data for each PE is kept as a per-CPU data field.
56 ehf_pri_bits_t active_pri_bits
;
58 /* Priority mask value before any priority levels were active */
59 uint8_t init_pri_mask
;
61 /* Non-secure priority mask value stashed during Secure execution */
63 } __aligned(sizeof(uint64_t)) pe_exc_data_t
;
65 typedef int (*ehf_handler_t
)(uint32_t intr_raw
, uint32_t flags
, void *handle
,
68 typedef struct ehf_pri_desc
{
70 * 4-byte-aligned exception handler. Bit 0 indicates the corresponding
71 * priority level is valid. This is effectively of ehf_handler_t type,
72 * but left as uintptr_t in order to make pointer arithmetic convenient.
74 uintptr_t ehf_handler
;
77 typedef struct ehf_priority_type
{
78 ehf_pri_desc_t
*ehf_priorities
;
79 unsigned int num_priorities
;
80 unsigned int pri_bits
;
84 void ehf_activate_priority(unsigned int priority
);
85 void ehf_deactivate_priority(unsigned int priority
);
86 void ehf_register_priority_handler(unsigned int pri
, ehf_handler_t handler
);
87 void ehf_allow_ns_preemption(uint64_t preempt_ret_code
);
88 unsigned int ehf_is_ns_preemption_allowed(void);
90 #endif /* __ASSEMBLY__ */