1 | /* |
---|
2 | * This file implements a stub benchmark timer that is sufficient to |
---|
3 | * satisfy linking the RTEMS Benchmarks. |
---|
4 | */ |
---|
5 | |
---|
6 | /* |
---|
7 | * COPYRIGHT (c) 1989-2001. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | */ |
---|
10 | |
---|
11 | #include <bsp.h> |
---|
12 | #include <rtems/btimer.h> |
---|
13 | |
---|
14 | #include <varvects.h> |
---|
15 | |
---|
16 | bool benchmark_timer_find_average_overhead; |
---|
17 | uint32_t benchmark_timer_overhead = 10; |
---|
18 | |
---|
19 | #define TABSR *((uint8_t *)0x340) |
---|
20 | #define TA0MR *((uint8_t *)0x356) |
---|
21 | #define TA0 *((uint16_t *)0x346) |
---|
22 | #define TA0IC *((uint8_t *)0x6c) |
---|
23 | |
---|
24 | static int benchmark_timer_interrupts; |
---|
25 | |
---|
26 | static void __attribute__((interrupt)) timer_ra_interrupt(void); |
---|
27 | |
---|
28 | #define ivec_timer_a0 12 |
---|
29 | |
---|
30 | void __attribute__((interrupt)) |
---|
31 | timer_ra_interrupt(void) |
---|
32 | { |
---|
33 | benchmark_timer_interrupts++; |
---|
34 | TA0IC = 0x05; |
---|
35 | |
---|
36 | } |
---|
37 | |
---|
38 | void benchmark_timer_initialize(void) |
---|
39 | { |
---|
40 | benchmark_timer_interrupts = 0; |
---|
41 | _set_var_vect (timer_ra_interrupt, ivec_timer_a0); |
---|
42 | TA0MR = 0x00; |
---|
43 | TA0 = 0xffff; |
---|
44 | TA0IC = 0x05; |
---|
45 | TABSR = 0x55; |
---|
46 | } |
---|
47 | |
---|
48 | benchmark_timer_t benchmark_timer_read(void) |
---|
49 | { |
---|
50 | uint32_t count; |
---|
51 | |
---|
52 | count = 0xFFFF - TA0; |
---|
53 | count += benchmark_timer_interrupts * 0xFFFFL; |
---|
54 | |
---|
55 | if (!benchmark_timer_find_average_overhead) { |
---|
56 | if ( count > benchmark_timer_overhead ) |
---|
57 | count -= benchmark_timer_overhead; |
---|
58 | else |
---|
59 | count = 0; |
---|
60 | } |
---|
61 | return count; |
---|
62 | } |
---|
63 | |
---|
64 | void benchmark_timer_disable_subtracting_average_overhead( |
---|
65 | bool find_flag |
---|
66 | ) |
---|
67 | { |
---|
68 | benchmark_timer_find_average_overhead = find_flag; |
---|
69 | } |
---|