Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:04

0001 /**
0002  * @file
0003  *
0004  * @ingroup raspberrypi
0005  *
0006  * @brief Benchmark timer support.
0007  */
0008 
0009 /*
0010  * Copyright (c) 2013 by Alan Cudmore
0011  *
0012  *  The license and distribution terms for this file may be
0013  *  found in the file LICENSE in this distribution or at
0014  *
0015  *  http://www.rtems.org/license/LICENSE
0016  *
0017  */
0018 
0019 #include <bsp.h>
0020 #include <rtems.h>
0021 #include <rtems/btimer.h>
0022 #include <bsp/raspberrypi.h>
0023 
0024 static bool benchmark_timer_find_average_overhead = false;
0025 
0026 static uint64_t benchmark_timer_base;
0027 
0028 void benchmark_timer_initialize( void )
0029 {
0030   benchmark_timer_base = BCM2835_REG( BCM2835_GPU_TIMER_CLO );
0031 }
0032 
0033 benchmark_timer_t benchmark_timer_read( void )
0034 {
0035   uint32_t delta = BCM2835_REG( BCM2835_GPU_TIMER_CLO ) - benchmark_timer_base;
0036 
0037   if ( benchmark_timer_find_average_overhead ) {
0038     return delta;
0039   } else {
0040     return BCM2835_REG( BCM2835_GPU_TIMER_CLO );
0041   }
0042 }
0043 
0044 void benchmark_timer_disable_subtracting_average_overhead(
0045   bool find_average_overhead )
0046 {
0047   benchmark_timer_find_average_overhead = find_average_overhead;
0048 }