1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/resourcecontrol_trace.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,327 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32\include\drivers\resourcecontrol_trace.h
1.18 +//
1.19 +// WARNING: This file contains some APIs which are internal and are subject
1.20 +// to change without notice. Such APIs should therefore not be used
1.21 +// outside the Kernel and Hardware Services package.
1.22 +//
1.23 +
1.24 +/**
1.25 + @file
1.26 + @internalComponent
1.27 +*/
1.28 +#ifndef __RESOURCECONTROL_TRACE_H__
1.29 +#define __RESOURCECONTROL_TRACE_H__
1.30 +#ifdef BTRACE_RESOURCE_MANAGER
1.31 +
1.32 +//Function to format the output.
1.33 +static void TraceFormatPrint(TDes8& aBuf, const char* aFmt, ...)
1.34 + {
1.35 + if(aBuf.MaxLength() == 0)
1.36 + return;
1.37 + VA_LIST list;
1.38 + VA_START(list,aFmt);
1.39 + Kern::AppendFormat(aBuf,aFmt,list);
1.40 + }
1.41 +
1.42 +//definition of subcategories.
1.43 +#define PRM_REGISTER_RESOURCE BTrace::ERegisterResource
1.44 +#define PRM_REGISTER_CLIENT BTrace::ERegisterClient
1.45 +#define PRM_DEREGISTER_CLIENT BTrace::EDeRegisterClient
1.46 +#define PRM_CLIENT_STATE_CHANGE_START BTrace::ESetResourceStateStart
1.47 +#define PRM_CLIENT_STATE_CHANGE_END BTrace::ESetResourceStateEnd
1.48 +#define PRM_REGISTER_POST_NOTIFICATION BTrace::EPostNotificationRegister
1.49 +#define PRM_DEREGISTER_POST_NOTIFICATION BTrace::EPostNotificationDeRegister
1.50 +#define PRM_POST_NOTIFICATION_SENT BTrace::EPostNotificationSent
1.51 +#define PRM_CALLBACK_COMPLETE BTrace::ECallbackComplete
1.52 +#define PRM_MEMORY_USAGE BTrace::EMemoryUsage
1.53 +#define PRM_CLIENT_GET_STATE_START BTrace::EGetResourceStateStart
1.54 +#define PRM_CLIENT_GET_STATE_END BTrace::EGetResourceStateEnd
1.55 +#define PRM_CANCEL_LONG_LATENCY_OPERATION BTrace::ECancelLongLatencyOperation
1.56 +#define PRM_BOOTING BTrace::EBooting
1.57 +//subcategories used in PSL
1.58 +#define PRM_PSL_RESOURCE_CHANGE_STATE_START BTrace::EPslChangeResourceStateStart
1.59 +#define PRM_PSL_RESOURCE_CHANGE_STATE_END BTrace::EPslChangeResourceStateEnd
1.60 +#define PRM_PSL_RESOURCE_GET_STATE_START BTrace::EPslGetResourceStateStart
1.61 +#define PRM_PSL_RESOURCE_GET_STATE_END BTrace::EPslGetResourceStateEnd
1.62 +#define PRM_PSL_RESOURCE_CREATE BTrace::EPslResourceCreate
1.63 +
1.64 +#ifdef PRM_ENABLE_EXTENDED_VERSION
1.65 +//definition of subcategories for extended version.
1.66 +#define PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY BTrace::ERegisterStaticResourceWithDependency
1.67 +#define PRM_REGISTER_DYNAMIC_RESOURCE BTrace::ERegisterDynamicResource
1.68 +#define PRM_DEREGISTER_DYNAMIC_RESOURCE BTrace::EDeRegisterDynamicResource
1.69 +#define PRM_REGISTER_RESOURCE_DEPENDENCY BTrace::ERegisterResourceDependency
1.70 +#define PRM_DEREGISTER_RESOURCE_DEPENDENCY BTrace::EDeRegisterResourceDependency
1.71 +#endif
1.72 +//Macro to output resource information
1.73 +#define PRM_REGISTER_RESOURCE_TRACE \
1.74 + { \
1.75 + TBuf8<80> printBuf; \
1.76 + printBuf.Zero(); \
1.77 + TraceFormatPrint(printBuf, "%S %d %d %d", pR->iName, pResInfo->iMinLevel, pResInfo->iMaxLevel, \
1.78 + pResInfo->iDefaultLevel); \
1.79 + BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_RESOURCE, resCount+1, pR, printBuf.Ptr(), \
1.80 + printBuf.Length()); \
1.81 + }
1.82 +
1.83 +//Macro to output client details. Used during client registration
1.84 +#define PRM_CLIENT_REGISTER_TRACE \
1.85 + { \
1.86 + BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_CLIENT, aClientId, (TUint)pC, \
1.87 + pC->iName->Ptr(), pC->iName->Length()); \
1.88 + }
1.89 +
1.90 +//Used during client deregistration
1.91 +#define PRM_CLIENT_DEREGISTER_TRACE \
1.92 + { \
1.93 + BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_CLIENT, aClientId, \
1.94 + (TUint)pC, pC->iName->Ptr(), pC->iName->Length()); \
1.95 + }
1.96 +
1.97 +//Used to resource state change operation.Used at the start of the operation.
1.98 +#define PRM_CLIENT_CHANGE_STATE_START_TRACE \
1.99 + { \
1.100 + TBuf8<80> printBuf; \
1.101 + printBuf.Zero(); \
1.102 + TraceFormatPrint(printBuf, "%S %S %d", pC->iName, pR->iName, aNewState); \
1.103 + BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_STATE_CHANGE_START, pC->iClientId, \
1.104 + aResourceId, printBuf.Ptr(), printBuf.Length()); \
1.105 + }
1.106 +
1.107 +//Used to resource state change operation. Used at the end of the operation.
1.108 +#define PRM_CLIENT_CHANGE_STATE_END_TRACE \
1.109 + { \
1.110 + TBuf8<80> printBuf; \
1.111 + printBuf.Zero(); \
1.112 + TraceFormatPrint(printBuf, "%S %S %d %d", pC->iName, pR->iName, r, aNewState); \
1.113 + BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_STATE_CHANGE_END, pC->iClientId, \
1.114 + aResourceId, printBuf.Ptr(), printBuf.Length()); \
1.115 + }
1.116 +
1.117 +//Used during request notificiation
1.118 +#define PRM_POSTNOTIFICATION_REGISTER_TRACE \
1.119 + { \
1.120 + TInt printBuf[2]; \
1.121 + printBuf[0] = (TInt)&aN.iCallback; \
1.122 + printBuf[1] = r; \
1.123 + BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_POST_NOTIFICATION, aClientId, \
1.124 + aResourceId, printBuf, sizeof(printBuf)); \
1.125 + }
1.126 +
1.127 +//Used during cancel notification
1.128 +#define PRM_POSTNOTIFICATION_DEREGISTER_TRACE \
1.129 + { \
1.130 + TInt printBuf[2]; \
1.131 + printBuf[0] = (TInt)&aN.iCallback; \
1.132 + printBuf[1] = r; \
1.133 + BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_POST_NOTIFICATION, aClientId, \
1.134 + aResourceId, printBuf, sizeof(printBuf)); \
1.135 + }
1.136 +
1.137 +//Used during when notification is sent.
1.138 +#define PRM_POSTNOTIFICATION_SENT_TRACE \
1.139 + { \
1.140 + BTraceContext8(BTrace::EResourceManager, PRM_POST_NOTIFICATION_SENT, aClientId, \
1.141 + pN->iCallback.iResourceId); \
1.142 + }
1.143 +
1.144 +//Used when callback is completed.
1.145 +//Calling TraceFormatPrint just to avoid warning
1.146 +#define PRM_CALLBACK_COMPLETION_TRACE \
1.147 + { \
1.148 + TPtr8 zeroDes(NULL, 0); \
1.149 + TraceFormatPrint(zeroDes, "%d", pCb->iClientId); \
1.150 + BTraceContext8(BTrace::EResourceManager, PRM_CALLBACK_COMPLETE, pCb->iClientId, \
1.151 + pCb->iResourceId); \
1.152 + }
1.153 +
1.154 +//Used to output memory used by resource manager.
1.155 +#define PRM_MEMORY_USAGE_TRACE \
1.156 + { \
1.157 + BTraceContext4(BTrace::EResourceManager, PRM_MEMORY_USAGE, size); \
1.158 + }
1.159 +
1.160 +#define PRM_PSL_RESOURCE_GET_STATE_START_TRACE \
1.161 + { \
1.162 + TBuf8<80> printBuf; \
1.163 + printBuf.Zero(); \
1.164 + TraceFormatPrint(printBuf, "%S ", iName); \
1.165 + BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_GET_STATE_START, aRequest.ClientId(), \
1.166 + aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length()); \
1.167 + }
1.168 +
1.169 +//Used during get resource state operation, used at the start of the operation.
1.170 +#define PRM_RESOURCE_GET_STATE_START_TRACE \
1.171 + { \
1.172 + TBuf8<80> printBuf; \
1.173 + printBuf.Zero(); \
1.174 + TraceFormatPrint(printBuf, "%S %S", pC->iName, pR->iName); \
1.175 + BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_GET_STATE_START, pC->iClientId, aResourceId,\
1.176 + printBuf.Ptr(), printBuf.Length());\
1.177 + }
1.178 +
1.179 +#define PRM_PSL_RESOURCE_GET_STATE_END_TRACE \
1.180 + { \
1.181 + TBuf8<80> printBuf; \
1.182 + printBuf.Zero(); \
1.183 + TraceFormatPrint(printBuf, "%S %d %d", iName, iCurLevel,retVal); \
1.184 + BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_GET_STATE_END, aRequest.ClientId(), \
1.185 + aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length()); \
1.186 + }
1.187 +
1.188 +//Used during get resource state operation, used at the end of the operation.
1.189 +#define PRM_RESOURCE_GET_STATE_END_TRACE \
1.190 + { \
1.191 + TBuf8<80> printBuf; \
1.192 + printBuf.Zero(); \
1.193 + TraceFormatPrint(printBuf, "%S %S %d %d", pC->iName, pR->iName, aState, r); \
1.194 + BTraceContextN(BTrace::EResourceManager, PRM_CLIENT_GET_STATE_END, pC->iClientId, aResourceId, \
1.195 + printBuf.Ptr(), printBuf.Length());\
1.196 + }
1.197 +
1.198 +//Used during cancellation of long latency operation
1.199 +#define PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE \
1.200 + { \
1.201 + TBuf8<80> printBuf; \
1.202 + printBuf.Zero(); \
1.203 + TraceFormatPrint(printBuf, "%S %S %d", pC->iName, pR->iName, r); \
1.204 + BTraceContextN(BTrace::EResourceManager, PRM_CANCEL_LONG_LATENCY_OPERATION, pC->iClientId, \
1.205 + aResourceId, printBuf.Ptr(), printBuf.Length()); \
1.206 + }
1.207 +
1.208 +#define PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE \
1.209 + { \
1.210 + TBuf8<80> printBuf; \
1.211 + printBuf.Zero(); \
1.212 + TraceFormatPrint(printBuf, "%S %d %d", iName, iCurLevel, aRequest.Level()); \
1.213 + BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CHANGE_STATE_START, aRequest.ClientId(), \
1.214 + aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length()); \
1.215 + }
1.216 +
1.217 +#define PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE \
1.218 + { \
1.219 + TBuf8<80> printBuf; \
1.220 + printBuf.Zero(); \
1.221 + TraceFormatPrint(printBuf, "%S %d %d %d", iName, iCurLevel, aRequest.Level(),retVal); \
1.222 + BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CHANGE_STATE_END, aRequest.ClientId(), \
1.223 + aRequest.ResourceId(), printBuf.Ptr(), printBuf.Length()); \
1.224 + }
1.225 +
1.226 +#define PRM_PSL_RESOURCE_CREATE_TRACE \
1.227 + { \
1.228 + TBuf8<80> printBuf; \
1.229 + printBuf.Zero(); \
1.230 + TraceFormatPrint(printBuf, "%d %d %S", iDefaultLevel, iFlags, iName); \
1.231 + BTraceContextN(BTrace::EResourceManager, PRM_PSL_RESOURCE_CREATE, iMinLevel, iMaxLevel, \
1.232 + printBuf.Ptr(), printBuf.Length()); \
1.233 + }
1.234 +
1.235 +//Used during booting of resource manager
1.236 +//Calling TraceFormatPrint just to avoid warning
1.237 +#define PRM_BOOTING_TRACE \
1.238 + { \
1.239 + TPtr8 zeroDes(NULL, 0); \
1.240 + TraceFormatPrint(zeroDes, "%d", aReason); \
1.241 + BTraceContext4(BTrace::EResourceManager, PRM_BOOTING, (TUint)aReason); \
1.242 + }
1.243 +
1.244 +#ifdef PRM_ENABLE_EXTENDED_VERSION
1.245 +//Macro to output static resource with dependency
1.246 +#define PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE \
1.247 + { \
1.248 + TBuf8<80> pBuf; \
1.249 + pBuf.Zero(); \
1.250 + TraceFormatPrint(pBuf, "%S %d %d %d", pR->iName, pResInfo->iMinLevel, pResInfo->iMaxLevel, \
1.251 + pResInfo->iDefaultLevel); \
1.252 + BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY, pR->iResourceId, \
1.253 + pR, pBuf.Ptr(), pBuf.Length()); \
1.254 + }
1.255 +
1.256 +//Macro to output dynamic resource registration.
1.257 +#define PRM_REGISTER_DYNAMIC_RESOURCE_TRACE \
1.258 + { \
1.259 + TBuf8<80> printBuf; \
1.260 + printBuf.Zero(); \
1.261 + TraceFormatPrint(printBuf, "%S %S %d", aClientPtr->iName, aPDRes->iName, aPDRes); \
1.262 + BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_DYNAMIC_RESOURCE, aClientPtr->iClientId, \
1.263 + aPDRes->iResourceId, printBuf.Ptr(), printBuf.Length()); \
1.264 + }
1.265 +
1.266 +//Macro to output dynamic resource deregistration.
1.267 +#define PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE \
1.268 + { \
1.269 + TBuf8<80> printBuf; \
1.270 + printBuf.Zero(); \
1.271 + TraceFormatPrint(printBuf, "%S %S %d %d", aClientPtr->iName, pDR->iName, pDR, level); \
1.272 + BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_DYNAMIC_RESOURCE, aClientPtr->iClientId, \
1.273 + pDR->iResourceId, printBuf.Ptr(), printBuf.Length()); \
1.274 + }
1.275 +
1.276 +//Macro to output registration of resource dependency.
1.277 +#define PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE \
1.278 + { \
1.279 + TBuf8<256> printBuf; \
1.280 + printBuf.Zero(); \
1.281 + TraceFormatPrint(printBuf, "%S %S %d %S %d %d", aClientPtr->iName, pR1->iName, pR2->iResourceId, \
1.282 + pR2->iName, pR1, pR2); \
1.283 + BTraceContextN(BTrace::EResourceManager, PRM_REGISTER_RESOURCE_DEPENDENCY, aClientPtr->iClientId, \
1.284 + pR1->iResourceId, printBuf.Ptr(), printBuf.Length()); \
1.285 + }
1.286 +
1.287 +//Macro to output deregistration of resource dependency.
1.288 +#define PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE \
1.289 + { \
1.290 + TBuf8<256> printBuf; \
1.291 + printBuf.Zero(); \
1.292 + TraceFormatPrint(printBuf, "%S %S %d %S %d %d", aClientPtr->iName, pDR1->iName, pDR2->iResourceId, \
1.293 + pDR2->iName, pDR1, pDR2); \
1.294 + BTraceContextN(BTrace::EResourceManager, PRM_DEREGISTER_RESOURCE_DEPENDENCY, aClientPtr->iClientId, \
1.295 + pDR1->iResourceId, printBuf.Ptr(), printBuf.Length()); \
1.296 + }
1.297 +#endif
1.298 +#else
1.299 +
1.300 +#define PRM_REGISTER_RESOURCE_TRACE
1.301 +#define PRM_CLIENT_REGISTER_TRACE
1.302 +#define PRM_CLIENT_DEREGISTER_TRACE
1.303 +#define PRM_CLIENT_CHANGE_STATE_START_TRACE
1.304 +#define PRM_CLIENT_CHANGE_STATE_END_TRACE
1.305 +#define PRM_POSTNOTIFICATION_REGISTER_TRACE
1.306 +#define PRM_POSTNOTIFICATION_DEREGISTER_TRACE
1.307 +#define PRM_POSTNOTIFICATION_SENT_TRACE
1.308 +#define PRM_CALLBACK_COMPLETION_TRACE
1.309 +#define PRM_MEMORY_USAGE_TRACE
1.310 +#define PRM_RESOURCE_GET_STATE_START_TRACE
1.311 +#define PRM_RESOURCE_GET_STATE_END_TRACE
1.312 +#define PRM_RESOURCE_CANCEL_LONGLATENCY_OPERATION_TRACE
1.313 +#define PRM_BOOTING_TRACE ((void)aReason);
1.314 +#define PRM_PSL_RESOURCE_GET_STATE_START_TRACE
1.315 +#define PRM_PSL_RESOURCE_GET_STATE_END_TRACE
1.316 +#define PRM_PSL_RESOURCE_CHANGE_STATE_START_TRACE
1.317 +#define PRM_PSL_RESOURCE_CHANGE_STATE_END_TRACE
1.318 +
1.319 +#ifdef PRM_ENABLE_EXTENDED_VERSION
1.320 +#define PRM_REGISTER_STATIC_RESOURCE_WITH_DEPENDENCY_TRACE
1.321 +#define PRM_REGISTER_DYNAMIC_RESOURCE_TRACE
1.322 +#define PRM_DEREGISTER_DYNAMIC_RESOURCE_TRACE
1.323 +#define PRM_REGISTER_RESOURCE_DEPENDENCY_TRACE
1.324 +#define PRM_DEREGISTER_RESOURCE_DEPENDENCY_TRACE
1.325 +#endif //PRM_ENABLE_EXTENDED_VERSION
1.326 +
1.327 +#endif //BTRACE_RESOURCE_MANAGER
1.328 +
1.329 +#endif //__RESOURCECONTROL_TRACE_H__
1.330 +