@@ -161,7 +161,7 @@ InitEL3:
161161 orr w1 , w1 , #( 1 << 1 ) / * Set IRQ bit (IRQs routed to EL3) * /
162162 msr SCR_EL3 , x1
163163
164- / * configure cpu auxiliary control register EL1 * /
164+ / * Configure cpu auxiliary control register EL1 * /
165165 ldr x0 , = 0x80CA000 / * L1 Data prefetch control - 5 , Enable device split throttle , 2 independent data prefetch streams * /
166166#if CONFIG_ARM_ERRATA_855873
167167 / * Set ENDCCASCI bit in CPUACTLR_EL1 register , to execute data
@@ -171,11 +171,11 @@ InitEL3:
171171#endif
172172 msr S3_1_C15_C2_0 , x0 / * CPUACTLR_EL1 * /
173173
174- / * program the counter frequency * /
174+ / * Program the counter frequency * /
175175 ldr x0 , =counterfreq
176176 msr CNTFRQ_EL0 , x0
177177
178- / * Enable hardware coherency between cores * /
178+ / * Enable hardware coherency between cores * /
179179 mrs x0 , S3_1_c15_c2_1 / * Read EL1 CPU Extended Control Register * /
180180 orr x0 , x0 , #( 1 << 6 ) / * Set the SMPEN bit * /
181181 msr S3_1_c15_c2_1 , x0 / * Write EL1 CPU Extended Control Register * /
@@ -203,11 +203,11 @@ InitEL3:
203203 msr MAIR_EL3 , x1
204204
205205 / **********************************************
206- * Set up TCR_EL3
207- * Physical Address Size PS = 010 - > 40bits 1TB
208- * Granual Size TG0 = 00 - > 4KB
209- * size offset of the memory region T0SZ = 24 - > (region size 2 ^( 64 - 24 ) = 2 ^ 40 )
210- *************************************************** /
206+ * Set up TCR_EL3
207+ * Physical Address Size PS = 010 - > 40bits 1TB
208+ * Granual Size TG0 = 00 - > 4KB
209+ * size offset of the memory region T0SZ = 24 - > (region size 2 ^( 64 - 24 ) = 2 ^ 40 )
210+ *************************************************** /
211211 ldr x1 , = 0x80823518
212212
213213 msr TCR_EL3 , x1
@@ -240,13 +240,59 @@ InitEL2:
240240 ldr x1 , =vector_base
241241 msr VBAR_EL2 , x1
242242
243- mov x0 , # 0x33ff
244- msr CPTR_EL2 , x0 / * Enable FP/SIMD * /
245-
246243 / * Define stack pointer for current exception level * /
247244 ldr x2 , =EL2_stack
248245 mov sp , x2
249246
247+ mov x0 , # 0x33ff
248+ msr CPTR_EL2 , x0 / * Enable FP/SIMD * /
249+
250+ / * Invalidate TLB * /
251+ tlbi alle2
252+ / * Invalidate ICache * /
253+ ic ialluis
254+ isb sy
255+ / * Invalidate DCache * /
256+ bl invalidate_dcaches
257+ dsb sy
258+ isb
259+
260+ ldr x1 , =L0Table / * Get address of level 0 for TTBR0_EL2 * /
261+ msr TTBR0_EL2 , x1 / * Set TTBR0_EL2 * /
262+
263+ / **********************************************
264+ * Set up memory attributes
265+ * This equates to:
266+ * 0 = b01000100 = Normal , Inner/Outer Non - Cacheable
267+ * 1 = b11111111 = Normal , Inner/Outer WB/WA/RA
268+ * 2 = b00000000 = Device - nGnRnE
269+ * 3 = b00000100 = Device - nGnRE
270+ * 4 = b10111011 = Normal , Inner/Outer WT/WA/RA
271+ ********************************************** /
272+ ldr x1 , = 0x000000BB0400FF44
273+ msr MAIR_EL2 , x1
274+
275+ / **********************************************
276+ * Set up TCR_EL2
277+ * Physical Address Size PS = 010 - > 40bits 1TB
278+ * Granual Size TG0 = 00 - > 4KB
279+ * size offset of the memory region T0SZ = 24 - > (region size 2 ^( 64 - 24 ) = 2 ^ 40 )
280+ *************************************************** /
281+ ldr x1 , = 0x80823518
282+
283+ msr TCR_EL2 , x1
284+ isb
285+
286+ / * Enable ICache * /
287+ mrs x1 , SCTLR_EL2
288+ orr x1 , x1 , #( 1 << 12 ) / * Enable ICache * /
289+ orr x1 , x1 , #( 1 << 3 ) / * Enable SP alignment check * /
290+ orr x1 , x1 , #( 1 << 2 ) / * Enable DCaches * /
291+ orr x1 , x1 , #( 1 << 0 ) / * Enable MMU * /
292+ msr SCTLR_EL2 , x1
293+ dsb sy
294+ isb
295+
250296 bl boot_entry_C / * jump to start * /
251297#else
252298 / * present exception level and selected exception level mismatch * /
@@ -289,8 +335,7 @@ InitEL1:
289335 msr SCTLR_EL1 , x1
290336 isb
291337
292- TLBI VMALLE1
293-
338+ tlbi VMALLE1
294339 ic IALLU / * Invalidate I cache to PoU * /
295340 bl invalidate_dcaches
296341 dsb sy
@@ -946,9 +991,7 @@ RestorePrevStatefiq:
946991SErrorInterruptHandler:
947992
948993 saveregister
949-
950994 bl SErrorInterrupt
951-
952995 restoreregister
953996 exception_return
954997
0 commit comments