source:
rtems/c/src/lib/libcpu/powerpc/mpc505/timer/timer.c
@
73b5bd5d
Last change on this file since 73b5bd5d was 66c373bf, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/31/04 at 02:04:00 | |
---|---|
|
|
File size: 1.7 KB |
Line | |
---|---|
1 | /* timer.c |
2 | * |
3 | * This file manages the benchmark timer used by the RTEMS Timing Test |
4 | * Suite. Each measured time period is demarcated by calls to |
5 | * Timer_initialize() and Read_timer(). Read_timer() usually returns |
6 | * the number of microseconds since Timer_initialize() exitted. |
7 | * |
8 | * NOTE: It is important that the timer start/stop overhead be |
9 | * determined when porting or modifying this code. |
10 | * |
11 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
12 | * On-Line Applications Research Corporation (OAR). |
13 | * |
14 | * $Id$ |
15 | */ |
16 | |
17 | #include <rtems.h> |
18 | |
19 | rtems_boolean Timer_driver_Find_average_overhead; |
20 | |
21 | static unsigned int volatile lastInitValue; |
22 | |
23 | void Timer_initialize( void ) |
24 | { |
25 | asm volatile( " mftb %0": "=r" (lastInitValue) ); |
26 | } |
27 | |
28 | /* |
29 | * The following controls the behavior of Read_timer(). |
30 | * |
31 | * AVG_OVEREHAD is the overhead for starting and stopping the timer. It |
32 | * is usually deducted from the number returned. |
33 | * |
34 | * LEAST_VALID is the lowest number this routine should trust. Numbers |
35 | * below this are "noise" and zero is returned. |
36 | */ |
37 | |
38 | #define AVG_OVERHEAD 0 /* It typically takes X.X microseconds */ |
39 | /* (Y countdowns) to start/stop the timer. */ |
40 | /* This value is in microseconds. */ |
41 | #define LEAST_VALID 1 /* Don't trust a clicks value lower than this */ |
42 | |
43 | int Read_timer( void ) |
44 | { |
45 | uint32_t value; |
46 | asm volatile ( " mftb %0": "=r" (value) ); |
47 | return value - lastInitValue; |
48 | } |
49 | |
50 | /* |
51 | * Empty function call used in loops to measure basic cost of looping |
52 | * in Timing Test Suite. |
53 | */ |
54 | |
55 | rtems_status_code Empty_function( void ) |
56 | { |
57 | return RTEMS_SUCCESSFUL; |
58 | } |
59 | |
60 | void Set_find_average_overhead( |
61 | rtems_boolean find_flag |
62 | ) |
63 | { |
64 | Timer_driver_Find_average_overhead = find_flag; |
65 | } |
Note: See TracBrowser
for help on using the repository browser.