summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-07-06 09:32:22 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-07-06 09:32:22 +0000
commite48e7000b0f88dee06f52bcda8e1e7fafe37afaa (patch)
tree39ddd7814b4ece813101cf43a30607918601218e /src
parent83655bf49bfa03b0c57c20123984cf09c4c09393 (diff)
downloadopenocd+libswd-e48e7000b0f88dee06f52bcda8e1e7fafe37afaa.tar.gz
openocd+libswd-e48e7000b0f88dee06f52bcda8e1e7fafe37afaa.tar.bz2
openocd+libswd-e48e7000b0f88dee06f52bcda8e1e7fafe37afaa.tar.xz
openocd+libswd-e48e7000b0f88dee06f52bcda8e1e7fafe37afaa.zip
10ms timeout check on cp15 read/write
git-svn-id: svn://svn.berlios.de/openocd/trunk@2470 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r--src/target/arm926ejs.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c
index d9c677ff..d5c4cabe 100644
--- a/src/target/arm926ejs.c
+++ b/src/target/arm926ejs.c
@@ -159,8 +159,9 @@ int arm926ejs_cp15_read(target_t *target, uint32_t op1, uint32_t op2, uint32_t C
jtag_add_dr_scan(4, fields, jtag_get_end_state());
- /*TODO: add timeout*/
- do
+ long long then = timeval_ms();
+
+ for (;;)
{
/* rescan with NOP, to wait for the access to complete */
access = 0;
@@ -173,7 +174,19 @@ int arm926ejs_cp15_read(target_t *target, uint32_t op1, uint32_t op2, uint32_t C
{
return retval;
}
- } while (buf_get_u32(&access, 0, 1) != 1);
+
+ if (buf_get_u32(&access, 0, 1) == 1)
+ {
+ break;
+ }
+
+ /* 10ms timeout */
+ if ((timeval_ms()-then)>10)
+ {
+ LOG_ERROR("cp15 read operation timed out");
+ return ERROR_FAIL;
+ }
+ }
#ifdef _DEBUG_INSTRUCTION_EXECUTION_
LOG_DEBUG("addr: 0x%x value: %8.8x", address, *value);
@@ -228,8 +241,10 @@ int arm926ejs_cp15_write(target_t *target, uint32_t op1, uint32_t op2, uint32_t
fields[3].in_value = NULL;
jtag_add_dr_scan(4, fields, jtag_get_end_state());
- /*TODO: add timeout*/
- do
+
+ long long then = timeval_ms();
+
+ for (;;)
{
/* rescan with NOP, to wait for the access to complete */
access = 0;
@@ -239,7 +254,19 @@ int arm926ejs_cp15_write(target_t *target, uint32_t op1, uint32_t op2, uint32_t
{
return retval;
}
- } while (buf_get_u32(&access, 0, 1) != 1);
+
+ if (buf_get_u32(&access, 0, 1) == 1)
+ {
+ break;
+ }
+
+ /* 10ms timeout */
+ if ((timeval_ms()-then)>10)
+ {
+ LOG_ERROR("cp15 write operation timed out");
+ return ERROR_FAIL;
+ }
+ }
#ifdef _DEBUG_INSTRUCTION_EXECUTION_
LOG_DEBUG("addr: 0x%x value: %8.8x", address, value);