From: oharboe at B. <oh...@ma...> - 2009-07-06 11:32:23
|
Author: oharboe Date: 2009-07-06 11:32:22 +0200 (Mon, 06 Jul 2009) New Revision: 2470 Modified: trunk/src/target/arm926ejs.c Log: 10ms timeout check on cp15 read/write Modified: trunk/src/target/arm926ejs.c =================================================================== --- trunk/src/target/arm926ejs.c 2009-07-06 09:28:37 UTC (rev 2469) +++ trunk/src/target/arm926ejs.c 2009-07-06 09:32:22 UTC (rev 2470) @@ -159,8 +159,9 @@ 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 @@ { 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 @@ 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,8 +254,20 @@ { 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); #endif |