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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Debug Register Interfaces<br />

Example C6-4 OS debug register restore sequence, Extended CP14 interface<br />

; On entry, R0 points to a block of saved debug registers.<br />

RestoreDebugRegisters<br />

; (1) Set OS Lock Access Register (DBGOSLAR) <strong>and</strong> reset pointer. The lock<br />

; will already be set, but this write is needed to reset the pointer.<br />

LDR R1, =0xC5ACCE55<br />

MCR p14, 0, R1, c1, c0, 4 ; Write DBGOSLAR<br />

ISB<br />

; (2) Clear the Sticky Power-down Status bit.<br />

MRC p14, 0, R1, c1, c5, 4 ; Read DBGPRSR to clear StickyPD<br />

ISB<br />

; (3) Get the number of words saved.<br />

MRC p14, 0, R1, c1, c2, 4 ; Dummy read of DBGOSSRR<br />

LDR R1, [R0], #4 ; Load size from the save stack<br />

; (4) Loop writing words from the DBGOSSRR.<br />

CMP R1, #0 ; Check for zero<br />

RestoreDebugRegisters_Loop<br />

ITTT NE<br />

LDRNE R2, [R0], #4 ; Load a word from the save stack<br />

MCRNE p14, 0, R2, c1, c2, 4 ; Store a word of data<br />

SUBSNE R1, R1, #1<br />

BNE RestoreDebugRegisters_Loop<br />

; (5) Clear the OS Lock Access Register (DBGOSLAR). Writing any non-key value<br />

; clears the lock, so use the zero value in R1.<br />

ISB<br />

MCR p14, 0, R1, c1, c0, 4 ; Write DBGOSLAR<br />

; (6) A final ISB guarantees the restored register values are visible to subsequent<br />

; instructions.<br />

ISB<br />

; (7) Return the pointer to first word not read. This pointer is already in R0, so<br />

; all that is needed is to return from this function.<br />

BX LR<br />

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

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

Saved successfully!

Ooh no, something went wrong!