|
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 "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 #ifndef __PLUGINSAMPLER_H__ |
|
20 #define __PLUGINSAMPLER_H__ |
|
21 |
|
22 /* |
|
23 * The user-interface to the sampling device driver sued by the profiling engine |
|
24 */ |
|
25 // #include <piprofiler/ProfilerConfig.h> |
|
26 // #include <piprofiler/ProfilerVersion.h> // versions removed from ProfilerConfig.h |
|
27 |
|
28 #ifndef __KERNEL_MODE__ |
|
29 #include <utf.h> |
|
30 #endif |
|
31 |
|
32 /* |
|
33 * Forward declarations |
|
34 */ |
|
35 class TBapBuf; |
|
36 |
|
37 /** |
|
38 * A minimal capabilities class for the Sampling device. |
|
39 * It just returns the version number. |
|
40 */ |
|
41 class TCapsSamplerV01 |
|
42 { |
|
43 public: |
|
44 TVersion iVersion; |
|
45 }; |
|
46 |
|
47 |
|
48 const TInt KMinDelay = 1; |
|
49 const TInt KMaxDelay = 10000; |
|
50 |
|
51 /** |
|
52 * The user device driver class for controlling the plugin sampler. |
|
53 */ |
|
54 |
|
55 class RPluginSampler : public RBusLogicalChannel |
|
56 { |
|
57 friend class DPluginDriver; |
|
58 public: |
|
59 enum TControl |
|
60 { |
|
61 EOutputSettingsForTrace, |
|
62 EMarkTraceActive, |
|
63 EMarkTraceInactive, |
|
64 ESample, |
|
65 EStartSampling, |
|
66 EGetSampleTime, |
|
67 EGetSamplerVersion, |
|
68 EStopAndWaitForEnd, |
|
69 ESetSamplingPeriod, |
|
70 EAdditionalTraceSettings, |
|
71 EAdditionalTraceSettings2, |
|
72 EAdditionalTraceSettings3, |
|
73 EAdditionalTraceSettings4, |
|
74 //EPrintTraces, |
|
75 ECancelStreamRead, |
|
76 ERequestFillThisStreamBuffer, |
|
77 ERequestPrintStreamBuffer, |
|
78 ETest |
|
79 }; |
|
80 |
|
81 public: |
|
82 #ifndef __KERNEL_MODE__ |
|
83 |
|
84 inline ~RPluginSampler(); |
|
85 |
|
86 /** |
|
87 * |
|
88 * Methods for controlling the sampler device |
|
89 * |
|
90 **/ |
|
91 /** Open a channel to the sampling device **/ |
|
92 virtual TInt Open() = 0; |
|
93 |
|
94 /** Set sampling period for sampler */ |
|
95 inline void SetSamplingPeriod(TInt samplerId, TInt settings); |
|
96 |
|
97 /** Set additional trace settings **/ |
|
98 inline void AdditionalSettingsForTrace(TInt samplerId,TInt settings); |
|
99 inline void AdditionalSettingsForTrace2(TInt samplerId,TInt settings); |
|
100 inline void AdditionalSettingsForTrace3(TInt samplerId,TInt settings); |
|
101 inline void AdditionalSettingsForTrace4(TInt samplerId,TInt settings); |
|
102 |
|
103 /** Mark trace active **/ |
|
104 inline void MarkTraceActive(TUint32 id); |
|
105 |
|
106 /** Mark trace inactive **/ |
|
107 inline void MarkTraceInactive(TUint32 id); |
|
108 |
|
109 /** Sample command to kernel LDD**/ |
|
110 inline void Sample(); |
|
111 |
|
112 /** Start tracing **/ |
|
113 inline void StartSampling(); |
|
114 |
|
115 /** Stop tracing **/ |
|
116 inline void StopSampling(); |
|
117 |
|
118 /** Get current sampling time **/ |
|
119 inline TUint32 GetSampleTime(); |
|
120 |
|
121 /** Get sampler version as descriptor **/ |
|
122 virtual void GetSamplerVersion(TDes*); |
|
123 |
|
124 /** Get next filled buffer in stream mode **/ |
|
125 void GetNextbuffer( ); |
|
126 |
|
127 /** Request stream read **/ |
|
128 void FillThisStreamBuffer(TBapBuf* aBuffer, TRequestStatus& aStatus); |
|
129 |
|
130 /** Request print buffer**/ |
|
131 void PrintStreamBuffer(TDesC16* aBuffer); |
|
132 |
|
133 /** Run test case **/ |
|
134 inline void Test(TUint32 testCase); |
|
135 |
|
136 #endif // !__KERNEL_MODE__ |
|
137 }; |
|
138 |
|
139 |
|
140 #ifndef __KERNEL_MODE__ |
|
141 inline RPluginSampler::~RPluginSampler() |
|
142 { |
|
143 } |
|
144 |
|
145 inline void RPluginSampler::AdditionalSettingsForTrace(TInt samplerId,TInt settings) |
|
146 { |
|
147 DoControl(EAdditionalTraceSettings, |
|
148 reinterpret_cast<TAny*>(samplerId), |
|
149 reinterpret_cast<TAny*>(settings)); |
|
150 } |
|
151 |
|
152 inline void RPluginSampler::AdditionalSettingsForTrace2(TInt samplerId,TInt settings) |
|
153 { |
|
154 DoControl(EAdditionalTraceSettings2, |
|
155 reinterpret_cast<TAny*>(samplerId), |
|
156 reinterpret_cast<TAny*>(settings)); |
|
157 } |
|
158 |
|
159 inline void RPluginSampler::AdditionalSettingsForTrace3(TInt samplerId,TInt settings) |
|
160 { |
|
161 DoControl(EAdditionalTraceSettings3, |
|
162 reinterpret_cast<TAny*>(samplerId), |
|
163 reinterpret_cast<TAny*>(settings)); |
|
164 } |
|
165 |
|
166 inline void RPluginSampler::AdditionalSettingsForTrace4(TInt samplerId,TInt settings) |
|
167 { |
|
168 DoControl(EAdditionalTraceSettings4, |
|
169 reinterpret_cast<TAny*>(samplerId), |
|
170 reinterpret_cast<TAny*>(settings)); |
|
171 } |
|
172 |
|
173 inline void RPluginSampler::SetSamplingPeriod(TInt samplerId, TInt settings) |
|
174 { |
|
175 DoControl(ESetSamplingPeriod, |
|
176 reinterpret_cast<TAny*>(samplerId), |
|
177 reinterpret_cast<TAny*>(settings)); |
|
178 } |
|
179 |
|
180 |
|
181 inline void RPluginSampler::MarkTraceActive(TUint32 id) |
|
182 { |
|
183 DoControl(EMarkTraceActive, reinterpret_cast<TAny*>(id)); |
|
184 } |
|
185 |
|
186 inline void RPluginSampler::MarkTraceInactive(TUint32 id) |
|
187 { |
|
188 DoControl(EMarkTraceInactive, reinterpret_cast<TAny*>(id)); |
|
189 } |
|
190 |
|
191 inline void RPluginSampler::Sample() |
|
192 { |
|
193 DoControl(ESample); |
|
194 } |
|
195 |
|
196 inline void RPluginSampler::StartSampling() |
|
197 { |
|
198 // at first, start the kernel side samplers |
|
199 DoControl(EStartSampling); |
|
200 } |
|
201 |
|
202 inline void RPluginSampler::StopSampling() |
|
203 { |
|
204 // stop the device driver and the kernel mode samplers |
|
205 TRequestStatus status; |
|
206 status = KRequestPending; |
|
207 DoRequest(EStopAndWaitForEnd,status); |
|
208 User::WaitForRequest(status); |
|
209 } |
|
210 |
|
211 inline TUint32 RPluginSampler::GetSampleTime() |
|
212 { |
|
213 TUint32* sampleTime = new TUint32; |
|
214 |
|
215 DoControl(EGetSampleTime,reinterpret_cast<TAny*>(sampleTime)); |
|
216 TUint32 value = *sampleTime; |
|
217 delete sampleTime; |
|
218 |
|
219 return value; |
|
220 } |
|
221 |
|
222 inline void RPluginSampler::GetSamplerVersion(TDes* aDes) |
|
223 { |
|
224 TBuf8<16> buf; |
|
225 DoControl(EGetSamplerVersion,(TAny*)&buf); |
|
226 CnvUtfConverter::ConvertToUnicodeFromUtf8(*aDes,buf); |
|
227 } |
|
228 |
|
229 inline void RPluginSampler::PrintStreamBuffer(TDesC16* aDes) |
|
230 { |
|
231 DoControl(ERequestPrintStreamBuffer,reinterpret_cast<TAny*>(aDes)); |
|
232 } |
|
233 |
|
234 inline void RPluginSampler::FillThisStreamBuffer(TBapBuf* aBuffer, TRequestStatus& aStatus) |
|
235 { |
|
236 aStatus = KRequestPending; |
|
237 DoRequest(ERequestFillThisStreamBuffer,aStatus,(TAny*)aBuffer); |
|
238 |
|
239 } |
|
240 |
|
241 inline void RPluginSampler::Test(TUint32 testCase) |
|
242 { |
|
243 DoControl(ETest,reinterpret_cast<TAny*>(testCase)); |
|
244 } |
|
245 |
|
246 #endif |
|
247 #endif |