4.104.114.84.95
Rev | Line | |
---|
[ac7d5ef0] | 1 | /* timer.c |
---|
| 2 | * |
---|
| 3 | * This file manages the interval timer on the PA-RISC. |
---|
| 4 | * |
---|
| 5 | * NOTE: It is important that the timer start/stop overhead be |
---|
| 6 | * determined when porting or modifying this code. |
---|
| 7 | * |
---|
[08311cc3] | 8 | * COPYRIGHT (c) 1989-1999. |
---|
[ac7d5ef0] | 9 | * On-Line Applications Research Corporation (OAR). |
---|
| 10 | * |
---|
[98e4ebf5] | 11 | * The license and distribution terms for this file may be |
---|
| 12 | * found in the file LICENSE in this distribution or at |
---|
[03f2154e] | 13 | * http://www.OARcorp.com/rtems/license.html. |
---|
[ac7d5ef0] | 14 | * |
---|
| 15 | * $Id$ |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | #include <rtems.h> |
---|
| 19 | |
---|
| 20 | volatile rtems_unsigned32 Timer_starting; |
---|
| 21 | rtems_boolean Timer_driver_Find_average_overhead; |
---|
| 22 | |
---|
| 23 | void Timer_initialize() |
---|
| 24 | { |
---|
| 25 | Timer_starting = get_itimer(); |
---|
[8b2ecf85] | 26 | set_eiem(0x80000000); |
---|
[ac7d5ef0] | 27 | } |
---|
| 28 | |
---|
| 29 | #define AVG_OVERHEAD 0 /* It typically takes 3.0 microseconds */ |
---|
| 30 | /* (6 countdowns) to start/stop the timer. */ |
---|
| 31 | #define LEAST_VALID 1 /* Don't trust a value lower than this */ |
---|
| 32 | |
---|
| 33 | int Read_timer() |
---|
| 34 | { |
---|
| 35 | rtems_unsigned32 clicks; |
---|
| 36 | rtems_unsigned32 total; |
---|
| 37 | |
---|
| 38 | clicks = get_itimer(); |
---|
| 39 | |
---|
| 40 | total = clicks - Timer_starting; |
---|
| 41 | |
---|
| 42 | if ( Timer_driver_Find_average_overhead == 1 ) |
---|
| 43 | return total; /* in XXX microsecond units */ |
---|
| 44 | |
---|
| 45 | else { |
---|
| 46 | if ( total < LEAST_VALID ) |
---|
| 47 | return 0; /* below timer resolution */ |
---|
| 48 | return (total - AVG_OVERHEAD); |
---|
| 49 | } |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | rtems_status_code Empty_function( void ) |
---|
| 53 | { |
---|
| 54 | return RTEMS_SUCCESSFUL; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | void Set_find_average_overhead( |
---|
| 58 | rtems_boolean find_flag |
---|
| 59 | ) |
---|
| 60 | { |
---|
| 61 | Timer_driver_Find_average_overhead = find_flag; |
---|
| 62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.