Datasheet

4-24 MCF5307 User’s Manual
Cache Management
4.11 Cache Management
The cache can be enabled and congured by using a MOVEC instruction to access CACR.
A hardware reset clears CACR, disabling the cache and removing all conguration
information; however, reset does not affect the tags, state information, and data in the cache.
Set CACR[CINVA] to invalidate the cache before enabling it.
The privileged CPUSHL instruction supports cache management by selectively pushing
and invalidating cache lines. The address register used with CPUSHL directly addresses the
cache’s directory array. The CPUSHL instruction ushes a cache line.
The value of CACR[DPI] determines whether CPUSHL invalidates a cache line after it is
pushed. To push the entire cache, implement a software loop to index through all sets and
through each of the four lines within each set
(a total of 512 lines). The state of CACR[EC]
does not affect the operation of CPUSHL or CACR[CINVA]. Disabling the cache by setting
CACR[EC] makes the cache nonoperational without affecting tags, state information, or
contents.
The contents of An used with CPUSHL specify cache row and line indexes. This differs
from the MC68040 where a physical address is specied. Figure 4-10 shows the An format.
The following code example ushes the entire
cache:
_cache_disable:
nop
move.w #0x2700,SR ;mask off IRQs
jsr _cache_flush ;flush the cache completely
clr.l d0
movec d0,ACR0 ;ACR0 off
movec d0,ACR1 ;ACR1 off
move.l #0x01000000,d0 ;Invalidate and disable cache
movec d0,CACR
rts
_cache_flush:
nop ;synchronize—flush store buffer
moveq.l #0,d0 ;initialize way counter
moveq.l #0,d1 ;initialize set counter
move.l d0,a0 ;initialize cpushl pointer
setloop:
cpushl bc,(a0) ;push cache line a0
add.l #0x0010,a0 ;increment set index by 1
addq.l #1,d1 ;increment set counter
cmpi.l #128,d1 ;are sets for this way done?
bne setloop
moveq.l #0,d1 ;set counter to zero again
addq.l #1,d0 ;increment to next way
31 11 10 4 3 0
0 Set Index Line Index
Figure 4-10. An Format
Fr
eescale S
emiconduct
or
, I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
nc...