blob: dc5f9565998f1c08d68487ac6fb67a152a961757 [file] [log] [blame]
Gary Morrison3d7f6542021-01-27 13:08:47 -06001/*
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002 * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
Gary Morrison3d7f6542021-01-27 13:08:47 -06003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <assert.h>
8#include <errno.h>
9#include <stdbool.h>
10#include <stdint.h>
11#include <stdio.h>
12
13#include <common/debug.h>
14#include <lib/utils_def.h>
15#include <lib/xlat_tables/xlat_tables_defs.h>
16#include <lib/xlat_tables/xlat_tables_v2.h>
17#include "xlat_mpu_private.h"
18
19#include <fvp_r_arch_helpers.h>
20#include <platform_def.h>
21
22#warning "xlat_mpu library is currently experimental and its API may change in future."
23
24
Gary Morrison3d7f6542021-01-27 13:08:47 -060025void xlat_mmap_print(__unused const mmap_region_t *mmap)
26{
27 /* Empty */
28}
29
johpow010033b252021-10-11 14:51:11 -050030#if LOG_LEVEL < LOG_LEVEL_VERBOSE
31
Gary Morrison3d7f6542021-01-27 13:08:47 -060032void xlat_tables_print(__unused xlat_ctx_t *ctx)
33{
34 /* Empty */
35}
36
37#else /* if LOG_LEVEL >= LOG_LEVEL_VERBOSE */
38
johpow010033b252021-10-11 14:51:11 -050039static void xlat_tables_print_internal(__unused xlat_ctx_t *ctx)
Gary Morrison3d7f6542021-01-27 13:08:47 -060040{
johpow010033b252021-10-11 14:51:11 -050041 int region_to_use = 0;
42 uintptr_t region_base;
43 size_t region_size;
44 uint64_t prenr_el2_value = 0U;
Gary Morrison3d7f6542021-01-27 13:08:47 -060045
johpow010033b252021-10-11 14:51:11 -050046 /*
47 * Keep track of how many invalid descriptors are counted in a row.
48 * Whenever multiple invalid descriptors are found, only the first one
49 * is printed, and a line is added to inform about how many descriptors
50 * have been omitted.
51 */
Gary Morrison3d7f6542021-01-27 13:08:47 -060052
johpow010033b252021-10-11 14:51:11 -050053 /*
54 * TODO: Remove this WARN() and comment when these API calls are more
55 * completely implemented and tested!
56 */
57 WARN("%s in this early version of xlat_mpu library may not produce reliable results!",
58 __func__);
Gary Morrison3d7f6542021-01-27 13:08:47 -060059
johpow010033b252021-10-11 14:51:11 -050060 /*
61 * Sequence through all regions and print those in-use (PRENR has an
62 * enable bit for each MPU region, 1 for in-use or 0 for unused):
63 */
64 prenr_el2_value = read_prenr_el2();
65 for (region_to_use = 0; region_to_use < N_MPU_REGIONS;
66 region_to_use++) {
67 if (((prenr_el2_value >> region_to_use) & 1U) == 0U) {
68 continue;
69 }
70 region_base = read_prbar_el2() & PRBAR_PRLAR_ADDR_MASK;
71 region_size = read_prlar_el2() & PRBAR_PRLAR_ADDR_MASK;
72 printf("Address: 0x%llx, size: 0x%llx ",
73 (long long) region_base,
74 (long long) region_size);
75 }
76}
77
78void xlat_tables_print(__unused xlat_ctx_t *ctx)
79{
80 xlat_tables_print_internal(ctx);
Gary Morrison3d7f6542021-01-27 13:08:47 -060081}
82
83#endif /* LOG_LEVEL >= LOG_LEVEL_VERBOSE */