summaryrefslogtreecommitdiff
path: root/firmware/target/arm/mmu-arm.S
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/mmu-arm.S')
-rw-r--r--firmware/target/arm/mmu-arm.S107
1 files changed, 63 insertions, 44 deletions
diff --git a/firmware/target/arm/mmu-arm.S b/firmware/target/arm/mmu-arm.S
index 02f1454399..5693ca587b 100644
--- a/firmware/target/arm/mmu-arm.S
+++ b/firmware/target/arm/mmu-arm.S
@@ -171,15 +171,18 @@ enable_mmu:
171/** Cache coherency **/ 171/** Cache coherency **/
172 172
173/* 173/*
174 * Invalidate DCache for this range 174 * Write DCache back to RAM for the given range and remove cache lines
175 * will do write back 175 * from DCache afterwards
176 * void invalidate_dcache_range(const void *base, unsigned int size); 176 * void commit_discard_dcache_range(const void *base, unsigned int size);
177 */ 177 */
178 .section .text, "ax", %progbits 178 .section .text, "ax", %progbits
179 .align 2 179 .align 2
180 .global invalidate_dcache_range 180 .global commit_discard_dcache_range
181 .type invalidate_dcache_range, %function 181 .type commit_discard_dcache_range, %function
182 .global invalidate_dcache_range @ Alias, deprecated
183
182 @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ 184 @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
185commit_discard_dcache_range:
183invalidate_dcache_range: 186invalidate_dcache_range:
184 add r1, r0, r1 @ size -> end 187 add r1, r0, r1 @ size -> end
185 cmp r1, r0 @ end <= start? 188 cmp r1, r0 @ end <= start?
@@ -214,18 +217,20 @@ invalidate_dcache_range:
214 mov r0, #0 @ 217 mov r0, #0 @
215 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer 218 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
216 bx lr @ 219 bx lr @
217 .size invalidate_dcache_range, .-invalidate_dcache_range 220 .size commit_discard_dcache_range, .-commit_discard_dcache_range
218 221
219/* 222/*
220 * clean DCache for this range 223 * Write DCache back to RAM for the given range
221 * forces DCache writeback for the specified range 224 * void commit_dcache_range(const void *base, unsigned int size);
222 * void clean_dcache_range(const void *base, unsigned int size);
223 */ 225 */
224 .section .text, "ax", %progbits 226 .section .text, "ax", %progbits
225 .align 2 227 .align 2
226 .global clean_dcache_range 228 .global commit_dcache_range
227 .type clean_dcache_range, %function 229 .type commit_dcache_range, %function
230 .global clean_dcache_range @ Alias, deprecated
231
228 @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ 232 @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
233commit_dcache_range:
229clean_dcache_range: 234clean_dcache_range:
230 add r1, r0, r1 @ size -> end 235 add r1, r0, r1 @ size -> end
231 cmp r1, r0 @ end <= start? 236 cmp r1, r0 @ end <= start?
@@ -260,19 +265,22 @@ clean_dcache_range:
260 mov r0, #0 @ 265 mov r0, #0 @
261 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer 266 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
262 bx lr @ 267 bx lr @
263 .size clean_dcache_range, .-clean_dcache_range 268 .size commit_dcache_range, .-commit_dcache_range
264 269
265/* 270/*
266 * Dump DCache for this range 271 * Remove cache lines for the given range from DCache
267 * will *NOT* do write back except for buffer edges not on a line boundary 272 * will *NOT* do write back except for buffer edges not on a line boundary
268 * void dump_dcache_range(const void *base, unsigned int size); 273 * void discard_dcache_range(const void *base, unsigned int size);
269 */ 274 */
270 .section .text, "ax", %progbits 275 .section .text, "ax", %progbits
271 .align 2 276 .align 2
272 .global dump_dcache_range 277 .global discard_dcache_range
273 .type dump_dcache_range, %function 278 .type discard_dcache_range, %function
279 .global dump_dcache_range @ Alias, deprecated
280
274 @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ 281 @ MVA format: 31:5 = Modified virtual address, 4:0 = SBZ
275 dump_dcache_range: 282discard_dcache_range:
283dump_dcache_range:
276 add r1, r0, r1 @ size -> end 284 add r1, r0, r1 @ size -> end
277 cmp r1, r0 @ end <= start? 285 cmp r1, r0 @ end <= start?
278 bxls lr @ 286 bxls lr @
@@ -287,7 +295,7 @@ clean_dcache_range:
287 mcrne p15, 0, r1, c7, c14, 1 @ Clean and invalidate line by MVA 295 mcrne p15, 0, r1, c7, c14, 1 @ Clean and invalidate line by MVA
288 @ if not cache aligned 296 @ if not cache aligned
289 cmp r1, r0 @ end <= start now? 297 cmp r1, r0 @ end <= start now?
2901: @ dump_start @ 2981: @ discard_start @
291 mcrhi p15, 0, r0, c7, c6, 1 @ Invalidate line by MVA 299 mcrhi p15, 0, r0, c7, c6, 1 @ Invalidate line by MVA
292 addhi r0, r0, #32 @ 300 addhi r0, r0, #32 @
293 cmphi r1, r0 @ 301 cmphi r1, r0 @
@@ -312,30 +320,35 @@ clean_dcache_range:
312 mcrhi p15, 0, r0, c7, c6, 1 @ Invalidate line by MVA 320 mcrhi p15, 0, r0, c7, c6, 1 @ Invalidate line by MVA
313 addhi r0, r0, #32 @ 321 addhi r0, r0, #32 @
314 cmphi r1, r0 @ 322 cmphi r1, r0 @
315 bhi 1b @ dump_start @ 323 bhi 1b @ discard_start @
316 mov r0, #0 @ 324 mov r0, #0 @
317 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer 325 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
318 bx lr @ 326 bx lr @
319 .size dump_dcache_range, .-dump_dcache_range 327 .size discard_dcache_range, .-discard_dcache_range
320 328
321/* 329/*
322 * Cleans entire DCache 330 * Write entire DCache back to RAM
323 * void clean_dcache(void); 331 * void commit_dcache(void);
324 */ 332 */
325 .section .text, "ax", %progbits 333 .section .text, "ax", %progbits
326 .align 2 334 .align 2
327 .global clean_dcache 335 .global commit_dcache
328 .type clean_dcache, %function 336 .type commit_dcache, %function
329 .global cpucache_flush @ Alias 337 .global cpucache_commit @ Alias
338 .global clean_dcache @ Alias, deprecated
339 .global cpucache_flush @ Alias, deprecated
340
341commit_dcache:
342cpucache_commit:
330clean_dcache: 343clean_dcache:
331cpucache_flush: 344cpucache_flush:
332#ifdef HAVE_TEST_AND_CLEAN_CACHE 345#ifdef HAVE_TEST_AND_CLEAN_CACHE
333 mrc p15, 0, r15, c7, c10, 3 @ test and clean dcache 346 mrc p15, 0, r15, c7, c10, 3 @ test and clean dcache
334 bne clean_dcache 347 bne commit_dcache
335 mov r1, #0 348 mov r1, #0
336#else 349#else
337 mov r1, #0x00000000 @ 350 mov r1, #0x00000000 @
3381: @ clean_start @ 3511: @ commit_start @
339 mcr p15, 0, r1, c7, c10, 2 @ Clean entry by index 352 mcr p15, 0, r1, c7, c10, 2 @ Clean entry by index
340 add r0, r1, #(1<<CACHEALIGN_BITS) 353 add r0, r1, #(1<<CACHEALIGN_BITS)
341 mcr p15, 0, r0, c7, c10, 2 @ Clean entry by index 354 mcr p15, 0, r0, c7, c10, 2 @ Clean entry by index
@@ -344,25 +357,27 @@ cpucache_flush:
344 mcr p15, 0, r0, c7, c10, 2 @ Clean entry by index 357 mcr p15, 0, r0, c7, c10, 2 @ Clean entry by index
345.endr 358.endr
346 adds r1, r1, #0x04000000 @ will wrap to zero at loop end 359 adds r1, r1, #0x04000000 @ will wrap to zero at loop end
347 bne 1b @ clean_start @ 360 bne 1b @ commit_start @
348#endif /* HAVE_TEST_AND_CLEAN_CACHE */ 361#endif /* HAVE_TEST_AND_CLEAN_CACHE */
349 mcr p15, 0, r1, c7, c10, 4 @ Drain write buffer 362 mcr p15, 0, r1, c7, c10, 4 @ Drain write buffer
350 bx lr @ 363 bx lr @
351 .size clean_dcache, .-clean_dcache 364 .size commit_dcache, .-commit_dcache
352 365
353/* 366/*
354 * Invalidate entire DCache 367 * Commit and discard entire DCache, will do writeback
355 * will do writeback 368 * void commit_discard_dcache(void);
356 * void invalidate_dcache(void);
357 */ 369 */
358 .section .icode, "ax", %progbits 370 .section .icode, "ax", %progbits
359 .align 2 371 .align 2
360 .global invalidate_dcache 372 .global commit_discard_dcache
361 .type invalidate_dcache, %function 373 .type commit_discard_dcache, %function
374 .global invalidate_dcache @ Alias, deprecated
375
376commit_discard_dcache:
362invalidate_dcache: 377invalidate_dcache:
363#ifdef HAVE_TEST_AND_CLEAN_CACHE 378#ifdef HAVE_TEST_AND_CLEAN_CACHE
364 mrc p15, 0, r15, c7, c14, 3 @ test, clean and invalidate dcache 379 mrc p15, 0, r15, c7, c14, 3 @ test, clean and invalidate dcache
365 bne invalidate_dcache 380 bne commit_discard_dcache
366 mov r1, #0 381 mov r1, #0
367#else 382#else
368 mov r1, #0x00000000 @ 383 mov r1, #0x00000000 @
@@ -379,22 +394,26 @@ invalidate_dcache:
379#endif /* HAVE_TEST_AND_CLEAN_CACHE */ 394#endif /* HAVE_TEST_AND_CLEAN_CACHE */
380 mcr p15, 0, r1, c7, c10, 4 @ Drain write buffer 395 mcr p15, 0, r1, c7, c10, 4 @ Drain write buffer
381 bx lr @ 396 bx lr @
382 .size invalidate_dcache, .-invalidate_dcache 397 .size commit_discard_dcache, .-commit_discard_dcache
383 398
384/* 399/*
385 * Invalidate entire ICache and DCache 400 * Discards the entire ICache, and commit+discards the entire DCache
386 * will do writeback 401 * void commit_discard_idcache(void);
387 * void invalidate_idcache(void);
388 */ 402 */
389 .section .icode, "ax", %progbits 403 .section .icode, "ax", %progbits
390 .align 2 404 .align 2
391 .global invalidate_idcache 405 .global commit_discard_idcache
392 .type invalidate_idcache, %function 406 .type commit_discard_idcache, %function
393 .global cpucache_invalidate @ Alias 407 .global cpucache_commit_discard @ Alias
408 .global invalidate_idcache @ Alias, deprecated
409 .global cpucache_invalidate @ Alias, deprecated
410
411commit_discard_idcache:
412cpucache_commit_discard:
394invalidate_idcache: 413invalidate_idcache:
395cpucache_invalidate: 414cpucache_invalidate:
396 mov r2, lr @ save lr to r1, call uses r0 only 415 mov r2, lr @ save lr to r1, call uses r0 only
397 bl invalidate_dcache @ Clean and invalidate entire DCache 416 bl commit_discard_dcache @ commit and discard entire DCache
398 mcr p15, 0, r1, c7, c5, 0 @ Invalidate ICache (r1=0 from call) 417 mcr p15, 0, r1, c7, c5, 0 @ Invalidate ICache (r1=0 from call)
399 bx r2 418 bx r2
400 .size invalidate_idcache, .-invalidate_idcache 419 .size commit_discard_idcache, .-commit_discard_idcache