All pastes #613080 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-07-10 20:08 UTC
rendered paste body
#define icache_clear_256b()                                                   ;\
  nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop   ;\
  nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop   ;\
  nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop   ;\
  nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop   ;\
  nop; nop; nop; nop;                                                         ;\

#define icache_clear_1kb()                                                    ;\
  icache_clear_256b()                                                         ;\
  icache_clear_256b()                                                         ;\
  icache_clear_256b()                                                         ;\
  icache_clear_256b()                                                         ;\

#define icache_clear_4kb()                                                    ;\
  icache_clear_1kb()                                                          ;\
  icache_clear_1kb()                                                          ;\
  icache_clear_1kb()                                                          ;\
  icache_clear_1kb()                                                          ;\
  subs r2, r2, #1                                                             ;\
  bxeq lr                                                                     ;\


#define icache_clear_16kb()                                                   ;\
  icache_clear_4kb()                                                          ;\
  icache_clear_4kb()                                                          ;\
  icache_clear_4kb()                                                          ;\
  icache_clear_4kb()                                                          ;\


@ This will clear n blocks of 4kb of icache, up to 64kb
@ Pass n in r2.

invalidate_icache_region_software:
  cmp r1, #0                              @ if the size is zero, exit early
  bxeq lr

  icache_clear_16kb()
  icache_clear_16kb()
  icache_clear_16kb()
  icache_clear_16kb()

  bx lr

@ This will clear however much dcache you want, up to 512kb or so
@ Pass the amount to clear in r2.

1:
  .word ewram                             @ a nice random big array

invalidate_dcache_region_software:
  cmp r1, #0
  bxeq lr

  ldr r0, 1b                              @ r0 is a pointer to the array

2:
  ldr r1, [r0], #4                        @ load word
  subs r2, r2, #1
  bne 2b

  bx lr