Translation error at level1 in armv8 A72 cortex

Hi,

I am trying to enable MMU on LS1046ARDB using baremetal boot code . We are translating 1GB of DRAM as NORMAL READ WRITE memory . We are able to load entries into translation tables successfully . But as soon as MMU is enabled the execution is crashing and we are getting translation error at level 1 indicated in IFSC Field of ESR_EL3 Register.(Error code : 0x86000005)

Attached below is the assembly code we are using to set up Translation tables and enable MMU.

Are we missing anything? Any suggestions would be appreciated.

 

Thanks,

Faizanbaig Inamdar

MMU.txt
/*
 * This file was automatically generated using arm64-pgtable-tool.
 * See: https://github.com/ashwio/arm64-pgtable-tool
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * This code programs the following translation table structure:
 *
 *         level 1 table @ 0x80000000
 *         [#   2]---------------------------\
 *                 level 2 table @ 0x80001000
 *                 [# 128] 0x000090000000-0x0000901fffff, RW_Data, DRAM
 *                 [# 129] 0x000090200000-0x0000903fffff, RW_Data, DRAM
 *                 [# 130] 0x000090400000-0x0000905fffff, RW_Data, DRAM
 *                 [# 131] 0x000090600000-0x0000907fffff, RW_Data, DRAM
 *                 [# 132] 0x000090800000-0x0000909fffff, RW_Data, DRAM
 *                 [# 133] 0x000090a00000-0x000090bfffff, RW_Data, DRAM
 *                 [# 134] 0x000090c00000-0x000090dfffff, RW_Data, DRAM
 *                 [# 135] 0x000090e00000-0x000090ffffff, RW_Data, DRAM
 *                 [# 136] 0x000091000000-0x0000911fffff, RW_Data, DRAM
 *                 [# 137] 0x000091200000-0x0000913fffff, RW_Data, DRAM
 *                 [# 138] 0x000091400000-0x0000915fffff, RW_Data, DRAM
 *                 [# 139] 0x000091600000-0x0000917fffff, RW_Data, DRAM
 *                 [# 140] 0x000091800000-0x0000919fffff, RW_Data, DRAM
 *                 [# 141] 0x000091a00000-0x000091bfffff, RW_Data, DRAM
 *                 [# 142] 0x000091c00000-0x000091dfffff, RW_Data, DRAM
 *                 [# 143] 0x000091e00000-0x000091ffffff, RW_Data, DRAM
 *                 [# 144] 0x000092000000-0x0000921fffff, RW_Data, DRAM
 *                 [# 145] 0x000092200000-0x0000923fffff, RW_Data, DRAM
 *                 [# 146] 0x000092400000-0x0000925fffff, RW_Data, DRAM
 *                 [# 147] 0x000092600000-0x0000927fffff, RW_Data, DRAM
 *                 [# 148] 0x000092800000-0x0000929fffff, RW_Data, DRAM
 *                 [# 149] 0x000092a00000-0x000092bfffff, RW_Data, DRAM
 *                 [# 150] 0x000092c00000-0x000092dfffff, RW_Data, DRAM
 *                 [# 151] 0x000092e00000-0x000092ffffff, RW_Data, DRAM
 *                 [# 152] 0x000093000000-0x0000931fffff, RW_Data, DRAM
 *                 [# 153] 0x000093200000-0x0000933fffff, RW_Data, DRAM
 *                 [# 154] 0x000093400000-0x0000935fffff, RW_Data, DRAM
 *                 [# 155] 0x000093600000-0x0000937fffff, RW_Data, DRAM
 *                 [# 156] 0x000093800000-0x0000939fffff, RW_Data, DRAM
 *                 [# 157] 0x000093a00000-0x000093bfffff, RW_Data, DRAM
 *                 [# 158] 0x000093c00000-0x000093dfffff, RW_Data, DRAM
 *                 [# 159] 0x000093e00000-0x000093ffffff, RW_Data, DRAM
 *                 [# 160] 0x000094000000-0x0000941fffff, RW_Data, DRAM
 *                 [# 161] 0x000094200000-0x0000943fffff, RW_Data, DRAM
 *                 [# 162] 0x000094400000-0x0000945fffff, RW_Data, DRAM
 *                 [# 163] 0x000094600000-0x0000947fffff, RW_Data, DRAM
 *                 [# 164] 0x000094800000-0x0000949fffff, RW_Data, DRAM
 *                 [# 165] 0x000094a00000-0x000094bfffff, RW_Data, DRAM
 *                 [# 166] 0x000094c00000-0x000094dfffff, RW_Data, DRAM
 *                 [# 167] 0x000094e00000-0x000094ffffff, RW_Data, DRAM
 *                 [# 168] 0x000095000000-0x0000951fffff, RW_Data, DRAM
 *                 [# 169] 0x000095200000-0x0000953fffff, RW_Data, DRAM
 *                 [# 170] 0x000095400000-0x0000955fffff, RW_Data, DRAM
 *                 [# 171] 0x000095600000-0x0000957fffff, RW_Data, DRAM
 *                 [# 172] 0x000095800000-0x0000959fffff, RW_Data, DRAM
 *                 [# 173] 0x000095a00000-0x000095bfffff, RW_Data, DRAM
 *                 [# 174] 0x000095c00000-0x000095dfffff, RW_Data, DRAM
 *                 [# 175] 0x000095e00000-0x000095ffffff, RW_Data, DRAM
 *                 [# 176] 0x000096000000-0x0000961fffff, RW_Data, DRAM
 *                 [# 177] 0x000096200000-0x0000963fffff, RW_Data, DRAM
 *                 [# 178] 0x000096400000-0x0000965fffff, RW_Data, DRAM
 *                 [# 179] 0x000096600000-0x0000967fffff, RW_Data, DRAM
 *                 [# 180] 0x000096800000-0x0000969fffff, RW_Data, DRAM
 *                 [# 181] 0x000096a00000-0x000096bfffff, RW_Data, DRAM
 *                 [# 182] 0x000096c00000-0x000096dfffff, RW_Data, DRAM
 *                 [# 183] 0x000096e00000-0x000096ffffff, RW_Data, DRAM
 *                 [# 184] 0x000097000000-0x0000971fffff, RW_Data, DRAM
 *                 [# 185] 0x000097200000-0x0000973fffff, RW_Data, DRAM
 *                 [# 186] 0x000097400000-0x0000975fffff, RW_Data, DRAM
 *                 [# 187] 0x000097600000-0x0000977fffff, RW_Data, DRAM
 *                 [# 188] 0x000097800000-0x0000979fffff, RW_Data, DRAM
 *                 [# 189] 0x000097a00000-0x000097bfffff, RW_Data, DRAM
 *                 [# 190] 0x000097c00000-0x000097dfffff, RW_Data, DRAM
 *                 [# 191] 0x000097e00000-0x000097ffffff, RW_Data, DRAM
 *                 [# 192] 0x000098000000-0x0000981fffff, RW_Data, DRAM
 *                 [# 193] 0x000098200000-0x0000983fffff, RW_Data, DRAM
 *                 [# 194] 0x000098400000-0x0000985fffff, RW_Data, DRAM
 *                 [# 195] 0x000098600000-0x0000987fffff, RW_Data, DRAM
 *                 [# 196] 0x000098800000-0x0000989fffff, RW_Data, DRAM
 *                 [# 197] 0x000098a00000-0x000098bfffff, RW_Data, DRAM
 *                 [# 198] 0x000098c00000-0x000098dfffff, RW_Data, DRAM
 *                 [# 199] 0x000098e00000-0x000098ffffff, RW_Data, DRAM
 *                 [# 200] 0x000099000000-0x0000991fffff, RW_Data, DRAM
 *                 [# 201] 0x000099200000-0x0000993fffff, RW_Data, DRAM
 *                 [# 202] 0x000099400000-0x0000995fffff, RW_Data, DRAM
 *                 [# 203] 0x000099600000-0x0000997fffff, RW_Data, DRAM
 *                 [# 204] 0x000099800000-0x0000999fffff, RW_Data, DRAM
 *                 [# 205] 0x000099a00000-0x000099bfffff, RW_Data, DRAM
 *                 [# 206] 0x000099c00000-0x000099dfffff, RW_Data, DRAM
 *                 [# 207] 0x000099e00000-0x000099ffffff, RW_Data, DRAM
 *                 [# 208] 0x00009a000000-0x00009a1fffff, RW_Data, DRAM
 *                 [# 209] 0x00009a200000-0x00009a3fffff, RW_Data, DRAM
 *                 [# 210] 0x00009a400000-0x00009a5fffff, RW_Data, DRAM
 *                 [# 211] 0x00009a600000-0x00009a7fffff, RW_Data, DRAM
 *                 [# 212] 0x00009a800000-0x00009a9fffff, RW_Data, DRAM
 *                 [# 213] 0x00009aa00000-0x00009abfffff, RW_Data, DRAM
 *                 [# 214] 0x00009ac00000-0x00009adfffff, RW_Data, DRAM
 *                 [# 215] 0x00009ae00000-0x00009affffff, RW_Data, DRAM
 *                 [# 216] 0x00009b000000-0x00009b1fffff, RW_Data, DRAM
 *                 [# 217] 0x00009b200000-0x00009b3fffff, RW_Data, DRAM
 *                 [# 218] 0x00009b400000-0x00009b5fffff, RW_Data, DRAM
 *                 [# 219] 0x00009b600000-0x00009b7fffff, RW_Data, DRAM
 *                 [# 220] 0x00009b800000-0x00009b9fffff, RW_Data, DRAM
 *                 [# 221] 0x00009ba00000-0x00009bbfffff, RW_Data, DRAM
 *                 [# 222] 0x00009bc00000-0x00009bdfffff, RW_Data, DRAM
 *                 [# 223] 0x00009be00000-0x00009bffffff, RW_Data, DRAM
 *                 [# 224] 0x00009c000000-0x00009c1fffff, RW_Data, DRAM
 *                 [# 225] 0x00009c200000-0x00009c3fffff, RW_Data, DRAM
 *                 [# 226] 0x00009c400000-0x00009c5fffff, RW_Data, DRAM
 *                 [# 227] 0x00009c600000-0x00009c7fffff, RW_Data, DRAM
 *                 [# 228] 0x00009c800000-0x00009c9fffff, RW_Data, DRAM
 *                 [# 229] 0x00009ca00000-0x00009cbfffff, RW_Data, DRAM
 *                 [# 230] 0x00009cc00000-0x00009cdfffff, RW_Data, DRAM
 *                 [# 231] 0x00009ce00000-0x00009cffffff, RW_Data, DRAM
 *                 [# 232] 0x00009d000000-0x00009d1fffff, RW_Data, DRAM
 *                 [# 233] 0x00009d200000-0x00009d3fffff, RW_Data, DRAM
 *                 [# 234] 0x00009d400000-0x00009d5fffff, RW_Data, DRAM
 *                 [# 235] 0x00009d600000-0x00009d7fffff, RW_Data, DRAM
 *                 [# 236] 0x00009d800000-0x00009d9fffff, RW_Data, DRAM
 *                 [# 237] 0x00009da00000-0x00009dbfffff, RW_Data, DRAM
 *                 [# 238] 0x00009dc00000-0x00009ddfffff, RW_Data, DRAM
 *                 [# 239] 0x00009de00000-0x00009dffffff, RW_Data, DRAM
 *                 [# 240] 0x00009e000000-0x00009e1fffff, RW_Data, DRAM
 *                 [# 241] 0x00009e200000-0x00009e3fffff, RW_Data, DRAM
 *                 [# 242] 0x00009e400000-0x00009e5fffff, RW_Data, DRAM
 *                 [# 243] 0x00009e600000-0x00009e7fffff, RW_Data, DRAM
 *                 [# 244] 0x00009e800000-0x00009e9fffff, RW_Data, DRAM
 *                 [# 245] 0x00009ea00000-0x00009ebfffff, RW_Data, DRAM
 *                 [# 246] 0x00009ec00000-0x00009edfffff, RW_Data, DRAM
 *                 [# 247] 0x00009ee00000-0x00009effffff, RW_Data, DRAM
 *                 [# 248] 0x00009f000000-0x00009f1fffff, RW_Data, DRAM
 *                 [# 249] 0x00009f200000-0x00009f3fffff, RW_Data, DRAM
 *                 [# 250] 0x00009f400000-0x00009f5fffff, RW_Data, DRAM
 *                 [# 251] 0x00009f600000-0x00009f7fffff, RW_Data, DRAM
 *                 [# 252] 0x00009f800000-0x00009f9fffff, RW_Data, DRAM
 *                 [# 253] 0x00009fa00000-0x00009fbfffff, RW_Data, DRAM
 *                 [# 254] 0x00009fc00000-0x00009fdfffff, RW_Data, DRAM
 *                 [# 255] 0x00009fe00000-0x00009fffffff, RW_Data, DRAM
 *                 [# 256] 0x0000a0000000-0x0000a01fffff, RW_Data, DRAM
 *                 [# 257] 0x0000a0200000-0x0000a03fffff, RW_Data, DRAM
 *                 [# 258] 0x0000a0400000-0x0000a05fffff, RW_Data, DRAM
 *                 [# 259] 0x0000a0600000-0x0000a07fffff, RW_Data, DRAM
 *                 [# 260] 0x0000a0800000-0x0000a09fffff, RW_Data, DRAM
 *                 [# 261] 0x0000a0a00000-0x0000a0bfffff, RW_Data, DRAM
 *                 [# 262] 0x0000a0c00000-0x0000a0dfffff, RW_Data, DRAM
 *                 [# 263] 0x0000a0e00000-0x0000a0ffffff, RW_Data, DRAM
 *                 [# 264] 0x0000a1000000-0x0000a11fffff, RW_Data, DRAM
 *                 [# 265] 0x0000a1200000-0x0000a13fffff, RW_Data, DRAM
 *                 [# 266] 0x0000a1400000-0x0000a15fffff, RW_Data, DRAM
 *                 [# 267] 0x0000a1600000-0x0000a17fffff, RW_Data, DRAM
 *                 [# 268] 0x0000a1800000-0x0000a19fffff, RW_Data, DRAM
 *                 [# 269] 0x0000a1a00000-0x0000a1bfffff, RW_Data, DRAM
 *                 [# 270] 0x0000a1c00000-0x0000a1dfffff, RW_Data, DRAM
 *                 [# 271] 0x0000a1e00000-0x0000a1ffffff, RW_Data, DRAM
 *                 [# 272] 0x0000a2000000-0x0000a21fffff, RW_Data, DRAM
 *                 [# 273] 0x0000a2200000-0x0000a23fffff, RW_Data, DRAM
 *                 [# 274] 0x0000a2400000-0x0000a25fffff, RW_Data, DRAM
 *                 [# 275] 0x0000a2600000-0x0000a27fffff, RW_Data, DRAM
 *                 [# 276] 0x0000a2800000-0x0000a29fffff, RW_Data, DRAM
 *                 [# 277] 0x0000a2a00000-0x0000a2bfffff, RW_Data, DRAM
 *                 [# 278] 0x0000a2c00000-0x0000a2dfffff, RW_Data, DRAM
 *                 [# 279] 0x0000a2e00000-0x0000a2ffffff, RW_Data, DRAM
 *                 [# 280] 0x0000a3000000-0x0000a31fffff, RW_Data, DRAM
 *                 [# 281] 0x0000a3200000-0x0000a33fffff, RW_Data, DRAM
 *                 [# 282] 0x0000a3400000-0x0000a35fffff, RW_Data, DRAM
 *                 [# 283] 0x0000a3600000-0x0000a37fffff, RW_Data, DRAM
 *                 [# 284] 0x0000a3800000-0x0000a39fffff, RW_Data, DRAM
 *                 [# 285] 0x0000a3a00000-0x0000a3bfffff, RW_Data, DRAM
 *                 [# 286] 0x0000a3c00000-0x0000a3dfffff, RW_Data, DRAM
 *                 [# 287] 0x0000a3e00000-0x0000a3ffffff, RW_Data, DRAM
 *                 [# 288] 0x0000a4000000-0x0000a41fffff, RW_Data, DRAM
 *                 [# 289] 0x0000a4200000-0x0000a43fffff, RW_Data, DRAM
 *                 [# 290] 0x0000a4400000-0x0000a45fffff, RW_Data, DRAM
 *                 [# 291] 0x0000a4600000-0x0000a47fffff, RW_Data, DRAM
 *                 [# 292] 0x0000a4800000-0x0000a49fffff, RW_Data, DRAM
 *                 [# 293] 0x0000a4a00000-0x0000a4bfffff, RW_Data, DRAM
 *                 [# 294] 0x0000a4c00000-0x0000a4dfffff, RW_Data, DRAM
 *                 [# 295] 0x0000a4e00000-0x0000a4ffffff, RW_Data, DRAM
 *                 [# 296] 0x0000a5000000-0x0000a51fffff, RW_Data, DRAM
 *                 [# 297] 0x0000a5200000-0x0000a53fffff, RW_Data, DRAM
 *                 [# 298] 0x0000a5400000-0x0000a55fffff, RW_Data, DRAM
 *                 [# 299] 0x0000a5600000-0x0000a57fffff, RW_Data, DRAM
 *                 [# 300] 0x0000a5800000-0x0000a59fffff, RW_Data, DRAM
 *                 [# 301] 0x0000a5a00000-0x0000a5bfffff, RW_Data, DRAM
 *                 [# 302] 0x0000a5c00000-0x0000a5dfffff, RW_Data, DRAM
 *                 [# 303] 0x0000a5e00000-0x0000a5ffffff, RW_Data, DRAM
 *                 [# 304] 0x0000a6000000-0x0000a61fffff, RW_Data, DRAM
 *                 [# 305] 0x0000a6200000-0x0000a63fffff, RW_Data, DRAM
 *                 [# 306] 0x0000a6400000-0x0000a65fffff, RW_Data, DRAM
 *                 [# 307] 0x0000a6600000-0x0000a67fffff, RW_Data, DRAM
 *                 [# 308] 0x0000a6800000-0x0000a69fffff, RW_Data, DRAM
 *                 [# 309] 0x0000a6a00000-0x0000a6bfffff, RW_Data, DRAM
 *                 [# 310] 0x0000a6c00000-0x0000a6dfffff, RW_Data, DRAM
 *                 [# 311] 0x0000a6e00000-0x0000a6ffffff, RW_Data, DRAM
 *                 [# 312] 0x0000a7000000-0x0000a71fffff, RW_Data, DRAM
 *                 [# 313] 0x0000a7200000-0x0000a73fffff, RW_Data, DRAM
 *                 [# 314] 0x0000a7400000-0x0000a75fffff, RW_Data, DRAM
 *                 [# 315] 0x0000a7600000-0x0000a77fffff, RW_Data, DRAM
 *                 [# 316] 0x0000a7800000-0x0000a79fffff, RW_Data, DRAM
 *                 [# 317] 0x0000a7a00000-0x0000a7bfffff, RW_Data, DRAM
 *                 [# 318] 0x0000a7c00000-0x0000a7dfffff, RW_Data, DRAM
 *                 [# 319] 0x0000a7e00000-0x0000a7ffffff, RW_Data, DRAM
 *                 [# 320] 0x0000a8000000-0x0000a81fffff, RW_Data, DRAM
 *                 [# 321] 0x0000a8200000-0x0000a83fffff, RW_Data, DRAM
 *                 [# 322] 0x0000a8400000-0x0000a85fffff, RW_Data, DRAM
 *                 [# 323] 0x0000a8600000-0x0000a87fffff, RW_Data, DRAM
 *                 [# 324] 0x0000a8800000-0x0000a89fffff, RW_Data, DRAM
 *                 [# 325] 0x0000a8a00000-0x0000a8bfffff, RW_Data, DRAM
 *                 [# 326] 0x0000a8c00000-0x0000a8dfffff, RW_Data, DRAM
 *                 [# 327] 0x0000a8e00000-0x0000a8ffffff, RW_Data, DRAM
 *                 [# 328] 0x0000a9000000-0x0000a91fffff, RW_Data, DRAM
 *                 [# 329] 0x0000a9200000-0x0000a93fffff, RW_Data, DRAM
 *                 [# 330] 0x0000a9400000-0x0000a95fffff, RW_Data, DRAM
 *                 [# 331] 0x0000a9600000-0x0000a97fffff, RW_Data, DRAM
 *                 [# 332] 0x0000a9800000-0x0000a99fffff, RW_Data, DRAM
 *                 [# 333] 0x0000a9a00000-0x0000a9bfffff, RW_Data, DRAM
 *                 [# 334] 0x0000a9c00000-0x0000a9dfffff, RW_Data, DRAM
 *                 [# 335] 0x0000a9e00000-0x0000a9ffffff, RW_Data, DRAM
 *                 [# 336] 0x0000aa000000-0x0000aa1fffff, RW_Data, DRAM
 *                 [# 337] 0x0000aa200000-0x0000aa3fffff, RW_Data, DRAM
 *                 [# 338] 0x0000aa400000-0x0000aa5fffff, RW_Data, DRAM
 *                 [# 339] 0x0000aa600000-0x0000aa7fffff, RW_Data, DRAM
 *                 [# 340] 0x0000aa800000-0x0000aa9fffff, RW_Data, DRAM
 *                 [# 341] 0x0000aaa00000-0x0000aabfffff, RW_Data, DRAM
 *                 [# 342] 0x0000aac00000-0x0000aadfffff, RW_Data, DRAM
 *                 [# 343] 0x0000aae00000-0x0000aaffffff, RW_Data, DRAM
 *                 [# 344] 0x0000ab000000-0x0000ab1fffff, RW_Data, DRAM
 *                 [# 345] 0x0000ab200000-0x0000ab3fffff, RW_Data, DRAM
 *                 [# 346] 0x0000ab400000-0x0000ab5fffff, RW_Data, DRAM
 *                 [# 347] 0x0000ab600000-0x0000ab7fffff, RW_Data, DRAM
 *                 [# 348] 0x0000ab800000-0x0000ab9fffff, RW_Data, DRAM
 *                 [# 349] 0x0000aba00000-0x0000abbfffff, RW_Data, DRAM
 *                 [# 350] 0x0000abc00000-0x0000abdfffff, RW_Data, DRAM
 *                 [# 351] 0x0000abe00000-0x0000abffffff, RW_Data, DRAM
 *                 [# 352] 0x0000ac000000-0x0000ac1fffff, RW_Data, DRAM
 *                 [# 353] 0x0000ac200000-0x0000ac3fffff, RW_Data, DRAM
 *                 [# 354] 0x0000ac400000-0x0000ac5fffff, RW_Data, DRAM
 *                 [# 355] 0x0000ac600000-0x0000ac7fffff, RW_Data, DRAM
 *                 [# 356] 0x0000ac800000-0x0000ac9fffff, RW_Data, DRAM
 *                 [# 357] 0x0000aca00000-0x0000acbfffff, RW_Data, DRAM
 *                 [# 358] 0x0000acc00000-0x0000acdfffff, RW_Data, DRAM
 *                 [# 359] 0x0000ace00000-0x0000acffffff, RW_Data, DRAM
 *                 [# 360] 0x0000ad000000-0x0000ad1fffff, RW_Data, DRAM
 *                 [# 361] 0x0000ad200000-0x0000ad3fffff, RW_Data, DRAM
 *                 [# 362] 0x0000ad400000-0x0000ad5fffff, RW_Data, DRAM
 *                 [# 363] 0x0000ad600000-0x0000ad7fffff, RW_Data, DRAM
 *                 [# 364] 0x0000ad800000-0x0000ad9fffff, RW_Data, DRAM
 *                 [# 365] 0x0000ada00000-0x0000adbfffff, RW_Data, DRAM
 *                 [# 366] 0x0000adc00000-0x0000addfffff, RW_Data, DRAM
 *                 [# 367] 0x0000ade00000-0x0000adffffff, RW_Data, DRAM
 *                 [# 368] 0x0000ae000000-0x0000ae1fffff, RW_Data, DRAM
 *                 [# 369] 0x0000ae200000-0x0000ae3fffff, RW_Data, DRAM
 *                 [# 370] 0x0000ae400000-0x0000ae5fffff, RW_Data, DRAM
 *                 [# 371] 0x0000ae600000-0x0000ae7fffff, RW_Data, DRAM
 *                 [# 372] 0x0000ae800000-0x0000ae9fffff, RW_Data, DRAM
 *                 [# 373] 0x0000aea00000-0x0000aebfffff, RW_Data, DRAM
 *                 [# 374] 0x0000aec00000-0x0000aedfffff, RW_Data, DRAM
 *                 [# 375] 0x0000aee00000-0x0000aeffffff, RW_Data, DRAM
 *                 [# 376] 0x0000af000000-0x0000af1fffff, RW_Data, DRAM
 *                 [# 377] 0x0000af200000-0x0000af3fffff, RW_Data, DRAM
 *                 [# 378] 0x0000af400000-0x0000af5fffff, RW_Data, DRAM
 *                 [# 379] 0x0000af600000-0x0000af7fffff, RW_Data, DRAM
 *                 [# 380] 0x0000af800000-0x0000af9fffff, RW_Data, DRAM
 *                 [# 381] 0x0000afa00000-0x0000afbfffff, RW_Data, DRAM
 *                 [# 382] 0x0000afc00000-0x0000afdfffff, RW_Data, DRAM
 *                 [# 383] 0x0000afe00000-0x0000afffffff, RW_Data, DRAM
 *                 [# 384] 0x0000b0000000-0x0000b01fffff, RW_Data, DRAM
 *                 [# 385] 0x0000b0200000-0x0000b03fffff, RW_Data, DRAM
 *                 [# 386] 0x0000b0400000-0x0000b05fffff, RW_Data, DRAM
 *                 [# 387] 0x0000b0600000-0x0000b07fffff, RW_Data, DRAM
 *                 [# 388] 0x0000b0800000-0x0000b09fffff, RW_Data, DRAM
 *                 [# 389] 0x0000b0a00000-0x0000b0bfffff, RW_Data, DRAM
 *                 [# 390] 0x0000b0c00000-0x0000b0dfffff, RW_Data, DRAM
 *                 [# 391] 0x0000b0e00000-0x0000b0ffffff, RW_Data, DRAM
 *                 [# 392] 0x0000b1000000-0x0000b11fffff, RW_Data, DRAM
 *                 [# 393] 0x0000b1200000-0x0000b13fffff, RW_Data, DRAM
 *                 [# 394] 0x0000b1400000-0x0000b15fffff, RW_Data, DRAM
 *                 [# 395] 0x0000b1600000-0x0000b17fffff, RW_Data, DRAM
 *                 [# 396] 0x0000b1800000-0x0000b19fffff, RW_Data, DRAM
 *                 [# 397] 0x0000b1a00000-0x0000b1bfffff, RW_Data, DRAM
 *                 [# 398] 0x0000b1c00000-0x0000b1dfffff, RW_Data, DRAM
 *                 [# 399] 0x0000b1e00000-0x0000b1ffffff, RW_Data, DRAM
 *                 [# 400] 0x0000b2000000-0x0000b21fffff, RW_Data, DRAM
 *                 [# 401] 0x0000b2200000-0x0000b23fffff, RW_Data, DRAM
 *                 [# 402] 0x0000b2400000-0x0000b25fffff, RW_Data, DRAM
 *                 [# 403] 0x0000b2600000-0x0000b27fffff, RW_Data, DRAM
 *                 [# 404] 0x0000b2800000-0x0000b29fffff, RW_Data, DRAM
 *                 [# 405] 0x0000b2a00000-0x0000b2bfffff, RW_Data, DRAM
 *                 [# 406] 0x0000b2c00000-0x0000b2dfffff, RW_Data, DRAM
 *                 [# 407] 0x0000b2e00000-0x0000b2ffffff, RW_Data, DRAM
 *                 [# 408] 0x0000b3000000-0x0000b31fffff, RW_Data, DRAM
 *                 [# 409] 0x0000b3200000-0x0000b33fffff, RW_Data, DRAM
 *                 [# 410] 0x0000b3400000-0x0000b35fffff, RW_Data, DRAM
 *                 [# 411] 0x0000b3600000-0x0000b37fffff, RW_Data, DRAM
 *                 [# 412] 0x0000b3800000-0x0000b39fffff, RW_Data, DRAM
 *                 [# 413] 0x0000b3a00000-0x0000b3bfffff, RW_Data, DRAM
 *                 [# 414] 0x0000b3c00000-0x0000b3dfffff, RW_Data, DRAM
 *                 [# 415] 0x0000b3e00000-0x0000b3ffffff, RW_Data, DRAM
 *                 [# 416] 0x0000b4000000-0x0000b41fffff, RW_Data, DRAM
 *                 [# 417] 0x0000b4200000-0x0000b43fffff, RW_Data, DRAM
 *                 [# 418] 0x0000b4400000-0x0000b45fffff, RW_Data, DRAM
 *                 [# 419] 0x0000b4600000-0x0000b47fffff, RW_Data, DRAM
 *                 [# 420] 0x0000b4800000-0x0000b49fffff, RW_Data, DRAM
 *                 [# 421] 0x0000b4a00000-0x0000b4bfffff, RW_Data, DRAM
 *                 [# 422] 0x0000b4c00000-0x0000b4dfffff, RW_Data, DRAM
 *                 [# 423] 0x0000b4e00000-0x0000b4ffffff, RW_Data, DRAM
 *                 [# 424] 0x0000b5000000-0x0000b51fffff, RW_Data, DRAM
 *                 [# 425] 0x0000b5200000-0x0000b53fffff, RW_Data, DRAM
 *                 [# 426] 0x0000b5400000-0x0000b55fffff, RW_Data, DRAM
 *                 [# 427] 0x0000b5600000-0x0000b57fffff, RW_Data, DRAM
 *                 [# 428] 0x0000b5800000-0x0000b59fffff, RW_Data, DRAM
 *                 [# 429] 0x0000b5a00000-0x0000b5bfffff, RW_Data, DRAM
 *                 [# 430] 0x0000b5c00000-0x0000b5dfffff, RW_Data, DRAM
 *                 [# 431] 0x0000b5e00000-0x0000b5ffffff, RW_Data, DRAM
 *                 [# 432] 0x0000b6000000-0x0000b61fffff, RW_Data, DRAM
 *                 [# 433] 0x0000b6200000-0x0000b63fffff, RW_Data, DRAM
 *                 [# 434] 0x0000b6400000-0x0000b65fffff, RW_Data, DRAM
 *                 [# 435] 0x0000b6600000-0x0000b67fffff, RW_Data, DRAM
 *                 [# 436] 0x0000b6800000-0x0000b69fffff, RW_Data, DRAM
 *                 [# 437] 0x0000b6a00000-0x0000b6bfffff, RW_Data, DRAM
 *                 [# 438] 0x0000b6c00000-0x0000b6dfffff, RW_Data, DRAM
 *                 [# 439] 0x0000b6e00000-0x0000b6ffffff, RW_Data, DRAM
 *                 [# 440] 0x0000b7000000-0x0000b71fffff, RW_Data, DRAM
 *                 [# 441] 0x0000b7200000-0x0000b73fffff, RW_Data, DRAM
 *                 [# 442] 0x0000b7400000-0x0000b75fffff, RW_Data, DRAM
 *                 [# 443] 0x0000b7600000-0x0000b77fffff, RW_Data, DRAM
 *                 [# 444] 0x0000b7800000-0x0000b79fffff, RW_Data, DRAM
 *                 [# 445] 0x0000b7a00000-0x0000b7bfffff, RW_Data, DRAM
 *                 [# 446] 0x0000b7c00000-0x0000b7dfffff, RW_Data, DRAM
 *                 [# 447] 0x0000b7e00000-0x0000b7ffffff, RW_Data, DRAM
 *                 [# 448] 0x0000b8000000-0x0000b81fffff, RW_Data, DRAM
 *                 [# 449] 0x0000b8200000-0x0000b83fffff, RW_Data, DRAM
 *                 [# 450] 0x0000b8400000-0x0000b85fffff, RW_Data, DRAM
 *                 [# 451] 0x0000b8600000-0x0000b87fffff, RW_Data, DRAM
 *                 [# 452] 0x0000b8800000-0x0000b89fffff, RW_Data, DRAM
 *                 [# 453] 0x0000b8a00000-0x0000b8bfffff, RW_Data, DRAM
 *                 [# 454] 0x0000b8c00000-0x0000b8dfffff, RW_Data, DRAM
 *                 [# 455] 0x0000b8e00000-0x0000b8ffffff, RW_Data, DRAM
 *                 [# 456] 0x0000b9000000-0x0000b91fffff, RW_Data, DRAM
 *                 [# 457] 0x0000b9200000-0x0000b93fffff, RW_Data, DRAM
 *                 [# 458] 0x0000b9400000-0x0000b95fffff, RW_Data, DRAM
 *                 [# 459] 0x0000b9600000-0x0000b97fffff, RW_Data, DRAM
 *                 [# 460] 0x0000b9800000-0x0000b99fffff, RW_Data, DRAM
 *                 [# 461] 0x0000b9a00000-0x0000b9bfffff, RW_Data, DRAM
 *                 [# 462] 0x0000b9c00000-0x0000b9dfffff, RW_Data, DRAM
 *                 [# 463] 0x0000b9e00000-0x0000b9ffffff, RW_Data, DRAM
 *                 [# 464] 0x0000ba000000-0x0000ba1fffff, RW_Data, DRAM
 *                 [# 465] 0x0000ba200000-0x0000ba3fffff, RW_Data, DRAM
 *                 [# 466] 0x0000ba400000-0x0000ba5fffff, RW_Data, DRAM
 *                 [# 467] 0x0000ba600000-0x0000ba7fffff, RW_Data, DRAM
 *                 [# 468] 0x0000ba800000-0x0000ba9fffff, RW_Data, DRAM
 *                 [# 469] 0x0000baa00000-0x0000babfffff, RW_Data, DRAM
 *                 [# 470] 0x0000bac00000-0x0000badfffff, RW_Data, DRAM
 *                 [# 471] 0x0000bae00000-0x0000baffffff, RW_Data, DRAM
 *                 [# 472] 0x0000bb000000-0x0000bb1fffff, RW_Data, DRAM
 *                 [# 473] 0x0000bb200000-0x0000bb3fffff, RW_Data, DRAM
 *                 [# 474] 0x0000bb400000-0x0000bb5fffff, RW_Data, DRAM
 *                 [# 475] 0x0000bb600000-0x0000bb7fffff, RW_Data, DRAM
 *                 [# 476] 0x0000bb800000-0x0000bb9fffff, RW_Data, DRAM
 *                 [# 477] 0x0000bba00000-0x0000bbbfffff, RW_Data, DRAM
 *                 [# 478] 0x0000bbc00000-0x0000bbdfffff, RW_Data, DRAM
 *                 [# 479] 0x0000bbe00000-0x0000bbffffff, RW_Data, DRAM
 *                 [# 480] 0x0000bc000000-0x0000bc1fffff, RW_Data, DRAM
 *                 [# 481] 0x0000bc200000-0x0000bc3fffff, RW_Data, DRAM
 *                 [# 482] 0x0000bc400000-0x0000bc5fffff, RW_Data, DRAM
 *                 [# 483] 0x0000bc600000-0x0000bc7fffff, RW_Data, DRAM
 *                 [# 484] 0x0000bc800000-0x0000bc9fffff, RW_Data, DRAM
 *                 [# 485] 0x0000bca00000-0x0000bcbfffff, RW_Data, DRAM
 *                 [# 486] 0x0000bcc00000-0x0000bcdfffff, RW_Data, DRAM
 *                 [# 487] 0x0000bce00000-0x0000bcffffff, RW_Data, DRAM
 *                 [# 488] 0x0000bd000000-0x0000bd1fffff, RW_Data, DRAM
 *                 [# 489] 0x0000bd200000-0x0000bd3fffff, RW_Data, DRAM
 *                 [# 490] 0x0000bd400000-0x0000bd5fffff, RW_Data, DRAM
 *                 [# 491] 0x0000bd600000-0x0000bd7fffff, RW_Data, DRAM
 *                 [# 492] 0x0000bd800000-0x0000bd9fffff, RW_Data, DRAM
 *                 [# 493] 0x0000bda00000-0x0000bdbfffff, RW_Data, DRAM
 *                 [# 494] 0x0000bdc00000-0x0000bddfffff, RW_Data, DRAM
 *                 [# 495] 0x0000bde00000-0x0000bdffffff, RW_Data, DRAM
 *                 [# 496] 0x0000be000000-0x0000be1fffff, RW_Data, DRAM
 *                 [# 497] 0x0000be200000-0x0000be3fffff, RW_Data, DRAM
 *                 [# 498] 0x0000be400000-0x0000be5fffff, RW_Data, DRAM
 *                 [# 499] 0x0000be600000-0x0000be7fffff, RW_Data, DRAM
 *                 [# 500] 0x0000be800000-0x0000be9fffff, RW_Data, DRAM
 *                 [# 501] 0x0000bea00000-0x0000bebfffff, RW_Data, DRAM
 *                 [# 502] 0x0000bec00000-0x0000bedfffff, RW_Data, DRAM
 *                 [# 503] 0x0000bee00000-0x0000beffffff, RW_Data, DRAM
 *                 [# 504] 0x0000bf000000-0x0000bf1fffff, RW_Data, DRAM
 *                 [# 505] 0x0000bf200000-0x0000bf3fffff, RW_Data, DRAM
 *                 [# 506] 0x0000bf400000-0x0000bf5fffff, RW_Data, DRAM
 *                 [# 507] 0x0000bf600000-0x0000bf7fffff, RW_Data, DRAM
 *                 [# 508] 0x0000bf800000-0x0000bf9fffff, RW_Data, DRAM
 *                 [# 509] 0x0000bfa00000-0x0000bfbfffff, RW_Data, DRAM
 *                 [# 510] 0x0000bfc00000-0x0000bfdfffff, RW_Data, DRAM
 *                 [# 511] 0x0000bfe00000-0x0000bfffffff, RW_Data, DRAM
 *         [#   3] 0x0000c0000000-0x0000ffffffff, RW_Data, DRAM
 *
 * The following command line arguments were passed to arm64-pgtable-tool:
 *
 *      -i examples/dram.txt
 *      -ttb 0x80000000
 *      -el 3
 *      -tg 4K
 *      -tsz 32
 *
 * This memory map requires a total of 3 translation tables.
 * Each table occupies 4K of memory (0x1000 bytes).
 * The buffer pointed to by 0x80000000 must therefore be 3x 4K = 0x3000 bytes long.
 * It is the programmer's responsibility to guarantee this.
 *
 * The programmer must also ensure that the virtual memory region containing the
 * translation tables is itself marked as NORMAL in the memory map file.
 */

    .section .data.mmu
    .balign 2

    mmu_lock: .4byte 0                   // lock to ensure only 1 CPU runs init
    #define LOCKED 1

    mmu_init: .4byte 0                   // whether init has been run
    #define INITIALISED 1

    .section .text.mmu_on
    .balign 2
    .global mmu_on
    .type mmu_on, @function

