blob: 67d70b6bba256aaaac8d5e757bed082cd95e80b5 [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6#include <arch.h>
7#include <arch_helpers.h>
8#include <assert.h>
9#include <stdint.h>
10#include <utils_def.h>
11
12/*
13 * Return the PA width supported by the current system.
14 */
15unsigned int arch_feat_get_pa_width(void)
16{
17 /*
18 * Physical Address ranges supported in the AArch64 Memory Model.
19 * Value 0b110 is supported in ARMv8.2 onwards but not used in RMM.
20 */
21 static const unsigned int pa_range_bits_arr[] = {
22 PARANGE_0000_WIDTH, PARANGE_0001_WIDTH, PARANGE_0010_WIDTH,
23 PARANGE_0011_WIDTH, PARANGE_0100_WIDTH, PARANGE_0101_WIDTH,
24 /*
25 * FEAT_LPA/LPA2 is not supported yet in RMM,
26 * so max PA width is 48.
27 */
28 PARANGE_0101_WIDTH
29 };
30
31 register_t pa_range = (read_id_aa64mmfr0_el1() >>
32 ID_AA64MMFR0_EL1_PARANGE_SHIFT) &
33 ID_AA64MMFR0_EL1_PARANGE_MASK;
34
35 assert(pa_range < ARRAY_SIZE(pa_range_bits_arr));
36
37 return pa_range_bits_arr[pa_range];
38}