source: rtems/c/src/lib/libbsp/mips/csb350/timer/timer.c @ 46432d4

4.104.114.84.95
Last change on this file since 46432d4 was 418899d, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/10/05 at 06:27:31

Eliminate unsigned{8|16|32}.

  • Property mode set to 100644
File size: 1.5 KB
Line 
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
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <assert.h>
16
17#include <bsp.h>
18
19rtems_boolean Timer_driver_Find_average_overhead;
20uint32_t tstart;
21
22void 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
33int Read_timer()
34{
35  uint32_t  total;
36  uint32_t  cnt;
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
53rtems_status_code Empty_function( void )
54{
55  return RTEMS_SUCCESSFUL;
56}
57
58void 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.