|
1 // Copyright (c) 2007-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 "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 // |
|
15 |
|
16 |
|
17 |
|
18 /** |
|
19 @file d32utrace.h |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #ifndef D32UTRACE_H |
|
24 #define D32UTRACE_H |
|
25 |
|
26 #ifndef __KERNEL_MODE__ |
|
27 #include <e32std.h> |
|
28 #endif |
|
29 #include <e32cmn.h> |
|
30 #include <e32ver.h> |
|
31 #include "te_tracerecord.h" |
|
32 |
|
33 //needs to be the filename of the driver |
|
34 _LIT(KUTraceDDDisabledFilename, "te_ostdd_disabled.ldd"); |
|
35 _LIT(KUTraceDDEnabledFilename, "te_ostdd_enabled.ldd"); |
|
36 _LIT(KUTraceDDSystemDisabledFilename, "te_utracedd_system_disabled.ldd"); |
|
37 _LIT(KUTraceDDSystemEnabledFilename, "te_utracedd_system_enabled.ldd"); |
|
38 _LIT(KUTraceDDEnabled, "UTraceDDEnabled"); |
|
39 _LIT(KUTraceDDDisabled, "UTraceDDDisabled"); |
|
40 _LIT(KUTraceDDSystemEnabled, "UTraceDDSystemEnabled"); |
|
41 _LIT(KUTraceDDSystemDisabled, "UTraceDDSystemDisabled"); |
|
42 |
|
43 struct TTimerResults |
|
44 { |
|
45 TUint32 iTime; |
|
46 TUint32 iCount; |
|
47 TInt iError; |
|
48 }; |
|
49 |
|
50 /** |
|
51 Interface to the utrace api. |
|
52 |
|
53 @internalTechnology |
|
54 */ |
|
55 class RUTrace : public RBusLogicalChannel |
|
56 { |
|
57 public: |
|
58 /** |
|
59 Structure for holding driver capabilities information |
|
60 (Just a version number in this example.) |
|
61 */ |
|
62 class TCaps |
|
63 { |
|
64 public: |
|
65 TVersion iVersion; |
|
66 }; |
|
67 |
|
68 enum TControl |
|
69 { |
|
70 ETestTrace, |
|
71 ETimeTrace |
|
72 }; |
|
73 |
|
74 inline static const TDesC& Name(); |
|
75 inline static TVersion VersionRequired(); |
|
76 |
|
77 /** |
|
78 Open channel to device driver. |
|
79 Must be called before any other methods are used. |
|
80 @return KErrNone or standard error code. |
|
81 */ |
|
82 TInt Open(); |
|
83 TInt Close(); |
|
84 TInt TestTraces(TTraceConfigs aTraceData); |
|
85 TInt TimeTraces(TTraceConfigs aTraceData, TUint32& aTime, TUint32& aCount); |
|
86 }; |
|
87 |
|
88 /** |
|
89 Returns the driver's name |
|
90 */ |
|
91 inline const TDesC& RUTrace::Name() |
|
92 { |
|
93 #ifdef SYMBIAN_TRACE_SYSTEM_IS_INCLUDED |
|
94 #ifdef SYMBIAN_TRACE_EXECUTABLE_IS_INCLUDED |
|
95 return KUTraceDDEnabledFilename; |
|
96 #else |
|
97 return KUTraceDDDisabledFilename; |
|
98 #endif |
|
99 #else |
|
100 #ifdef SYMBIAN_TRACE_EXECUTABLE_IS_INCLUDED |
|
101 return KUTraceDDSystemEnabledFilename; |
|
102 #else |
|
103 return KUTraceDDSystemDisabledFilename; |
|
104 #endif |
|
105 #endif |
|
106 } |
|
107 /** |
|
108 Returns the version number of the driver |
|
109 */ |
|
110 inline TVersion RUTrace::VersionRequired() |
|
111 { |
|
112 const TInt KMajorVersionNumber=1; |
|
113 const TInt KMinorVersionNumber=0; |
|
114 const TInt KBuildVersionNumber=3; |
|
115 return TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); |
|
116 } |
|
117 |
|
118 #ifndef __KERNEL_MODE__ |
|
119 |
|
120 TInt RUTrace::Open() |
|
121 { |
|
122 //this loads the driver in by using the filename |
|
123 //of the driver (adding the ldd extension if missing) |
|
124 TInt r = User::LoadLogicalDevice(Name()); |
|
125 if(r!=KErrNone && r!=KErrAlreadyExists) |
|
126 return r; |
|
127 //this uses the name of the logical device |
|
128 //(the name of the LDD factory object, not the |
|
129 //filename of the LDD DLL) |
|
130 #ifdef SYMBIAN_TRACE_SYSTEM_IS_INCLUDED |
|
131 #ifdef SYMBIAN_TRACE_EXECUTABLE_IS_INCLUDED |
|
132 r = DoCreate(KUTraceDDEnabled, TVersion(), KNullUnit, NULL, NULL, EOwnerThread); |
|
133 #else |
|
134 r = DoCreate(KUTraceDDDisabled, TVersion(), KNullUnit, NULL, NULL, EOwnerThread); |
|
135 #endif |
|
136 #else |
|
137 #ifdef SYMBIAN_TRACE_EXECUTABLE_IS_INCLUDED |
|
138 r = DoCreate(KUTraceDDSystemEnabled, TVersion(), KNullUnit, NULL, NULL, EOwnerThread); |
|
139 #else |
|
140 r = DoCreate(KUTraceDDSystemDisabled, TVersion(), KNullUnit, NULL, NULL, EOwnerThread); |
|
141 #endif |
|
142 #endif |
|
143 |
|
144 return r; |
|
145 }; |
|
146 |
|
147 TInt RUTrace::TestTraces(TTraceConfigs aTraceRecord) |
|
148 { |
|
149 TInt result = KErrNone; |
|
150 TInt error = KErrNone; |
|
151 error = DoControl(ETestTrace,(TAny*)&aTraceRecord,(TAny*)&result); |
|
152 if(error != KErrNone) |
|
153 return error; |
|
154 return result; |
|
155 } |
|
156 |
|
157 TInt RUTrace::TimeTraces(TTraceConfigs aTraceRecord, TUint32& aTime, TUint32& aCount) |
|
158 { |
|
159 |
|
160 TInt error = KErrNone; |
|
161 TTimerResults timer; |
|
162 error = DoControl(ETimeTrace,(TAny*)&aTraceRecord,(TAny*)&timer); |
|
163 aTime = timer.iTime; |
|
164 aCount = timer.iCount; |
|
165 return error; |
|
166 } |
|
167 |
|
168 TInt RUTrace::Close() |
|
169 { |
|
170 RBusLogicalChannel::Close(); |
|
171 return User::FreeLogicalDevice(RUTrace::Name()); |
|
172 } |
|
173 #endif //__KERNEL_MODE__ |
|
174 |
|
175 #endif |