diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/common/debug.h | 27 | ||||
| -rw-r--r-- | include/lib/aarch32/arch.h | 51 | ||||
| -rw-r--r-- | include/lib/aarch64/arch.h | 49 | ||||
| -rw-r--r-- | include/lib/xlat_tables/xlat_tables_defs.h | 8 | ||||
| -rw-r--r-- | include/lib/xlat_tables/xlat_tables_v2.h | 7 | ||||
| -rw-r--r-- | include/plat/common/platform.h | 1 |
6 files changed, 133 insertions, 10 deletions
diff --git a/include/common/debug.h b/include/common/debug.h index 814cf840..3f0f84a1 100644 --- a/include/common/debug.h +++ b/include/common/debug.h @@ -24,47 +24,62 @@ #define LOG_LEVEL_VERBOSE 50 #ifndef __ASSEMBLY__ +#include <stdarg.h> #include <stdio.h> +/* + * Define Log Markers corresponding to each log level which will + * be embedded in the format string and is expected by tf_log() to determine + * the log level. + */ +#define LOG_MARKER_ERROR "\xa" /* 10 */ +#define LOG_MARKER_NOTICE "\x14" /* 20 */ +#define LOG_MARKER_WARNING "\x1e" /* 30 */ +#define LOG_MARKER_INFO "\x28" /* 40 */ +#define LOG_MARKER_VERBOSE "\x32" /* 50 */ + #if LOG_LEVEL >= LOG_LEVEL_NOTICE -# define NOTICE(...) tf_printf("NOTICE: " __VA_ARGS__) +# define NOTICE(...) tf_log(LOG_MARKER_NOTICE __VA_ARGS__) #else # define NOTICE(...) #endif #if LOG_LEVEL >= LOG_LEVEL_ERROR -# define ERROR(...) tf_printf("ERROR: " __VA_ARGS__) +# define ERROR(...) tf_log(LOG_MARKER_ERROR __VA_ARGS__) #else # define ERROR(...) #endif #if LOG_LEVEL >= LOG_LEVEL_WARNING -# define WARN(...) tf_printf("WARNING: " __VA_ARGS__) +# define WARN(...) tf_log(LOG_MARKER_WARNING __VA_ARGS__) #else # define WARN(...) #endif #if LOG_LEVEL >= LOG_LEVEL_INFO -# define INFO(...) tf_printf("INFO: " __VA_ARGS__) +# define INFO(...) tf_log(LOG_MARKER_INFO __VA_ARGS__) #else # define INFO(...) #endif #if LOG_LEVEL >= LOG_LEVEL_VERBOSE -# define VERBOSE(...) tf_printf("VERBOSE: " __VA_ARGS__) +# define VERBOSE(...) tf_log(LOG_MARKER_VERBOSE __VA_ARGS__) #else # define VERBOSE(...) #endif - void __dead2 do_panic(void); #define panic() do_panic() /* Function called when stack protection check code detects a corrupted stack */ void __dead2 __stack_chk_fail(void); +void tf_log(const char *fmt, ...) __printflike(1, 2); void tf_printf(const char *fmt, ...) __printflike(1, 2); int tf_snprintf(char *s, size_t n, const char *fmt, ...) __printflike(3, 4); +void tf_vprintf(const char *fmt, va_list args); +void tf_string_print(const char *str); +void tf_log_set_max_level(unsigned int log_level); #endif /* __ASSEMBLY__ */ #endif /* __DEBUG_H__ */ diff --git a/include/lib/aarch32/arch.h b/include/lib/aarch32/arch.h index 56163c8b..5fbb83a6 100644 --- a/include/lib/aarch32/arch.h +++ b/include/lib/aarch32/arch.h @@ -7,6 +7,8 @@ #ifndef __ARCH_H__ #define __ARCH_H__ +#include <utils_def.h> + /******************************************************************************* * MIDR bit definitions ******************************************************************************/ @@ -459,4 +461,53 @@ #define ICC_ASGI1R_EL1_64 p15, 1, c12 #define ICC_SGI0R_EL1_64 p15, 2, c12 +/******************************************************************************* + * Definitions of MAIR encodings for device and normal memory + ******************************************************************************/ +/* + * MAIR encodings for device memory attributes. + */ +#define MAIR_DEV_nGnRnE U(0x0) +#define MAIR_DEV_nGnRE U(0x4) +#define MAIR_DEV_nGRE U(0x8) +#define MAIR_DEV_GRE U(0xc) + +/* + * MAIR encodings for normal memory attributes. + * + * Cache Policy + * WT: Write Through + * WB: Write Back + * NC: Non-Cacheable + * + * Transient Hint + * NTR: Non-Transient + * TR: Transient + * + * Allocation Policy + * RA: Read Allocate + * WA: Write Allocate + * RWA: Read and Write Allocate + * NA: No Allocation + */ +#define MAIR_NORM_WT_TR_WA U(0x1) +#define MAIR_NORM_WT_TR_RA U(0x2) +#define MAIR_NORM_WT_TR_RWA U(0x3) +#define MAIR_NORM_NC U(0x4) +#define MAIR_NORM_WB_TR_WA U(0x5) +#define MAIR_NORM_WB_TR_RA U(0x6) +#define MAIR_NORM_WB_TR_RWA U(0x7) +#define MAIR_NORM_WT_NTR_NA U(0x8) +#define MAIR_NORM_WT_NTR_WA U(0x9) +#define MAIR_NORM_WT_NTR_RA U(0xa) +#define MAIR_NORM_WT_NTR_RWA U(0xb) +#define MAIR_NORM_WB_NTR_NA U(0xc) +#define MAIR_NORM_WB_NTR_WA U(0xd) +#define MAIR_NORM_WB_NTR_RA U(0xe) +#define MAIR_NORM_WB_NTR_RWA U(0xf) + +#define MAIR_NORM_OUTER_SHIFT 4 + +#define MAKE_MAIR_NORMAL_MEMORY(inner, outer) ((inner) | ((outer) << MAIR_NORM_OUTER_SHIFT)) + #endif /* __ARCH_H__ */ diff --git a/include/lib/aarch64/arch.h b/include/lib/aarch64/arch.h index 2adf7699..e38a5307 100644 --- a/include/lib/aarch64/arch.h +++ b/include/lib/aarch64/arch.h @@ -504,4 +504,53 @@ #define PMCR_EL0_N_MASK U(0x1f) #define PMCR_EL0_N_BITS (PMCR_EL0_N_MASK << PMCR_EL0_N_SHIFT) +/******************************************************************************* + * Definitions of MAIR encodings for device and normal memory + ******************************************************************************/ +/* + * MAIR encodings for device memory attributes. + */ +#define MAIR_DEV_nGnRnE ULL(0x0) +#define MAIR_DEV_nGnRE ULL(0x4) +#define MAIR_DEV_nGRE ULL(0x8) +#define MAIR_DEV_GRE ULL(0xc) + +/* + * MAIR encodings for normal memory attributes. + * + * Cache Policy + * WT: Write Through + * WB: Write Back + * NC: Non-Cacheable + * + * Transient Hint + * NTR: Non-Transient + * TR: Transient + * + * Allocation Policy + * RA: Read Allocate + * WA: Write Allocate + * RWA: Read and Write Allocate + * NA: No Allocation + */ +#define MAIR_NORM_WT_TR_WA ULL(0x1) +#define MAIR_NORM_WT_TR_RA ULL(0x2) +#define MAIR_NORM_WT_TR_RWA ULL(0x3) +#define MAIR_NORM_NC ULL(0x4) +#define MAIR_NORM_WB_TR_WA ULL(0x5) +#define MAIR_NORM_WB_TR_RA ULL(0x6) +#define MAIR_NORM_WB_TR_RWA ULL(0x7) +#define MAIR_NORM_WT_NTR_NA ULL(0x8) +#define MAIR_NORM_WT_NTR_WA ULL(0x9) +#define MAIR_NORM_WT_NTR_RA ULL(0xa) +#define MAIR_NORM_WT_NTR_RWA ULL(0xb) +#define MAIR_NORM_WB_NTR_NA ULL(0xc) +#define MAIR_NORM_WB_NTR_WA ULL(0xd) +#define MAIR_NORM_WB_NTR_RA ULL(0xe) +#define MAIR_NORM_WB_NTR_RWA ULL(0xf) + +#define MAIR_NORM_OUTER_SHIFT 4 + +#define MAKE_MAIR_NORMAL_MEMORY(inner, outer) ((inner) | ((outer) << MAIR_NORM_OUTER_SHIFT)) + #endif /* __ARCH_H__ */ diff --git a/include/lib/xlat_tables/xlat_tables_defs.h b/include/lib/xlat_tables/xlat_tables_defs.h index 008ae9bc..b0f5a04c 100644 --- a/include/lib/xlat_tables/xlat_tables_defs.h +++ b/include/lib/xlat_tables/xlat_tables_defs.h @@ -7,6 +7,7 @@ #ifndef __XLAT_TABLES_DEFS_H__ #define __XLAT_TABLES_DEFS_H__ +#include <arch.h> #include <utils_def.h> /* Miscellaneous MMU related constants */ @@ -96,12 +97,13 @@ #define ATTR_DEVICE_INDEX U(0x1) #define ATTR_IWBWA_OWBWA_NTR_INDEX U(0x0) #define LOWER_ATTRS(x) (((x) & U(0xfff)) << 2) + /* Normal Memory, Outer Write-Through non-transient, Inner Non-cacheable */ -#define ATTR_NON_CACHEABLE U(0x44) +#define ATTR_NON_CACHEABLE MAKE_MAIR_NORMAL_MEMORY(MAIR_NORM_NC, MAIR_NORM_NC) /* Device-nGnRE */ -#define ATTR_DEVICE U(0x4) +#define ATTR_DEVICE MAIR_DEV_nGnRE /* Normal Memory, Outer Write-Back non-transient, Inner Write-Back non-transient */ -#define ATTR_IWBWA_OWBWA_NTR U(0xff) +#define ATTR_IWBWA_OWBWA_NTR MAKE_MAIR_NORMAL_MEMORY(MAIR_NORM_WB_NTR_RWA, MAIR_NORM_WB_NTR_RWA) #define MAIR_ATTR_SET(attr, index) ((attr) << ((index) << 3)) #define ATTR_INDEX_MASK U(0x3) #define ATTR_INDEX_GET(attr) (((attr) >> 2) & ATTR_INDEX_MASK) diff --git a/include/lib/xlat_tables/xlat_tables_v2.h b/include/lib/xlat_tables/xlat_tables_v2.h index 288a8e0b..2be43296 100644 --- a/include/lib/xlat_tables/xlat_tables_v2.h +++ b/include/lib/xlat_tables/xlat_tables_v2.h @@ -23,7 +23,12 @@ /* Helper macro to define entries for mmap_region_t. It allows to * re-map address mappings from 'pa' to 'va' for each region. */ -#define MAP_REGION(pa, va, sz, attr) {(pa), (va), (sz), (attr)} +#define MAP_REGION(_pa, _va, _sz, _attr) ((mmap_region_t){ \ + .base_pa = (_pa), \ + .base_va = (_va), \ + .size = (_sz), \ + .attr = (_attr), \ + }) /* * Shifts and masks to access fields of an mmap_attr_t diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h index bd721bba..e189f648 100644 --- a/include/plat/common/platform.h +++ b/include/plat/common/platform.h @@ -79,6 +79,7 @@ int plat_crash_console_putc(int c); int plat_crash_console_flush(void); void plat_error_handler(int err) __dead2; void plat_panic_handler(void) __dead2; +const char *plat_log_get_prefix(unsigned int log_level); /******************************************************************************* * Mandatory BL1 functions |