mmu_on:
zero_out_tables:

    LDR     x2, =0x80000000              // address of first table
    LDR     x3, =0x3000                  // combined length of all tables
    LSR     x3, x3, #5                   // number of required STP instructions
    FMOV    d0, xzr                      // clear q0
1:
    STP     q0, q0, [x2], #32            // zero out 4 table entries at a time
    SUBS    x3, x3, #1
    B.NE    1b

load_descriptor_templates:

    LDR     x2, =0x40000000000705        // Device block
    LDR     x3, =0x40000000000707        // Device page
    LDR     x4, =0x40000000000701        // RW data block
    LDR     x5, =0x40000000000703        // RW data page
    LDR     x20, =0x781                  // code block
    LDR     x21, =0x783                  // code page
    

program_table_0:

    LDR     x8, =0x80000000              // base address of this table
    LDR     x9, =0x40000000              // chunk size

program_table_0_entry_2:

    LDR     x10, =2                      // idx
    LDR     x11, =0x80001000             // next-level table address
    ORR     x11, x11, #0x3               // next-level table descriptor
    STR     x11, [x8, x10, lsl #3]       // write entry into table

program_table_0_entry_3:

    LDR     x10, =3                      // idx
    LDR     x11, =1                      // number of contiguous entries
    LDR     x12, =0xc0000000             // output address of entry[idx]
1:
    ORR     x12, x12, x4                 // merge output address with template
    STR     X12, [x8, x10, lsl #3]       // write entry into table
    ADD     x10, x10, #1                 // prepare for next entry idx+1
    ADD     x12, x12, x9                 // add chunk to address
    SUBS    x11, x11, #1                 // loop as required
    B.NE    1b
program_table_1:

    LDR     x8, =0x80001000              // base address of this table
    LDR     x9, =0x200000                // chunk size

program_table_1_entry_128_to_511:

    LDR     x10, =128                    // idx
    LDR     x11, =384                    // number of contiguous entries
    LDR     x12, =0x90000000             // output address of entry[idx]
1:
    ORR     x12, x12, x4                 // merge output address with template
    STR     X12, [x8, x10, lsl #3]       // write entry into table
    ADD     x10, x10, #1                 // prepare for next entry idx+1
    ADD     x12, x12, x9                 // add chunk to address
    SUBS    x11, x11, #1                 // loop as required
    B.NE    1b
program_table_2:

    LDR     x8, =0x80002000              // base address of this table
    LDR     x9, =0x200000                // chunk size

program_table_2_entry_0_to_127:

    LDR     x10, =0                      // idx
    LDR     x11, =128                    // number of contiguous entries
    LDR     x12, =0xc0000000             // output address of entry[idx]
1:
    ORR     x12, x12, x4                 // merge output address with template
    STR     X12, [x8, x10, lsl #3]       // write entry into table
    ADD     x10, x10, #1                 // prepare for next entry idx+1
    ADD     x12, x12, x9                 // add chunk to address
    SUBS    x11, x11, #1                 // loop as required
    B.NE    1b

init_done:

    MOV     w2, #INITIALISED
    STR     w2, [x1]

end:

    LDR     x1, =0x80000000              // program ttbr0 on this CPU
    MSR     ttbr0_el3, x1
    LDR     x1, =0xff                    // program mair on this CPU
    MSR     mair_el3, x1
    LDR     x1, =0x80803520              // program tcr on this CPU
    MSR     tcr_el3, x1
    ISB
    MRS     x2, tcr_el3                  // verify CPU supports desired config
    CMP     x2, x1
    B.NE    .
    LDR     x1, =0x1005                  // program sctlr on this CPU
    MSR     sctlr_el3, x1
    ISB                                  // synchronize context on this CPU
    RET                                  // done!

More questions in this forum