kernel/eka/include/nkern/nk_trace.h
changeset 0 a41df078684a
child 4 56f325a607ea
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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 @internalComponent
       
   323 @released
       
   324 */
       
   325 #define KREALTIME	63 //0x80000000, index 1
       
   326 
       
   327 /**
       
   328 @internalComponent
       
   329 @released
       
   330 */
       
   331 #define KPAGING		62 //0x40000000, index 1
       
   332 
       
   333 /**
       
   334 @internalComponent
       
   335 @released
       
   336 */
       
   337 #define KLOCDPAGING		61 //0x20000000, index 1
       
   338 
       
   339 /**
       
   340 @internalComponent
       
   341 @released
       
   342 */
       
   343 #define KDATAPAGEWARN	60 //0x10000000, index 1
       
   344 
       
   345 /**
       
   346 @internalComponent
       
   347 @prototype
       
   348 */
       
   349 #define KPCI	59 //0x08000000, index 1
       
   350 
       
   351 /**
       
   352 @internalComponent
       
   353 @prototype
       
   354 */
       
   355 #define KPIPE	58 //0x04000000, index 1
       
   356 
       
   357 // RESERVED: Trace bits 192 - 255 are reserved for licensee partners
       
   358 
       
   359 
       
   360 /**
       
   361 @publishedPartner
       
   362 @released
       
   363 */
       
   364 #define KALWAYS		-1     //0xffffffff
       
   365 #define KMAXTRACE   (KNumTraceMaskWords*32-1)    // the maximum debug trace bit
       
   366 #else
       
   367 #define __KTRACE_OPT(a,p)
       
   368 #define __KTRACE_ALL(a,p)
       
   369 #define __KTRACE_OPT2(a,b,p)
       
   370 #define KALWAYS		-1
       
   371 #define KMAXTRACE   (KNumTraceMaskWords*32-1)
       
   372 #endif
       
   373 
       
   374 
       
   375 /**
       
   376 @publishedPartner
       
   377 @released
       
   378 */
       
   379 #define DEBUGMASKWORD2	2
       
   380 
       
   381 /*
       
   382 words 0 & 1 of debug mask should be used for kernel debugging
       
   383 word  2     of debug mask should be used to configure the ways the kernel behaves
       
   384 word  3     of debug mask should be used to configure the ways the user library behaves
       
   385 words 4 & 5 of debug mask should be used for file system debugging
       
   386 words 6 & 7 of debug mask are reserved for licensees
       
   387 */
       
   388 
       
   389 /**
       
   390 @publishedPartner
       
   391 @released
       
   392 */
       
   393 #define KALLTHREADSSYSTEM	64 //0x00000001, index 2
       
   394 
       
   395 /**
       
   396 Suppresses console output (in EWSRV) for faster automated tests.
       
   397 @publishedPartner
       
   398 @released
       
   399 */
       
   400 #define KTESTFAST			65 //0x00000002, index 2
       
   401 
       
   402 /**
       
   403 Suppresses anything which might disturb latency testing,
       
   404 for example platsec diagnostics emitted with the system lock held.
       
   405 @publishedPartner
       
   406 @released
       
   407 */
       
   408 #define KTESTLATENCY		66 //0x00000004, index 2
       
   409 
       
   410 /**
       
   411 When a crash occurs this flag determines whether the debugger executes.
       
   412 If set the crash debugger will NOT operate (even if it's in rom).
       
   413 If clear the crash debugger will run.
       
   414 @publishedPartner
       
   415 @released
       
   416  */
       
   417 #define KDEBUGMONITORDISABLE	67 //0x00000008, index 2
       
   418 
       
   419 /**
       
   420 When a crash occurs this flag determines whether the logger executes.
       
   421 If set the crash logger will NOT operate (even if it's in rom).
       
   422 If clear the crash logger will run.
       
   423 @publishedPartner
       
   424 @released
       
   425  */
       
   426 #define KCRASHLOGGERDISABLE	68 //0x00000010, index 2
       
   427 
       
   428 /**
       
   429 Delay scheduling of newly unblocked threads until the next timer tick
       
   430 occurs, to check for thread priority dependencies. Part of the crazy
       
   431 scheduler functionality.
       
   432 @publishedPartner
       
   433 @released
       
   434  */
       
   435 #define KCRAZYSCHEDDELAY 69 //0x00000020, index 2
       
   436 
       
   437 
       
   438 
       
   439 /* Word 3 of debug mask : configures user library behaviour */
       
   440 
       
   441 /**
       
   442 @publishedPartner
       
   443 @released
       
   444 */
       
   445 #define KUSERHEAPTRACE		96 //0x00000001, index 3
       
   446 
       
   447 
       
   448 
       
   449 #ifdef KFAIL
       
   450 
       
   451 /**
       
   452 @publishedPartner
       
   453 @released
       
   454 */
       
   455 #define __KTRACE_FAIL(r,p) {if ((r)!=KErrNone && (DEBUGNUM(KFAIL))) p;}
       
   456 
       
   457 #else
       
   458 #define __KTRACE_FAIL(r,p)
       
   459 #endif
       
   460 
       
   461 #include <e32btrace.h>
       
   462 
       
   463 #ifdef __KERNEL_MODE__
       
   464 
       
   465 
       
   466 class DBTraceFilter2;
       
   467 
       
   468 /**
       
   469 @internalComponent
       
   470 */
       
   471 struct SBTraceData
       
   472 	{
       
   473 	TUint8 iFilter[256];
       
   474 	BTrace::THandler iHandler;
       
   475 	BTrace::TControlFunction iControl;
       
   476 	DBTraceFilter2*volatile iFilter2;
       
   477 
       
   478 	TBool CheckFilter2(TUint32 aUid);
       
   479 	};
       
   480 
       
   481 /**
       
   482 @internalComponent
       
   483 */
       
   484 extern SBTraceData BTraceData;
       
   485 
       
   486 #if defined(_DEBUG) || defined(BTRACE_KERNEL_ALL)
       
   487 
       
   488 #undef BTRACE_THREAD_IDENTIFICATION
       
   489 #undef BTRACE_CPU_USAGE
       
   490 #undef BTRACE_CHUNKS
       
   491 #undef BTRACE_CODESEGS
       
   492 #undef BTRACE_PAGING
       
   493 #undef BTRACE_PAGING_MEDIA
       
   494 #undef BTRACE_KERNEL_MEMORY
       
   495 #undef BTRACE_RAM_ALLOCATOR
       
   496 #undef BTRACE_FAST_MUTEX
       
   497 #undef BTRACE_RESOURCE_MANAGER
       
   498 #undef BTRACE_RESMANUS
       
   499 #undef BTRACE_TRAWEVENT
       
   500 #undef BTRACE_SYMBIAN_KERNEL_SYNC
       
   501 #undef BTRACE_FLEXIBLE_MEM_MODEL
       
   502 
       
   503 
       
   504 /**
       
   505 If defined, code for BTrace category BTrace::EThreadIdentification
       
   506 is compiled into the kernel.
       
   507 @publishedPartner
       
   508 @released
       
   509 */
       
   510 #define BTRACE_THREAD_IDENTIFICATION
       
   511 
       
   512 /**
       
   513 If defined, code for BTrace category BTrace::ECpuUsage
       
   514 is compiled into the kernel.
       
   515 @publishedPartner
       
   516 @released
       
   517 */
       
   518 #define BTRACE_CPU_USAGE
       
   519 
       
   520 /**
       
   521 If defined, code for BTrace category BTrace::EChunks is compiled into the
       
   522 kernel.
       
   523 @publishedPartner
       
   524 @released
       
   525 */
       
   526 #define BTRACE_CHUNKS
       
   527 
       
   528 /**
       
   529 If defined, code for BTrace category BTrace::ECodeSegs is compiled into the
       
   530 kernel.
       
   531 @publishedPartner
       
   532 @released
       
   533 */
       
   534 #define BTRACE_CODESEGS
       
   535 
       
   536 /**
       
   537 If defined, code for BTrace category BTrace::EPaging is compiled into the
       
   538 kernel.
       
   539 @publishedPartner
       
   540 @released 9.3
       
   541 */
       
   542 #define BTRACE_PAGING
       
   543 
       
   544 /**
       
   545 If defined, code for BTrace category BTrace::EPagingMedia is compiled into the
       
   546 Local Media Subsystem and relevant paging media drivers.
       
   547 @publishedPartner
       
   548 @released 9.3
       
   549 */
       
   550 #define BTRACE_PAGING_MEDIA
       
   551 
       
   552 /**
       
   553 If defined, code for BTrace category BTrace::EKernelMemory is compiled into the
       
   554 kernel.
       
   555 @publishedPartner
       
   556 @released 9.4
       
   557 */
       
   558 #define BTRACE_KERNEL_MEMORY
       
   559 
       
   560 /**
       
   561 If defined, code for BTrace category BTrace::ERamAllocator is compiled into the
       
   562 kernel.
       
   563 
       
   564 This BTrace category is only supported on the multiple and moving memory models.
       
   565 
       
   566 @publishedPartner
       
   567 @released 9.4
       
   568 */
       
   569 #if defined(__MEMMODEL_MOVING__) || defined (__MEMMODEL_MULTIPLE__)
       
   570 #define BTRACE_RAM_ALLOCATOR
       
   571 #endif
       
   572 
       
   573 /**
       
   574 If defined, code for BTrace category BTrace::EFastMutex is compiled into the
       
   575 kernel.
       
   576 */
       
   577 #define BTRACE_FAST_MUTEX
       
   578 
       
   579 /**
       
   580 If defined, code for BTrace category BTrace::EResourceManager is compiled into the
       
   581 Resource Manager Subsystem.
       
   582 @publishedPartner
       
   583 @released 9.5
       
   584 */
       
   585 #define BTRACE_RESOURCE_MANAGER
       
   586 
       
   587 /**
       
   588 If defined, code for BTrace category BTrace::EResourceManagerUs is compiled into the
       
   589 Resource Manager Subsystem's User-Side API.
       
   590 @publishedPartner
       
   591 @released 9.5
       
   592 */
       
   593 #define BTRACE_RESMANUS
       
   594 
       
   595 /**
       
   596 If defined, code for BTrace category BTrace::ERawEvent is compiled into the
       
   597 kernel.
       
   598 @publishedPartner
       
   599 @released 9.5
       
   600 */
       
   601 #define BTRACE_TRAWEVENT
       
   602 
       
   603 /**
       
   604 If defined, code for BTrace category BTrace::ESymbianKernelSync is compiled into
       
   605 the kernel.
       
   606 */
       
   607 #define BTRACE_SYMBIAN_KERNEL_SYNC
       
   608 
       
   609 /**
       
   610 If defined, code for BTrace category BTrace::EFlexibleMemModel is compiled into
       
   611 the kernel.
       
   612 
       
   613 This BTrace category is only supported on the flexible memory model.
       
   614 */
       
   615 #define BTRACE_FLEXIBLE_MEM_MODEL
       
   616 
       
   617 /**
       
   618 If defined, code for BTrace category BTrace::EIic is compiled into the
       
   619 IIC Subsystem.
       
   620 */
       
   621 #define BTRACE_IIC
       
   622 
       
   623 #endif // _DEBUG
       
   624 
       
   625 #endif // __KERNEL_MODE__
       
   626 
       
   627 
       
   628 #if defined(BTRACE_KERNEL_PROTOTYPE)
       
   629 // Prototype trace categories...
       
   630 #undef BTRACE_CLIENT_SERVER
       
   631 #define BTRACE_CLIENT_SERVER
       
   632 #undef BTRACE_REQUESTS
       
   633 #define BTRACE_REQUESTS
       
   634 #undef BTRACE_THREAD_PRIORITY
       
   635 #define BTRACE_THREAD_PRIORITY
       
   636 #endif
       
   637 
       
   638 #if defined(BTRACE_KERNEL_VERBOSE)
       
   639 // Verbose trace options
       
   640 
       
   641 #ifdef BTRACE_PAGING
       
   642 /**
       
   643 If defined, verbose code for BTrace category BTrace::EPaging is compiled into the
       
   644 kernel.
       
   645 @publishedPartner
       
   646 @released 9.3
       
   647 */
       
   648 #define BTRACE_PAGING_VERBOSE
       
   649 #endif
       
   650 
       
   651 #endif //BTRACE_KERNEL_VERBOSE
       
   652 
       
   653 #if defined(_DEBUG) && !defined(__SMP__)
       
   654 /**
       
   655 @internalComponent
       
   656 */
       
   657 TInt KCrazySchedulerEnabled();
       
   658 #endif
       
   659 
       
   660 #endif // NK_TRACE_H