
4-6
Caches
Copyright 2000–2001 by LSI Logic Corporation. All rights reserved.
Clearing bit 12 of the CP15 Control register disables the I-cache. This
action prevents all I-cache look ups and line fills, and forces all instruction
fetches to be performed as single external accesses.
4.2.3 I-Cache Validity
The ARM946E-S does not support external memory snooping.
Therefore, if you write self-modifying code, the instructions in the I-cache
can become incoherent with external memory. Similarly, if you reprogram
the protection regions, code might exist in the cache that should be in a
noncacheable region. In either of these cases, you must flush the
I-cache.
4.2.4 I-Cache Flush
You can flush the entire I-cache by software in one operation, or you can
flush individual cache lines by writing to the CP15 Cache Operations
register (register 7). The I-cache is automatically flushed during reset.
The I-cache never has to be cleaned because its only source of data is
from external memory. (The ARM9E-S processor only performs reads
from the I-cache, except during debug operations.)
Flushing the Entire Cache –
As shown in
Table 3.4
on
page 3-22
, you
can flush the entire I-cache using an MCR instruction. In this case, the
contents of the ARM register transferred to CP15 must be 0. You can use
the following code to do this:
MOV
MCR
r0, #0
p15, r0, c7, c5, 0; Flush entire instruction cache
; Clear r0
Note:
The use of r0 is arbitrary.
Flushing the entire cache also flushes any locked-down code. If you want
to preserve locked-down code, you must flush cache lines individually
and avoid the locked-down lines.
Flushing a Single Cache Line –
You can flush single cache lines. To
do this, you must specify in Rd the address to be flushed from the cache.
You can use the following code to do this:
LDR r0, = FlushAddress; Load r0 with address
FlushAddress
MCR p15, r0, c7, c5, 1; Flush single cache line