4.104.114.84.95
Last change
on this file since e5ef747 was
e5ef747,
checked in by Joel Sherrill <joel.sherrill@…>, on 03/12/07 at 11:17:51
|
2007-03-12 Joel Sherrill <joel@…>
- clock/clockdrv.c, console/console-io.c, include/bsp.h,
network/network.c, start/start.S, startup/bspclean.c,
startup/bspstart.c, timer/timer.c: Correct license URL and/or fix
mistake in copyright notice. Both of these mistakes appear to be from
code submitted after these changes were made previously.
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[7cde240] | 1 | /* |
---|
| 2 | * This file implements a benchmark timer using the count/compare |
---|
| 3 | * CP0 registers. |
---|
| 4 | * |
---|
| 5 | * Copyright (c) 2005 by Cogent Computer Systems |
---|
| 6 | * Written by Jay Monkman <jtm@lopingdog.com> |
---|
| 7 | * |
---|
| 8 | * The license and distribution terms for this file may be |
---|
| 9 | * found in found in the file LICENSE in this distribution or at |
---|
[e5ef747] | 10 | * http://www.rtems.com/license/LICENSE. |
---|
[7cde240] | 11 | * |
---|
| 12 | * $Id$ |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | #include <assert.h> |
---|
| 16 | |
---|
| 17 | #include <bsp.h> |
---|
| 18 | |
---|
| 19 | rtems_boolean Timer_driver_Find_average_overhead; |
---|
[418899d] | 20 | uint32_t tstart; |
---|
[7cde240] | 21 | |
---|
| 22 | void Timer_initialize() |
---|
| 23 | { |
---|
| 24 | asm volatile ("mfc0 %0, $9\n" : "=r" (tstart)); |
---|
| 25 | /* tick time in picooseconds */ |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | #define AVG_OVERHEAD 0 /* It typically takes N instructions */ |
---|
| 29 | /* to start/stop the timer. */ |
---|
| 30 | #define LEAST_VALID 1 /* Don't trust a value lower than this */ |
---|
| 31 | /* tx39 simulator can count instructions. :) */ |
---|
| 32 | |
---|
| 33 | int Read_timer() |
---|
| 34 | { |
---|
[418899d] | 35 | uint32_t total; |
---|
| 36 | uint32_t cnt; |
---|
[7cde240] | 37 | |
---|
| 38 | asm volatile ("mfc0 %0, $9\n" : "=r" (cnt)); |
---|
| 39 | |
---|
| 40 | total = cnt - tstart; |
---|
| 41 | total = (total * 1000) / 396; /* convert to nanoseconds */ |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | if ( Timer_driver_Find_average_overhead == 1 ) |
---|
| 45 | return total; /* in one microsecond units */ |
---|
| 46 | |
---|
| 47 | if ( total < LEAST_VALID ) |
---|
| 48 | return 0; /* below timer resolution */ |
---|
| 49 | |
---|
| 50 | return total - AVG_OVERHEAD; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | rtems_status_code Empty_function( void ) |
---|
| 54 | { |
---|
| 55 | return RTEMS_SUCCESSFUL; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | void Set_find_average_overhead( |
---|
| 59 | rtems_boolean find_flag |
---|
| 60 | ) |
---|
| 61 | { |
---|
| 62 | Timer_driver_Find_average_overhead = find_flag; |
---|
| 63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.