1 | /* |
---|
2 | * COPYRIGHT (c) 1989-1999. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #include <bsp.h> |
---|
11 | #include <rtems/btimer.h> |
---|
12 | |
---|
13 | bool benchmark_timer_find_average_overhead; |
---|
14 | |
---|
15 | extern rtems_isr Clock_isr(void); |
---|
16 | |
---|
17 | void benchmark_timer_initialize( void ) |
---|
18 | { |
---|
19 | } |
---|
20 | |
---|
21 | /* |
---|
22 | * The following controls the behavior of benchmark_timer_read(). |
---|
23 | * |
---|
24 | * FIND_AVG_OVERHEAD * instructs the routine to return the "raw" count. |
---|
25 | * |
---|
26 | * AVG_OVEREHAD is the overhead for starting and stopping the timer. It |
---|
27 | * is usually deducted from the number returned. |
---|
28 | * |
---|
29 | * LEAST_VALID is the lowest number this routine should trust. Numbers |
---|
30 | * below this are "noise" and zero is returned. |
---|
31 | */ |
---|
32 | |
---|
33 | #define AVG_OVERHEAD 0 /* It typically takes X.X microseconds */ |
---|
34 | /* (Y countdowns) to start/stop the timer. */ |
---|
35 | /* This value is in microseconds. */ |
---|
36 | #define LEAST_VALID 1 /* Don't trust a clicks value lower than this */ |
---|
37 | |
---|
38 | /* |
---|
39 | * Return timer value in 1/2-microsecond units |
---|
40 | */ |
---|
41 | uint32_t benchmark_timer_read( void ) |
---|
42 | { |
---|
43 | uint32_t total; |
---|
44 | total = 0; |
---|
45 | |
---|
46 | if ( benchmark_timer_find_average_overhead == true ) |
---|
47 | return total; /* in XXX microsecond units */ |
---|
48 | |
---|
49 | if ( total < LEAST_VALID ) |
---|
50 | return 0; /* below timer resolution */ |
---|
51 | |
---|
52 | return (total - AVG_OVERHEAD); |
---|
53 | } |
---|
54 | |
---|
55 | void benchmark_timer_disable_subtracting_average_overhead( |
---|
56 | bool find_flag |
---|
57 | ) |
---|
58 | { |
---|
59 | benchmark_timer_find_average_overhead = find_flag; |
---|
60 | } |
---|