ARM r1p3 Computer Hardware User Manual


 
Debug
ARM DDI 0363E Copyright © 2009 ARM Limited. All rights reserved. 11-59
ID013010 Non-Confidential, Unrestricted Access
For a simple watchpoint, you can program the settings for the other control bits as Table 11-44
shows:
Example 11-8 shows the code for setting a simple aligned watchpoint.
Example 11-8 Setting a simple aligned watchpoint
SetSimpleAlignedWatchpoint(int watch_num, uint32 address, int size)
{
// Step 1. Disable the watchpoint being set.
WriteDebugRegister(112 + watch_num, 0);
// (Step 2. Write address to the WVR, leaving the bottom 3 bits zero.
WriteDebugRegister(96 + watch_num, address & 0xFFFFFF8);
// Step 3. Determine the byte address select value to use.
case (size) of
{
when 1:
byte_address_select := (1 << (address & 7));
when 2:
byte_address_select := (3 << (address & 6));
when 4:
byte_address_select := (15 << (address & 4));
when 8:
byte_address_select := 255;
}
// Step 4. Write the mask and control register to enable the watchpoint.
breakpoint
WriteDebugRegister(112 + watch_num, 23 | (byte_address_select << 5));
}
Setting a simple unaligned watchpoint
Using the byte address select bits, certain unaligned objects up to a doubleword (64 bits) can be
watched in a single watchpoint. However, this cannot cover all cases, and in many cases a
second watchpoint might be required.
Table 11-44 Values to write to WCR for a simple watchpoint
Bits Value to write Description
[31:29]
0b000
Reserved
[28:24]
0b00000
Watchpoint address mask
[23:21]
0b000
Reserved
[20]
0b0
Enable linking
[19:16]
0b0000
Linked BRP number
[15:13]
0b00
Reserved
[12:5] Derived from address Byte address select
[4:3]
0b10
Load/Store access control
[2:1]
0b11
Privileged access control
[0]
0b1
Watchpoint enable