|
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 #ifndef __MMC_TEST_UTILS_H__ |
|
20 #define __MMC_TEST_UTILS_H__ |
|
21 |
|
22 |
|
23 #ifdef __KERNEL_MODE__ |
|
24 #include <mmc.h> |
|
25 #include <locmedia.h> |
|
26 #endif // __KERNEL_MODE__ |
|
27 |
|
28 |
|
29 //Test Types |
|
30 enum TMmcTestType |
|
31 { |
|
32 EMmcGeneralTest, |
|
33 EMmcTestPsu, |
|
34 EMmcTestMediaChange, |
|
35 EMmcTestStack, |
|
36 EMmcTestSocket |
|
37 }; |
|
38 |
|
39 //Bus States |
|
40 enum TBusState |
|
41 { |
|
42 EBusCardAbsent=0, |
|
43 EBusOff=1, |
|
44 EBusPoweringUp=2, |
|
45 EBusOn=3, |
|
46 EBusPsuFault=4, |
|
47 EBusPowerUpPending=5, |
|
48 }; |
|
49 |
|
50 //Psu States |
|
51 enum TDPsuState |
|
52 { |
|
53 EDPsuOff, |
|
54 EDPsuOnCurLimit, |
|
55 EDPsuOnFull |
|
56 }; |
|
57 |
|
58 //Voltage Check Method |
|
59 enum TDPsuVoltChkMethod |
|
60 { |
|
61 EDPsuChkComparator, |
|
62 EDPsuChkADCType, |
|
63 EDPsuChkADCType2 |
|
64 }; |
|
65 |
|
66 //Media States |
|
67 enum TMediaStates |
|
68 { |
|
69 EOpened, |
|
70 EClosed, |
|
71 }; |
|
72 |
|
73 //Bus Types |
|
74 enum TCardBusType |
|
75 { |
|
76 EBusTypeNone, |
|
77 EBusTypePcCard, |
|
78 EBusTypeMultiMedia, |
|
79 EBusTypeUSB, |
|
80 }; |
|
81 |
|
82 //Media Types |
|
83 enum TMmcMediaType |
|
84 { |
|
85 EMmcROM, |
|
86 EMmcFlash, |
|
87 EMmcIO, |
|
88 EMmcOther, |
|
89 EMmcNotSupported |
|
90 }; |
|
91 |
|
92 #ifdef __KERNEL_MODE__ |
|
93 //Used for Password Store |
|
94 const TInt KPasswordStoreCIDLength = KMMCCIDLength + sizeof(TInt32); |
|
95 #endif |
|
96 |
|
97 const TInt KMmcPwdLen = 16; |
|
98 |
|
99 /** |
|
100 * Stores test case enums as 2 16 bit values from supplied TInt |
|
101 * |
|
102 */ |
|
103 class TTCFunctionId |
|
104 { |
|
105 public: |
|
106 |
|
107 #ifdef __KERNEL_MODE__ |
|
108 |
|
109 explicit TTCFunctionId(TInt aValue) : iValue(aValue) {} |
|
110 |
|
111 #endif |
|
112 |
|
113 TTCFunctionId(TInt aFunctionId, TMmcTestType aTestType) |
|
114 { iValue = ((aFunctionId << 16 ) + (aTestType & 0xFFFF)); } |
|
115 |
|
116 |
|
117 TMmcTestType TestType() |
|
118 { return (TMmcTestType)(iValue & 0xFFFF); } // TestType stored in lower 16 bits |
|
119 |
|
120 TInt FunctionId() |
|
121 { return (iValue >> 16); } |
|
122 |
|
123 TInt iValue; |
|
124 }; |
|
125 |
|
126 /** |
|
127 * Used to wrap data passed to kernel side for DMMCStack::PartialRead and DMMCSocket::PartialRead |
|
128 * |
|
129 */ |
|
130 class TPartialReadData |
|
131 { |
|
132 public: |
|
133 TUint iStart; |
|
134 TUint iEnd; |
|
135 TUint iPhysStart; |
|
136 TUint iPhysEnd; |
|
137 }; |
|
138 |
|
139 /** |
|
140 * Used to wrap data passed to kernel side for DMMCStack::ReadPasswordData |
|
141 * |
|
142 */ |
|
143 class TStackPasswordStoreData |
|
144 { |
|
145 |
|
146 public: |
|
147 TStackPasswordStoreData() : iPwdStorePtr(NULL) {} |
|
148 TBuf8<KMmcPwdLen> iPassword; |
|
149 TAny* iPwdStorePtr; |
|
150 |
|
151 #ifdef __KERNEL_MODE__ |
|
152 TBool CreateFormattedPassword(TDes8 &aFormattedPassword, const TCID& aCID); |
|
153 void SetFormattedPassword(const TDesC8 &aFormattedPassword); |
|
154 #endif |
|
155 }; |
|
156 |
|
157 /** |
|
158 * Used to wrap data passed to kernel side for DMMCSocket::PrepareStore |
|
159 * |
|
160 */ |
|
161 class TPasswordPrepareStoreData |
|
162 { |
|
163 |
|
164 public: |
|
165 TPasswordPrepareStoreData() {} |
|
166 TInt iBus; |
|
167 TInt iFunc; |
|
168 TBuf8<KMmcPwdLen> iOldPassword; |
|
169 TBuf8<KMmcPwdLen> iNewPassword; |
|
170 }; |
|
171 |
|
172 /** |
|
173 * Class used for retrieving buffer info (socket & stack) |
|
174 * |
|
175 */ |
|
176 class TBufferInfo |
|
177 { |
|
178 public: |
|
179 TBufferInfo() : iBuf(NULL), iBufLen(0), iMinorBufLen(0) {} |
|
180 TUint8* iBuf; // pointer to start of buffer |
|
181 TInt iBufLen; // the length of allocated buffer |
|
182 TInt iMinorBufLen; // the length of minor buffer (only valid from DMMCStack::BufferInfo) |
|
183 }; |
|
184 |
|
185 /** |
|
186 * Used to wrap data passed to kernel side for DMMCStack::CardP |
|
187 * |
|
188 */ |
|
189 class TCardPtr |
|
190 { |
|
191 public: |
|
192 TCardPtr() : iCardPtr(NULL), iCardNumber(0) {} |
|
193 TAny* iCardPtr; // pointer to TMMCard |
|
194 TInt iCardNumber; // the card number |
|
195 }; |
|
196 |
|
197 /** |
|
198 * Used to wrap data passed to kernel side for DMMCSocket::Stack |
|
199 * |
|
200 */ |
|
201 class TStackPtr |
|
202 { |
|
203 public: |
|
204 TStackPtr() : iStackPtr(NULL), iBus(0) {} |
|
205 TAny* iStackPtr; // pointer to DMMCStack |
|
206 TInt iBus; // the bus number |
|
207 }; |
|
208 |
|
209 /** |
|
210 * Class used for retrieving machine info (socket & stack) |
|
211 * |
|
212 */ |
|
213 class TMachineInfo |
|
214 { |
|
215 public: |
|
216 |
|
217 #ifdef __KERNEL_MODE__ |
|
218 TMachineInfo(const TMMCMachineInfo& aMachineInfo); |
|
219 #else |
|
220 TMachineInfo() : iTotalSockets(0), iTotalMediaChanges(0), iTotalPrimarySupplies(0), iSPIMode(EFalse), iBaseBusNumber(0) |
|
221 , iSupportsSPIMode(EFalse), iSupportsDoubleBuffering(EFalse), iSupportsR7(EFalse), iDma8BitAddressing(EFalse) |
|
222 , iDma16BitAddressing(EFalse), iDma32BitAddressing(EFalse), iDma64BitAddressing(EFalse), iSupportsDMA(EFalse) |
|
223 , iMaxTransferLength_256K(EFalse), iMaxTransferLength_512K(EFalse), iMaxTransferLength_1M(EFalse) |
|
224 , iMaxTransferLength_2M(EFalse), iMaxTransferLength_4M(EFalse), iMaxTransferLength_8M(EFalse), iMaxTransferLength_16M(EFalse) |
|
225 {} |
|
226 #endif |
|
227 |
|
228 public: |
|
229 /** The total number of MultiMediaCard slots for this stack */ |
|
230 TInt iTotalSockets; |
|
231 /** Not currently used */ |
|
232 TInt iTotalMediaChanges; |
|
233 /** Not currently used */ |
|
234 TInt iTotalPrimarySupplies; |
|
235 /** Indicates whether the SPI protocol is being used or not */ |
|
236 TBool iSPIMode; |
|
237 /** The number of the first peripheral bus slot claimed by the MultiMediaCard controller */ |
|
238 TInt iBaseBusNumber; |
|
239 /** Set if hardware supports SPI mode */ |
|
240 TBool iSupportsSPIMode; |
|
241 /** Set if the PSL is enabled for double-buffered data transfers */ |
|
242 TBool iSupportsDoubleBuffering; |
|
243 /** Set if the PSL supports response type R7 */ |
|
244 TBool iSupportsR7; |
|
245 /** Set this bit if the hardware DMA controller utilises 8-Bit Addressing */ |
|
246 TBool iDma8BitAddressing; |
|
247 /** Set this bit if the hardware DMA controller utilises 16-Bit Addressing */ |
|
248 TBool iDma16BitAddressing; |
|
249 /** Set this bit if the hardware DMA controller utilises 32-Bit Addressing */ |
|
250 TBool iDma32BitAddressing; |
|
251 /** Set this bit if the hardware DMA controller utilises 64-Bit Addressing */ |
|
252 TBool iDma64BitAddressing; |
|
253 /** Set this if the hardware supports DMA and can cope with being given a physical address */ |
|
254 TBool iSupportsDMA; |
|
255 /** Set if the hardware is unable to perform data transfers of more than 256K */ |
|
256 TBool iMaxTransferLength_256K; |
|
257 /** Set if the hardware is unable to perform data transfers of more than 512K */ |
|
258 TBool iMaxTransferLength_512K; |
|
259 /** Set if the hardware is unable to perform data transfers of more than 1M */ |
|
260 TBool iMaxTransferLength_1M; |
|
261 /** Set f the hardware is unable to perform data transfers of more than 2M */ |
|
262 TBool iMaxTransferLength_2M; |
|
263 /** Set if the hardware is unable to perform data transfers of more than 4M */ |
|
264 TBool iMaxTransferLength_4M; |
|
265 /** Set if the hardware is unable to perform data transfers of more than 8M */ |
|
266 TBool iMaxTransferLength_8M; |
|
267 /** Set if the hardware is unable to perform data transfers of more than 16M */ |
|
268 TBool iMaxTransferLength_16M; |
|
269 |
|
270 }; |
|
271 |
|
272 /** |
|
273 * Class used for retrieving card info |
|
274 * |
|
275 */ |
|
276 class TMMCCardInfo |
|
277 { |
|
278 public: |
|
279 inline TMMCCardInfo() |
|
280 {memset(this,0x00,sizeof(TMMCCardInfo)); iMediaType=EMmcNotSupported;} |
|
281 public: |
|
282 /** Indicates the card is Ready */ |
|
283 TBool iIsReady; |
|
284 /** Indicates the card is locked */ |
|
285 TBool iIsLocked; |
|
286 /** Holds Card CID register */ |
|
287 TUint8 iCID[16]; |
|
288 /** Holds Card CSD register */ |
|
289 TUint8 iCSD[16]; |
|
290 /** Card address */ |
|
291 TUint16 iRCA; |
|
292 /** MMC Media type */ |
|
293 TMmcMediaType iMediaType; |
|
294 /** Device Size*/ |
|
295 TInt64 iCardSizeInBytes; |
|
296 /** Maximum Read Block Length */ |
|
297 TInt iMaxReadBlLen; |
|
298 /** READ_BL_LEN*/ |
|
299 TUint iReadBlLen; |
|
300 /** Max Write data block length */ |
|
301 TUint iWriteBlLen; |
|
302 /** Is partial block read allowed */ |
|
303 TBool iReadBlPartial; |
|
304 /** Is partial block write allowed */ |
|
305 TBool iWriteBlPartial; |
|
306 /** Is read block misalignment allowed */ |
|
307 TBool iReadBlkMisalign; |
|
308 /** Is write block misalignment allowed */ |
|
309 TBool iWriteBlkMisalign; |
|
310 /** Maximum read current in milli ampere */ |
|
311 TInt iReadCurrentInMilliAmps; |
|
312 /** Maximum write current in milli ampere */ |
|
313 TInt iWriteCurrentInMilliAmps; |
|
314 /** MMC/SD Specification, version */ |
|
315 TUint iSpecVers; |
|
316 /** Asynchronous part of data access time */ |
|
317 TUint iTAAC; |
|
318 /** Defines clock dependent factor of the data access time */ |
|
319 TUint iNSAC; |
|
320 /** Clock frequency */ |
|
321 TUint iTransferSpeed; |
|
322 /** Card command class */ |
|
323 TUint iCommandRegister; |
|
324 /** This will be updated to ETrue if the card belongs to high capacity */ |
|
325 TBool iHighCapacity; |
|
326 /** Flag to indentity card type */ |
|
327 TUint32 iFlags; |
|
328 |
|
329 #ifdef __KERNEL_MODE__ |
|
330 void SetCardInfo(const TMMCard& aCard); |
|
331 #endif |
|
332 |
|
333 }; |
|
334 |
|
335 /** |
|
336 * Class used for retrieving SD card info |
|
337 * |
|
338 */ |
|
339 class TSDCardInfo : public TMMCCardInfo |
|
340 { |
|
341 public: |
|
342 inline TSDCardInfo() : iBusWidth(0), iProtectedAreaSize(0) |
|
343 {;} |
|
344 |
|
345 public: |
|
346 TInt iBusWidth; |
|
347 TUint32 iProtectedAreaSize; |
|
348 }; |
|
349 |
|
350 |
|
351 /** |
|
352 * Mirrors the DMMCStack::DemandPagingInfo on the user side |
|
353 * |
|
354 */ |
|
355 class TTCDemandPagingInfo |
|
356 { |
|
357 public: |
|
358 const TInt* iPagingDriveList; |
|
359 TInt iDriveCount; |
|
360 TUint iPagingType; |
|
361 TInt iReadShift; |
|
362 TUint iNumPages; |
|
363 TBool iWriteProtected; |
|
364 }; |
|
365 |
|
366 /** |
|
367 * Class used for retrieving extended CSD info |
|
368 * |
|
369 */ |
|
370 class TExtendedCSDInfo |
|
371 { |
|
372 public: |
|
373 |
|
374 #ifdef __KERNEL_MODE__ |
|
375 TExtendedCSDInfo(const TExtendedCSD& aExtendedCSD); |
|
376 #else |
|
377 inline TExtendedCSDInfo() {memset(this,0x00,sizeof(TExtendedCSDInfo));} |
|
378 #endif |
|
379 |
|
380 // this class holds extended csd info as members rather than bitmasks on a 128 bit buffer |
|
381 // as described in the mmc spec. It is also neccessary as mmc.h cannot be included in user side code |
|
382 |
|
383 public: |
|
384 TUint iSupportedCmdSet; |
|
385 TUint iSectorCount; |
|
386 TUint iMinPerfWrite8Bit52Mhz; |
|
387 TUint iMinPerfRead8Bit52Mhz; |
|
388 TUint iMinPerfWrite8Bit26Mhz_4Bit52Mhz; |
|
389 TUint iMinPerfRead8Bit26Mhz_4Bit52Mhz; |
|
390 TUint iMinPerfWrite4Bit26Mhz; |
|
391 TUint iMinPerfRead4Bit26Mhz; |
|
392 TUint iPowerClass26Mhz360V; |
|
393 TUint iPowerClass52Mhz360V; |
|
394 TUint iPowerClass26Mhz195V; |
|
395 TUint iPowerClass52Mhz195V; |
|
396 TUint iCardType; |
|
397 TUint iCSDStructureVer; |
|
398 TUint iExtendedCSDRev; |
|
399 TUint iCmdSet; |
|
400 TUint iCmdSetRev; |
|
401 TUint iPowerClass; |
|
402 TUint iHighSpeedTiming; |
|
403 }; |
|
404 |
|
405 /** |
|
406 * Class used for retrieving CSD info |
|
407 * |
|
408 */ |
|
409 class TCSDInfo |
|
410 { |
|
411 public: |
|
412 |
|
413 #ifdef __KERNEL_MODE__ |
|
414 TCSDInfo(const TCSD& aCSD); |
|
415 #else |
|
416 inline TCSDInfo() {memset(this,0x00,sizeof(TCSDInfo)); iMediaType=EMultiMediaNotSupported;} |
|
417 #endif |
|
418 |
|
419 // mirrors TMMCMediaTypeEnum |
|
420 enum TMMCMediaTypeEnumInfo { EMultiMediaROM, EMultiMediaFlash, EMultiMediaIO, EMultiMediaOther, EMultiMediaNotSupported }; |
|
421 |
|
422 // this class holds csd info as members rather than bitmasks on a 128 bit buffer |
|
423 // as described in the mmc spec. It is also neccessary as mmc.h cannot be included in user side code |
|
424 |
|
425 public: |
|
426 TUint iCSDStructure; |
|
427 TUint iSpecVers; |
|
428 TUint iReserved120; |
|
429 TUint iTAAC; |
|
430 TUint iNSAC; |
|
431 TUint iTranSpeed; |
|
432 TUint iCCC; |
|
433 TUint iReadBlLen; |
|
434 TBool iReadBlPartial; |
|
435 TBool iWriteBlkMisalign; |
|
436 TBool iReadBlkMisalign; |
|
437 TBool iDSRImp; |
|
438 TUint iReserved74; |
|
439 TUint iCSize; |
|
440 TUint iVDDRCurrMin; |
|
441 TUint iVDDRCurrMax; |
|
442 TUint iVDDWCurrMin; |
|
443 TUint iVDDWCurrMax; |
|
444 TUint iCSizeMult; |
|
445 TUint iEraseGrpSize; |
|
446 TUint iEraseGrpMult; |
|
447 TUint iWPGrpSize; |
|
448 TBool iWPGrpEnable; |
|
449 TUint iDefaultECC; |
|
450 TUint iR2WFactor; |
|
451 TUint iWriteBlLen; |
|
452 TBool iWriteBlPartial; |
|
453 TUint iReserved16; |
|
454 TBool iFileFormatGrp; |
|
455 TBool iCopy; |
|
456 TBool iPermWriteProtect; |
|
457 TBool iTmpWriteProtect; |
|
458 TUint iFileFormat; |
|
459 TUint iECC; |
|
460 TUint iCRC; |
|
461 TUint iDeviceSize; |
|
462 TMMCMediaTypeEnumInfo iMediaType; |
|
463 TUint iReadBlockLength; |
|
464 TUint iWriteBlockLength; |
|
465 TUint iEraseSectorSize; |
|
466 TUint iEraseGroupSize; |
|
467 TUint iMinReadCurrentInMilliamps; |
|
468 TUint iMinWriteCurrentInMilliamps; |
|
469 TUint iMaxReadCurrentInMilliamps; |
|
470 TUint iMaxWriteCurrentInMilliamps; |
|
471 TUint iMaxTranSpeedInKilohertz; |
|
472 |
|
473 }; |
|
474 |
|
475 |
|
476 #endif // MMC_TEST_UTILS |
|
477 |