|
1 // Copyright (c) 2007-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 // e32\include\drivers\resourcecontrol_trace.h |
|
15 // |
|
16 // WARNING: This file contains some APIs which are internal and are subject |
|
17 // to change without notice. Such APIs should therefore not be used |
|
18 // outside the Kernel and Hardware Services package. |
|
19 // |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent |
|
24 */ |
|
25 #ifndef __RESOURCECONTROL_TRACE_H__ |
|
26 #define __RESOURCECONTROL_TRACE_H__ |
|
27 #ifdef BTRACE_RESOURCE_MANAGER |
|
28 |
|
29 //Function to format the output. |
|
30 static void TraceFormatPrint(TDes8& aBuf, const char* aFmt, ...) |
|
31 { |
|
32 if(aBuf.MaxLength() == 0) |
|
33 return; |
|
34 VA_LIST list; |
|
35 VA_START(list,aFmt); |
|
36 Kern::AppendFormat(aBuf,aFmt,list); |
|
37 } |
|
38 |
|
39 //definition of subcategories. |
|
40 #define PRM_REGISTER_RESOURCE BTrace::ERegisterResource |
|
41 #define PRM_REGISTER_CLIENT BTrace::ERegisterClient |
|
42 #define PRM_DEREGISTER_CLIENT BTrace::EDeRegisterClient |
|
43 #define PRM_CLIENT_STATE_CHANGE_START BTrace::ESetResourceStateStart |
|
44 #define PRM_CLIENT_STATE_CHANGE_END BTrace::ESetResourceStateEnd |
|
45 #define PRM_REGISTER_POST_NOTIFICATION BTrace::EPostNotificationRegister |
|
46 #define PRM_DEREGISTER_POST_NOTIFICATION BTrace::EPostNotificationDeRegister |
|
47 #define PRM_POST_NOTIFICATION_SENT BTrace::EPostNotificationSent |
|
48 #define PRM_CALLBACK_COMPLETE BTrace::ECallbackComplete |
|
49 #define PRM_MEMORY_USAGE BTrace::EMemoryUsage |
|
50 #define PRM_CLIENT_GET_STATE_START BTrace::EGetResourceStateStart |
|
51 #define PRM_CLIENT_GET_STATE_END BTrace::EGetResourceStateEnd |
|
52 #define PRM_CANCEL_LONG_LATENCY_OPERATION BTrace::ECancelLongLatencyOperation |
|
53 #define PRM_BOOTING BTrace::EBooting |
|
54 //subcategories used in PSL |
|
55 #define PRM_PSL_RESOURCE_CHANGE_STATE_START BTrace::EPslChangeResourceStateStart |
|
56 #define PRM_PSL_RESOURCE_CHANGE_STATE_END BTrace::EPslChangeResourceStateEnd |
|
57 #define PRM_PSL_RESOURCE_GET_STATE_START BTrace::EPslGetResourceStateStart |
|
58 #define PRM_PSL_RESOURCE_GET_STATE_END BTrace::EPslGetResourceStateEnd |
|
59 #define PRM_PSL_RESOURCE_CREATE BTrace::EPslResourceCreate |
|
60 |
|
61 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
62 //definition of subcategories for extended version. |
|
63 #define PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY BTrace::ERegisterStaticResourceWithDependency |
|
64 #define PRM_REGISTER_DYNAMIC_RESOURCE BTrace::ERegisterDynamicResource |
|
65 #define PRM_DEREGISTER_DYNAMIC_RESOURCE BTrace::EDeRegisterDynamicResource |
|
66 #define PRM_REGISTER_RESOURCE_DEPENDENCY BTrace::ERegisterResourceDependency |
|
67 #define PRM_DEREGISTER_RESOURCE_DEPENDENCY BTrace::EDeRegisterResourceDependency |
|
68 #endif |
|
69 //Macro to output resource information |
|
70 #define PRM_REGISTER_RESOURCE_TRACE \ |
|
71 { \ |
|
72 TBuf8<80> printBuf; \ |
|
73 printBuf.Zero(); \ |
|
74 TraceFormatPrint(printBuf, "%S %d %d %d", pR->iName, pResInfo->iMinLevel, pResInfo->iMaxLevel, \ |
|
75 pResInfo->iDefaultLevel); \ |
|
76 BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_RESOURCE, resCount+1, pR, printBuf.Ptr(), \ |
|
77 printBuf.Length()); \ |
|
78 } |
|
79 |
|
80 //Macro to output client details. Used during client registration |
|
81 #define PRM_CLIENT_REGISTER_TRACE \ |
|
82 { \ |
|
83 BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_CLIENT, aClientId, (TUint)pC, \ |
|
84 pC->iName->Ptr(), pC->iName->Length()); \ |
|
85 } |
|
86 |
|
87 //Used during client deregistration |
|
88 #define PRM_CLIENT_DEREGISTER_TRACE \ |
|
89 { \ |
|
90 BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_CLIENT, aClientId, \ |
|
91 (TUint)pC, pC->iName->Ptr(), pC->iName->Length()); \ |
|
92 } |
|
93 |
|
94 //Used to resource state change operation.Used at the start of the operation. |
|
95 #define PRM_CLIENT_CHANGE_STATE_START_TRACE \ |
|
96 { \ |
|
97 TBuf8<80> printBuf; \ |
|
98 printBuf.Zero(); \ |
|
99 TraceFormatPrint(printBuf, "%S %S %d", pC->iName, pR->iName, aNewState); \ |
|
100 BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_STATE_CHANGE_START, pC->iClientId, \ |
|
101 aResourceId, printBuf.Ptr(), printBuf.Length()); \ |
|
102 } |
|
103 |
|
104 //Used to resource state change operation. Used at the end of the operation. |
|
105 #define PRM_CLIENT_CHANGE_STATE_END_TRACE \ |
|
106 { \ |
|
107 TBuf8<80> printBuf; \ |
|
108 printBuf.Zero(); \ |
|
109 TraceFormatPrint(printBuf, "%S %S %d %d", pC->iName, pR->iName, r, aNewState); \ |
|
110 BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_STATE_CHANGE_END, pC->iClientId, \ |
|
111 aResourceId, printBuf.Ptr(), printBuf.Length()); \ |
|
112 } |
|
113 |
|
114 //Used during request notificiation |
|
115 #define PRM_POSTNOTIFICATION_REGISTER_TRACE \ |
|
116 { \ |
|
117 TInt printBuf[2]; \ |
|
118 printBuf[0] = (TInt)&aN.iCallback; \ |
|
119 printBuf[1] = r; \ |
|
120 BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_POST_NOTIFICATION, aClientId, \ |
|
121 aResourceId, printBuf, sizeof(printBuf)); \ |
|
122 } |
|
123 |
|
124 //Used during cancel notification |
|
125 #define PRM_POSTNOTIFICATION_DEREGISTER_TRACE \ |
|
126 { \ |
|
127 TInt printBuf[2]; \ |
|
128 printBuf[0] = (TInt)&aN.iCallback; \ |
|
129 printBuf[1] = r; \ |
|
130 BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_POST_NOTIFICATION, aClientId, \ |
|
131 aResourceId, printBuf, sizeof(printBuf)); \ |
|
132 } |
|
133 |
|
134 //Used during when notification is sent. |
|
135 #define PRM_POSTNOTIFICATION_SENT_TRACE \ |
|
136 { \ |
|
137 BTraceContext8(BTrace::EResourceManager, PRM_POST_NOTIFICATION_SENT, aClientId, \ |
|
138 pN->iCallback.iResourceId); \ |
|
139 } |
|
140 |
|
141 //Used when callback is completed. |
|
142 //Calling TraceFormatPrint just to avoid warning |
|
143 #define PRM_CALLBACK_COMPLETION_TRACE \ |
|
144 { \ |
|
145 TPtr8 zeroDes(NULL, 0); \ |
|
146 TraceFormatPrint(zeroDes, "%d", pCb->iClientId); \ |
|
147 BTraceContext8(BTrace::EResourceManager, PRM_CALLBACK_COMPLETE, pCb->iClientId, \ |
|
148 pCb->iResourceId); \ |
|
149 } |
|
150 |
|
151 //Used to output memory used by resource manager. |
|
152 #define PRM_MEMORY_USAGE_TRACE \ |
|
153 { \ |
|
154 BTraceContext4(BTrace::EResourceManager, PRM_MEMORY_USAGE, size); \ |
|
155 } |
|
156 |
|
157 #define PRM_PSL_RESOURCE_GET_STATE_START_TRACE \ |
|
158 { \ |
|
159 TBuf8<80> printBuf; \ |
|
160 printBuf.Zero(); \ |
|
161 TraceFormatPrint(printBuf, "%S ", iName); \ |
|
162 BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_GET_STATE_START, aRequest.ClientId(), \ |
|
163 aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length()); \ |
|
164 } |
|
165 |
|
166 //Used during get resource state operation, used at the start of the operation. |
|
167 #define PRM_RESOURCE_GET_STATE_START_TRACE \ |
|
168 { \ |
|
169 TBuf8<80> printBuf; \ |
|
170 printBuf.Zero(); \ |
|
171 TraceFormatPrint(printBuf, "%S %S", pC->iName, pR->iName); \ |
|
172 BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_GET_STATE_START, pC->iClientId, aResourceId,\ |
|
173 printBuf.Ptr(), printBuf.Length());\ |
|
174 } |
|
175 |
|
176 #define PRM_PSL_RESOURCE_GET_STATE_END_TRACE \ |
|
177 { \ |
|
178 TBuf8<80> printBuf; \ |
|
179 printBuf.Zero(); \ |
|
180 TraceFormatPrint(printBuf, "%S %d %d", iName, iCurLevel,retVal); \ |
|
181 BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_GET_STATE_END, aRequest.ClientId(), \ |
|
182 aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length()); \ |
|
183 } |
|
184 |
|
185 //Used during get resource state operation, used at the end of the operation. |
|
186 #define PRM_RESOURCE_GET_STATE_END_TRACE \ |
|
187 { \ |
|
188 TBuf8<80> printBuf; \ |
|
189 printBuf.Zero(); \ |
|
190 TraceFormatPrint(printBuf, "%S %S %d %d", pC->iName, pR->iName, aState, r); \ |
|
191 BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_GET_STATE_END, pC->iClientId, aResourceId, \ |
|
192 printBuf.Ptr(), printBuf.Length());\ |
|
193 } |
|
194 |
|
195 //Used during cancellation of long latency operation |
|
196 #define PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE \ |
|
197 { \ |
|
198 TBuf8<80> printBuf; \ |
|
199 printBuf.Zero(); \ |
|
200 TraceFormatPrint(printBuf, "%S %S %d", pC->iName, pR->iName, r); \ |
|
201 BTraceContextN(BTrace::EResourceManager, PRM_CANCEL_LONG_LATENCY_OPERATION, pC->iClientId, \ |
|
202 aResourceId, printBuf.Ptr(), printBuf.Length()); \ |
|
203 } |
|
204 |
|
205 #define PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE \ |
|
206 { \ |
|
207 TBuf8<80> printBuf; \ |
|
208 printBuf.Zero(); \ |
|
209 TraceFormatPrint(printBuf, "%S %d %d", iName, iCurLevel, aRequest.Level()); \ |
|
210 BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CHANGE_STATE_START, aRequest.ClientId(), \ |
|
211 aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length()); \ |
|
212 } |
|
213 |
|
214 #define PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE \ |
|
215 { \ |
|
216 TBuf8<80> printBuf; \ |
|
217 printBuf.Zero(); \ |
|
218 TraceFormatPrint(printBuf, "%S %d %d %d", iName, iCurLevel, aRequest.Level(),retVal); \ |
|
219 BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CHANGE_STATE_END, aRequest.ClientId(), \ |
|
220 aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length()); \ |
|
221 } |
|
222 |
|
223 #define PRM_PSL_RESOURCE_CREATE_TRACE \ |
|
224 { \ |
|
225 TBuf8<80> printBuf; \ |
|
226 printBuf.Zero(); \ |
|
227 TraceFormatPrint(printBuf, "%d %d %S", iDefaultLevel, iFlags, iName); \ |
|
228 BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CREATE, iMinLevel, iMaxLevel, \ |
|
229 printBuf.Ptr(), printBuf.Length()); \ |
|
230 } |
|
231 |
|
232 //Used during booting of resource manager |
|
233 //Calling TraceFormatPrint just to avoid warning |
|
234 #define PRM_BOOTING_TRACE \ |
|
235 { \ |
|
236 TPtr8 zeroDes(NULL, 0); \ |
|
237 TraceFormatPrint(zeroDes, "%d", aReason); \ |
|
238 BTraceContext4(BTrace::EResourceManager, PRM_BOOTING, (TUint)aReason); \ |
|
239 } |
|
240 |
|
241 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
242 //Macro to output static resource with dependency |
|
243 #define PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE \ |
|
244 { \ |
|
245 TBuf8<80> pBuf; \ |
|
246 pBuf.Zero(); \ |
|
247 TraceFormatPrint(pBuf, "%S %d %d %d", pR->iName, pResInfo->iMinLevel, pResInfo->iMaxLevel, \ |
|
248 pResInfo->iDefaultLevel); \ |
|
249 BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY, pR->iResourceId, \ |
|
250 pR, pBuf.Ptr(), pBuf.Length()); \ |
|
251 } |
|
252 |
|
253 //Macro to output dynamic resource registration. |
|
254 #define PRM_REGISTER_DYNAMIC_RESOURCE_TRACE \ |
|
255 { \ |
|
256 TBuf8<80> printBuf; \ |
|
257 printBuf.Zero(); \ |
|
258 TraceFormatPrint(printBuf, "%S %S %d", aClientPtr->iName, aPDRes->iName, aPDRes); \ |
|
259 BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_DYNAMIC_RESOURCE, aClientPtr->iClientId, \ |
|
260 aPDRes->iResourceId, printBuf.Ptr(), printBuf.Length()); \ |
|
261 } |
|
262 |
|
263 //Macro to output dynamic resource deregistration. |
|
264 #define PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE \ |
|
265 { \ |
|
266 TBuf8<80> printBuf; \ |
|
267 printBuf.Zero(); \ |
|
268 TraceFormatPrint(printBuf, "%S %S %d %d", aClientPtr->iName, pDR->iName, pDR, level); \ |
|
269 BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_DYNAMIC_RESOURCE, aClientPtr->iClientId, \ |
|
270 pDR->iResourceId, printBuf.Ptr(), printBuf.Length()); \ |
|
271 } |
|
272 |
|
273 //Macro to output registration of resource dependency. |
|
274 #define PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE \ |
|
275 { \ |
|
276 TBuf8<256> printBuf; \ |
|
277 printBuf.Zero(); \ |
|
278 TraceFormatPrint(printBuf, "%S %S %d %S %d %d", aClientPtr->iName, pR1->iName, pR2->iResourceId, \ |
|
279 pR2->iName, pR1, pR2); \ |
|
280 BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_RESOURCE_DEPENDENCY, aClientPtr->iClientId, \ |
|
281 pR1->iResourceId, printBuf.Ptr(), printBuf.Length()); \ |
|
282 } |
|
283 |
|
284 //Macro to output deregistration of resource dependency. |
|
285 #define PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE \ |
|
286 { \ |
|
287 TBuf8<256> printBuf; \ |
|
288 printBuf.Zero(); \ |
|
289 TraceFormatPrint(printBuf, "%S %S %d %S %d %d", aClientPtr->iName, pDR1->iName, pDR2->iResourceId, \ |
|
290 pDR2->iName, pDR1, pDR2); \ |
|
291 BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_RESOURCE_DEPENDENCY, aClientPtr->iClientId, \ |
|
292 pDR1->iResourceId, printBuf.Ptr(), printBuf.Length()); \ |
|
293 } |
|
294 #endif |
|
295 #else |
|
296 |
|
297 #define PRM_REGISTER_RESOURCE_TRACE |
|
298 #define PRM_CLIENT_REGISTER_TRACE |
|
299 #define PRM_CLIENT_DEREGISTER_TRACE |
|
300 #define PRM_CLIENT_CHANGE_STATE_TRACE |
|
301 #define PRM_POSTNOTIFICATION_REGISTER_TRACE |
|
302 #define PRM_POSTNOTIFICATION_DEREGISTER_TRACE |
|
303 #define PRM_POSTNOTIFICATION_SENT_TRACE |
|
304 #define PRM_CALLBACK_COMPLETION_TRACE |
|
305 #define PRM_MEMORY_USAGE_MACRO |
|
306 #define PRM_RESOURCE_GET_STATE_START_MACRO |
|
307 #define PRM_RESOURCE_GET_STATE_END_MACRO |
|
308 #define PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_MACRO |
|
309 #define PRM_BOOTING_TRACE ((void)aReason); |
|
310 #define PRM_PSL_RESOURCE_GET_STATE_START_TRACE |
|
311 #define PRM_PSL_RESOURCE_GET_STATE_END_TRACE |
|
312 #define PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE |
|
313 #define PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE |
|
314 |
|
315 #ifdef PRM_ENABLE_EXTENDED_VERSION |
|
316 #define PRM_REGISTER_DYNAMIC_RESOURCE_TRACE |
|
317 #define PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE |
|
318 #define PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE |
|
319 #define PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE |
|
320 #endif //PRM_ENABLE_EXTENDED_VERSION |
|
321 |
|
322 #endif //BTRACE_RESOURCE_MANAGER |
|
323 |
|
324 #endif //__RESOURCECONTROL_TRACE_H__ |
|
325 |