mmu.txt 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. MMUv3 initialization sequence.
  2. The code in the initialize_mmu macro sets up MMUv3 memory mapping
  3. identically to MMUv2 fixed memory mapping. Depending on
  4. CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX symbol this code is
  5. located in addresses it was linked for (symbol undefined), or not
  6. (symbol defined), so it needs to be position-independent.
  7. The code has the following assumptions:
  8. This code fragment is run only on an MMU v3.
  9. TLBs are in their reset state.
  10. ITLBCFG and DTLBCFG are zero (reset state).
  11. RASID is 0x04030201 (reset state).
  12. PS.RING is zero (reset state).
  13. LITBASE is zero (reset state, PC-relative literals); required to be PIC.
  14. TLB setup proceeds along the following steps.
  15. Legend:
  16. VA = virtual address (two upper nibbles of it);
  17. PA = physical address (two upper nibbles of it);
  18. pc = physical range that contains this code;
  19. After step 2, we jump to virtual address in the range 0x40000000..0x5fffffff
  20. or 0x00000000..0x1fffffff, depending on whether the kernel was loaded below
  21. 0x40000000 or above. That address corresponds to next instruction to execute
  22. in this code. After step 4, we jump to intended (linked) address of this code.
  23. The scheme below assumes that the kernel is loaded below 0x40000000.
  24. Step0 Step1 Step2 Step3 Step4 Step5
  25. ===== ===== ===== ===== ===== =====
  26. VA PA PA PA PA VA PA PA
  27. ------ -- -- -- -- ------ -- --
  28. E0..FF -> E0 -> E0 -> E0 F0..FF -> F0 -> F0
  29. C0..DF -> C0 -> C0 -> C0 E0..EF -> F0 -> F0
  30. A0..BF -> A0 -> A0 -> A0 D8..DF -> 00 -> 00
  31. 80..9F -> 80 -> 80 -> 80 D0..D7 -> 00 -> 00
  32. 60..7F -> 60 -> 60 -> 60
  33. 40..5F -> 40 -> pc -> pc 40..5F -> pc
  34. 20..3F -> 20 -> 20 -> 20
  35. 00..1F -> 00 -> 00 -> 00
  36. The default location of IO peripherals is above 0xf0000000. This may be changed
  37. using a "ranges" property in a device tree simple-bus node. See ePAPR 1.1, §6.5
  38. for details on the syntax and semantic of simple-bus nodes. The following
  39. limitations apply:
  40. 1. Only top level simple-bus nodes are considered
  41. 2. Only one (first) simple-bus node is considered
  42. 3. Empty "ranges" properties are not supported
  43. 4. Only the first triplet in the "ranges" property is considered
  44. 5. The parent-bus-address value is rounded down to the nearest 256MB boundary
  45. 6. The IO area covers the entire 256MB segment of parent-bus-address; the
  46. "ranges" triplet length field is ignored
  47. MMUv3 address space layouts.
  48. ============================
  49. Default MMUv2-compatible layout.
  50. Symbol VADDR Size
  51. +------------------+
  52. | Userspace | 0x00000000 TASK_SIZE
  53. +------------------+ 0x40000000
  54. +------------------+
  55. | Page table | 0x80000000
  56. +------------------+ 0x80400000
  57. +------------------+
  58. | KMAP area | PKMAP_BASE PTRS_PER_PTE *
  59. | | DCACHE_N_COLORS *
  60. | | PAGE_SIZE
  61. | | (4MB * DCACHE_N_COLORS)
  62. +------------------+
  63. | Atomic KMAP area | FIXADDR_START KM_TYPE_NR *
  64. | | NR_CPUS *
  65. | | DCACHE_N_COLORS *
  66. | | PAGE_SIZE
  67. +------------------+ FIXADDR_TOP 0xbffff000
  68. +------------------+
  69. | VMALLOC area | VMALLOC_START 0xc0000000 128MB - 64KB
  70. +------------------+ VMALLOC_END
  71. | Cache aliasing | TLBTEMP_BASE_1 0xc7ff0000 DCACHE_WAY_SIZE
  72. | remap area 1 |
  73. +------------------+
  74. | Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE
  75. | remap area 2 |
  76. +------------------+
  77. +------------------+
  78. | Cached KSEG | XCHAL_KSEG_CACHED_VADDR 0xd0000000 128MB
  79. +------------------+
  80. | Uncached KSEG | XCHAL_KSEG_BYPASS_VADDR 0xd8000000 128MB
  81. +------------------+
  82. | Cached KIO | XCHAL_KIO_CACHED_VADDR 0xe0000000 256MB
  83. +------------------+
  84. | Uncached KIO | XCHAL_KIO_BYPASS_VADDR 0xf0000000 256MB
  85. +------------------+
  86. 256MB cached + 256MB uncached layout.
  87. Symbol VADDR Size
  88. +------------------+
  89. | Userspace | 0x00000000 TASK_SIZE
  90. +------------------+ 0x40000000
  91. +------------------+
  92. | Page table | 0x80000000
  93. +------------------+ 0x80400000
  94. +------------------+
  95. | KMAP area | PKMAP_BASE PTRS_PER_PTE *
  96. | | DCACHE_N_COLORS *
  97. | | PAGE_SIZE
  98. | | (4MB * DCACHE_N_COLORS)
  99. +------------------+
  100. | Atomic KMAP area | FIXADDR_START KM_TYPE_NR *
  101. | | NR_CPUS *
  102. | | DCACHE_N_COLORS *
  103. | | PAGE_SIZE
  104. +------------------+ FIXADDR_TOP 0x9ffff000
  105. +------------------+
  106. | VMALLOC area | VMALLOC_START 0xa0000000 128MB - 64KB
  107. +------------------+ VMALLOC_END
  108. | Cache aliasing | TLBTEMP_BASE_1 0xa7ff0000 DCACHE_WAY_SIZE
  109. | remap area 1 |
  110. +------------------+
  111. | Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE
  112. | remap area 2 |
  113. +------------------+
  114. +------------------+
  115. | Cached KSEG | XCHAL_KSEG_CACHED_VADDR 0xb0000000 256MB
  116. +------------------+
  117. | Uncached KSEG | XCHAL_KSEG_BYPASS_VADDR 0xc0000000 256MB
  118. +------------------+
  119. +------------------+
  120. | Cached KIO | XCHAL_KIO_CACHED_VADDR 0xe0000000 256MB
  121. +------------------+
  122. | Uncached KIO | XCHAL_KIO_BYPASS_VADDR 0xf0000000 256MB
  123. +------------------+
  124. 512MB cached + 512MB uncached layout.
  125. Symbol VADDR Size
  126. +------------------+
  127. | Userspace | 0x00000000 TASK_SIZE
  128. +------------------+ 0x40000000
  129. +------------------+
  130. | Page table | 0x80000000
  131. +------------------+ 0x80400000
  132. +------------------+
  133. | KMAP area | PKMAP_BASE PTRS_PER_PTE *
  134. | | DCACHE_N_COLORS *
  135. | | PAGE_SIZE
  136. | | (4MB * DCACHE_N_COLORS)
  137. +------------------+
  138. | Atomic KMAP area | FIXADDR_START KM_TYPE_NR *
  139. | | NR_CPUS *
  140. | | DCACHE_N_COLORS *
  141. | | PAGE_SIZE
  142. +------------------+ FIXADDR_TOP 0x8ffff000
  143. +------------------+
  144. | VMALLOC area | VMALLOC_START 0x90000000 128MB - 64KB
  145. +------------------+ VMALLOC_END
  146. | Cache aliasing | TLBTEMP_BASE_1 0x97ff0000 DCACHE_WAY_SIZE
  147. | remap area 1 |
  148. +------------------+
  149. | Cache aliasing | TLBTEMP_BASE_2 DCACHE_WAY_SIZE
  150. | remap area 2 |
  151. +------------------+
  152. +------------------+
  153. | Cached KSEG | XCHAL_KSEG_CACHED_VADDR 0xa0000000 512MB
  154. +------------------+
  155. | Uncached KSEG | XCHAL_KSEG_BYPASS_VADDR 0xc0000000 512MB
  156. +------------------+
  157. | Cached KIO | XCHAL_KIO_CACHED_VADDR 0xe0000000 256MB
  158. +------------------+
  159. | Uncached KIO | XCHAL_KIO_BYPASS_VADDR 0xf0000000 256MB
  160. +------------------+