diff options
author | Dimitris Papastamos <dimitris.papastamos@arm.com> | 2018-06-14 14:33:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-14 14:33:13 +0100 |
commit | 59c4346383407dad6b7573fccb7af85a97a5df3e (patch) | |
tree | 2bdfb5a1804540fc592d9465ead8e36655511ce6 /lib/xlat_tables_v2 | |
parent | f3a5e3d6ec20da13619d57a523d5e87a3ed3d3e2 (diff) | |
parent | d801a1d035e8868fc2b131653c5fd96ceed10a21 (diff) |
Merge pull request #1415 from antonio-nino-diaz-arm/an/spm-fixes
Minor fixes to SPM
Diffstat (limited to 'lib/xlat_tables_v2')
-rw-r--r-- | lib/xlat_tables_v2/aarch32/xlat_tables_arch.c | 17 | ||||
-rw-r--r-- | lib/xlat_tables_v2/aarch64/xlat_tables_arch.c | 36 |
2 files changed, 53 insertions, 0 deletions
diff --git a/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c b/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c index 7d67a4ad..f66f802f 100644 --- a/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c +++ b/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c @@ -18,6 +18,23 @@ #error ARMv7 target does not support LPAE MMU descriptors #endif +/* + * Returns 1 if the provided granule size is supported, 0 otherwise. + */ +int xlat_arch_is_granule_size_supported(size_t size) +{ + /* + * The Trusted Firmware uses long descriptor translation table format, + * which supports 4 KiB pages only. + */ + return (size == (4U * 1024U)); +} + +size_t xlat_arch_get_max_supported_granule_size(void) +{ + return 4U * 1024U; +} + #if ENABLE_ASSERTIONS unsigned long long xlat_arch_get_max_supported_pa(void) { diff --git a/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c b/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c index b3504e1e..c501e707 100644 --- a/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c +++ b/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c @@ -16,6 +16,42 @@ #include <xlat_tables_v2.h> #include "../xlat_tables_private.h" +/* + * Returns 1 if the provided granule size is supported, 0 otherwise. + */ +int xlat_arch_is_granule_size_supported(size_t size) +{ + u_register_t id_aa64mmfr0_el1 = read_id_aa64mmfr0_el1(); + + if (size == (4U * 1024U)) { + return ((id_aa64mmfr0_el1 >> ID_AA64MMFR0_EL1_TGRAN4_SHIFT) & + ID_AA64MMFR0_EL1_TGRAN4_MASK) == + ID_AA64MMFR0_EL1_TGRAN4_SUPPORTED; + } else if (size == (16U * 1024U)) { + return ((id_aa64mmfr0_el1 >> ID_AA64MMFR0_EL1_TGRAN16_SHIFT) & + ID_AA64MMFR0_EL1_TGRAN16_MASK) == + ID_AA64MMFR0_EL1_TGRAN16_SUPPORTED; + } else if (size == (64U * 1024U)) { + return ((id_aa64mmfr0_el1 >> ID_AA64MMFR0_EL1_TGRAN64_SHIFT) & + ID_AA64MMFR0_EL1_TGRAN64_MASK) == + ID_AA64MMFR0_EL1_TGRAN64_SUPPORTED; + } + + return 0; +} + +size_t xlat_arch_get_max_supported_granule_size(void) +{ + if (xlat_arch_is_granule_size_supported(64U * 1024U)) { + return 64U * 1024U; + } else if (xlat_arch_is_granule_size_supported(16U * 1024U)) { + return 16U * 1024U; + } else { + assert(xlat_arch_is_granule_size_supported(4U * 1024U)); + return 4U * 1024U; + } +} + unsigned long long tcr_physical_addr_size_bits(unsigned long long max_addr) { /* Physical address can't exceed 48 bits */ |