|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #if !defined(__D_MMCSDIF_H__) |
|
20 #include <e32cmn.h> |
|
21 #ifndef __KERNEL_MODE__ |
|
22 #include <e32std.h> |
|
23 #endif |
|
24 #include "MmcTestUtils.h" |
|
25 |
|
26 |
|
27 #ifdef __DEBUG |
|
28 #define _MMCSDLDDLOGGING // Enable LDD logging |
|
29 #endif |
|
30 |
|
31 #if defined( _MMCSDLDDLOGGING ) |
|
32 #define MMCSDLOG(A) Kern::Printf(A) |
|
33 #define MMCSDLOG2(A, B) Kern::Printf(A, B) |
|
34 #define MMCSDLOG3(A, B, C) Kern::Printf(A, B, C) |
|
35 #define MMCSDLOG4(A, B, C, D) Kern::Printf(A, B, C, D) |
|
36 #define MMCSDLOG5(A, B, C, D, E) Kern::Printf(A, B, C, D, E) |
|
37 #define MMCSDLOG6(A, B, C, D, E, F) Kern::Printf(A, B, C, D, E, F) |
|
38 #else |
|
39 #define MMCSDLOG(A) |
|
40 #define MMCSDLOG2(A, B) |
|
41 #define MMCSDLOG3(A, B, C) |
|
42 #define MMCSDLOG4(A, B, C, D) |
|
43 #define MMCSDLOG5(A, B, C, D, E) |
|
44 #define MMCSDLOG6(A, B, C, D, E, F) |
|
45 #endif |
|
46 |
|
47 |
|
48 _LIT(KLddName, "MMCSDTestCtrlInf"); |
|
49 |
|
50 //Card Constants |
|
51 const TInt KMaxCardsPerStack=2; |
|
52 const TInt KSectorSizeInBytes=512; |
|
53 const TInt KMaxBlocklengthInBytes=1024; |
|
54 const TInt KSectorSizeShift=9; |
|
55 const TInt KDrvBufSizeInSectors=8; |
|
56 |
|
57 const TInt KStackNo=0; |
|
58 |
|
59 //Used to check erase command is supported by the card. |
|
60 const TUint32 KMMCEraseClassCmdSupported=KBit0; |
|
61 |
|
62 //Used to check group erase command is supported by the card. |
|
63 const TUint32 KMMCEraseGroupCmdSupported=KBit1; |
|
64 |
|
65 |
|
66 /** |
|
67 * Card power supply information |
|
68 * |
|
69 */ |
|
70 class TPBusPsuInf |
|
71 { |
|
72 public: |
|
73 |
|
74 /** Indicates the voltage level, or range of voltages supported. |
|
75 Reperesented in OCR (Operation Condition Register) */ |
|
76 TUint iVoltageSupported; |
|
77 |
|
78 /** Maximum Current Supplied by the PSU */ |
|
79 TInt iMaxCurrentInMicroAmps; |
|
80 |
|
81 /** PSU Voltage level within expected limit while turning ON */ |
|
82 TUint iVoltCheckInterval; |
|
83 |
|
84 /** VCC voltage when ON */ |
|
85 TUint iVoltCheckMethod; |
|
86 |
|
87 /** Bus not locked timeout period,in seconds,when no clients are registered */ |
|
88 TInt iNotLockedTimeOut; |
|
89 |
|
90 /** Bus inactivity timeout period, in seconds, when clients are registered */ |
|
91 TInt iInactivityTimeOut; |
|
92 |
|
93 }; |
|
94 |
|
95 /** |
|
96 * MMC card Version |
|
97 * |
|
98 */ |
|
99 class TCapsMmcIfV01 |
|
100 { |
|
101 public: |
|
102 TVersion version; |
|
103 }; |
|
104 |
|
105 |
|
106 /** |
|
107 * Class for MMCSD controller interface to test MMC/SD Cards |
|
108 * |
|
109 */ |
|
110 class RMMCSDTestControllerInterface : public RBusLogicalChannel |
|
111 { |
|
112 public: |
|
113 enum {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=1}; |
|
114 enum TRequest |
|
115 { |
|
116 /** Read a sector */ |
|
117 EReadSector, |
|
118 /** Write a sector */ |
|
119 EWriteSector |
|
120 }; |
|
121 enum TControl |
|
122 { |
|
123 /** Return whether SD card is in use */ |
|
124 ESDCard, |
|
125 /** Read CSD register */ |
|
126 EReadCSD, |
|
127 /** Read extended CSD register */ |
|
128 EReadExtCSD, |
|
129 /** Get card info */ |
|
130 ECardInfo, |
|
131 /** Return card object */ |
|
132 ECard, |
|
133 /** Return card is present status */ |
|
134 ECardIsPresent, |
|
135 /** Return card is ready status */ |
|
136 ECardIsReady, |
|
137 /** Return card is locked status */ |
|
138 ECardIsLocked |
|
139 }; |
|
140 enum TPsuControl |
|
141 { |
|
142 /** Return psu object */ |
|
143 EPsu, |
|
144 /** Gets the PSU Information */ |
|
145 EPsuInfo, |
|
146 /** Set Power Supply State */ |
|
147 EPsuState, |
|
148 /**Set Psu Voltage in OCR format */ |
|
149 EPsuVoltage, |
|
150 /** Read Power supply unit number */ |
|
151 EPsuNum, |
|
152 /** Read the Media Change ID */ |
|
153 EMediaChangeNum, |
|
154 /** PSU current limit safe level or Not */ |
|
155 EPsuCurLimit, |
|
156 /** Gets the PBUS state */ |
|
157 EPbusState, |
|
158 /** Gets the Power Supply Status */ |
|
159 EVccState, |
|
160 /** Checks whether this PSU is powering a bus containing a locked device*/ |
|
161 EIsLocked, |
|
162 /** Checks whether the PSU is off*/ |
|
163 EIsOff, |
|
164 /** Gets the maximum current (in microAmps) that the PSU is able to supply*/ |
|
165 EMaxCurrentInMicroAmps, |
|
166 /** Resets inactivity and not-locked counts*/ |
|
167 EResetInactivityTimer, |
|
168 /** Gets the voltage level, or range of supported voltage levels*/ |
|
169 EVoltageSupported, |
|
170 /** Bus inactivity counter*/ |
|
171 EMemInactivityCount, |
|
172 /** Bus not locked counter*/ |
|
173 EMemNotLockedCount, |
|
174 /** Bus inactivity timeout period, in seconds, when clients are registered*/ |
|
175 EMemInactivityTimeout, |
|
176 /** Bus not locked timeout period, in seconds, when no clients are registered*/ |
|
177 EMemNotLockedTimeout, |
|
178 /** Indicates the voltage level, or range of voltages supported*/ |
|
179 EMemVoltageSupported, |
|
180 /** The maximum current (in microAmps) that the PSU is able to supply*/ |
|
181 EMemMaxCurrentInMicroAmps, |
|
182 /**Indicates whether the platform hardware has support for checking whether the voltage level*/ |
|
183 EMemVoltCheckInterval |
|
184 }; |
|
185 enum TMediaChangeControl |
|
186 { |
|
187 /** Return media change object */ |
|
188 EMediaChange, |
|
189 /** Gets the MMC stack media state */ |
|
190 EMediaStateInfo, |
|
191 /** Force Media Change */ |
|
192 EForceMediaChange, |
|
193 /** Media Change Replay Count */ |
|
194 EMediaChangeCounter |
|
195 }; |
|
196 enum TSocketControl |
|
197 { |
|
198 /** Return socket object */ |
|
199 ESocket |
|
200 /** DMMCSocket::AdjustPartialRead */ |
|
201 ,ESocketAdjustPartialRead |
|
202 /** DMMCSocket::CardIsPresent */ |
|
203 ,ESocketCardIsPresent |
|
204 /** DMMCSocket::GetBufferInfo */ |
|
205 ,ESocketGetBufferInfo |
|
206 /** DMMCSocket::Init */ |
|
207 ,ESocketInit |
|
208 /** DMMCSocket::InitiatePowerUpSequence */ |
|
209 ,ESocketInitiatePowerUpSequence |
|
210 /** DMMCSocket::MachineInfo */ |
|
211 ,ESocketMachineInfo |
|
212 /** DMMCSocket::PrepareStore */ |
|
213 ,ESocketPrepareStore |
|
214 /** DMMCSocket::Reset1 */ |
|
215 ,ESocketReset1 |
|
216 /** DMMCSocket::Reset2 */ |
|
217 ,ESocketReset2 |
|
218 /** DMMCSocket::ResetInactivity */ |
|
219 ,ESocketResetInactivity |
|
220 /** DMMCSocket::Stack */ |
|
221 ,ESocketStack |
|
222 /** DMMCSocket::iState */ |
|
223 ,ESocketiState_Get |
|
224 /** DMMCSocket::iDoorOpened */ |
|
225 ,ESocketiDoorOpened_Get |
|
226 /** DMMCSocket::iStandby */ |
|
227 ,ESocketiStandby_Get |
|
228 /** DMMCSocket::iType */ |
|
229 ,ESocketiType_Get |
|
230 /** DMMCSocket::PowerUp */ |
|
231 ,ESocketPowerUp |
|
232 }; |
|
233 enum TStackControl |
|
234 { |
|
235 /** Return stack object */ |
|
236 EStack |
|
237 /** DMMCStack::AdjustPartialRead */ |
|
238 ,EStackAdjustPartialRead |
|
239 /** DMMCStack::AllocSession */ |
|
240 ,EStackAllocSession |
|
241 /** DMMCStack::BufferInfo */ |
|
242 ,EStackBufferInfo |
|
243 /** DMMCStack::CardP */ |
|
244 ,EStackCardP |
|
245 /** DMMCStack::DemandPagingInfo */ |
|
246 ,EStackDemandPagingInfo |
|
247 /** DMMCStack::EffectiveModes */ |
|
248 ,EStackEffectiveModes |
|
249 /** DMMCStack::GetBufferInfo */ |
|
250 ,EStackGetBufferInfo |
|
251 /** DMMCStack::HasCardsPresent */ |
|
252 ,EStackHasCardsPresent |
|
253 /** DMMCStack::HasSessionsQueued */ |
|
254 ,EStackHasSessionsQueued |
|
255 /** DMMCStack::Init */ |
|
256 , EStackInit |
|
257 /** DMMCStack::InitStackInProgress */ |
|
258 , EStackInitStackInProgress |
|
259 /** DMMCStack::MMCSocket */ |
|
260 , EStackMMCSocket |
|
261 /** DMMCStack::MachineInfo */ |
|
262 , EStackMachineInfo |
|
263 /** DMMCStack::MaxCardsInStack */ |
|
264 , EStackMaxCardsInStack |
|
265 /** DMMCStack::PasswordStore read*/ |
|
266 , EStackReadPasswordStore |
|
267 /** DMMCStack::PasswordStore write*/ |
|
268 , EStackWritePasswordStore |
|
269 /** DMMCStack::ProgramPeriodInMs */ |
|
270 , EStackProgramPeriodInMs |
|
271 /** DMMCStack::StackStop */ |
|
272 , EStackStop |
|
273 /** DMMCStack::ReportPowerDown */ |
|
274 , EStackReportPowerDown |
|
275 /** DMMCStack::ReportPowerUp */ |
|
276 , EStackReportPowerUp |
|
277 /** see TEffectiveModesFunctionId enum */ |
|
278 , EStackConfigureEffectiveModes |
|
279 }; |
|
280 |
|
281 enum TEffectiveModesFunctionId { |
|
282 /** TMMCStackConfig::RemoveMode(TUint32 aMask) */ |
|
283 EStackEffectiveModesRemoveMode = 1 |
|
284 /** TMMCStackConfig::SetBusClockInKhz(TUint aParam) */ |
|
285 , EStackEffectiveModesSetBusClockInKhz |
|
286 /** TMMCStackConfig:: SetBusClockInKhz(TUint aParam); */ |
|
287 , EStackEffectiveModesSetBusyTimeOutInMcs |
|
288 /** TMMCStackConfig::SetCRCRetries(TUint aData)*/ |
|
289 , EStackEffectiveModesSetCRCRetries |
|
290 /** TMMCStackConfig::SetDataTimeOutInMcs(TUint aParam) */ |
|
291 , EStackEffectiveModesSetDataTimeOutInMcs |
|
292 /** TMMCStackConfig::TUint32 aMask*/ |
|
293 , EStackEffectiveModesSetMode |
|
294 /** TMMCStackConfig::SetOpCondBusyTimeout(TUint16 aData); */ |
|
295 , EStackEffectiveModesSetOpCondBusyTimeout |
|
296 /** TMMCStackConfig::SetPollAttempts(TUint aData); */ |
|
297 , EStackEffectiveModesSetPollAttempts |
|
298 /** TMMCStackConfig::SetResponseTimeOutInTicks(TUint aParam); */ |
|
299 , EStackEffectiveModesSetResponseTimeOutInTicks |
|
300 /** TMMCStackConfig:: SetTicksClockIn(TUint aParam); */ |
|
301 , EStackEffectiveModesSetTicksClockIn |
|
302 /** TMMCStackConfig::SetTicksClockOut(TUint aParam); */ |
|
303 , EStackEffectiveModesSetTicksClockOut |
|
304 /** TMMCStackConfig::SetTimeOutRetries(TUint aData); */ |
|
305 , EStackEffectiveModesSetTimeOutRetries |
|
306 |
|
307 }; |
|
308 public: |
|
309 inline void Cancel(); |
|
310 inline TInt Open(TInt aStack,const TVersion& aVer); |
|
311 inline TVersion VersionRequired() const; |
|
312 inline void Reset(); |
|
313 // requests |
|
314 inline TInt ReadBlock(); |
|
315 |
|
316 //DMMCPsu |
|
317 inline TInt Psu(TAny* aPsu); |
|
318 inline TInt PsuInfo(TPBusPsuInf& anInfo); |
|
319 inline TInt SetPsuState(TInt& aState); |
|
320 inline TInt SetPsuVoltage(TUint& aVol); |
|
321 inline TInt PsuNumber(TInt& aPsuNum); |
|
322 inline TInt MediaChangeID(TInt& aMCId); |
|
323 inline TInt PsuCurLimit(TBool& aSafe); |
|
324 inline TInt PbusState(TInt& aState); |
|
325 inline TInt VccState(TInt& aVccState); |
|
326 inline TInt IsLocked(TBool& aState); |
|
327 inline TInt IsOff(TBool& aState); |
|
328 inline TInt MaxCurrentInMicroAmps(TInt& aMaxCurrent); |
|
329 inline TInt ResetInactivityTimer(); |
|
330 inline TInt VoltageSupported(TUint& aVoltage); |
|
331 inline TInt InactivityCount(TInt& aInactivityCount); |
|
332 inline TInt NotLockedCount(TInt& aNotLockedCount); |
|
333 inline TInt InactivityTimeout(TInt& aInactivityTimeout); |
|
334 inline TInt NotLockedTimeout(TInt& aNotLockedTimeout); |
|
335 inline TInt MemVoltageSupported(TUint& aVoltage); |
|
336 inline TInt MemMaxCurrentInMicroAmps(TInt& aMaxCurrent); |
|
337 inline TInt VoltCheckInterval(TUint& aVoltCheckInterval); |
|
338 |
|
339 //DMMCMediaChange |
|
340 inline TInt MediaChange(TAny* aMediaChange); |
|
341 inline TInt MediaStateInfo(TInt& aMediaState); |
|
342 inline TInt ForceMediaChange(); |
|
343 inline TInt MediaChangeCounter(TInt& aCounter); |
|
344 |
|
345 // DMMCSocket |
|
346 inline TInt Socket(TAny* aSocket); |
|
347 inline TInt SocketAdjustPartialRead(TPartialReadData& aPartialReadData); |
|
348 inline TInt SocketCardIsPresent(TBool& aCardPresent); |
|
349 inline TInt SocketGetBufferInfo(TBufferInfo& aBufferInfo); |
|
350 inline TInt SocketInit(); |
|
351 inline TInt SocketInitiatePowerUpSequence(); |
|
352 inline TInt SocketMachineInfo(TMachineInfo& aMachineInfo); |
|
353 inline TInt SocketPrepareStore(TPasswordPrepareStoreData& aData); |
|
354 inline TInt SocketReset1(); |
|
355 inline TInt SocketReset2(); |
|
356 inline TInt SocketResetInactivity(TInt aBusNumber); |
|
357 inline TInt SocketStack(TStackPtr& aStackPtr); |
|
358 inline TInt SocketiState_Get(TBusState& aState); |
|
359 inline TInt SocketiDoorOpened_Get(TBool& aDoorOpened); |
|
360 inline TInt SocketiStandby_Get(TBool& aStandby); |
|
361 inline TInt SocketiType_Get(TCardBusType& aType); |
|
362 inline void SocketPowerUp(TRequestStatus& aStatus); |
|
363 |
|
364 // DMMCStack |
|
365 inline TInt Stack(TAny* aStack); |
|
366 inline TInt StackAdjustPartialRead(TPartialReadData& aPartialReadData); |
|
367 inline TInt StackAllocSession(); |
|
368 inline TInt StackGetBufferInfo(TBufferInfo& aBufferInfo); |
|
369 inline TInt StackBufferInfo(TBufferInfo& aBufferInfo); |
|
370 inline TInt StackCardP(TCardPtr& aCardPtr); |
|
371 inline TInt StackStop(); |
|
372 inline TInt StackMaxCardsInStack(TUint& aNumCardsInStack); |
|
373 inline TInt StackMMCSocket(TAny* aAny); |
|
374 |
|
375 inline TInt StackPasswordStore(TAny** aPwdStorePtr); |
|
376 inline TInt StackReadPasswordStore(TStackPasswordStoreData& aPwdStoreData); |
|
377 inline TInt StackWritePasswordStore(TStackPasswordStoreData& aPwdStoreData); |
|
378 inline TInt StackProgramPeriodInMilliSeconds(TInt& aPeriodMs); |
|
379 inline TInt StackInitStackInProgress(TBool& aInProgress); |
|
380 inline TInt StackHasSessionsQueued(TBool& aSessionsQueued); |
|
381 inline TInt StackHasCardsPresent(TBool& aCardsPresent); |
|
382 inline TInt StackMachineInfo(TMachineInfo& aMachineInfo); |
|
383 inline TInt StackDemandPagingInfo(TTCDemandPagingInfo& aInfo); |
|
384 inline TInt StackEffectiveModes(TUint32& aRetVal); |
|
385 inline TInt StackInit(); |
|
386 inline TInt StackReportPowerUp(); |
|
387 inline TInt StackReportPowerDown(); |
|
388 inline TInt StackAlterEffectiveModes( TEffectiveModesFunctionId FunctionId, TAny* aData); |
|
389 |
|
390 // general |
|
391 inline void ReadSector(TRequestStatus &aStatus,TInt aSectNum,TDes8 &aDes); |
|
392 inline void WriteSector(TRequestStatus &aStatus,TInt aSectNum,const TDesC8 &aDes); |
|
393 inline TInt CardInfo(TMMCCardInfo& aCardInfo); |
|
394 inline TInt ReadCSD(TCSDInfo& aCSDInfo); |
|
395 inline TInt ReadExtCSD(TExtendedCSDInfo& aExtCSDInfo); |
|
396 inline TInt Card(TAny* aCard); |
|
397 inline TInt CardIsPresent(TBool& aIsPresent); |
|
398 inline TInt CardIsReady(TBool& aIsReady); |
|
399 inline TInt CardIsLocked(TBool& aIsLocked); |
|
400 inline void PwrDownStack(); |
|
401 |
|
402 private: |
|
403 inline TInt TestDoControl(TTCFunctionId aFunctionId, TAny *a1 = NULL, TAny *a2 = NULL); |
|
404 inline void TestDoRequest(TTCFunctionId aFunctionId, TRequestStatus &aStatus, TAny *a1 = NULL, TAny *a2 = NULL); |
|
405 }; |
|
406 |
|
407 #include "d_mmcsdif.inl" |
|
408 |
|
409 #endif |