baseport/syborg/specific/highrestimer.h
changeset 2 d55eb581a87c
parent 0 ffa851df0825
equal deleted inserted replaced
1:2fb8b9db1c86 2:d55eb581a87c
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19  * @file
       
    20  * @internalTechnology
       
    21  *
       
    22  * The highrestimer.h header file defines how to access the high resoltion
       
    23  * timer, if one is supported.  This file is used by default if the variant does
       
    24  * not export one to \epoc32\include\nkern. 
       
    25  */
       
    26 
       
    27 #ifndef __HIGHRESTIMER_H__
       
    28 #define __HIGHRESTIMER_H__
       
    29 //
       
    30 // Copyright (c) 2008 Symbian Ltd. All rights reserved.
       
    31 //
       
    32 
       
    33 #include <syborg.h>
       
    34 
       
    35 /**
       
    36  * Macro indicating that a high resolution timer is supported.
       
    37  */
       
    38 #define HAS_HIGH_RES_TIMER
       
    39 
       
    40 /**
       
    41  * Assembler macro to get the the current value of the high res timer and place
       
    42  * it in the specified register.
       
    43  * Reads the 32-bit value from a free-running counter that represents the current time. 
       
    44  * Syborg timers have 'microsecond resolution'. NB. This value comes from the host clock
       
    45  * and so there is a good chance that the kernels tick based notion of time (elapsed) and that
       
    46  * measured by the free running timer will get out of kilter. This affects t_cputime from e32test
       
    47  * amongst other things.
       
    48  */
       
    49 //#define GET_HIGH_RES_TICK_COUNT(Rd) asm("nop");
       
    50 // Hi-jacking r10 for tmp, not good if Rd is R10 -- grepping the the kernel shows it's not (for now)
       
    51 #define GET_HIGH_RES_TICK_COUNT(Rd)						         \
       
    52   asm("push {r10}");										     \
       
    53   asm("mov r10, #2");										     \
       
    54   asm("ldr "#Rd", =%a0"               : : "i" (KHwBaseRtc + 4)); \
       
    55   asm("str r10, ["#Rd", #%a0]"        : : "i" (0));			     \
       
    56   asm("pop {r10}");                                              \
       
    57   asm("ldr "#Rd", =%a0"               : : "i" (KHwBaseRtc + 8)); \
       
    58   asm("ldr "#Rd", ["#Rd", #%a0]"      : : "i" (0));              
       
    59 
       
    60 /**
       
    61  * The frequency of the timer in Hz.
       
    62  */
       
    63 const TInt KHighResTimerFrequency = 1000000;
       
    64 
       
    65 /**
       
    66  * Macro indicating that the timer counts up if defined.
       
    67  */
       
    68 #define HIGH_RES_TIMER_COUNTS_UP
       
    69 
       
    70 #endif  // __HIGHRESTIMER_H__