|
1 // Copyright (c) 2006-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\power\d_powermisctest.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <kernel/kernel.h> |
|
19 #include <kernel/kpower.h> |
|
20 #include "d_powermisctest.h" |
|
21 #include <smppower/idlehelper.h> |
|
22 #include "smpidlehandler.h" |
|
23 |
|
24 #ifdef __SMP__ |
|
25 NONSHARABLE_CLASS(DTest_SMPIdleHandler) : public DSMPIdleHandler |
|
26 { |
|
27 public: |
|
28 DTest_SMPIdleHandler() : DSMPIdleHandler() {}; |
|
29 TInt SelfTest() |
|
30 { |
|
31 // call unused functions to ensure it is covered in tests |
|
32 ResetSyncPoints(); |
|
33 return DoEnterIdle(0,0,NULL); |
|
34 } |
|
35 TBool GetLowPowerMode(TInt aIdleTime, TInt &aLowPowerMode) {return ETrue;} |
|
36 TBool EnterLowPowerMode(TInt aMode, TInt aCpuMask, TBool aLastCpu) {return ETrue;} |
|
37 }; |
|
38 #endif |
|
39 |
|
40 class DTestFactory : public DLogicalDevice |
|
41 // |
|
42 // Test LDD factory |
|
43 // |
|
44 { |
|
45 public: |
|
46 DTestFactory(); |
|
47 virtual TInt Install(); |
|
48 virtual void GetCaps(TDes8& aDes) const; |
|
49 virtual TInt Create(DLogicalChannelBase*& aChannel); |
|
50 }; |
|
51 |
|
52 class DTest1 : public DLogicalChannelBase |
|
53 // |
|
54 // Test logical channel |
|
55 // |
|
56 { |
|
57 public: |
|
58 virtual ~DTest1(); |
|
59 protected: |
|
60 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); |
|
61 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); |
|
62 |
|
63 private: |
|
64 TInt DoTest(); |
|
65 #ifdef __SMP__ |
|
66 private: |
|
67 DTest_SMPIdleHandler* iH; |
|
68 #endif |
|
69 }; |
|
70 |
|
71 |
|
72 |
|
73 DECLARE_STANDARD_LDD() |
|
74 { |
|
75 return new DTestFactory; |
|
76 } |
|
77 |
|
78 // |
|
79 // Constructor |
|
80 // |
|
81 DTestFactory::DTestFactory() |
|
82 { |
|
83 |
|
84 } |
|
85 |
|
86 TInt DTestFactory::Create(DLogicalChannelBase*& aChannel) |
|
87 { |
|
88 // |
|
89 // Create new channel |
|
90 // |
|
91 aChannel=new DTest1; |
|
92 return aChannel?KErrNone:KErrNoMemory; |
|
93 } |
|
94 |
|
95 TInt DTestFactory::Install() |
|
96 // |
|
97 // Install the LDD - overriding pure virtual |
|
98 // |
|
99 { |
|
100 return SetName(&KLddName); |
|
101 } |
|
102 |
|
103 void DTestFactory::GetCaps(TDes8& /*aDes*/) const |
|
104 // |
|
105 // Get capabilities - overriding pure virtual |
|
106 // |
|
107 { |
|
108 } |
|
109 |
|
110 TInt DTest1::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) |
|
111 // |
|
112 // Create channel |
|
113 // |
|
114 { |
|
115 #ifdef __SMP__ |
|
116 iH = new DTest_SMPIdleHandler(); |
|
117 TIdleSupport(); |
|
118 #endif |
|
119 return KErrNone; |
|
120 } |
|
121 |
|
122 DTest1::~DTest1() |
|
123 // |
|
124 // Destructor |
|
125 // |
|
126 { |
|
127 #ifdef __SMP__ |
|
128 delete iH; |
|
129 #endif |
|
130 } |
|
131 |
|
132 TInt DTest1::Request(TInt aReqNo, TAny* /*a1*/, TAny* /*a2*/) |
|
133 { |
|
134 |
|
135 // 'Control' functions... |
|
136 switch(aReqNo) |
|
137 { |
|
138 // DoControl |
|
139 case RLddTest1::ECONTROL_TEST: |
|
140 DoTest(); |
|
141 break; |
|
142 } |
|
143 |
|
144 return KErrNone; |
|
145 } |
|
146 |
|
147 TInt DTest1::DoTest() |
|
148 { |
|
149 #ifdef __SMP__ |
|
150 TInt r = KErrNone; |
|
151 |
|
152 // smp idle handler self tests |
|
153 Kern::Printf("smp idle handler self test"); |
|
154 iH->SelfTest(); |
|
155 |
|
156 // Test GetTimerCount using supplied timer |
|
157 Kern::Printf("test GetTimerCount using supplied timer"); |
|
158 TUint32 TimerCount = 10; |
|
159 TIdleSupport::SetupIdleSupport(0, 0, &TimerCount); |
|
160 if(TIdleSupport::GetTimerCount() != 10) |
|
161 { |
|
162 return KErrGeneral; |
|
163 } |
|
164 // Test GetTimerCount using default timer |
|
165 Kern::Printf("test GetTimerCound using default timer"); |
|
166 TIdleSupport::SetupIdleSupport(0, 0, 0); |
|
167 TimerCount = TIdleSupport::GetTimerCount(); |
|
168 |
|
169 // Test MarkCoreRetired() |
|
170 Kern::Printf("test MarkCoreRetired"); |
|
171 TUint32 engagedMask = *(TIdleSupport::EngagedCpusMaskAddr()); |
|
172 TIdleSupport::MarkCoreRetired(0x1); |
|
173 if(*(TIdleSupport::EngagedCpusMaskAddr())!= (engagedMask&(~0x1))) |
|
174 { |
|
175 return KErrGeneral; |
|
176 } |
|
177 // Test MarkCoreEngaged() |
|
178 Kern::Printf("test MarkCoreEngaged"); |
|
179 TIdleSupport::MarkCoreEngaged(0x1); |
|
180 if(*(TIdleSupport::EngagedCpusMaskAddr())!= (engagedMask|0x1)) |
|
181 { |
|
182 return KErrGeneral; |
|
183 } |
|
184 return r; |
|
185 #else |
|
186 Kern::Printf("DoTest no supported"); |
|
187 return KErrNotSupported; |
|
188 #endif |
|
189 |
|
190 } |