os/kernelhwsrv/kerneltest/e32test/nkern/d_nktrace.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2005-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
// e32test\nkern\d_nktrace.cpp
sl@0
    15
// LDD for testing nanokernel debug trace bits
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
#define __INCLUDE_NTHREADBASE_DEFINES__
sl@0
    20
sl@0
    21
#include "platform.h"
sl@0
    22
#include "nk_priv.h"
sl@0
    23
#include "d_nktrace.h"
sl@0
    24
sl@0
    25
const TInt KMajorVersionNumber=0;
sl@0
    26
const TInt KMinorVersionNumber=1;
sl@0
    27
const TInt KBuildVersionNumber=1;
sl@0
    28
sl@0
    29
class DNKTraceTestFactory : public DLogicalDevice
sl@0
    30
//
sl@0
    31
// NK Trace test LDD factory
sl@0
    32
//
sl@0
    33
	{
sl@0
    34
public:
sl@0
    35
	DNKTraceTestFactory();
sl@0
    36
	virtual TInt Install();						//overriding pure virtual
sl@0
    37
	virtual void GetCaps(TDes8& aDes) const;	//overriding pure virtual
sl@0
    38
	virtual TInt Create(DLogicalChannelBase*& aChannel);	//overriding pure virtual
sl@0
    39
	};
sl@0
    40
sl@0
    41
class DNKTraceTest : public DLogicalChannelBase
sl@0
    42
//
sl@0
    43
// NK Trace test LDD channel
sl@0
    44
//
sl@0
    45
	{
sl@0
    46
public:
sl@0
    47
	DNKTraceTest();
sl@0
    48
protected:
sl@0
    49
	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
sl@0
    50
	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
sl@0
    51
public:
sl@0
    52
	TInt iTestNum;
sl@0
    53
	};
sl@0
    54
sl@0
    55
sl@0
    56
DECLARE_STANDARD_LDD()
sl@0
    57
	{
sl@0
    58
	//=== load
sl@0
    59
    return new DNKTraceTestFactory;
sl@0
    60
    }
sl@0
    61
sl@0
    62
DNKTraceTestFactory::DNKTraceTestFactory()
sl@0
    63
//
sl@0
    64
// Constructor
sl@0
    65
//
sl@0
    66
    {
sl@0
    67
	//=== load
sl@0
    68
    iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
sl@0
    69
    }
sl@0
    70
sl@0
    71
TInt DNKTraceTestFactory::Create(DLogicalChannelBase*& aChannel)
sl@0
    72
//
sl@0
    73
// Create a new DNKTraceTest on this logical device
sl@0
    74
//
sl@0
    75
    {
sl@0
    76
	//=== open
sl@0
    77
	aChannel=new DNKTraceTest;
sl@0
    78
    return aChannel?KErrNone:KErrNoMemory;
sl@0
    79
    }
sl@0
    80
sl@0
    81
TInt DNKTraceTestFactory::Install()
sl@0
    82
//
sl@0
    83
// Install the LDD - overriding pure virtual
sl@0
    84
//
sl@0
    85
    {
sl@0
    86
	//=== load
sl@0
    87
    return SetName(&KLddName);
sl@0
    88
    }
sl@0
    89
sl@0
    90
sl@0
    91
void DNKTraceTestFactory::GetCaps(TDes8& aDes) const
sl@0
    92
//
sl@0
    93
// Get capabilities - overriding pure virtual
sl@0
    94
//
sl@0
    95
    {
sl@0
    96
    TCapsNKTraceTestV01 b;
sl@0
    97
    b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
sl@0
    98
    Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b));
sl@0
    99
    }
sl@0
   100
sl@0
   101
DNKTraceTest::DNKTraceTest()
sl@0
   102
//
sl@0
   103
// Constructor
sl@0
   104
//
sl@0
   105
	//=== open
sl@0
   106
	: iTestNum(-1)
sl@0
   107
    {
sl@0
   108
    }
sl@0
   109
sl@0
   110
TInt DNKTraceTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer)
sl@0
   111
//
sl@0
   112
// Create channel
sl@0
   113
//
sl@0
   114
    {
sl@0
   115
sl@0
   116
	//=== open
sl@0
   117
    if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
sl@0
   118
    	return KErrNotSupported;
sl@0
   119
	return KErrNone;
sl@0
   120
	}
sl@0
   121
sl@0
   122
