05.02.2013 Views

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ARM</strong>v6 Differences<br />

Accessing the Cache Dirty Status Register<br />

To access the Cache Dirty Status Register you read the CP15 registers with set to 0, set to c7,<br />

set to c10, <strong>and</strong> set to 6. For example:<br />

MRC p15, 0, , c7, c10, 6<br />

Cleaning <strong>and</strong> invalidating operations for the entire data cache<br />

The CP15 c7 encodings include operations for cleaning the entire data cache, <strong>and</strong> for performing a clean<br />

<strong>and</strong> invalidate of the entire data cache. If these operations are interrupted, the LR value that is captured on<br />

the interrupt is (address of instruction that launched the cache operation + 4). This permits the st<strong>and</strong>ard<br />

return mechanism for interrupts to restart the operation.<br />

If a particular operation requires that the cache is clean, or clean <strong>and</strong> invalid, then it is essential that the<br />

sequence of instructions for cleaning or cleaning <strong>and</strong> invalidating the cache can cope with the arrival of an<br />

interrupt at any time when interrupts are not disabled. This is because interrupts might write to a previously<br />

cleaned cache block. For this reason, the Cache Dirty Status Register indicates whether the cache has been<br />

written to since the last successful cache clean.<br />

You can interrogate the Cache Dirty Status Register to determine whether the cache is clean, <strong>and</strong> if you do<br />

this while interrupts are disabled, a subsequent operation can rely on having a clean cache. The following<br />

sequence illustrates this approach.<br />

; The following code assumes interrupts are enabled at this point.<br />

Loop1<br />

MOV R1, #0<br />

MCR p15, 0, R1, c7, c10, 0 ; Clean data cache. For Clean <strong>and</strong> Invalidate,<br />

; use MCR p15, 0, R1, c7, c14, 0 instead<br />

MRS R2, CPSR ; Save PSR context<br />

CPSID iaf ; Disable interrupts<br />

MRC p15, 0, R1, c7, c10, 6 ; Read Cache Dirty Status Register<br />

TST R1, #1 ; Check if it is clean<br />

BEQ UseClean<br />

MSR CPSR_xc, R2 ; Re-enable interrupts<br />

B Loop1 ; Clean the cache again<br />

UseClean<br />

Do_Clean_Operations ; Perform whatever operation relies on<br />

; the cache being clean or clean & invalid.<br />

; To reduce impact on interrupt latency,<br />

; this sequence should be short.<br />

MCR p15, 0, R1, c7, c6, 0 ; Optional. Can use this Invalidate all comm<strong>and</strong><br />

; to invalidate a Clean loop.<br />

MSR CPSR_xc, R2 ; Re-enable interrupts<br />

Note<br />

The long cache clean operation is performed with interrupts enabled throughout this routine.<br />

AppxG-40 Copyright © 1996-1998, 2000, 2004-2008 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DDI 0406B

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!