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