developer | 6d8e8f8 | 2022-06-20 10:25:35 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022, MediaTek Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef MTK_MMAP_POOL_H |
| 8 | #define MTK_MMAP_POOL_H |
| 9 | |
| 10 | #include <cdefs.h> |
| 11 | #include <lib/xlat_tables/xlat_tables_compat.h> |
| 12 | |
| 13 | struct mtk_mmap_descriptor { |
| 14 | const char *mmap_name; |
| 15 | const mmap_region_t *mmap_ptr; |
| 16 | const uint32_t mmap_size; |
| 17 | }; |
| 18 | |
| 19 | #define MTK_MMAP_SECTION \ |
| 20 | __used \ |
| 21 | __aligned(sizeof(void *)) \ |
| 22 | __section(".mtk_mmap_lists") |
| 23 | |
| 24 | #define DECLARE_MTK_MMAP_REGIONS(_mmap_array) \ |
| 25 | static const struct mtk_mmap_descriptor _mtk_mmap_descriptor_##_mmap_array \ |
| 26 | __used \ |
| 27 | __aligned(sizeof(void *)) \ |
| 28 | __section(".mtk_mmap_pool") \ |
| 29 | = { \ |
| 30 | .mmap_name = #_mmap_array, \ |
| 31 | .mmap_ptr = _mmap_array, \ |
| 32 | .mmap_size = ARRAY_SIZE(_mmap_array) \ |
| 33 | } |
| 34 | |
| 35 | #define MAP_BL_RW MAP_REGION_FLAT( \ |
| 36 | DATA_START, \ |
| 37 | BL_END - DATA_START, \ |
| 38 | MT_MEMORY | MT_RW | MT_SECURE) |
| 39 | |
| 40 | #if SEPARATE_CODE_AND_RODATA |
| 41 | #define MAP_BL_RO \ |
| 42 | MAP_REGION_FLAT( \ |
| 43 | BL_CODE_BASE, \ |
| 44 | BL_CODE_END - BL_CODE_BASE, \ |
| 45 | MT_CODE | MT_SECURE), \ |
| 46 | MAP_REGION_FLAT( \ |
| 47 | BL_RO_DATA_BASE, \ |
| 48 | BL_RO_DATA_END - BL_RO_DATA_BASE, \ |
| 49 | MT_RO_DATA | MT_SECURE) |
| 50 | #else |
| 51 | #define MAP_BL_RO MAP_REGION_FLAT(BL_CODE_BASE, \ |
| 52 | BL_CODE_END - BL_CODE_BASE, \ |
| 53 | MT_CODE | MT_SECURE) |
| 54 | #endif |
| 55 | |
| 56 | void mtk_xlat_init(const mmap_region_t *bl_regions); |
| 57 | |
| 58 | #endif /* MTK_MMAP_POOL_H */ |