Sandrine Bailleux | 090c849 | 2017-05-19 09:59:37 +0100 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | 50eb374 | 2018-07-24 10:20:53 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
Sandrine Bailleux | 090c849 | 2017-05-19 09:59:37 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 50eb374 | 2018-07-24 10:20:53 +0100 | [diff] [blame] | 7 | #ifndef XLAT_TABLES_ARCH_H |
| 8 | #define XLAT_TABLES_ARCH_H |
Sandrine Bailleux | 090c849 | 2017-05-19 09:59:37 +0100 | [diff] [blame] | 9 | |
| 10 | #ifdef AARCH32 |
| 11 | #include "aarch32/xlat_tables_aarch32.h" |
| 12 | #else |
| 13 | #include "aarch64/xlat_tables_aarch64.h" |
| 14 | #endif |
| 15 | |
| 16 | /* |
| 17 | * Evaluates to 1 if the given virtual address space size is valid, or 0 if it's |
| 18 | * not. |
| 19 | * |
| 20 | * A valid size is one that is a power of 2 and is within the architectural |
| 21 | * limits. Not that these limits are different for AArch32 and AArch64. |
| 22 | */ |
| 23 | #define CHECK_VIRT_ADDR_SPACE_SIZE(size) \ |
Antonio Nino Diaz | 50eb374 | 2018-07-24 10:20:53 +0100 | [diff] [blame] | 24 | (((unsigned long long)(size) >= MIN_VIRT_ADDR_SPACE_SIZE) && \ |
| 25 | ((unsigned long long)(size) <= MAX_VIRT_ADDR_SPACE_SIZE) && \ |
Sandrine Bailleux | 090c849 | 2017-05-19 09:59:37 +0100 | [diff] [blame] | 26 | IS_POWER_OF_TWO(size)) |
| 27 | |
| 28 | /* |
| 29 | * Evaluates to 1 if the given physical address space size is a power of 2, |
| 30 | * or 0 if it's not. |
| 31 | */ |
| 32 | #define CHECK_PHY_ADDR_SPACE_SIZE(size) \ |
| 33 | (IS_POWER_OF_TWO(size)) |
| 34 | |
| 35 | /* |
| 36 | * Compute the number of entries required at the initial lookup level to address |
| 37 | * the whole virtual address space. |
| 38 | */ |
| 39 | #define GET_NUM_BASE_LEVEL_ENTRIES(addr_space_size) \ |
| 40 | ((addr_space_size) >> \ |
| 41 | XLAT_ADDR_SHIFT(GET_XLAT_TABLE_LEVEL_BASE(addr_space_size))) |
| 42 | |
Antonio Nino Diaz | 50eb374 | 2018-07-24 10:20:53 +0100 | [diff] [blame] | 43 | #endif /* XLAT_TABLES_ARCH_H */ |