kernel/eka/include/nkern/nk_trace.h
changeset 9 96e5fb8b040d
equal deleted inserted replaced
-1:000000000000 9:96e5fb8b040d
       
     1 // Copyright (c) 1998-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\nkern\nk_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 #ifndef NK_TRACE_H
       
    22 #define NK_TRACE_H
       
    23 
       
    24 /**
       
    25 @internalComponent
       
    26 */
       
    27 #define DEBUGPRINT	KPrintf
       
    28 
       
    29 /**
       
    30 @publishedPartner
       
    31 @released
       
    32 */
       
    33 #define DEBUGMASK (KDebugMask())
       
    34 #define DEBUGNUM(x) (KDebugNum(x))
       
    35 
       
    36 GLREF_C void KPrintf(const char*,...);
       
    37 
       
    38 /**
       
    39 @publishedPartner
       
    40 @released
       
    41 */
       
    42 IMPORT_C TInt  KDebugMask();
       
    43 IMPORT_C TBool KDebugNum(TInt aBitNum);
       
    44 
       
    45 #if defined(_DEBUG)
       
    46 //#if (1)
       
    47 /**
       
    48 @publishedPartner
       
    49 @released
       
    50 */
       
    51 // __KTRACE_MASK only supports the first 32 debug trace bits
       
    52 #define __KTRACE_MASK(a,p) {if((DEBUGMASK&(a)))p;}
       
    53 #define __KTRACE_OPT(a,p) {if((DEBUGNUM(a)))p;}
       
    54 #define __KTRACE_OPT2(a,b,p) {if( (DEBUGNUM(a)) || (DEBUGNUM(b)) )p;}
       
    55 
       
    56 /**
       
    57 @publishedPartner
       
    58 @released
       
    59 */
       
    60 // __KTRACE_ALL only supports the first 32 debug trace bits
       
    61 #define __KTRACE_ALL(a,p) {if((DEBUGMASK&(a))==(a))p;}
       
    62 
       
    63 /**
       
    64 @publishedPartner
       
    65 @released
       
    66 */
       
    67 #define KHARDWARE	0 //0x00000001
       
    68 
       
    69 /**
       
    70 @publishedPartner
       
    71 @released
       
    72 */
       
    73 #define KBOOT		1 //0x00000002
       
    74 
       
    75 /**
       
    76 @publishedPartner
       
    77 @released
       
    78 */
       
    79 #define KSERVER		2 //0x00000004
       
    80 
       
    81 /**
       
    82 @publishedPartner
       
    83 @released
       
    84 */
       
    85 #define KMMU		3 //0x00000008
       
    86 
       
    87 /**
       
    88 @publishedPartner
       
    89 @released
       
    90 */
       
    91 #define KSEMAPHORE	4 //0x00000010
       
    92 
       
    93 /**
       
    94 @publishedPartner
       
    95 @released
       
    96 */
       
    97 #define KSCHED		5 //0x00000020
       
    98 
       
    99 /**
       
   100 @publishedPartner
       
   101 @released
       
   102 */
       
   103 #define KPROC		6 //0x00000040
       
   104 
       
   105 /**
       
   106 @publishedPartner
       
   107 @released
       
   108 */
       
   109 #define KEXEC		7 //0x00000080
       
   110 
       
   111 /**
       
   112 @publishedPartner
       
   113 @released
       
   114 */
       
   115 #define KDEBUGGER	8 //0x00000100  // for kernel-side debug agents
       
   116 
       
   117 /**
       
   118 @publishedPartner
       
   119 @released
       
   120 */
       
   121 #define KTHREAD		9 //0x00000200
       
   122 
       
   123 /**
       
   124 @publishedPartner
       
   125 @released
       
   126 */
       
   127 #define KDLL		10 //0x00000400
       
   128 
       
   129 /**
       
   130 @publishedPartner
       
   131 @released
       
   132 */
       
   133 #define KIPC		11 //0x00000800
       
   134 
       
   135 /**
       
   136 @publishedPartner
       
   137 @released
       
   138 */
       
   139 #define KPBUS1		12 //0x00001000
       
   140 
       
   141 /**
       
   142 @publishedPartner
       
   143 @released
       
   144 */
       
   145 #define KPBUS2		13 //0x00002000
       
   146 
       
   147 /**
       
   148 @publishedPartner
       
   149 @released
       
   150 */
       
   151 #define KPBUSDRV	14 //0x00004000
       
   152 
       
   153 /**
       
   154 @publishedPartner
       
   155 @released
       
   156 */
       
   157 #define KPOWER      15 //0x00008000
       
   158 
       
   159 /**
       
   160 @publishedPartner
       
   161 @released
       
   162 */
       
   163 #define KTIMING     16 //0x00010000
       
   164 
       
   165 /**
       
   166 @publishedPartner
       
   167 @released
       
   168 */
       
   169 #define KEVENT      17 //0x00020000
       
   170 
       
   171 /**
       
   172 @publishedPartner
       
   173 @released
       
   174 */
       
   175 #define KOBJECT		18 //0x00040000
       
   176 
       
   177 /**
       
   178 @publishedPartner
       
   179 @released
       
   180 */
       
   181 #define KDFC		19 //0x00080000
       
   182 
       
   183 /**
       
   184 @publishedPartner
       
   185 @released
       
   186 */
       
   187 #define KEXTENSION	20 //0x00100000
       
   188 
       
   189 /**
       
   190 @publishedPartner
       
   191 @released
       
   192 */
       
   193 #define KSCHED2		21 //0x00200000
       
   194 
       
   195 /**
       
   196 @publishedPartner
       
   197 @released
       
   198 */
       
   199 #define KLOCDRV		22 //0x00400000
       
   200 
       
   201 /**
       
   202 @publishedPartner
       
   203 @released
       
   204 */
       
   205 #define KFAIL		23 //0x00800000
       
   206 
       
   207 /**
       
   208 @publishedPartner
       
   209 @released
       
   210 */
       
   211 #define KTHREAD2	24 //0x01000000
       
   212 
       
   213 /**
       
   214 @publishedPartner
       
   215 @released
       
   216 */
       
   217 #define KDEVICE		25 //0x02000000
       
   218 
       
   219 /**
       
   220 @publishedPartner
       
   221 @released
       
   222 */
       
   223 #define KMEMTRACE	26 //0x04000000
       
   224 
       
   225 /**
       
   226 @publishedPartner
       
   227 @released
       
   228 */
       
   229 #define KDMA        27 //0x08000000
       
   230 
       
   231 /**
       
   232 @publishedPartner
       
   233 @released
       
   234 */
       
   235 #define KMMU2		28 //0x10000000
       
   236 
       
   237 /**
       
   238 @publishedPartner
       
   239 @released
       
   240 */
       
   241 #define KNKERN		29 //0x20000000
       
   242 
       
   243 /**
       
   244 @publishedPartner
       
   245 @released
       
   246 */
       
   247 #define KSCRATCH	30 //0x40000000	// reserved for temporary debugging
       
   248 
       
   249 /**
       
   250 @publishedPartner
       
   251 @released
       
   252 */
       
   253 #define KPANIC		31 //0x80000000
       
   254 
       
   255 /**
       
   256 @publishedPartner
       
   257 @released
       
   258 */
       
   259 #define KUSB		32 //0x00000001, index 1
       
   260 
       
   261 /**
       
   262 @publishedPartner
       
   263 @released
       
   264 */
       
   265 #define KUSBPSL		33 //0x00000002, index 1
       
   266  
       
   267 /**
       
   268 @internalComponent
       
   269 @released	
       
   270 */
       
   271 #define KNETWORK1	34 //0x00000004, index 1
       
   272  
       
   273 /**
       
   274 @internalComponent
       
   275 @released
       
   276 */
       
   277 #define KNETWORK2   35 //0x00000008, index 1
       
   278 
       
   279 /**
       
   280 @publishedPartner
       
   281 @released
       
   282 */
       
   283 #define KSOUND1		36 //0x00000010, index 1
       
   284  
       
   285 /**
       
   286 @publishedPartner
       
   287 @released
       
   288 */
       
   289 #define KUSBHOST	37 //0x00000020, index 1
       
   290 
       
   291 /**
       
   292 @publishedPartner
       
   293 @released
       
   294 */
       
   295 #define KUSBOTG		38 //0x00000040, index 1
       
   296 
       
   297 /**
       
   298 @publishedPartner
       
   299 @released
       
   300 */
       
   301 #define KUSBJOURNAL	39 //0x00000080, index 1
       
   302 
       
   303 /**
       
   304 @publishedPartner
       
   305 @released
       
   306 */
       
   307 #define KUSBHO		40 //0x00000100, index 1
       
   308 
       
   309 /**
       
   310 @publishedPartner
       
   311 @released
       
   312 */
       
   313 #define KRESMANAGER 41 //0x00000200, index 1
       
   314 
       
   315 /**
       
   316 @publishedPartner
       
   317 @prototype
       
   318 */
       
   319 #define KIIC 42 //0x00000400, index 1
       
   320 
       
   321 /**
       
   322 @publishedPartner
       
   323 @prototype
       
   324 */
       
   325 #define KHCR 43 //0x00000800, index 1
       
   326 
       
   327 /**
       
   328 @internalComponent
       
   329 @released
       
   330 */
       
   331 #define KREALTIME	63 //0x80000000, index 1
       
   332 
       
   333 /**
       
   334 @internalComponent
       
   335 @released
       
   336 */
       
   337 #define KPAGING		62 //0x40000000, index 1
       
   338 
       
   339 /**
       
   340 @internalComponent
       
   341 @released
       
   342 */
       
   343 #define KLOCDPAGING		61 //0x20000000, index 1
       
   344 
       
   345 /**
       
   346 @internalComponent
       
   347 @released
       
   348 */
       
   349 #define KDATAPAGEWARN	60 //0x10000000, index 1
       
   350 
       
   351 /**
       
   352 @internalComponent
       
   353 @prototype
       
   354 */
       
   355 #define KPCI	59 //0x08000000, index 1
       
   356 
       
   357 /**
       
   358 @internalComponent
       
   359 @prototype
       
   360 */
       
   361 #define KPIPE	58 //0x04000000, index 1
       
   362 
       
   363 // RESERVED: Trace bits 192 - 255 are reserved for licensee partners
       
   364 
       
   365 
       
   366 /**
       
   367 @publishedPartner
       
   368 @released
       
   369 */
       
   370 #define KALWAYS		-1     //0xffffffff
       
   371 #define KMAXTRACE   (KNumTraceMaskWords*32-1)    // the maximum debug trace bit
       
   372 #else
       
   373 #define __KTRACE_OPT(a,p)
       
   374 #define __KTRACE_ALL(a,p)
       
   375 #define __KTRACE_OPT2(a,b,p)
       
   376 #define KALWAYS		-1
       
   377 #define KMAXTRACE   (KNumTraceMaskWords*32-1)
       
   378 #endif
       
   379 
       
   380 
       
   381 /**
       
   382 @publishedPartner
       
   383 @released
       
   384 */
       
   385 #define DEBUGMASKWORD2	2
       
   386 
       
   387 /*
       
   388 words 0 & 1 of debug mask should be used for kernel debugging
       
   389 word  2     of debug mask should be used to configure the ways the kernel behaves
       
   390 word  3     of debug mask should be used to configure the ways the user library behaves
       
   391 words 4 & 5 of debug mask should be used for file system debugging
       
   392 words 6 & 7 of debug mask are reserved for licensees
       
   393 */
       
   394 
       
   395 /**
       
   396 @publishedPartner
       
   397 @released
       
   398 */
       
   399 #define KALLTHREADSSYSTEM	64 //0x00000001, index 2
       
   400 
       
   401 /**
       
   402 Suppresses console output (in EWSRV) for faster automated tests.
       
   403 @publishedPartner
       
   404 @released
       
   405 */
       
   406 #define KTESTFAST			65 //0x00000002, index 2
       
   407 
       
   408 /**
       
   409 Suppresses anything which might disturb latency testing,
       
   410 for example platsec diagnostics emitted with the system lock held.
       
   411 @publishedPartner
       
   412 @released
       
   413 */
       
   414 #define KTESTLATENCY		66 //0x00000004, index 2
       
   415 
       
   416 /**
       
   417 When a crash occurs this flag determines whether the debugger executes.
       
   418 If set the crash debugger will NOT operate (even if it's in rom).
       
   419 If clear the crash debugger will run.
       
   420 @publishedPartner
       
   421 @released
       
   422  */
       
   423 #define KDEBUGMONITORDISABLE	67 //0x00000008, index 2
       
   424 
       
   425 /**
       
   426 When a crash occurs this flag determines whether the logger executes.
       
   427 If set the crash logger will NOT operate (even if it's in rom).
       
   428 If clear the crash logger will run.
       
   429 @publishedPartner
       
   430 @released
       
   431  */
       
   432 #define KCRASHLOGGERDISABLE	68 //0x00000010, index 2
       
   433 
       
   434 /**
       
   435 Delay scheduling of newly unblocked threads until the next timer tick
       
   436 occurs, to check for thread priority dependencies. Part of the crazy
       
   437 scheduler functionality.
       
   438 @publishedPartner
       
   439 @released
       
   440  */
       
   441 #define KCRAZYSCHEDDELAY 69 //0x00000020, index 2
       
   442 
       
   443 
       
   444 
       
   445 /* Word 3 of debug mask : configures user library behaviour */
       
   446 
       
   447 /**
       
   448 @publishedPartner
       
   449 @released
       
   450 */
       
   451 #define KUSERHEAPTRACE		96 //0x00000001, index 3
       
   452 
       
   453 
       
   454 
       
   455 #ifdef KFAIL
       
   456 
       
   457 /**
       
   458 @publishedPartner
       
   459 @released
       
   460 */
       
   461 #define __KTRACE_FAIL(r,p) {if ((r)!=KErrNone && (DEBUGNUM(KFAIL))) p;}
       
   462 
       
   463 #else
       
   464 #define __KTRACE_FAIL(r,p)
       
   465 #endif
       
   466 
       
   467 #include <e32btrace.h>
       
   468 
       
   469 #ifdef __KERNEL_MODE__
       
   470 
       
   471 
       
   472 class DBTraceFilter2;
       
   473 
       
   474 /**
       
   475 @internalComponent
       
   476 */
       
   477 struct SBTraceData
       
   478 	{
       
   479 	TUint8 iFilter[256];
       
   480 	BTrace::THandler iHandler;
       
   481 	BTrace::TControlFunction iControl;
       
   482 	DBTraceFilter2*volatile iFilter2;
       
   483 
       
   484 	TBool CheckFilter2(TUint32 aUid);
       
   485 	};
       
   486 
       
   487 /**
       
   488 @internalComponent
       
   489 */
       
   490 extern SBTraceData BTraceData;
       
   491 
       
   492 #if defined(_DEBUG) || defined(BTRACE_KERNEL_ALL)
       
   493 
       
   494 #undef BTRACE_THREAD_IDENTIFICATION
       
   495 #undef BTRACE_CPU_USAGE
       
   496 #undef BTRACE_CHUNKS
       
   497 #undef BTRACE_CODESEGS
       
   498 #undef BTRACE_PAGING
       
   499 #undef BTRACE_PAGING_MEDIA
       
   500 #undef BTRACE_KERNEL_MEMORY
       
   501 #undef BTRACE_RAM_ALLOCATOR
       
   502 #undef BTRACE_FAST_MUTEX
       
   503 #undef BTRACE_RESOURCE_MANAGER
       
   504 #undef BTRACE_RESMANUS
       
   505 #undef BTRACE_TRAWEVENT
       
   506 #undef BTRACE_SYMBIAN_KERNEL_SYNC
       
   507 #undef BTRACE_FLEXIBLE_MEM_MODEL
       
   508 #undef BTRACE_CLIENT_SERVER
       
   509 #undef BTRACE_REQUESTS
       
   510 
       
   511 
       
   512 /**
       
   513 If defined, code for BTrace category BTrace::EThreadIdentification
       
   514 is compiled into the kernel.
       
   515 @publishedPartner
       
   516 @released
       
   517 */
       
   518 #define BTRACE_THREAD_IDENTIFICATION
       
   519 
       
   520 /**
       
   521 If defined, code for BTrace category BTrace::ECpuUsage
       
   522 is compiled into the kernel.
       
   523 @publishedPartner
       
   524 @released
       
   525 */
       
   526 #define BTRACE_CPU_USAGE
       
   527 
       
   528 /**
       
   529 If defined, code for BTrace category BTrace::EChunks is compiled into the
       
   530 kernel.
       
   531 @publishedPartner
       
   532 @released
       
   533 */
       
   534 #define BTRACE_CHUNKS
       
   535 
       
   536 /**
       
   537 If defined, code for BTrace category BTrace::ECodeSegs is compiled into the
       
   538 kernel.
       
   539 @publishedPartner
       
   540 @released
       
   541 */
       
   542 #define BTRACE_CODESEGS
       
   543 
       
   544 /**
       
   545 If defined, code for BTrace category BTrace::EPaging is compiled into the
       
   546 kernel.
       
   547 @publishedPartner
       
   548 @released 9.3
       
   549 */
       
   550 #define BTRACE_PAGING
       
   551 
       
   552 /**
       
   553 If defined, code for BTrace category BTrace::EPagingMedia is compiled into the
       
   554 Local Media Subsystem and relevant paging media drivers.
       
   555 @publishedPartner
       
   556 @released 9.3
       
   557 */
       
   558 #define BTRACE_PAGING_MEDIA
       
   559 
       
   560 /**
       
   561 If defined, code for BTrace category BTrace::EKernelMemory is compiled into the
       
   562 kernel.
       
   563 @publishedPartner
       
   564 @released 9.4
       
   565 */
       
   566 #define BTRACE_KERNEL_MEMORY
       
   567 
       
   568 /**
       
   569 If defined, code for BTrace category BTrace::ERamAllocator is compiled into the
       
   570 kernel.
       
   571 
       
   572 This BTrace category is only supported on the multiple and moving memory models.
       
   573 
       
   574 @publishedPartner
       
   575 @released 9.4
       
   576 */
       
   577 #if defined(__MEMMODEL_MOVING__) || defined (__MEMMODEL_MULTIPLE__)
       
   578 #define BTRACE_RAM_ALLOCATOR
       
   579 #endif
       
   580 
       
   581 /**
       
   582 If defined, code for BTrace category BTrace::EFastMutex is compiled into the
       
   583 kernel.
       
   584 */
       
   585 #define BTRACE_FAST_MUTEX
       
   586 
       
   587 /**
       
   588 If defined, code for BTrace category BTrace::EResourceManager is compiled into the
       
   589 Resource Manager Subsystem.
       
   590 @publishedPartner
       
   591 @released 9.5
       
   592 */
       
   593 #define BTRACE_RESOURCE_MANAGER
       
   594 
       
   595 /**
       
   596 If defined, code for BTrace category BTrace::EResourceManagerUs is compiled into the
       
   597 Resource Manager Subsystem's User-Side API.
       
   598 @publishedPartner
       
   599 @released 9.5
       
   600 */
       
   601 #define BTRACE_RESMANUS
       
   602 
       
   603 /**
       
   604 If defined, code for BTrace category BTrace::ERawEvent is compiled into the
       
   605 kernel.
       
   606 @publishedPartner
       
   607 @released 9.5
       
   608 */
       
   609 #define BTRACE_TRAWEVENT
       
   610 
       
   611 /**
       
   612 If defined, code for BTrace category BTrace::ESymbianKernelSync is compiled into
       
   613 the kernel.
       
   614 */
       
   615 #define BTRACE_SYMBIAN_KERNEL_SYNC
       
   616 
       
   617 /**
       
   618 If defined, code for BTrace category BTrace::EFlexibleMemModel is compiled into
       
   619 the kernel.
       
   620 
       
   621 This BTrace category is only supported on the flexible memory model.
       
   622 */
       
   623 #define BTRACE_FLEXIBLE_MEM_MODEL
       
   624 
       
   625 /**
       
   626 If defined, code for BTrace category BTrace::EIic is compiled into the
       
   627 IIC Subsystem.
       
   628 */
       
   629 #define BTRACE_IIC
       
   630 
       
   631 /**
       
   632 If defined, code for BTrace category BTrace::EClientServer is compiled into the
       
   633 kernel.
       
   634 */
       
   635 #define BTRACE_CLIENT_SERVER
       
   636 
       
   637 /**
       
   638 If defined, code for BTrace category BTrace::ERequest is compiled into the
       
   639 kernel.
       
   640 */
       
   641 #define BTRACE_REQUESTS
       
   642 
       
   643 #endif // _DEBUG
       
   644 
       
   645 #endif // __KERNEL_MODE__
       
   646 
       
   647 
       
   648 #if defined(BTRACE_KERNEL_PROTOTYPE)
       
   649 // Prototype trace categories...
       
   650 #undef BTRACE_THREAD_PRIORITY
       
   651 #define BTRACE_THREAD_PRIORITY
       
   652 #endif
       
   653 
       
   654 #if defined(BTRACE_KERNEL_VERBOSE)
       
   655 // Verbose trace options
       
   656 
       
   657 #ifdef BTRACE_PAGING
       
   658 /**
       
   659 If defined, verbose code for BTrace category BTrace::EPaging is compiled into the
       
   660 kernel.
       
   661 @publishedPartner
       
   662 @released 9.3
       
   663 */
       
   664 #define BTRACE_PAGING_VERBOSE
       
   665 #endif
       
   666 
       
   667 #endif //BTRACE_KERNEL_VERBOSE
       
   668 
       
   669 #if defined(_DEBUG) && !defined(__SMP__)
       
   670 /**
       
   671 @internalComponent
       
   672 */
       
   673 TInt KCrazySchedulerEnabled();
       
   674 #endif
       
   675 
       
   676 #endif // NK_TRACE_H