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 | * |
---|
8 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * All rights assigned to U.S. Government, 1994. |
---|
11 | * |
---|
12 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
13 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
14 | * notice must appear in all copies of this file and its derivatives. |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #include <rtems.h> |
---|
20 | |
---|
21 | volatile rtems_unsigned32 Timer_starting; |
---|
22 | rtems_boolean Timer_driver_Find_average_overhead; |
---|
23 | |
---|
24 | void Timer_initialize() |
---|
25 | { |
---|
26 | Timer_starting = get_itimer(); |
---|
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 | } |
---|