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 | |
| 15 | /* Determine the physical address space encoded in the 'attr' parameter. */ |
| 16 | uint64_t xlat_arch_get_pas(uint64_t attr); |
| 17 | |
| 18 | /* |
| 19 | * Invalidate all TLB entries that match the given virtual address. This |
| 20 | * operation applies to all PEs in the same Inner Shareable domain as the PE |
| 21 | * that executes this function. This functions must be called for every |
| 22 | * translation table entry that is modified. It only affects the EL2 |
| 23 | * Translate regime |
| 24 | */ |
| 25 | void xlat_arch_tlbi_va(uintptr_t va); |
| 26 | |
| 27 | /* |
| 28 | * This function has to be called at the end of any code that uses the function |
| 29 | * xlat_arch_tlbi_va(). |
| 30 | */ |
| 31 | void xlat_arch_tlbi_va_sync(void); |
| 32 | |
| 33 | /* Print VA, PA, size and attributes of all regions in the mmap array. */ |
| 34 | void xlat_mmap_print(const struct xlat_ctx *ctx); |
| 35 | |
| 36 | /* |
| 37 | * Print the current state of the translation tables by reading them from |
| 38 | * memory. |
| 39 | */ |
| 40 | void xlat_tables_print(struct xlat_ctx *ctx); |
| 41 | |
| 42 | /* |
| 43 | * Returns a block/page table descriptor for the given level and attributes. |
| 44 | */ |
| 45 | uintptr_t xlat_desc(uint64_t attr, uintptr_t addr_pa, unsigned int level); |
| 46 | |
| 47 | /* |
| 48 | * Return the maximum physical address supported by the hardware. |
| 49 | */ |
| 50 | uintptr_t xlat_arch_get_max_supported_pa(void); |
| 51 | |
| 52 | /* |
| 53 | * Return the unpriviledged execute-never mask that will prevent instruction |
| 54 | * fetch by EL0 at the EL2&0 translation regime. |
| 55 | */ |
| 56 | #define XLAT_GET_UXN_DESC() (UPPER_ATTRS(UXN)) |
| 57 | |
| 58 | /* |
| 59 | * Return the priviledged execute-never mask that will prevent instruction |
| 60 | * fetch by EL2 at the EL2&0 translation regime. |
| 61 | */ |
| 62 | #define XLAT_GET_PXN_DESC() (UPPER_ATTRS(PXN)) |
| 63 | |
| 64 | /* |
| 65 | * Return the contiguous mask for a page or block descriptor |
| 66 | */ |
| 67 | #define XLAT_GET_CONT_HINT() (UPPER_ATTRS(CONT_HINT)) |
| 68 | |
| 69 | /* |
| 70 | * Return the NG flag for a page or block descriptor |
| 71 | */ |
| 72 | #define XLAT_GET_NG_HINT() (LOWER_ATTRS(NG_HINT)) |
| 73 | |
| 74 | /* |
| 75 | * Set up the xlat_ctx_cfg field of a given context. |
| 76 | * This macro doesn't check parameters. |
| 77 | * |
| 78 | * _ctx: |
| 79 | * Pointer to xlat_ctx. |
| 80 | * |
| 81 | * _cfg: |
| 82 | * reference to xlat_ctx_cfg that needs to be set to _ctx. |
| 83 | */ |
| 84 | #define XLAT_SETUP_CTX_CFG(_ctx, _cfg) (_ctx)->cfg = (_cfg) |
| 85 | |
| 86 | /* |
| 87 | * Set up the xlat_ctx_tbls field of a given context. |
| 88 | * This macro doesn't check parameters. |
| 89 | * |
| 90 | * _ctx: |
| 91 | * Context where to add the configuration strucutre. |
| 92 | * |
| 93 | * _tlbs: |
| 94 | * Reference to the xlat_ctx_tlbs structure where to add to the context. |
| 95 | */ |
| 96 | #define XLAT_SETUP_CTX_TBLS(_ctx, _tbls) (_ctx)->tbls = (_tbls) |
| 97 | |
| 98 | /* |
| 99 | * Initialize an existing xlat_ctx_tbls structure with the given parameters |
| 100 | * This macro doesn't check parameters. |
| 101 | * |
| 102 | * _tlbs: |
| 103 | * Pointer to xlat_ctx. |
| 104 | * |
| 105 | * _tables: |
| 106 | * pointer to non-base xlat_ctx_tbls. |
| 107 | * |
| 108 | * _tnum: |
| 109 | * Maximum number of intermediate tables that can fit in the _tables area. |
| 110 | * |
| 111 | * _btables: |
| 112 | * pointer to base xlat_ctx_tbls. |
| 113 | * |
| 114 | * _bt_entries: |
| 115 | * Maximum number of entries available on the base table. |
| 116 | */ |
| 117 | #define XLAT_INIT_CTX_TBLS(_tbls, _tables, _tnum, \ |
| 118 | _btables, _bt_entries) \ |
| 119 | { \ |
| 120 | (_tbls)->tables = (_tables); \ |
| 121 | (_tbls)->tables_num = (_tnum); \ |
| 122 | (_tbls)->base_table = (_btables); \ |
| 123 | (_tbls)->max_base_table_entries = (_bt_entries); \ |
| 124 | (_tbls)->next_table = 0U; \ |
| 125 | (_tbls)->initialized = false; \ |
| 126 | } |
| 127 | |
| 128 | #endif /* XLAT_TABLES_PRIVATE_H */ |