Intel Processor Computer Hardware User Manual


 
6-12 March, 2003 Developers Manual
Intel
®
80200 Processor based on Intel
®
XScale
Microarchitecture
Data Cache
6.4 Re-configuring the Data Cache as Data RAM
Software has the ability to lock tags associated with 32-byte lines in the data cache, thus creating
the appearance of data RAM. Any subsequent access to this line always hits the cache unless it is
invalidated. Once a line is locked into the data cache it is no longer available for cache allocation
on a line fill. Up to 28 lines in each set can be reconfigured as data RAM, such that the maximum
data RAM size is 28 Kbytes.
Hardware does not support locking lines into the mini-data cache; any attempt to do this produces
unpredictable results.
There are two methods for locking tags into the data cache; the method of choice depends on the
application. One method is used to lock data that resides in external memory into the data cache
and the other method is used to re-configure lines in the data cache as data RAM. Locking data
from external memory into the data cache is useful for lookup tables, constants, and any other data
that is frequently accessed. Re-configuring a portion of the data cache as data RAM is useful when
an application needs scratch memory (bigger than the register file can provide) for frequently used
variables. These variables may be strewn across memory, making it advantageous for software to
pack them into data RAM memory.
Code examples for these two applications are shown in Example 6-3 on page 6-13 and Example
6-4 on page 6-14. The difference between these two routines is that Example 6-3 on page 6-13
actually requests the entire line of data from external memory and Example 6-4 on page 6-14 uses
the line-allocate operation to lock the tag into the cache. No external memory request is made,
which means software can map any unallocated area of memory as data RAM. However, the
line-allocate operation does validate the target address with the MMU, so system software must
ensure that the memory has a valid descriptor in the page table.
Another item to note in Example 6-4 on page 6-14 is that the 32 bytes of data located in a newly
allocated line in the cache must be initialized by software before it can be read. The line allocate
operation does not initialize the 32 bytes and therefore reading from that line produces
unpredictable results.
In both examples, the code drains the pending loads before and after locking data. This step ensures
that outstanding loads do not end up in the wrong place—either unintentionally locked into the
cache or not locked at all. Note also that a drain operation has been placed after the operation that
locks the tag into the cache. This drain ensures predictable results if a programmer tries to lock
more than 28 lines in a set; the tag gets allocated in this case but not locked into the cache.