09.12.2012 Views

Cortex-A8 Technical Reference Manual - ARM Information Center

Cortex-A8 Technical Reference Manual - ARM Information Center

Cortex-A8 Technical Reference Manual - ARM Information Center

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.

Writing the CPSR in debug state<br />

Example 12-17 shows the code for writing the CPSR.<br />

WriteCPSR(uint32 cpsr_val)<br />

{<br />

// Step 1. Save R0.<br />

saved_r0 := ReadRegister(0);<br />

// Step 2. Write the new CPSR value to r0.<br />

WriteRegister(0, cpsr_val);<br />

// Step 3. Execute instruction MSR r0, CPSR through the ITR.<br />

Execute<strong>ARM</strong>Instruction(0xE12FF000);<br />

// Step 4. Execute a PrefetchFlush instruction through the ITR.<br />

Execute<strong>ARM</strong>Instruction(9xEE070F95);<br />

// Step 5. Restore the value of r0.<br />

WriteRegister(0, saved_r0);<br />

}<br />

Reading memory<br />

Example 12-18 shows the code for reading a byte of memory.<br />

Debug<br />

Example 12-17 Writing the CPSR<br />

Example 12-18 Reading a byte of memory<br />

uint8 ReadByte(uint32 address, bool &aborted)<br />

{<br />

// Step 1. Save the values of r0 and r1.<br />

saved_r0 := ReadRegister(0);<br />

saved_r1 := ReadRegister(1);<br />

// Step 2. Write the address to r0.<br />

WriteRegister(0, address);<br />

// Step 3. Execute the instruction LDRB r1,[r0] through the ITR.<br />

Execute<strong>ARM</strong>Instruction(0xE5D01000);<br />

// Step 4. Read the value of r1 that contains the data at the address.<br />

datum := ReadRegister(1);<br />

// Step 5. Restore the corrupted registers r0 and r1.<br />

WriteRegister(0, saved_r0);<br />

WriteRegister(1, saved_r1);<br />

// Step 6. Check the DSCR for a sticky abort.<br />

aborted := CheckForAborts();<br />

return datum;<br />

}<br />

Example 12-19 shows the code for checking for aborts after a memory access.<br />

Example 12-19 Checking for an abort after memory access<br />

bool CheckForAborts()<br />

{<br />

// Step 1. Check the DSCR for a sticky abort.<br />

dscr := ReadDebugRegister(34);<br />

if (dscr & ((1

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

Saved successfully!

Ooh no, something went wrong!