sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\nkern\d_nktrace.cpp sl@0: // LDD for testing nanokernel debug trace bits sl@0: // sl@0: // sl@0: sl@0: #define __INCLUDE_NTHREADBASE_DEFINES__ sl@0: sl@0: #include "platform.h" sl@0: #include "nk_priv.h" sl@0: #include "d_nktrace.h" sl@0: sl@0: const TInt KMajorVersionNumber=0; sl@0: const TInt KMinorVersionNumber=1; sl@0: const TInt KBuildVersionNumber=1; sl@0: sl@0: class DNKTraceTestFactory : public DLogicalDevice sl@0: // sl@0: // NK Trace test LDD factory sl@0: // sl@0: { sl@0: public: sl@0: DNKTraceTestFactory(); sl@0: virtual TInt Install(); //overriding pure virtual sl@0: virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual sl@0: virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual sl@0: }; sl@0: sl@0: class DNKTraceTest : public DLogicalChannelBase sl@0: // sl@0: // NK Trace test LDD channel sl@0: // sl@0: { sl@0: public: sl@0: DNKTraceTest(); sl@0: protected: sl@0: virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); sl@0: virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); sl@0: public: sl@0: TInt iTestNum; sl@0: }; sl@0: sl@0: sl@0: DECLARE_STANDARD_LDD() sl@0: { sl@0: //=== load sl@0: return new DNKTraceTestFactory; sl@0: } sl@0: sl@0: DNKTraceTestFactory::DNKTraceTestFactory() sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: //=== load sl@0: iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); sl@0: } sl@0: sl@0: TInt DNKTraceTestFactory::Create(DLogicalChannelBase*& aChannel) sl@0: // sl@0: // Create a new DNKTraceTest on this logical device sl@0: // sl@0: { sl@0: //=== open sl@0: aChannel=new DNKTraceTest; sl@0: return aChannel?KErrNone:KErrNoMemory; sl@0: } sl@0: sl@0: TInt DNKTraceTestFactory::Install() sl@0: // sl@0: // Install the LDD - overriding pure virtual sl@0: // sl@0: { sl@0: //=== load sl@0: return SetName(&KLddName); sl@0: } sl@0: sl@0: sl@0: void DNKTraceTestFactory::GetCaps(TDes8& aDes) const sl@0: // sl@0: // Get capabilities - overriding pure virtual sl@0: // sl@0: { sl@0: TCapsNKTraceTestV01 b; sl@0: b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); sl@0: Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b)); sl@0: } sl@0: sl@0: DNKTraceTest::DNKTraceTest() sl@0: // sl@0: // Constructor sl@0: // sl@0: //=== open sl@0: : iTestNum(-1) sl@0: { sl@0: } sl@0: sl@0: TInt DNKTraceTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer) sl@0: // sl@0: // Create channel sl@0: // sl@0: { sl@0: sl@0: //=== open sl@0: if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer)) sl@0: return KErrNotSupported; sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt DNKTraceTest::Request(TInt aReqNo, TAny* a1, TAny*) sl@0: { sl@0: TInt r=KErrNotSupported; sl@0: switch (aReqNo) sl@0: { sl@0: case RNKTraceTest::EControlKTrace: sl@0: { sl@0: r=KErrNone; sl@0: Kern::Printf("D_NKTRACE : Test the __KTRACE_OPT macros"); sl@0: __KTRACE_OPT(KALWAYS,Kern::Printf("D_NKTRACE : KALWAYS")); sl@0: __KTRACE_OPT(KPANIC,Kern::Printf("D_NKTRACE : KPANIC")); sl@0: __KTRACE_OPT(KSCRATCH,Kern::Printf("D_NKTRACE : KSCRATCH")); sl@0: __KTRACE_OPT(KPROC,Kern::Printf("D_NKTRACE : KPROC -- THIS SHOULD NOT PRINT!")); sl@0: __KTRACE_OPT(35,Kern::Printf("D_NKTRACE : Debug bit 35 is set")); sl@0: __KTRACE_OPT(36,Kern::Printf("D_NKTRACE : Debug bit 36 -- THIS SHOULD NOT PRINT!")); sl@0: __KTRACE_OPT(68,Kern::Printf("D_NKTRACE : Debug bit 68 is set")); sl@0: __KTRACE_OPT(101,Kern::Printf("D_NKTRACE : Debug bit 101 is set")); sl@0: __KTRACE_OPT(136,Kern::Printf("D_NKTRACE : Debug bit 136 is set")); sl@0: __KTRACE_OPT(172,Kern::Printf("D_NKTRACE : Debug bit 172 is set")); sl@0: __KTRACE_OPT(192,Kern::Printf("D_NKTRACE : Debug bit 192 is set")); sl@0: __KTRACE_OPT(230,Kern::Printf("D_NKTRACE : Debug bit 230 is set")); sl@0: __KTRACE_ALL(0xC0000000,Kern::Printf("D_NKTRACE : KTRACE_ALL returned true")); sl@0: __KTRACE_ALL(0xC0000001,Kern::Printf("D_NKTRACE : KTRACE_ALL -- THIS SHOULD NOT PRINT!")); sl@0: } sl@0: break; sl@0: case RNKTraceTest::EControlKDebug: sl@0: { sl@0: TInt arg =(TInt)a1; sl@0: sl@0: Kern::Printf(""); sl@0: Kern::Printf("D_NKTRACE : KDebug tests (%d)", arg); sl@0: r=KErrNone; sl@0: TUint32 m = KDebugMask(); sl@0: Kern::Printf("D_NKTRACE : KDebugMask() = 0x%08x", m); sl@0: TBool b = KDebugNum(30); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(30) = %d", b); sl@0: b = KDebugNum(31); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(31) = %d", b); sl@0: b = KDebugNum(3); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(3) = %d", b); sl@0: b = KDebugNum(9); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(9) = %d", b); sl@0: b = KDebugNum(10000); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(10000) = %d", b); sl@0: b = KDebugNum(-1); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(-1) = %d", b); sl@0: b = KDebugNum(-2); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(-2) = %d", b); sl@0: b = KDebugNum(35); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(35) = %d", b); sl@0: b = KDebugNum(36); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(36) = %d", b); sl@0: b = KDebugNum(101); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(101) = %d", b); sl@0: b = KDebugNum(192); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(192) = %d", b); sl@0: b = KDebugNum(230); sl@0: Kern::Printf("D_NKTRACE : KDebugNum(230) = %d", b); sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: return r; sl@0: } sl@0: