RCS file: /usr1/CVS/rtems/c/src/lib/libbsp/i386/pc386/timer/timer.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
|
|
|
24 | 24 | * found in the file LICENSE in this distribution or at |
25 | 25 | * http://www.rtems.com/license/LICENSE. |
26 | 26 | * |
27 | | * $Id: timer.c,v 1.32 2011/02/09 08:22:58 ralf Exp $ |
| 27 | * $Id: timer.c,v 1.33 2011/03/04 21:56:45 joel Exp $ |
28 | 28 | */ |
29 | 29 | |
30 | 30 | #include <stdlib.h> |
… |
… |
|
334 | 334 | unsigned int targetClockBits, currentClockBits; |
335 | 335 | unsigned int slowLoopGranularity, fastLoopGranularity; |
336 | 336 | rtems_interrupt_level level; |
| 337 | int retries = 0; |
337 | 338 | |
| 339 | rtems_interrupt_disable(level); |
| 340 | |
| 341 | retry: |
| 342 | if ( ++retries >= 5 ) { |
| 343 | printk( "Calibrate_loop_1ms: too many attempts. giving up!!\n" ); |
| 344 | while (1); |
| 345 | } |
338 | 346 | #ifdef DEBUG_CALIBRATE |
339 | 347 | printk("Calibrate_loop_1ms is starting, please wait (but not too long.)\n"); |
340 | 348 | #endif |
341 | 349 | targetClockBits = US_TO_TICK(1000); |
342 | | |
343 | | rtems_interrupt_disable(level); |
344 | 350 | /* |
345 | 351 | * Fill up the cache to get a correct offset |
346 | 352 | */ |
… |
… |
|
384 | 390 | fastLoop (10000); |
385 | 391 | res = readTimer0() - offset; |
386 | 392 | if (res < emptyCall) { |
387 | | printk("Problem #1 in offset computation in Calibrate_loop_1ms in file libbsp/i386/pc386/timer/timer.c\n"); |
388 | | while (1); |
| 393 | printk( |
| 394 | "Problem #1 in offset computation in Calibrate_loop_1ms " |
| 395 | " in file libbsp/i386/pc386/timer/timer.c\n" |
| 396 | ); |
| 397 | goto retry; |
389 | 398 | } |
390 | 399 | fastLoopGranularity = (res - emptyCall) / 10000; |
391 | 400 | /* |
… |
… |
|
395 | 404 | slowLoop(10); |
396 | 405 | res = readTimer0(); |
397 | 406 | if (res < offset + emptyCall) { |
398 | | printk("Problem #2 in offset computation in Calibrate_loop_1ms in file libbsp/i386/pc386/timer/timer.c\n"); |
399 | | while (1); |
| 407 | printk( |
| 408 | "Problem #2 in offset computation in Calibrate_loop_1ms " |
| 409 | " in file libbsp/i386/pc386/timer/timer.c\n" |
| 410 | ); |
| 411 | goto retry; |
400 | 412 | } |
401 | 413 | slowLoopGranularity = (res - offset - emptyCall)/ 10; |
402 | 414 | |
403 | 415 | if (slowLoopGranularity == 0) { |
404 | | printk("Problem #3 in Calibrate_loop_1ms in file libbsp/i386/pc386/timer/timer.c\n"); |
405 | | while (1); |
| 416 | printk( |
| 417 | "Problem #3 in offset computation in Calibrate_loop_1ms " |
| 418 | " in file libbsp/i386/pc386/timer/timer.c\n" |
| 419 | ); |
| 420 | goto retry; |
406 | 421 | } |
407 | 422 | |
408 | 423 | targetClockBits += offset; |