TInt DNKTraceTest::Request(TInt aReqNo, TAny* a1, TAny*)
sl@0
   123
	{
sl@0
   124
	TInt r=KErrNotSupported;
sl@0
   125
	switch (aReqNo)
sl@0
   126
		{
sl@0
   127
		case RNKTraceTest::EControlKTrace:
sl@0
   128
			{
sl@0
   129
			r=KErrNone;
sl@0
   130
			Kern::Printf("D_NKTRACE : Test the __KTRACE_OPT macros");
sl@0
   131
			__KTRACE_OPT(KALWAYS,Kern::Printf("D_NKTRACE : KALWAYS"));
sl@0
   132
			__KTRACE_OPT(KPANIC,Kern::Printf("D_NKTRACE : KPANIC"));
sl@0
   133
			__KTRACE_OPT(KSCRATCH,Kern::Printf("D_NKTRACE : KSCRATCH"));
sl@0
   134
			__KTRACE_OPT(KPROC,Kern::Printf("D_NKTRACE : KPROC -- THIS SHOULD NOT PRINT!"));
sl@0
   135
			__KTRACE_OPT(35,Kern::Printf("D_NKTRACE : Debug bit 35 is set"));
sl@0
   136
			__KTRACE_OPT(36,Kern::Printf("D_NKTRACE : Debug bit 36 -- THIS SHOULD NOT PRINT!"));
sl@0
   137
			__KTRACE_OPT(68,Kern::Printf("D_NKTRACE : Debug bit 68 is set"));
sl@0
   138
			__KTRACE_OPT(101,Kern::Printf("D_NKTRACE : Debug bit 101 is set"));
sl@0
   139
			__KTRACE_OPT(136,Kern::Printf("D_NKTRACE : Debug bit 136 is set"));
sl@0
   140
			__KTRACE_OPT(172,Kern::Printf("D_NKTRACE : Debug bit 172 is set"));
sl@0
   141
			__KTRACE_OPT(192,Kern::Printf("D_NKTRACE : Debug bit 192 is set"));
sl@0
   142
			__KTRACE_OPT(230,Kern::Printf("D_NKTRACE : Debug bit 230 is set"));
sl@0
   143
			__KTRACE_ALL(0xC0000000,Kern::Printf("D_NKTRACE : KTRACE_ALL returned true"));
sl@0
   144
			__KTRACE_ALL(0xC0000001,Kern::Printf("D_NKTRACE : KTRACE_ALL -- THIS SHOULD NOT PRINT!"));
sl@0
   145
			}
sl@0
   146
			break;
sl@0
   147
		case RNKTraceTest::EControlKDebug:
sl@0
   148
			{
sl@0
   149
			TInt arg =(TInt)a1;
sl@0
   150
sl@0
   151
			Kern::Printf("");
sl@0
   152
			Kern::Printf("D_NKTRACE : KDebug tests (%d)", arg);
sl@0
   153
			r=KErrNone;
sl@0
   154
			TUint32 m = KDebugMask();
sl@0
   155
			Kern::Printf("D_NKTRACE : KDebugMask() = 0x%08x", m);
sl@0
   156
			TBool b = KDebugNum(30);
sl@0
   157
			Kern::Printf("D_NKTRACE : KDebugNum(30) = %d", b);
sl@0
   158
			b = KDebugNum(31);
sl@0
   159
			Kern::Printf("D_NKTRACE : KDebugNum(31) = %d", b);
sl@0
   160
			b = KDebugNum(3);
sl@0
   161
			Kern::Printf("D_NKTRACE : KDebugNum(3) = %d", b);
sl@0
   162
			b = KDebugNum(9);
sl@0
   163
			Kern::Printf("D_NKTRACE : KDebugNum(9) = %d", b);
sl@0
   164
			b = KDebugNum(10000);
sl@0
   165
			Kern::Printf("D_NKTRACE : KDebugNum(10000) = %d", b);
sl@0
   166
			b = KDebugNum(-1);
sl@0
   167
			Kern::Printf("D_NKTRACE : KDebugNum(-1) = %d", b);
sl@0
   168
			b = KDebugNum(-2);
sl@0
   169
			Kern::Printf("D_NKTRACE : KDebugNum(-2) = %d", b);
sl@0
   170
			b = KDebugNum(35);
sl@0
   171
			Kern::Printf("D_NKTRACE : KDebugNum(35) = %d", b);
sl@0
   172
			b = KDebugNum(36);
sl@0
   173
			Kern::Printf("D_NKTRACE : KDebugNum(36) = %d", b);
sl@0
   174
			b = KDebugNum(101);
sl@0
   175
			Kern::Printf("D_NKTRACE : KDebugNum(101) = %d", b);
sl@0
   176
			b = KDebugNum(192);
sl@0
   177
			Kern::Printf("D_NKTRACE : KDebugNum(192) = %d", b);
sl@0
   178
			b = KDebugNum(230);
sl@0
   179
			Kern::Printf("D_NKTRACE : KDebugNum(230) = %d", b);
sl@0
   180
			}
sl@0
   181
			break;
sl@0
   182
		default:
sl@0
   183
			break;
sl@0
   184
		}
sl@0
   185
	return r;
sl@0
   186
	}
sl@0
   187