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