IdMap.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: BSD-2-Clause-Patent
  2. // Copyright 2022 Google LLC
  3. // Author: Ard Biesheuvel <ardb@google.com>
  4. .set TT_TYPE_BLOCK, 0x1
  5. .set TT_TYPE_PAGE, 0x3
  6. .set TT_TYPE_TABLE, 0x3
  7. .set TT_AF, 0x1 << 10
  8. .set TT_NG, 0x1 << 11
  9. .set TT_RO, 0x2 << 6
  10. .set TT_XN, 0x3 << 53
  11. .set TT_MT_DEV, 0x0 << 2 // MAIR #0
  12. .set TT_MT_MEM, (0x3 << 2) | (0x3 << 8) // MAIR #3
  13. .set PAGE_XIP, TT_TYPE_PAGE | TT_MT_MEM | TT_AF | TT_RO | TT_NG
  14. .set BLOCK_XIP, TT_TYPE_BLOCK | TT_MT_MEM | TT_AF | TT_RO | TT_NG
  15. .set BLOCK_DEV, TT_TYPE_BLOCK | TT_MT_DEV | TT_AF | TT_XN | TT_NG
  16. .set BLOCK_MEM, TT_TYPE_BLOCK | TT_MT_MEM | TT_AF | TT_XN | TT_NG
  17. .globl idmap
  18. .section ".rodata.idmap", "a", %progbits
  19. .align 12
  20. idmap: /* level 0 */
  21. .quad 1f + TT_TYPE_TABLE
  22. .fill 511, 8, 0x0
  23. 1: /* level 1 */
  24. .quad 20f + TT_TYPE_TABLE // 1 GB of flash and device mappings
  25. .quad 21f + TT_TYPE_TABLE // up to 1 GB of DRAM
  26. .fill 510, 8, 0x0 // 510 GB of remaining VA space
  27. 20: /* level 2 */
  28. .quad 3f + TT_TYPE_TABLE // up to 2 MB of flash
  29. .quad BLOCK_XIP | (0x1 << 21) // another 2 MB of flash
  30. .fill 62, 8, 0x0 // 124 MB of unused flash
  31. .set idx, 64
  32. .rept 448
  33. .quad BLOCK_DEV | (idx << 21) // 896 MB of RW- device mappings
  34. .set idx, idx + 1
  35. .endr
  36. 21: /* level 2 */
  37. .set idx, 0x40000000 >> 21
  38. .rept 64
  39. .quad BLOCK_MEM | (idx << 21) // 128 MB of RW- memory mappings
  40. .set idx, idx + 1
  41. .endr
  42. .fill 448, 8, 0x0
  43. 3: /* level 3 */
  44. .quad 0x0 // omit first 4k page
  45. .set idx, 1
  46. .rept 511
  47. .quad PAGE_XIP | (idx << 12) // 2044 KiB of R-X flash mappings
  48. .set idx, idx + 1
  49. .endr