
Caches and Write Buffer
4-8
Copyright 1999, 2000 ARM Limited. All rights reserved.
ARM DDI 0144B
4.3
DCache
The ARM940T has a 4KB DCache comprising 256 lines of 16 bytes (four words),
arranged as four 64-way associative segments. The DCache uses the physical address
generated by the processor core. It uses an
allocate on read-miss
policy, and is always
reloaded a cache line (four words) at a time through the external interface.
The DCache supports both
Write-Back
(WB) and
Write-Through
(WT) modes. For data
stores that hit in the DCache, in WB mode the cache line is updated, and an additional
dirty bit associated with the cache line is set. This indicates that the internal version of
the data differs from that in the external memory. In WT mode, a store that hits in the
DCache causes the cache line to be updated but not marked as dirty, because the data
store is also written to the write buffer to keep the external memory consistent. In both
WB and WT modes, a store that misses in the cache is sent to the write buffer. When a
line fetch causes a cache line to be evicted from the DCache, the dirty bit for the victim
line is read and if the line contains valid and dirty data, it is written back to the write
buffer before the linefill replaces it.
The GCd bit and the GBd bit control the DCache behavior. For this reason the
protection unit must be enabled when the DCache is enabled.
4.3.1
Enabling and disabling the DCache
You can enable the DCache by writing to bit 2 of the CP15 control register. You must
only enable the cache if you have already enabled the protection unit, or if you enable
them simultaneously. You can enable the DCache and protection unit simultaneously
with a single write to the CP15 control register.
You can disable the DCache by clearing bit 2 of the CP15 control register.
The DCache is automatically disabled and flushed on reset.
When the DCache is disabled, DCache searches are prevented. This has the effect of
making all data accesses noncachable and forcing the ARM940T to perform external
accesses. The write buffer control is still decoded from the GBd and the GCd bit. The
GCd bit is forced to 0 (noncachable).
Note
When the caches are disabled their contents are preserved. This means that if a write to
an address that was held in the data cache occurs while the data cache is disabled, the
update does not affect the data cache. If the data cache is then switched back on, it still
holds the out of date version of the data, which appears valid. This results in
unrecoverable data corruption. To prevent this, you are recommended to always clean
and flush the data cache before you disable it