sq_xlat_setup.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <common/debug.h>
  8. #include <lib/xlat_tables/xlat_tables_v2.h>
  9. #define SQ_REG_REGION_BASE 0x20000000ULL
  10. #define SQ_REG_REGION_SIZE 0x60000000ULL
  11. void sq_mmap_setup(uintptr_t total_base, size_t total_size,
  12. const struct mmap_region *mmap)
  13. {
  14. VERBOSE("Trusted RAM seen by this BL image: %p - %p\n",
  15. (void *)total_base, (void *)(total_base + total_size));
  16. mmap_add_region(total_base, total_base,
  17. total_size,
  18. MT_NON_CACHEABLE | MT_RW | MT_SECURE);
  19. /* remap the code section */
  20. VERBOSE("Code region: %p - %p\n",
  21. (void *)BL_CODE_BASE, (void *)BL_CODE_END);
  22. mmap_add_region(BL_CODE_BASE, BL_CODE_BASE,
  23. round_up(BL_CODE_END, PAGE_SIZE) - BL_CODE_BASE,
  24. MT_NON_CACHEABLE | MT_RO | MT_SECURE);
  25. /* Re-map the read-only data section */
  26. VERBOSE("Read-only data region: %p - %p\n",
  27. (void *)BL_RO_DATA_BASE, (void *)BL_RO_DATA_END);
  28. mmap_add_region(BL_RO_DATA_BASE, BL_RO_DATA_BASE,
  29. round_up(BL_RO_DATA_END, PAGE_SIZE) - BL_RO_DATA_BASE,
  30. (MT_NON_CACHEABLE | MT_RO | MT_EXECUTE_NEVER |
  31. MT_SECURE));
  32. /* remap the coherent memory region */
  33. VERBOSE("Coherent region: %p - %p\n",
  34. (void *)BL_COHERENT_RAM_BASE, (void *)BL_COHERENT_RAM_END);
  35. mmap_add_region(BL_COHERENT_RAM_BASE, BL_COHERENT_RAM_BASE,
  36. BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE,
  37. MT_DEVICE | MT_RW | MT_SECURE);
  38. /* register region */
  39. mmap_add_region(SQ_REG_REGION_BASE, SQ_REG_REGION_BASE,
  40. SQ_REG_REGION_SIZE,
  41. MT_DEVICE | MT_RW | MT_SECURE);
  42. /* additional regions if needed */
  43. if (mmap)
  44. mmap_add(mmap);
  45. init_xlat_tables();
  46. }