os/kernelhwsrv/kerneltest/e32test/benchmark/k32bm.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #if !defined(__K32BM_H__)
    17 #define __K32BM_H__
    18 
    19 #include <e32cmn.h>
    20 #include <kernel/kernel.h>
    21 #include <kernel/kern_priv.h>
    22 
    23 #include "d32bm.h"
    24 
    25 /**
    26  * <code>MBMIsr</code> interface is typically implemented by the LDD that binds
    27  * an ISR to the PDD interrupt source using <code>DBMPChannel::BindInterrupt(MBMIsr*)</code>. 
    28  */
    29 class MBMIsr
    30 	{
    31 public:
    32 	/**
    33 	 * LDD-level Interrupt Service Routine interface. 
    34 	 * This function is called by the PDD in response to a <code>DBMPChannel::RequestInterrupt()</code> request..
    35 	 * 
    36 	 * @param aNow the current time in ticks
    37 	 */
    38 	virtual void Isr(TBMTicks aNow) = 0;
    39 	};
    40 
    41 /**
    42  * <code>MBMInterruptLatencyIsr</code> interface is typically implemented by the LDD that binds
    43  * an ISR to the PDD interrupt source using <code>DBMPChannel::BindInterrupt(MBMInterruptLatencyIsr*)</code>. 
    44  */
    45 class MBMInterruptLatencyIsr
    46 	{
    47 public:
    48 	/**
    49 	 * LDD-level Interrupt Service Routine interface. 
    50 	 * This function is called by the PDD to deliver to LDD one interrupt latency measurement 
    51 	 * that was performed by PDD in response to a <code>DBMPChannel::RequestInterrupt()</code> request.
    52 	 *
    53 	 * @param aLatency the result in tick of one interrupt latency measurement.
    54 	 */
    55 	virtual void InterruptLatencyIsr(TBMTicks aLatency) = 0;
    56 	};
    57 
    58 /**
    59  * The PDD interface.
    60  *
    61  * The caller must guarantee mutual excusion between the folloing calls:
    62  *		<code>BindInterrupt(MBMIsr* aIsr)</code>
    63  *		<code>BindInterrupt(MBMInterruptLatencyIsr* aIsr)</code>
    64  *		<code>RequestInterrupt()</code>
    65  *		<code>CancelInterrupt()</code>
    66  */
    67 class DBMPChannel : public DBase
    68 	{
    69 public:
    70 	/**
    71 	 * Gets the high-resolution timer period
    72 	 *
    73 	 * @return timer period in ticks
    74 	 */
    75 	virtual TBMTicks TimerPeriod() = 0;
    76 	/**
    77 	 * Gets the current value of the high-resolution timer
    78 	 *
    79 	 * @return current time in ticks
    80 	 */
    81 	virtual TBMTicks TimerStamp() = 0;
    82 	/**
    83 	 * Translates high-resolution timer ticks to nanoseconds
    84 	 *
    85 	 * @param aTicks time in ticks. The implementation must truncate <code>aTicks</code> value to 
    86 	 *			<code>aTicks % TimerPeriod()</code> prior to translation.
    87 	 *
    88 	 * @return time in nano-seconds
    89 	 */
    90 	virtual TBMNs TimerTicksToNs(TBMTicks aTicks) = 0;
    91 	/**
    92 	 * Translates nanoseconds to high-resolution timer ticks 
    93 	 *
    94 	 * @param aNs time in nanoseconds
    95 	 *
    96 	 * @return time in ticks
    97 	 */
    98 	virtual TBMTicks TimerNsToTicks(TBMNs aNs) = 0;
    99 	/**
   100 	 * Binds an LDD-level ISR to the PDD interrupt source.
   101 	 *
   102 	 * The <code>MBMIsr::Isr()</code> handler is called by the LDD's ISR 
   103 	 * in response to a <code>DBMChannel::RequestInterrupt()</code> request.
   104 	 * 
   105 	 * @param aIsr points to the LDD ISR object.
   106 	 * 
   107 	 * @return KErrNone - on success;otherwise - an error code .
   108 	 */
   109 	virtual TInt BindInterrupt(MBMIsr* aIsr) = 0;
   110 	/**
   111 	 * Binds an LDD-level ISR to the PDD interrupt source.
   112 	 *
   113 	 * The <code>MBMInterruptLatencyIsr::Isr()</code> handler is called by the LDD's ISR 
   114 	 * in response to a <code>DBMChannel::RequestInterrupt()</code> request.
   115 	 * 
   116 	 * @param aIsr points to the LDD ISR object.
   117 	 * 
   118 	 * @return KErrNone - on success;otherwise - an error code .
   119 	 */	
   120 	virtual TInt BindInterrupt(MBMInterruptLatencyIsr* aIsr) = 0;
   121 	/**
   122 	 * Asynchronously requests an interrupt.
   123 	 * The implmentation must provide 
   124 	 * When the interrupt will actually occur the PDD ISR will call the bound LDD-level
   125 	 * <code>MBMIsr</code> or <code>MBMInterruptLatencyIsr</code> object. Note that only one
   126 	 * LDD ISR object can be bound to the PDD interrupt source at any given moment of time.
   127 	 */
   128 	virtual void RequestInterrupt() = 0;
   129 	/**
   130 	 * Cancels a possibly outstanding interrupt request.
   131 	 * When returns the PDD interrupt has been either occured or canceled.
   132 	 */
   133 	virtual void CancelInterrupt() = 0;
   134 	};
   135 
   136 
   137 #define BM_ASSERT(aCond) \
   138 	__ASSERT_DEBUG( (aCond), (Kern::Printf("Assertion '" #aCond "' failed;\nFile: '" __FILE__ "' Line: %d\n", __LINE__), Kern::Fault("BM", 0)) )
   139 
   140 enum
   141 	{
   142 	KBMLDDHighPriority = 64 - 1, // KNumPriorities - 1,
   143 	KBMLDDMidPriority = KBMLDDHighPriority - 1,
   144 	KBMLDDLowPriority  = KBMLDDMidPriority - 1,
   145 	};
   146 
   147 #endif