![]() |
|
|||
File indexing completed on 2025-05-11 08:23:40
0001 /** 0002 * @file 0003 * @brief Timer for Blackfin 0004 * 0005 * This file manages the benchmark timer used by the RTEMS Timing Test 0006 * Suite. Each measured time period is demarcated by calls to 0007 * benchmark_timer_initialize() and benchmark_timer_read(). 0008 * benchmark_timer_read() usually returns the number of microseconds 0009 * since benchmark_timer_initialize() exitted. 0010 */ 0011 0012 /* 0013 * Copyright (c) 2006 by Atos Automacao Industrial Ltda. 0014 * written by Alain Schaefer <alain.schaefer@easc.ch> 0015 * and Antonio Giovanini <antonio@atos.com.br> 0016 * 0017 * The license and distribution terms for this file may be 0018 * found in the file LICENSE in this distribution or at 0019 * http://www.rtems.org/license/LICENSE. 0020 */ 0021 0022 #include <rtems.h> 0023 #include <bsp.h> 0024 #include <rtems/btimer.h> 0025 0026 uint32_t Timer_interrupts; 0027 bool benchmark_timer_find_average_overhead; 0028 0029 /* 0030 * benchmark_timer_initialize 0031 * 0032 * Blackfin processor has a counter for clock cycles. 0033 */ 0034 void benchmark_timer_initialize( void ) 0035 { 0036 0037 /*reset counters*/ 0038 __asm__ ("R2 = 0;"); 0039 __asm__ ("CYCLES = R2;"); 0040 __asm__ ("CYCLES2 = R2;"); 0041 /*start counters*/ 0042 __asm__ ("R2 = SYSCFG;"); 0043 __asm__ ("BITSET(R2,1);"); 0044 __asm__ ("SYSCFG = R2"); 0045 0046 } 0047 0048 /* 0049 * The following controls the behavior of benchmark_timer_read(). 0050 * 0051 * AVG_OVEREHAD is the overhead for starting and stopping the timer. It 0052 * is usually deducted from the number returned. 0053 * 0054 * LEAST_VALID is the lowest number this routine should trust. Numbers 0055 * below this are "noise" and zero is returned. 0056 */ 0057 0058 #define AVG_OVERHEAD 0 /* It typically takes X.X microseconds */ 0059 /* (Y countdowns) to start/stop the timer. */ 0060 /* This value is in microseconds. */ 0061 #define LEAST_VALID 1 /* Don't trust a clicks value lower than this */ 0062 0063 benchmark_timer_t benchmark_timer_read( void ) 0064 { 0065 uint32_t clicks; 0066 uint32_t total; 0067 register uint32_t cycles __asm__ ("R2"); 0068 0069 /* stop counter */ 0070 __asm__ ("R2 = SYSCFG;"); 0071 __asm__ ("BITCLR(R2,1);"); 0072 __asm__ ("SYSCFG = R2;"); 0073 __asm__ ("R2 = CYCLES;"); 0074 0075 0076 clicks = cycles; /* Clock cycles */ 0077 0078 /* converting to microseconds */ 0079 total = clicks / (CCLK/1000000); 0080 0081 if ( benchmark_timer_find_average_overhead == 1 ) 0082 return total; /* in XXX microsecond units */ 0083 else { 0084 if ( total < LEAST_VALID ) 0085 return 0; /* below timer resolution */ 0086 /* 0087 * Somehow convert total into microseconds 0088 */ 0089 return (total - AVG_OVERHEAD); 0090 } 0091 } 0092 0093 void benchmark_timer_disable_subtracting_average_overhead(bool find_flag) 0094 { 0095 benchmark_timer_find_average_overhead = find_flag; 0096 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |