Update contrib.
1 // Copyright (c) 2005-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\nkern\d_nktrace.cpp
15 // LDD for testing nanokernel debug trace bits
19 #define __INCLUDE_NTHREADBASE_DEFINES__
23 #include "d_nktrace.h"
25 const TInt KMajorVersionNumber=0;
26 const TInt KMinorVersionNumber=1;
27 const TInt KBuildVersionNumber=1;
29 class DNKTraceTestFactory : public DLogicalDevice
31 // NK Trace test LDD factory
35 DNKTraceTestFactory();
36 virtual TInt Install(); //overriding pure virtual
37 virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
38 virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual
41 class DNKTraceTest : public DLogicalChannelBase
43 // NK Trace test LDD channel
49 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
50 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
56 DECLARE_STANDARD_LDD()
59 return new DNKTraceTestFactory;
62 DNKTraceTestFactory::DNKTraceTestFactory()
68 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
71 TInt DNKTraceTestFactory::Create(DLogicalChannelBase*& aChannel)
73 // Create a new DNKTraceTest on this logical device
77 aChannel=new DNKTraceTest;
78 return aChannel?KErrNone:KErrNoMemory;
81 TInt DNKTraceTestFactory::Install()
83 // Install the LDD - overriding pure virtual
87 return SetName(&KLddName);
91 void DNKTraceTestFactory::GetCaps(TDes8& aDes) const
93 // Get capabilities - overriding pure virtual
96 TCapsNKTraceTestV01 b;
97 b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
98 Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b));
101 DNKTraceTest::DNKTraceTest()
110 TInt DNKTraceTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer)
117 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
118 return KErrNotSupported;
122 TInt DNKTraceTest::Request(TInt aReqNo, TAny* a1, TAny*)
124 TInt r=KErrNotSupported;
127 case RNKTraceTest::EControlKTrace:
130 Kern::Printf("D_NKTRACE : Test the __KTRACE_OPT macros");
131 __KTRACE_OPT(KALWAYS,Kern::Printf("D_NKTRACE : KALWAYS"));
132 __KTRACE_OPT(KPANIC,Kern::Printf("D_NKTRACE : KPANIC"));
133 __KTRACE_OPT(KSCRATCH,Kern::Printf("D_NKTRACE : KSCRATCH"));
134 __KTRACE_OPT(KPROC,Kern::Printf("D_NKTRACE : KPROC -- THIS SHOULD NOT PRINT!"));
135 __KTRACE_OPT(35,Kern::Printf("D_NKTRACE : Debug bit 35 is set"));
136 __KTRACE_OPT(36,Kern::Printf("D_NKTRACE : Debug bit 36 -- THIS SHOULD NOT PRINT!"));
137 __KTRACE_OPT(68,Kern::Printf("D_NKTRACE : Debug bit 68 is set"));
138 __KTRACE_OPT(101,Kern::Printf("D_NKTRACE : Debug bit 101 is set"));
139 __KTRACE_OPT(136,Kern::Printf("D_NKTRACE : Debug bit 136 is set"));
140 __KTRACE_OPT(172,Kern::Printf("D_NKTRACE : Debug bit 172 is set"));
141 __KTRACE_OPT(192,Kern::Printf("D_NKTRACE : Debug bit 192 is set"));
142 __KTRACE_OPT(230,Kern::Printf("D_NKTRACE : Debug bit 230 is set"));
143 __KTRACE_ALL(0xC0000000,Kern::Printf("D_NKTRACE : KTRACE_ALL returned true"));
144 __KTRACE_ALL(0xC0000001,Kern::Printf("D_NKTRACE : KTRACE_ALL -- THIS SHOULD NOT PRINT!"));
147 case RNKTraceTest::EControlKDebug:
152 Kern::Printf("D_NKTRACE : KDebug tests (%d)", arg);
154 TUint32 m = KDebugMask();
155 Kern::Printf("D_NKTRACE : KDebugMask() = 0x%08x", m);
156 TBool b = KDebugNum(30);
157 Kern::Printf("D_NKTRACE : KDebugNum(30) = %d", b);
159 Kern::Printf("D_NKTRACE : KDebugNum(31) = %d", b);
161 Kern::Printf("D_NKTRACE : KDebugNum(3) = %d", b);
163 Kern::Printf("D_NKTRACE : KDebugNum(9) = %d", b);
164 b = KDebugNum(10000);
165 Kern::Printf("D_NKTRACE : KDebugNum(10000) = %d", b);
167 Kern::Printf("D_NKTRACE : KDebugNum(-1) = %d", b);
169 Kern::Printf("D_NKTRACE : KDebugNum(-2) = %d", b);
171 Kern::Printf("D_NKTRACE : KDebugNum(35) = %d", b);
173 Kern::Printf("D_NKTRACE : KDebugNum(36) = %d", b);
175 Kern::Printf("D_NKTRACE : KDebugNum(101) = %d", b);
177 Kern::Printf("D_NKTRACE : KDebugNum(192) = %d", b);
179 Kern::Printf("D_NKTRACE : KDebugNum(230) = %d", b);