Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SPDX-License-Identifier: BSD-3-Clause |
| 3 | * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. |
| 4 | * SPDX-FileCopyrightText: Copyright Arm Limited and Contributors. |
| 5 | */ |
| 6 | |
| 7 | /* This file is derived from xlat_table_v2 library in TF-A project */ |
| 8 | |
| 9 | #ifndef XLAT_TABLES_PRIVATE_H |
| 10 | #define XLAT_TABLES_PRIVATE_H |
| 11 | |
| 12 | #include <stdbool.h> |
| 13 | #include <xlat_contexts.h> |
| 14 | |
Javier Almansa Sobrino | ed93259 | 2023-01-24 12:50:41 +0000 | [diff] [blame^] | 15 | /* |
| 16 | * Initialize translation tables associated to the current context. |
| 17 | * |
| 18 | * This function assumes that the xlat_ctx_cfg field of the context has been |
| 19 | * properly configured by previous calls to xlat_ctx_cfg_init(). |
| 20 | * |
| 21 | * This function returns 0 on success or an error code otherwise. |
| 22 | */ |
| 23 | int xlat_init_tables_ctx(struct xlat_ctx *ctx); |
| 24 | |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 25 | /* Determine the physical address space encoded in the 'attr' parameter. */ |
| 26 | uint64_t xlat_arch_get_pas(uint64_t attr); |
| 27 | |
| 28 | /* |
| 29 | * Invalidate all TLB entries that match the given virtual address. This |
| 30 | * operation applies to all PEs in the same Inner Shareable domain as the PE |
| 31 | * that executes this function. This functions must be called for every |
| 32 | * translation table entry that is modified. It only affects the EL2 |
| 33 | * Translate regime |
| 34 | */ |
| 35 | void xlat_arch_tlbi_va(uintptr_t va); |
| 36 | |
| 37 | /* |
| 38 | * This function has to be called at the end of any code that uses the function |
| 39 | * xlat_arch_tlbi_va(). |
| 40 | */ |
| 41 | void xlat_arch_tlbi_va_sync(void); |
| 42 | |
| 43 | /* Print VA, PA, size and attributes of all regions in the mmap array. */ |
| 44 | void xlat_mmap_print(const struct xlat_ctx *ctx); |
| 45 | |
| 46 | /* |
| 47 | * Print the current state of the translation tables by reading them from |
| 48 | * memory. |
| 49 | */ |
| 50 | void xlat_tables_print(struct xlat_ctx *ctx); |
| 51 | |
| 52 | /* |
| 53 | * Returns a block/page table descriptor for the given level and attributes. |
| 54 | */ |
| 55 | uintptr_t xlat_desc(uint64_t attr, uintptr_t addr_pa, unsigned int level); |
| 56 | |
| 57 | /* |
| 58 | * Return the maximum physical address supported by the hardware. |
| 59 | */ |
| 60 | uintptr_t xlat_arch_get_max_supported_pa(void); |
| 61 | |
| 62 | /* |
| 63 | * Return the unpriviledged execute-never mask that will prevent instruction |
| 64 | * fetch by EL0 at the EL2&0 translation regime. |
| 65 | */ |
| 66 | #define XLAT_GET_UXN_DESC() (UPPER_ATTRS(UXN)) |
| 67 | |
| 68 | /* |
| 69 | * Return the priviledged execute-never mask that will prevent instruction |
| 70 | * fetch by EL2 at the EL2&0 translation regime. |
| 71 | */ |
| 72 | #define XLAT_GET_PXN_DESC() (UPPER_ATTRS(PXN)) |
| 73 | |
| 74 | /* |
| 75 | * Return the contiguous mask for a page or block descriptor |
| 76 | */ |
| 77 | #define XLAT_GET_CONT_HINT() (UPPER_ATTRS(CONT_HINT)) |
| 78 | |
| 79 | /* |
| 80 | * Return the NG flag for a page or block descriptor |
| 81 | */ |
| 82 | #define XLAT_GET_NG_HINT() (LOWER_ATTRS(NG_HINT)) |
| 83 | |
| 84 | /* |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 85 | * Initialize an existing xlat_ctx_tbls structure with the given parameters |
| 86 | * This macro doesn't check parameters. |
| 87 | * |
| 88 | * _tlbs: |
Javier Almansa Sobrino | ed93259 | 2023-01-24 12:50:41 +0000 | [diff] [blame^] | 89 | * Pointer to xlat_ctx_tlbs structure. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 90 | * |
| 91 | * _tables: |
Javier Almansa Sobrino | ed93259 | 2023-01-24 12:50:41 +0000 | [diff] [blame^] | 92 | * pointer to a translation table array containing all the translation |
| 93 | * tables. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 94 | * |
| 95 | * _tnum: |
Javier Almansa Sobrino | ed93259 | 2023-01-24 12:50:41 +0000 | [diff] [blame^] | 96 | * Maximum number of tables that can fit in the _tables area. |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 97 | */ |
Javier Almansa Sobrino | ed93259 | 2023-01-24 12:50:41 +0000 | [diff] [blame^] | 98 | #define XLAT_INIT_CTX_TBLS(_tbls, _tables, _tnum) \ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 99 | { \ |
| 100 | (_tbls)->tables = (_tables); \ |
| 101 | (_tbls)->tables_num = (_tnum); \ |
Soby Mathew | b4c6df4 | 2022-11-09 11:13:29 +0000 | [diff] [blame] | 102 | (_tbls)->next_table = 0U; \ |
| 103 | (_tbls)->initialized = false; \ |
| 104 | } |
| 105 | |
| 106 | #endif /* XLAT_TABLES_PRIVATE_H */ |