|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test\nkern\d_nktrace.cpp |
|
15 // LDD for testing nanokernel debug trace bits |
|
16 // |
|
17 // |
|
18 |
|
19 #define __INCLUDE_NTHREADBASE_DEFINES__ |
|
20 |
|
21 #include "platform.h" |
|
22 #include "nk_priv.h" |
|
23 #include "d_nktrace.h" |
|
24 |
|
25 const TInt KMajorVersionNumber=0; |
|
26 const TInt KMinorVersionNumber=1; |
|
27 const TInt KBuildVersionNumber=1; |
|
28 |
|
29 class DNKTraceTestFactory : public DLogicalDevice |
|
30 // |
|
31 // NK Trace test LDD factory |
|
32 // |
|
33 { |
|
34 public: |
|
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 |
|
39 }; |
|
40 |
|
41 class DNKTraceTest : public DLogicalChannelBase |
|
42 // |
|
43 // NK Trace test LDD channel |
|
44 // |
|
45 { |
|
46 public: |
|
47 DNKTraceTest(); |
|
48 protected: |
|
49 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); |
|
50 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
51 public: |
|
52 TInt iTestNum; |
|
53 }; |
|
54 |
|
55 |
|
56 DECLARE_STANDARD_LDD() |
|
57 { |
|
58 //=== load |
|
59 return new DNKTraceTestFactory; |
|
60 } |
|
61 |
|
62 DNKTraceTestFactory::DNKTraceTestFactory() |
|
63 // |
|
64 // Constructor |
|
65 // |
|
66 { |
|
67 //=== load |
|
68 iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
69 } |
|
70 |
|
71 TInt DNKTraceTestFactory::Create(DLogicalChannelBase*& aChannel) |
|
72 // |
|
73 // Create a new DNKTraceTest on this logical device |
|
74 // |
|
75 { |
|
76 //=== open |
|
77 aChannel=new DNKTraceTest; |
|
78 return aChannel?KErrNone:KErrNoMemory; |
|
79 } |
|
80 |
|
81 TInt DNKTraceTestFactory::Install() |
|
82 // |
|
83 // Install the LDD - overriding pure virtual |
|
84 // |
|
85 { |
|
86 //=== load |
|
87 return SetName(&KLddName); |
|
88 } |
|
89 |
|
90 |
|
91 void DNKTraceTestFactory::GetCaps(TDes8& aDes) const |
|
92 // |
|
93 // Get capabilities - overriding pure virtual |
|
94 // |
|
95 { |
|
96 TCapsNKTraceTestV01 b; |
|
97 b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
98 Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b)); |
|
99 } |
|
100 |
|
101 DNKTraceTest::DNKTraceTest() |
|
102 // |
|
103 // Constructor |
|
104 // |
|
105 //=== open |
|
106 : iTestNum(-1) |
|
107 { |
|
108 } |
|
109 |
|
110 TInt DNKTraceTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*anInfo*/, const TVersion& aVer) |
|
111 // |
|
112 // Create channel |
|
113 // |
|
114 { |
|
115 |
|
116 //=== open |
|
117 if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer)) |
|
118 return KErrNotSupported; |
|
119 return KErrNone; |
|
120 } |
|
121 |
|
122 TInt DNKTraceTest::Request(TInt aReqNo, TAny* a1, TAny*) |
|
123 { |
|
124 TInt r=KErrNotSupported; |
|
125 switch (aReqNo) |
|
126 { |
|
127 case RNKTraceTest::EControlKTrace: |
|
128 { |
|
129 r=KErrNone; |
|
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!")); |
|
145 } |
|
146 break; |
|
147 case RNKTraceTest::EControlKDebug: |
|
148 { |
|
149 TInt arg =(TInt)a1; |
|
150 |
|
151 Kern::Printf(""); |
|
152 Kern::Printf("D_NKTRACE : KDebug tests (%d)", arg); |
|
153 r=KErrNone; |
|
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); |
|
158 b = KDebugNum(31); |
|
159 Kern::Printf("D_NKTRACE : KDebugNum(31) = %d", b); |
|
160 b = KDebugNum(3); |
|
161 Kern::Printf("D_NKTRACE : KDebugNum(3) = %d", b); |
|
162 b = KDebugNum(9); |
|
163 Kern::Printf("D_NKTRACE : KDebugNum(9) = %d", b); |
|
164 b = KDebugNum(10000); |
|
165 Kern::Printf("D_NKTRACE : KDebugNum(10000) = %d", b); |
|
166 b = KDebugNum(-1); |
|
167 Kern::Printf("D_NKTRACE : KDebugNum(-1) = %d", b); |
|
168 b = KDebugNum(-2); |
|
169 Kern::Printf("D_NKTRACE : KDebugNum(-2) = %d", b); |
|
170 b = KDebugNum(35); |
|
171 Kern::Printf("D_NKTRACE : KDebugNum(35) = %d", b); |
|
172 b = KDebugNum(36); |
|
173 Kern::Printf("D_NKTRACE : KDebugNum(36) = %d", b); |
|
174 b = KDebugNum(101); |
|
175 Kern::Printf("D_NKTRACE : KDebugNum(101) = %d", b); |
|
176 b = KDebugNum(192); |
|
177 Kern::Printf("D_NKTRACE : KDebugNum(192) = %d", b); |
|
178 b = KDebugNum(230); |
|
179 Kern::Printf("D_NKTRACE : KDebugNum(230) = %d", b); |
|
180 } |
|
181 break; |
|
182 default: |
|
183 break; |
|
184 } |
|
185 return r; |
|
186 } |
|
187 |