Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\include\drivers\resourcecontrol_trace.h
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.
25 #ifndef __RESOURCECONTROL_TRACE_H__
26 #define __RESOURCECONTROL_TRACE_H__
27 #ifdef BTRACE_RESOURCE_MANAGER
29 //Function to format the output.
30 static void TraceFormatPrint(TDes8& aBuf, const char* aFmt, ...)
32 if(aBuf.MaxLength() == 0)
36 Kern::AppendFormat(aBuf,aFmt,list);
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
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
69 //Macro to output resource information
70 #define PRM_REGISTER_RESOURCE_TRACE \
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(), \
80 //Macro to output client details. Used during client registration
81 #define PRM_CLIENT_REGISTER_TRACE \
83 BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_CLIENT, aClientId, (TUint)pC, \
84 pC->iName->Ptr(), pC->iName->Length()); \
87 //Used during client deregistration
88 #define PRM_CLIENT_DEREGISTER_TRACE \
90 BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_CLIENT, aClientId, \
91 (TUint)pC, pC->iName->Ptr(), pC->iName->Length()); \
94 //Used to resource state change operation.Used at the start of the operation.
95 #define PRM_CLIENT_CHANGE_STATE_START_TRACE \
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()); \
104 //Used to resource state change operation. Used at the end of the operation.
105 #define PRM_CLIENT_CHANGE_STATE_END_TRACE \
107 TBuf8<80> printBuf; \
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()); \
114 //Used during request notificiation
115 #define PRM_POSTNOTIFICATION_REGISTER_TRACE \
118 printBuf[0] = (TInt)&aN.iCallback; \
120 BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_POST_NOTIFICATION, aClientId, \
121 aResourceId, printBuf, sizeof(printBuf)); \
124 //Used during cancel notification
125 #define PRM_POSTNOTIFICATION_DEREGISTER_TRACE \
128 printBuf[0] = (TInt)&aN.iCallback; \
130 BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_POST_NOTIFICATION, aClientId, \
131 aResourceId, printBuf, sizeof(printBuf)); \
134 //Used during when notification is sent.
135 #define PRM_POSTNOTIFICATION_SENT_TRACE \
137 BTraceContext8(BTrace::EResourceManager, PRM_POST_NOTIFICATION_SENT, aClientId, \
138 pN->iCallback.iResourceId); \
141 //Used when callback is completed.
142 //Calling TraceFormatPrint just to avoid warning
143 #define PRM_CALLBACK_COMPLETION_TRACE \
145 TPtr8 zeroDes(NULL, 0); \
146 TraceFormatPrint(zeroDes, "%d", pCb->iClientId); \
147 BTraceContext8(BTrace::EResourceManager, PRM_CALLBACK_COMPLETE, pCb->iClientId, \
151 //Used to output memory used by resource manager.
152 #define PRM_MEMORY_USAGE_TRACE \
154 BTraceContext4(BTrace::EResourceManager, PRM_MEMORY_USAGE, size); \
157 #define PRM_PSL_RESOURCE_GET_STATE_START_TRACE \
159 TBuf8<80> printBuf; \
161 TraceFormatPrint(printBuf, "%S ", iName); \
162 BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_GET_STATE_START, aRequest.ClientId(), \
163 aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length()); \
166 //Used during get resource state operation, used at the start of the operation.
167 #define PRM_RESOURCE_GET_STATE_START_TRACE \
169 TBuf8<80> printBuf; \
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());\
176 #define PRM_PSL_RESOURCE_GET_STATE_END_TRACE \
178 TBuf8<80> printBuf; \
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()); \
185 //Used during get resource state operation, used at the end of the operation.
186 #define PRM_RESOURCE_GET_STATE_END_TRACE \
188 TBuf8<80> printBuf; \
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());\
195 //Used during cancellation of long latency operation
196 #define PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE \
198 TBuf8<80> printBuf; \
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()); \
205 #define PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE \
207 TBuf8<80> printBuf; \
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()); \
214 #define PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE \
216 TBuf8<80> printBuf; \
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()); \
223 #define PRM_PSL_RESOURCE_CREATE_TRACE \
225 TBuf8<80> printBuf; \
227 TraceFormatPrint(printBuf, "%d %d %S", iDefaultLevel, iFlags, iName); \
228 BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CREATE, iMinLevel, iMaxLevel, \
229 printBuf.Ptr(), printBuf.Length()); \
232 //Used during booting of resource manager
233 //Calling TraceFormatPrint just to avoid warning
234 #define PRM_BOOTING_TRACE \
236 TPtr8 zeroDes(NULL, 0); \
237 TraceFormatPrint(zeroDes, "%d", aReason); \
238 BTraceContext4(BTrace::EResourceManager, PRM_BOOTING, (TUint)aReason); \
241 #ifdef PRM_ENABLE_EXTENDED_VERSION
242 //Macro to output static resource with dependency
243 #define PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE \
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()); \
253 //Macro to output dynamic resource registration.
254 #define PRM_REGISTER_DYNAMIC_RESOURCE_TRACE \
256 TBuf8<80> printBuf; \
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()); \
263 //Macro to output dynamic resource deregistration.
264 #define PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE \
266 TBuf8<80> printBuf; \
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()); \
273 //Macro to output registration of resource dependency.
274 #define PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE \
276 TBuf8<256> printBuf; \
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()); \
284 //Macro to output deregistration of resource dependency.
285 #define PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE \
287 TBuf8<256> printBuf; \
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()); \
297 #define PRM_REGISTER_RESOURCE_TRACE
298 #define PRM_CLIENT_REGISTER_TRACE
299 #define PRM_CLIENT_DEREGISTER_TRACE
300 #define PRM_CLIENT_CHANGE_STATE_START_TRACE
301 #define PRM_CLIENT_CHANGE_STATE_END_TRACE
302 #define PRM_POSTNOTIFICATION_REGISTER_TRACE
303 #define PRM_POSTNOTIFICATION_DEREGISTER_TRACE
304 #define PRM_POSTNOTIFICATION_SENT_TRACE
305 #define PRM_CALLBACK_COMPLETION_TRACE
306 #define PRM_MEMORY_USAGE_TRACE
307 #define PRM_RESOURCE_GET_STATE_START_TRACE
308 #define PRM_RESOURCE_GET_STATE_END_TRACE
309 #define PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE
310 #define PRM_BOOTING_TRACE ((void)aReason);
311 #define PRM_PSL_RESOURCE_GET_STATE_START_TRACE
312 #define PRM_PSL_RESOURCE_GET_STATE_END_TRACE
313 #define PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE
314 #define PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE
316 #ifdef PRM_ENABLE_EXTENDED_VERSION
317 #define PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE
318 #define PRM_REGISTER_DYNAMIC_RESOURCE_TRACE
319 #define PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE
320 #define PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE
321 #define PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE
322 #endif //PRM_ENABLE_EXTENDED_VERSION
324 #endif //BTRACE_RESOURCE_MANAGER
326 #endif //__RESOURCECONTROL_TRACE_H__