![Intel XScale Core Скачать руководство пользователя страница 72](http://html.mh-extra.com/html/intel/xscale-core/xscale-core_developers-manual_2073165072.webp)
72
January, 2004
Developer’s Manual
Intel XScale® Core
Developer’s Manual
Data Cache
Example 6-3. Locking Data into the Data Cache
; R1 contains the virtual address of a region of memory to lock,
; configured with C=1 and B=1
; R0 is the number of 32-byte lines to lock into the data cache. In this
; example 16 lines of data are locked into the cache.
; MMU and data cache are enabled prior to this code.
MACRO DRAIN
MCR P15, 0, R0, C7, C10, 4
; drain pending loads and stores
ENDM
DRAIN
MOV R2, #0x1
MCR P15,0,R2,C9,C2,0
; Put the data cache in lock mode
CPWAIT
MOV R0, #16
LOOP1:
MCR P15,0,R1,C7,C10,1
; Write back the line if it’s dirty in the cache
MCR P15,0,R1, C7,C6,1
; Flush/Invalidate the line from the cache
LDR R2, [R1], #32
; Load and lock 32 bytes of data located at [R1]
; into the data cache. Post-increment the address
; in R1 to the next cache line.
SUBS R0, R0, #1; Decrement loop count
BNE LOOP1
; Turn off data cache locking
MOV R2, #0x0
MCR P15,0,R2,C9,C2,0
; Take the data cache out of lock mode.
CPWAIT