![]() |
|
|||
File indexing completed on 2025-05-11 08:23:51
0001 /** 0002 * @file 0003 * @brief IDT 4650 Timer Driver. 0004 * 0005 * This file manages the benchmark timer used by the RTEMS Timing Test 0006 * Suite. 0007 */ 0008 0009 /* 0010 * Author: Craig Lebakken <craigl@transition.com> 0011 * 0012 * COPYRIGHT (c) 1996 by Transition Networks Inc. 0013 * 0014 * To anyone who acknowledges that this file is provided "AS IS" 0015 * without any express or implied warranty: 0016 * permission to use, copy, modify, and distribute this file 0017 * for any purpose is hereby granted without fee, provided that 0018 * the above copyright notice and this notice appears in all 0019 * copies, and that the name of Transition Networks not be used in 0020 * advertising or publicity pertaining to distribution of the 0021 * software without specific, written prior permission. 0022 * Transition Networks makes no representations about the suitability 0023 * of this software for any purpose. 0024 * 0025 * derived from src/lib/libbsp/no_cpu/no_bsp/timer/timer.c 0026 * 0027 * COPYRIGHT (c) 1989-1999. 0028 * On-Line Applications Research Corporation (OAR). 0029 * 0030 * The license and distribution terms for this file may be 0031 * found in the file LICENSE in this distribution or at 0032 * http://www.rtems.org/license/LICENSE. 0033 */ 0034 0035 #include <rtems.h> 0036 #include <rtems/btimer.h> 0037 0038 #define CLOCKS_PER_MICROSECOND ( CPU_CLOCK_RATE_MHZ ) 0039 #define TIMER_MAX_VALUE 0xffffffff 0040 0041 extern uint32_t mips_read_timer( void ); 0042 0043 static bool benchmark_timer_find_average_overhead; 0044 static uint32_t benchmark_timer_initial_value = 0; 0045 0046 void benchmark_timer_initialize( void ) 0047 { 0048 benchmark_timer_initial_value = mips_read_timer(); 0049 /* 0050 * Somehow start the timer 0051 */ 0052 0053 /* Timer on 4650 is always running */ 0054 } 0055 0056 /* 0057 * The following controls the behavior of benchmark_timer_read(). 0058 * 0059 * AVG_OVEREHAD is the overhead for starting and stopping the timer. It 0060 * is usually deducted from the number returned. 0061 * 0062 * LEAST_VALID is the lowest number this routine should trust. Numbers 0063 * below this are "noise" and zero is returned. 0064 */ 0065 0066 #define AVG_OVERHEAD 8 /* It typically takes X.X microseconds */ 0067 /* (Y countdowns) to start/stop the timer. */ 0068 /* This value is in cycles. */ 0069 #define LEAST_VALID 1 /* Don't trust a clicks value lower than this */ 0070 0071 benchmark_timer_t benchmark_timer_read( void ) 0072 { 0073 uint64_t clicks; 0074 uint32_t total; 0075 0076 /* 0077 * Read the timer and see how many clicks it has been since we started. 0078 */ 0079 0080 clicks = mips_read_timer(); /* XXX: read some HW here */ 0081 if (clicks < benchmark_timer_initial_value) 0082 { 0083 clicks += TIMER_MAX_VALUE; 0084 } 0085 clicks -= benchmark_timer_initial_value; 0086 0087 /* 0088 * Total is calculated by taking into account the number of timer overflow 0089 * interrupts since the timer was initialized and clicks since the last 0090 * interrupts. 0091 */ 0092 #if 0 /* leave total in number of cycles */ 0093 total = clicks / CLOCKS_PER_MICROSECOND; 0094 #else 0095 total = clicks; 0096 #endif 0097 0098 if ( benchmark_timer_find_average_overhead == 1 ) 0099 return total; /* in # cycles units */ 0100 else { 0101 if ( total < LEAST_VALID ) 0102 return 0; /* below timer resolution */ 0103 /* 0104 * leave total in cycles 0105 */ 0106 return (total - AVG_OVERHEAD); 0107 } 0108 } 0109 0110 void benchmark_timer_disable_subtracting_average_overhead(bool find_flag) 0111 { 0112 benchmark_timer_find_average_overhead = find_flag; 0113 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |