mtk_mmap_init.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <common/bl_common.h>
  8. #include <common/debug.h>
  9. #include <drivers/console.h>
  10. #include <lib/xlat_tables/xlat_tables_compat.h>
  11. #include <mtk_mmap_pool.h>
  12. IMPORT_SYM(uintptr_t, __MTK_MMAP_POINTER_POOL_START__, MTK_MMAP_POINTER_POOL_START);
  13. IMPORT_SYM(uintptr_t, __MTK_MMAP_POINTER_POOL_END_UNALIGNED__, MTK_MMAP_POINTER_POOL_END_UNALIGNED);
  14. IMPORT_SYM(uintptr_t, __RW_START__, RW_START);
  15. IMPORT_SYM(uintptr_t, __DATA_START__, DATA_START);
  16. #define MAP_MTK_SECTIONS MAP_REGION_FLAT(RW_START, \
  17. DATA_START - RW_START, \
  18. MT_MEMORY | MT_RO | MT_SECURE)
  19. static void print_mmap(const mmap_region_t *regions)
  20. {
  21. while (regions->size != 0U) {
  22. VERBOSE("Region: 0x%lx - 0x%lx has attributes 0x%x\n",
  23. regions->base_va,
  24. regions->base_va + regions->size,
  25. regions->attr);
  26. regions++;
  27. }
  28. }
  29. void mtk_xlat_init(const mmap_region_t *bl_regions)
  30. {
  31. struct mtk_mmap_descriptor *iter;
  32. const mmap_region_t *regions = bl_regions;
  33. print_mmap(regions);
  34. mmap_add(bl_regions);
  35. if (MTK_MMAP_POINTER_POOL_START != MTK_MMAP_POINTER_POOL_END_UNALIGNED) {
  36. for (iter = (struct mtk_mmap_descriptor *)MTK_MMAP_POINTER_POOL_START;
  37. (char *)iter < (char *)MTK_MMAP_POINTER_POOL_END_UNALIGNED;
  38. iter++) {
  39. regions = iter->mmap_ptr;
  40. INFO("mmap_name: %s\n", iter->mmap_name);
  41. INFO("mmap_size: 0x%x\n", iter->mmap_size);
  42. print_mmap(regions);
  43. mmap_add(regions);
  44. }
  45. }
  46. init_xlat_tables();
  47. enable_mmu_el3(0);
  48. }