mtk_mmap_pool.h 1.3 KB

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