
MOTOROLA
Chapter 4. Instruction and Data Cache Operation
For More Information On This Product,
Go to: www.freescale.com
4-37
Cache Locking
causes the entire data cache to be invalidated. The following assembly code invalidates the
entire data cache (does not flush modified entries):
# Set and then clear the HID0[DCFI] bit, bit 21
mfspr
r1, HID0
mr
r2, r1
ori
r1, r1, 0x0400
mtspr
HID0, r1
mtspr
HID0, r2
sync
4.12.3.1.5 Loading the Data Cache
This section explains loading data into the data cache. The data cache can be loaded in
several ways. The example in this document loads the data from memory. The following
assembly code loads the data cache:
# Assuming interrupts are turned off, cache has been flushed,
# MMU on, and loading from contiguous cacheable memory.
# r6 = Starting address of code to lock
# r20 = Temporary register for loading into
# CTR = Number of cache blocks to lock
loop:
lwz
addi
bdnz
r20, 0(r6)
r6, r6, 32
loop
# Load data into d-cache
# Find next block to load
# CTR = CTR-1, branch if CTR != 0
4.12.3.1.6 Entire Data Cache Locking
Locking of the entire data cache is controlled by the data cache lock bit (HID0[DLOCK],
bit 19). Setting HID0[DLOCK] to 1 locks the entire data cache. To unlock the data, the
HID0[DLOCK] must be cleared to 0. Setting the DLOCK bit must be preceded by a
sync
instruction to prevent the data cache from being locked during a data access. The following
assembly code locks the entire data cache:
# Set the DLOCK bit in HID0 (bit 19)
mfspr
ori
sync
mtspr
r1, HID0
r1, r1, 0x1000
HID0, r1
4.12.3.1.7 Data Cache Way-Locking
Data cache way-locking is controlled by HID2[DWLCK], bits 24–26. Table 4-15 shows the
HID2[DWLCK[0–2]] settings for the G2 core embedded processor.
F
Freescale Semiconductor, Inc.
n
.