diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-03-07 17:36:01 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-03-07 17:36:01 +0000 |
commit | f5a5d570a830aad83407734553af6397f4375da2 (patch) | |
tree | 0519906789a665852fdd6134a827460810b7e5e9 | |
parent | 2011-03-04 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff) | |
download | rtems-f5a5d570a830aad83407734553af6397f4375da2.tar.bz2 |
2011-03-07 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1756/bsps
* timer/timer.c: Retry on timer calibration loop failure.
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/ChangeLog | 5 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/timer/timer.c | 36 |
2 files changed, 31 insertions, 10 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/ChangeLog b/c/src/lib/libbsp/i386/pc386/ChangeLog index 97bd34fcb3..4a49cb5bf7 100644 --- a/c/src/lib/libbsp/i386/pc386/ChangeLog +++ b/c/src/lib/libbsp/i386/pc386/ChangeLog @@ -1,3 +1,8 @@ +2011-03-07 Joel Sherrill <joel.sherrilL@OARcorp.com> + + PR 1756/bsps + * timer/timer.c: Retry on timer calibration loop failure. + 2010-11-23 Joel Sherrill <joel.sherrilL@OARcorp.com> * Makefile.am, preinstall.am: Add <bsp/tty_drv.h> to the set of diff --git a/c/src/lib/libbsp/i386/pc386/timer/timer.c b/c/src/lib/libbsp/i386/pc386/timer/timer.c index 534813e789..6f2f5b6a93 100644 --- a/c/src/lib/libbsp/i386/pc386/timer/timer.c +++ b/c/src/lib/libbsp/i386/pc386/timer/timer.c @@ -385,13 +385,20 @@ Calibrate_loop_1ms(void) unsigned int targetClockBits, currentClockBits; unsigned int slowLoopGranularity, fastLoopGranularity; rtems_interrupt_level level; + int retries = 0; + + rtems_interrupt_disable(level); -#ifdef DEBUG_CALIBRATE - printk( "Calibrate_loop_1ms is starting, please wait ( but not too loooong. )\n" ); -#endif +retry: + if ( ++retries >= 5 ) { + printk( "Calibrate_loop_1ms: too many attempts. giving up!!\n" ); + while (1); + } + #ifdef DEBUG_CALIBRATE + printk("Calibrate_loop_1ms is starting, please wait (but not too long.)\n"); + #endif targetClockBits = US_TO_TICK(1000); - rtems_interrupt_disable(level); /* * Fill up the cache to get a correct offset */ @@ -435,8 +442,11 @@ Calibrate_loop_1ms(void) fastLoop (10000); res = readTimer0() - offset; if (res < emptyCall) { - printk("Problem #1 in offset computation in Calibrate_loop_1ms in file libbsp/i386/pc386/timer/timer.c\n"); - while (1); + printk( + "Problem #1 in offset computation in Calibrate_loop_1ms " + " in file libbsp/i386/pc386/timer/timer.c\n" + ); + goto retry; } fastLoopGranularity = (res - emptyCall) / 10000; /* @@ -446,14 +456,20 @@ Calibrate_loop_1ms(void) slowLoop(10); res = readTimer0(); if (res < offset + emptyCall) { - printk("Problem #2 in offset computation in Calibrate_loop_1ms in file libbsp/i386/pc386/timer/timer.c\n"); - while (1); + printk( + "Problem #2 in offset computation in Calibrate_loop_1ms " + " in file libbsp/i386/pc386/timer/timer.c\n" + ); + goto retry; } slowLoopGranularity = (res - offset - emptyCall)/ 10; if (slowLoopGranularity == 0) { - printk("Problem #3 in Calibrate_loop_1ms in file libbsp/i386/pc386/timer/timer.c\n"); - while (1); + printk( + "Problem #3 in offset computation in Calibrate_loop_1ms " + " in file libbsp/i386/pc386/timer/timer.c\n" + ); + goto retry; } targetClockBits += offset; |