1 // Copyright (c) 2003-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 // Test for SDIO functions |
|
15 // |
|
16 // |
|
17 |
|
18 #include <d32comm.h> |
|
19 |
|
20 #include "d_sdioif.h" |
|
21 #include "sdio_io.h" |
|
22 #include "sdiotests.h" |
|
23 |
|
24 |
|
25 enum TPanic {ECreatingIO, ELoadingMmcDriver, EReadingCommandLine}; |
|
26 |
|
27 class RComm : public RBusDevComm |
|
28 /** |
|
29 Class to serialize writing to the COMM port |
|
30 |
|
31 @internal |
|
32 @test |
|
33 */ |
|
34 { |
|
35 public: |
|
36 TInt WriteS(const TDesC8& aDes); |
|
37 TInt WriteS(const TDesC8& aDes,TInt aLength); |
|
38 }; |
|
39 |
|
40 TInt RComm::WriteS(const TDesC8& aDes) |
|
41 /** |
|
42 Write to the COMM port an 8-bit descriptor |
|
43 |
|
44 @param aDes The descriptor to send to the UART. |
|
45 @return One of the system wide error codes. |
|
46 |
|
47 @internal |
|
48 @test |
|
49 */ |
|
50 { |
|
51 return(WriteS(aDes,aDes.Length())); |
|
52 } |
|
53 |
|
54 |
|
55 TInt RComm::WriteS(const TDesC8& aDes,TInt aLength) |
|
56 /** |
|
57 Write to the COMM port an 8-bit descriptor of a specific length |
|
58 |
|
59 @param aDes The descriptor to send to the UART. |
|
60 @param aLength The maximum length of data to send. |
|
61 @return One of the system wide error codes. |
|
62 |
|
63 @internal |
|
64 @test |
|
65 */ |
|
66 { |
|
67 TRequestStatus s; |
|
68 Write(s,aDes,aLength); |
|
69 User::WaitForRequest(s); |
|
70 return(s.Int()); |
|
71 } |
|
72 |
|
73 // |
|
74 // |
|
75 class TSdioCardDiagServices |
|
76 /** |
|
77 Class to provide test services for the SDIO common features. |
|
78 Uses the RSdioCardCntrlIf user side logical device driver. |
|
79 |
|
80 @internal |
|
81 @test |
|
82 */ |
|
83 { |
|
84 public: |
|
85 TSdioCardDiagServices(); |
|
86 ~TSdioCardDiagServices(); |
|
87 TInt Start(); |
|
88 |
|
89 TInt doPowerUp(CIOBase& aIO); |
|
90 TInt doGetCardInfo(CIOBase& aIO); |
|
91 TInt doCardCommonControlRegs(CIOBase& aIO); |
|
92 TInt doCardCommonConfig(CIOBase& aIO); |
|
93 TInt doGetFunctionInfo(CIOBase& aIO); |
|
94 |
|
95 TInt doQuit(); |
|
96 |
|
97 inline TInt CurrentSocket() |
|
98 {return(iSocket);} |
|
99 |
|
100 inline TInt CurrentFunc() |
|
101 {return(iFunc);} |
|
102 private: |
|
103 RSdioCardCntrlIf iDriver; |
|
104 TInt iSocket; |
|
105 TInt iFunc; |
|
106 TBool iDriverOpen; |
|
107 }; |
|
108 |
|
109 LOCAL_C void Panic(TPanic aPanic) |
|
110 /** |
|
111 Panic |
|
112 |
|
113 @param aPanic The panic code. |
|
114 |
|
115 @internal |
|
116 @test |
|
117 */ |
|
118 { |
|
119 User::Panic(_L("SDIOTEST"),aPanic); |
|
120 } |
|
121 |
|
122 LOCAL_C TPtrC MediaTypeText(TMmcMediaType aType) |
|
123 /** |
|
124 Convert a media type enumeration to human readable text. |
|
125 |
|
126 @param aType The media type enumeration value. |
|
127 @return A human readable format for the media type. |
|
128 |
|
129 @internal |
|
130 @test |
|
131 */ |
|
132 { |
|
133 switch(aType) |
|
134 { |
|
135 case EMmcROM: return(_L("ROM")); |
|
136 case EMmcFlash: return(_L("Flash")); |
|
137 case EMmcIO: return(_L("IO")); |
|
138 case EMmcOther: return(_L("Other")); |
|
139 case EMmcNotSupported: return(_L("Not Supported")); |
|
140 default: return(_L("Unknown")); |
|
141 } |
|
142 } |
|
143 |
|
144 TSdioCardDiagServices::TSdioCardDiagServices() |
|
145 /** |
|
146 Constructor. |
|
147 |
|
148 @internal |
|
149 @test |
|
150 */ |
|
151 { |
|
152 |
|
153 iSocket=0; |
|
154 iFunc=0; |
|
155 iDriverOpen=EFalse; |
|
156 } |
|
157 |
|
158 TSdioCardDiagServices::~TSdioCardDiagServices() |
|
159 /** |
|
160 Destructor. |
|
161 |
|
162 @internal |
|
163 @test |
|
164 */ |
|
165 { |
|
166 |
|
167 iDriver.Close(); |
|
168 } |
|
169 |
|
170 TInt TSdioCardDiagServices::Start() |
|
171 /** |
|
172 Start the testing by connecting to the uset side logical device driver. |
|
173 |
|
174 @return One of the system wide error codes. |
|
175 |
|
176 @internal |
|
177 @test |
|
178 */ |
|
179 { |
|
180 |
|
181 iDriver.Close(); |
|
182 TInt r=iDriver.Open(iSocket,iDriver.VersionRequired()); |
|
183 iDriverOpen=(r==KErrNone)?ETrue:EFalse; |
|
184 return(r); |
|
185 } |
|
186 |
|
187 |
|
188 //--------------------------------------------- |
|
189 //! @SYMTestCaseID FSBASE-SDIOTEST-1 |
|
190 //! @SYMTestType CIT |
|
191 //! @SYMTestCaseDesc Power up the SDIO stack |
|
192 //! @SYMPREQ PREQ1623 |
|
193 //! @SYMREQ REQ5742 |
|
194 //! @SYMTestPriority Critical |
|
195 //! @SYMTestActions Power up the SDIO stack with an SDIO card inserted |
|
196 //! @SYMTestExpectedResults The stack should report that it is powered up |
|
197 //--------------------------------------------- |
|
198 TInt TSdioCardDiagServices::doPowerUp(CIOBase& aIO) |
|
199 /** |
|
200 Power up the SDIO stack. |
|
201 |
|
202 @param aIO The input output device. |
|
203 @return One of the system wide error codes. |
|
204 |
|
205 @internal |
|
206 @test |
|
207 */ |
|
208 { |
|
209 |
|
210 if (!iDriverOpen) |
|
211 return(KErrNotSupported); |
|
212 |
|
213 aIO.ClearScreen(); |
|
214 aIO.Heading(_L("Powering up card\n\n")); |
|
215 |
|
216 TInt err; |
|
217 TRequestStatus rs; |
|
218 iDriver.PwrUpAndInitStack(rs); |
|
219 User::WaitForRequest(rs); |
|
220 if ((err=rs.Int())!=KErrNone) |
|
221 { |
|
222 aIO.ReportError(_L("Error Powering Stack"),err); |
|
223 return(err); |
|
224 } |
|
225 |
|
226 return(KErrNone); |
|
227 } |
|
228 |
|
229 //--------------------------------------------- |
|
230 //! @SYMTestCaseID FSBASE-SDIOTEST-2 |
|
231 //! @SYMTestType CIT |
|
232 //! @SYMTestCaseDesc Read general card information. |
|
233 //! @SYMPREQ PREQ1623 |
|
234 //! @SYMREQ REQ5742 |
|
235 //! @SYMTestPriority Critical |
|
236 //! @SYMTestActions Read the Media type, CID and CSD registers and number of functions and their names. Display the results. |
|
237 //! @SYMTestExpectedResults The CID and CSD registers should be read with no error. |
|
238 //--------------------------------------------- |
|
239 TInt TSdioCardDiagServices::doGetCardInfo(CIOBase& aIO) |
|
240 /** |
|
241 Read general card information. |
|
242 |
|
243 @param aIO The input output device. |
|
244 @return One of the system wide error codes. |
|
245 |
|
246 @internal |
|
247 @test |
|
248 */ |
|
249 { |
|
250 // Make sure stack is powered up |
|
251 TInt err = doPowerUp(aIO); |
|
252 if (err != KErrNone) |
|
253 return err; |
|
254 |
|
255 |
|
256 aIO.ClearScreen(); |
|
257 aIO.Heading(_L("Card Info")); |
|
258 |
|
259 TSdioCardInfo ci; |
|
260 err = iDriver.CardInfo(&ci); |
|
261 if (err!=KErrNone) |
|
262 { |
|
263 aIO.ReportError(_L("Error getting card info"),err); |
|
264 return(err); |
|
265 } |
|
266 |
|
267 aIO.CurserToDataStart(); |
|
268 aIO.Printf(_L("\nCard Ready : %d"),ci.iIsReady); |
|
269 aIO.Printf(_L("\nCard Locked : %d"),ci.iIsLocked); |
|
270 aIO.Printf(_L("\nCard Max Speed : %d Khz"),ci.iCardSpeed); |
|
271 aIO.Printf(_L("\nCard ID : ")); |
|
272 TInt i; |
|
273 for (i=12;i>=0;i-=4) |
|
274 { |
|
275 aIO.Printf(_L("%02x"), *(TUint8*)&ci.iCID[i]); |
|
276 aIO.Printf(_L("%02x"), *(TUint8*)&ci.iCID[i + 1]); |
|
277 aIO.Printf(_L("%02x"), *(TUint8*)&ci.iCID[i + 2]); |
|
278 aIO.Printf(_L("%02x"), *(TUint8*)&ci.iCID[i + 3]); |
|
279 aIO.Printf(_L("\n\t\t\t\t ")); |
|
280 } |
|
281 aIO.Printf(_L("\nCard CSD : ")); |
|
282 for (i=12;i>=0;i-=4) |
|
283 { |
|
284 aIO.Printf(_L("%02x"), *(TUint8*)&ci.iCSD[i]); |
|
285 aIO.Printf(_L("%02x"), *(TUint8*)&ci.iCSD[i + 1]); |
|
286 aIO.Printf(_L("%02x"), *(TUint8*)&ci.iCSD[i + 2]); |
|
287 aIO.Printf(_L("%02x"), *(TUint8*)&ci.iCSD[i + 3]); |
|
288 aIO.Printf(_L("\n\t\t\t\t ")); |
|
289 } |
|
290 aIO.Printf(_L("\nCard RCA : %x"),ci.iRCA); |
|
291 TPtrC mtt=MediaTypeText(ci.iMediaType); |
|
292 aIO.Printf(_L("\nMedia Type : %S"),&mtt); |
|
293 aIO.Printf(_L("\nCombo Card : %d"),ci.isComboCard); |
|
294 |
|
295 aIO.Printf(_L("\n\nDetected %d Function(s)\n"),ci.iFuncCount); |
|
296 for(i=1; i<ci.iFuncCount+1; i++) |
|
297 { |
|
298 TSdioFunctionType type = ci.iFunction[i].iType; |
|
299 TPtrC tt = TSDIOTestUtils::FunctionTypeText(type); |
|
300 aIO.Printf(_L("Function %d : %S (%d)\n"),i, &tt, type); |
|
301 } |
|
302 |
|
303 return KErrNone; |
|
304 } |
|
305 |
|
306 //--------------------------------------------- |
|
307 //! @SYMTestCaseID FSBASE-SDIOTEST-3 |
|
308 //! @SYMTestType CIT |
|
309 //! @SYMTestCaseDesc Read the Card Common Control Registers (CCCR) |
|
310 //! @SYMPREQ PREQ1623 |
|
311 //! @SYMREQ REQ5742 |
|
312 //! @SYMTestPriority Critical |
|
313 //! @SYMTestActions Read the CCCR and displays the results on the screen |
|
314 //! @SYMTestExpectedResults The CCCR should be read successfully. The CCCR Format Version number should be <= 1; the SDIO Specification number should be <= 1; The SD Format Version number should be <= 1; |
|
315 //--------------------------------------------- |
|
316 TInt TSdioCardDiagServices::doCardCommonControlRegs(CIOBase& aIO) |
|
317 /** |
|
318 Read the Card Common Control Registers (CCCR). |
|
319 |
|
320 @param aIO The input output device. |
|
321 @return One of the system wide error codes. |
|
322 |
|
323 @internal |
|
324 @test |
|
325 */ |
|
326 { |
|
327 |
|
328 if (!iDriverOpen) |
|
329 return(KErrNotSupported); |
|
330 |
|
331 // Make sure stack is powered up |
|
332 TInt err = doPowerUp(aIO); |
|
333 if (err != KErrNone) |
|
334 return err; |
|
335 |
|
336 aIO.ClearScreen(); |
|
337 aIO.Heading(_L("Read CCCR")); |
|
338 aIO.CurserToDataStart(); |
|
339 |
|
340 TUint8 reg[0x14]; |
|
341 for (TInt i=0;i<0x14;i++) |
|
342 { |
|
343 TRequestStatus rs; |
|
344 |
|
345 TUint tempVal; |
|
346 iDriver.ReadDirect(rs, i, tempVal); |
|
347 User::WaitForRequest(rs); |
|
348 reg[i] = (TUint8)tempVal; |
|
349 err=rs.Int(); |
|
350 if (err!=KErrNone) |
|
351 { |
|
352 aIO.ReportError(_L("Error reading config"),err); |
|
353 return(err); |
|
354 } |
|
355 } |
|
356 |
|
357 const TUint32 ptrCIS = reg[0x0b] << 16 | reg[0x0a] << 8 | reg[0x09]; |
|
358 const TUint16 blockSize = (TUint16) (reg[0x11] << 8 | reg[0x10]); |
|
359 |
|
360 TUint8 cccrFormatVersionNumber = (TUint8) (reg[0x00] & 0x0F); |
|
361 TUint8 sdioSpecRevisionNumber = (TUint8) ((reg[0x00] & 0xF0) >> 4); |
|
362 TUint8 sdFormatVersionNumber = (TUint8) (reg[0x01]); |
|
363 |
|
364 aIO.Printf(_L("\nCCCR/SDIO Revision : %02xH\n (CCCR Rev: %d, SDIO Rev: %d)"), reg[0x00], cccrFormatVersionNumber, sdioSpecRevisionNumber); |
|
365 aIO.Printf(_L("\nSD Format Revision : %02xH"),sdFormatVersionNumber); |
|
366 aIO.Printf(_L("\nI/O Enable : %02xH"),reg[0x02]); |
|
367 aIO.Printf(_L("\nI/O Ready : %02xH"),reg[0x03]); |
|
368 aIO.Printf(_L("\nInt Enable : %02xH"),reg[0x04]); |
|
369 aIO.Printf(_L("\nInt Pending : %02xH"),reg[0x05]); |
|
370 aIO.Printf(_L("\nI/O Abort : %02xH"),reg[0x06]); |
|
371 |
|
372 aIO.Printf(_L("\nBus Interface Control : %02xH"), reg[0x07]); |
|
373 aIO.Printf(_L("\n - CD Disable : %db"), (reg[0x07] & 0x80) ? ETrue : EFalse); |
|
374 aIO.Printf(_L("\n - SCSI : %db"), (reg[0x07] & 0x40) ? ETrue : EFalse); |
|
375 aIO.Printf(_L("\n - ECSI : %db"), (reg[0x07] & 0x20) ? ETrue : EFalse); |
|
376 aIO.Printf(_L("\n - Bus Width : %d-bit"), (reg[0x07] & 0x03) ? 4 : 1); |
|
377 aIO.Printf(_L("\nCard Capability : %02xH"),reg[0x08]); |
|
378 aIO.Printf(_L("\n - 4BLS : %db"), reg[0x08], reg[0x08] & 0x80 ? ETrue : EFalse); |
|
379 aIO.Printf(_L("\n - LSC : %db"), reg[0x08] & 0x40 ? ETrue : EFalse); |
|
380 aIO.Printf(_L("\n - E4MI : %db"), reg[0x08] & 0x20 ? ETrue : EFalse); |
|
381 aIO.Printf(_L("\n - S4MI : %db"), reg[0x08] & 0x10 ? ETrue : EFalse); |
|
382 aIO.Printf(_L("\n - SBS : %db"), reg[0x08] & 0x08 ? ETrue : EFalse); |
|
383 aIO.Printf(_L("\n - SRW : %db"), reg[0x08] & 0x04 ? ETrue : EFalse); |
|
384 aIO.Printf(_L("\n - SMB : %db"), reg[0x08] & 0x02 ? ETrue : EFalse); |
|
385 aIO.Printf(_L("\n - SDC : %db"), reg[0x08] & 0x01 ? ETrue : EFalse); |
|
386 aIO.Printf(_L("\n - SHS : %db"), reg[0x0D] & 0x01 ? ETrue : EFalse); |
|
387 |
|
388 aIO.Printf(_L("\nCommon CIS Ptr : %06xH"),ptrCIS); |
|
389 aIO.Printf(_L("\nBus Suspend : %02xH"),reg[0x0c]); |
|
390 aIO.Printf(_L("\nFunction Select : %02xH"),reg[0x0d]); |
|
391 aIO.Printf(_L("\nExec Flags : %02xH"),reg[0x0e]); |
|
392 aIO.Printf(_L("\nReady Flags : %02xH"),reg[0x0f]); |
|
393 aIO.Printf(_L("\nFN0 Block Size : %04xH\n"),blockSize); |
|
394 |
|
395 // Test the version numbers are correct |
|
396 if (cccrFormatVersionNumber > 1) |
|
397 { |
|
398 aIO.ReportError(_L("Invalid cccrFormatVersionNumber"), cccrFormatVersionNumber); |
|
399 aIO.Getch(); |
|
400 return KErrNotSupported; |
|
401 } |
|
402 if (sdioSpecRevisionNumber > 1) |
|
403 { |
|
404 aIO.ReportError(_L("Invalid sdioSpecRevisionNumber"), sdioSpecRevisionNumber); |
|
405 aIO.Getch(); |
|
406 return KErrNotSupported; |
|
407 } |
|
408 if (sdFormatVersionNumber > 1) |
|
409 { |
|
410 aIO.ReportError(_L("Invalid sdFormatVersionNumber"), sdFormatVersionNumber); |
|
411 aIO.Getch(); |
|
412 return KErrNotSupported; |
|
413 } |
|
414 |
|
415 return(KErrNone); |
|
416 } |
|
417 |
|
418 //--------------------------------------------- |
|
419 //! @SYMTestCaseID FSBASE-SDIOTEST-4 |
|
420 //! @SYMTestType CIT |
|
421 //! @SYMTestCaseDesc Read common configuration data |
|
422 //! @SYMPREQ PREQ1623 |
|
423 //! @SYMREQ REQ5742 |
|
424 //! @SYMTestPriority Critical |
|
425 //! @SYMTestActions Read data common to all functions. Some of the data comes from the CCCR, others from the common (function 0) tuple. |
|
426 //! @SYMTestExpectedResults The common data should be read with no error. |
|
427 //--------------------------------------------- |
|
428 TInt TSdioCardDiagServices::doCardCommonConfig(CIOBase& aIO) |
|
429 /** |
|
430 Read common configuration data. |
|
431 |
|
432 @param aIO The input output device. |
|
433 @return One of the system wide error codes. |
|
434 |
|
435 @internal |
|
436 @test |
|
437 */ |
|
438 { |
|
439 |
|
440 if (!iDriverOpen) |
|
441 return(KErrNotSupported); |
|
442 |
|
443 // Make sure stack is powered up |
|
444 TInt err = doPowerUp(aIO); |
|
445 if (err != KErrNone) |
|
446 return err; |
|
447 |
|
448 aIO.ClearScreen(); |
|
449 aIO.Printf(_L("\nCommon Configuration\n")); |
|
450 |
|
451 TRequestStatus rs; |
|
452 iDriver.ResetCis(rs, iFunc); |
|
453 User::WaitForRequest(rs); |
|
454 err = rs.Int(); |
|
455 if (err!=KErrNone) |
|
456 { |
|
457 aIO.ReportError(_L("Error reseting CIS"),err); |
|
458 return(err); |
|
459 } |
|
460 |
|
461 TSDIOCardConfigTest ci; |
|
462 aIO.CurserToDataStart(); |
|
463 |
|
464 |
|
465 TRequestStatus rs1; |
|
466 iDriver.GetCommonConfig(rs1, 0, &ci); |
|
467 User::WaitForRequest(rs1); |
|
468 err=rs1.Int(); |
|
469 if(err !=KErrNone) |
|
470 return err; |
|
471 |
|
472 aIO.Printf(_L("\n Manufacturer ID : %04x"), ci.iManufacturerID); |
|
473 aIO.Printf(_L("\n Card ID : %04x"), ci.iCardID); |
|
474 aIO.Printf(_L("\n FN0 Block Size : %04x"), ci.iFn0MaxBlockSize); |
|
475 aIO.Printf(_L("\n Max Tran Speed : %02x"), ci.iMaxTranSpeed); |
|
476 aIO.Printf(_L("\n CurrentBlockSize: %04x"), ci.iCurrentBlockSize); |
|
477 aIO.Printf(_L("\n Revision : %04x"), ci.iRevision); |
|
478 aIO.Printf(_L("\n SDFormatVer : %04x"), ci.iSDFormatVer); |
|
479 aIO.Printf(_L("\n CardCaps : %04x"), ci.iCardCaps); |
|
480 aIO.Printf(_L("\n CommonCisP : %04x\n"), ci.iCommonCisP); |
|
481 |
|
482 return(KErrNone); |
|
483 |
|
484 } |
|
485 |
|
486 //--------------------------------------------- |
|
487 //! @SYMTestCaseID FSBASE-SDIOTEST-5 |
|
488 //! @SYMTestType CIT |
|
489 //! @SYMTestCaseDesc Get the configuration data for each function. |
|
490 //! @SYMPREQ PREQ1623 |
|
491 //! @SYMREQ REQ5742 |
|
492 //! @SYMTestPriority Critical |
|
493 //! @SYMTestActions Determine the number of functions by reading the CCR and then retrieve information from the Card Information Structure CIS for each function. Display the results on the screen. |
|
494 //! @SYMTestExpectedResults The number of functions should be >= 1. The function number should increment by one for each function. The function description should be as expected for the type of card (e.g. Wireless LAN). |
|
495 //--------------------------------------------- |
|
496 TInt TSdioCardDiagServices::doGetFunctionInfo(CIOBase& aIO) |
|
497 /** |
|
498 Display the configuration data for each function. |
|
499 |
|
500 @param aIO The input output device. |
|
501 @return One of the system wide error codes. |
|
502 |
|
503 @internal |
|
504 @test |
|
505 */ |
|
506 { |
|
507 if (!iDriverOpen) |
|
508 return(KErrNotSupported); |
|
509 |
|
510 // Make sure stack is powered up |
|
511 TInt err = doPowerUp(aIO); |
|
512 if (err != KErrNone) |
|
513 return err; |
|
514 |
|
515 aIO.ClearScreen(); |
|
516 aIO.Heading(_L("Display Function Info")); |
|
517 |
|
518 TInt functionsFound = 0; |
|
519 for(TInt i=1; i<7; i++) |
|
520 { |
|
521 TSDIOFunctionCapsTest fc; |
|
522 |
|
523 TRequestStatus rs2; |
|
524 iDriver.GetFunctionConfig(rs2,i,&fc); |
|
525 User::WaitForRequest(rs2); |
|
526 err=rs2.Int(); |
|
527 |
|
528 if (err != KErrNone && err != KErrNotFound) |
|
529 return err; |
|
530 |
|
531 if(err==KErrNone) |
|
532 { |
|
533 functionsFound++; |
|
534 if(i > 1) |
|
535 { |
|
536 aIO.Printf(_L("\n\n\t...More (Hit a key)")); |
|
537 aIO.Getch(); |
|
538 aIO.ClearScreen(); |
|
539 aIO.Heading(_L("Display Function Info")); |
|
540 } |
|
541 |
|
542 aIO.Printf(_L("\nFunction # : %d"), fc.iNumber); |
|
543 TPtrC functionType = TSDIOTestUtils::FunctionTypeText(fc.iType); |
|
544 aIO.Printf(_L("\nFuncType : %S"), &functionType); |
|
545 aIO.Printf(_L("\nRevision : 0x%02x"), fc.iRevision); |
|
546 aIO.Printf(_L("\nSerial : 0x%08x"), fc.iSerialNumber); |
|
547 aIO.Printf(_L("\nOCR : 0x%08x"), fc.iOCR); |
|
548 aIO.Printf(_L("\nFn Info : 0x%02x"), fc.iFunctionInfo); |
|
549 aIO.Printf(_L("\nCSA Size : 0x%08x"), fc.iCSASize); |
|
550 aIO.Printf(_L("\nCSA Caps : 0x%02x"), fc.iCSAProperties); |
|
551 aIO.Printf(_L("\nMax Blk Sz : 0x%04x"), fc.iMaxBlockSize); |
|
552 aIO.Printf(_L("\nStby Min : %dmA"), fc.iMinPwrStby); |
|
553 aIO.Printf(_L("\nStby Ave : %dmA"), fc.iAvePwrStby); |
|
554 aIO.Printf(_L("\nStby Max : %dmA"), fc.iMaxPwrStby); |
|
555 aIO.Printf(_L("\nOp Min : %dmA"), fc.iMinPwrOp); |
|
556 aIO.Printf(_L("\nOp Ave : %dmA"), fc.iAvePwrOp); |
|
557 aIO.Printf(_L("\nOp Max : %dmA"), fc.iMaxPwrOp); |
|
558 aIO.Printf(_L("\nMin B/W : %dKB/s"), fc.iMinBandwidth); |
|
559 aIO.Printf(_L("\nOpt B/W : %dKB/s"), fc.iOptBandwidth); |
|
560 aIO.Printf(_L("\nEnable T/O : %dms"), fc.iEnableTimeout*10); |
|
561 aIO.Printf(_L("\nHiPwr Ave : %dmA"), fc.iAveHiPwr); |
|
562 aIO.Printf(_L("\nHiPwr Max : %dmA"), fc.iMaxHiPwr); |
|
563 |
|
564 aIO.Printf(_L("\n")); |
|
565 |
|
566 if (i != fc.iNumber) |
|
567 { |
|
568 aIO.ReportError(_L("Invalid function number"), fc.iNumber); |
|
569 aIO.Getch(); |
|
570 return KErrNotFound; |
|
571 } |
|
572 |
|
573 } |
|
574 } |
|
575 |
|
576 if (functionsFound < 1) |
|
577 { |
|
578 aIO.ReportError(_L("Not enough functions"), functionsFound); |
|
579 aIO.Getch(); |
|
580 return KErrNotFound; |
|
581 } |
|
582 |
|
583 return(KErrNone); |
|
584 |
|
585 } |
|
586 |
|
587 TInt TSdioCardDiagServices::doQuit() |
|
588 /** |
|
589 Quit the program and close the logical device driver. |
|
590 |
|
591 @return One of the system wide error codes. |
|
592 |
|
593 @internal |
|
594 @test |
|
595 */ |
|
596 { |
|
597 |
|
598 iDriver.Close(); |
|
599 return(KErrNone); |
|
600 } |
|
601 |
|
602 |
|
603 |
|
604 GLDEF_C TInt E32Main() |
|
605 /** |
|
606 The entry point. |
|
607 |
|
608 @return One of the system wide error codes. |
|
609 |
|
610 @internal |
|
611 @test |
|
612 */ |
|
613 { |
|
614 TInt err; |
|
615 err = User::LoadLogicalDevice(_L("D_SDIOIF")); |
|
616 __ASSERT_ALWAYS((err==KErrNone||err==KErrAlreadyExists),Panic(ELoadingMmcDriver)); |
|
617 |
|
618 TSdioCardDiagServices sdioIf; |
|
619 sdioIf.Start(); |
|
620 |
|
621 // Read the command line |
|
622 HBufC* commandLine = NULL; |
|
623 TRAPD(r, commandLine = HBufC::NewL(User::CommandLineLength())); |
|
624 __ASSERT_ALWAYS(r==KErrNone, Panic(EReadingCommandLine)); |
|
625 |
|
626 TPtr commandLinePtr(commandLine->Des()); |
|
627 User::CommandLine(commandLinePtr); |
|
628 |
|
629 if (commandLinePtr.FindC(_L("--auto")) != KErrNotFound) |
|
630 { |
|
631 CIOBase* inputOutput = new (ELeave) CIORDebug; |
|
632 TRAPD(r, inputOutput->CreateL(_L("SDIOTEST"))) |
|
633 __ASSERT_ALWAYS(r==KErrNone,Panic(ECreatingIO)); |
|
634 |
|
635 // Start tests |
|
636 sdioIf.doPowerUp(*inputOutput); |
|
637 |
|
638 // FSBASE-SDIOTEST-2 |
|
639 sdioIf.doGetCardInfo(*inputOutput); |
|
640 |
|
641 // FSBASE-SDIOTEST-3 |
|
642 sdioIf.doCardCommonControlRegs(*inputOutput); |
|
643 |
|
644 // FSBASE-SDIOTEST-4 |
|
645 sdioIf.doCardCommonConfig(*inputOutput); |
|
646 |
|
647 // FSBASE-SDIOTEST-5 |
|
648 sdioIf.doGetFunctionInfo(*inputOutput); |
|
649 |
|
650 delete inputOutput; |
|
651 } |
|
652 else |
|
653 { |
|
654 TBuf<20> b(_L("CDFIRPUQ\x1b")); |
|
655 |
|
656 CIOBase* inputOutput = new (ELeave) CIOConsole; |
|
657 TRAPD(r, inputOutput->CreateL(_L("SDIOTEST"))) |
|
658 __ASSERT_ALWAYS(r==KErrNone,Panic(ECreatingIO)); |
|
659 |
|
660 TBool quit=EFalse; |
|
661 while (!quit) |
|
662 { |
|
663 inputOutput->ClearScreen(); |
|
664 inputOutput->Heading(_L("Current socket: %d\n- Current Function: %d"),sdioIf.CurrentSocket(),sdioIf.CurrentFunc()); |
|
665 inputOutput->Instructions(EFalse, |
|
666 _L("(P)owerUp\nCard(I)nfo\n(R)eadCCCR\n(C)ommonConfig\n(F)unctionInfo\n(Q)uit\n")); |
|
667 TChar c; |
|
668 |
|
669 do |
|
670 { |
|
671 c=(TUint)inputOutput->Getch(); |
|
672 c.UpperCase(); |
|
673 } |
|
674 while(b.Locate(c)==KErrNotFound); |
|
675 |
|
676 TInt err = KErrNone; |
|
677 |
|
678 switch (c) |
|
679 { |
|
680 // FSBASE-SDIOTEST-1 |
|
681 case 'P': // PowerUp |
|
682 err = sdioIf.doPowerUp(*inputOutput); |
|
683 break; |
|
684 |
|
685 // FSBASE-SDIOTEST-2 |
|
686 case 'I': // Card Info - read CSD AND CID regs |
|
687 err = sdioIf.doGetCardInfo(*inputOutput); |
|
688 break; |
|
689 |
|
690 // FSBASE-SDIOTEST-3 |
|
691 case 'R': // CCCR |
|
692 err = sdioIf.doCardCommonControlRegs(*inputOutput); |
|
693 break; |
|
694 |
|
695 // FSBASE-SDIOTEST-4 |
|
696 case 'C': // Common configuration data |
|
697 err = sdioIf.doCardCommonConfig(*inputOutput); |
|
698 break; |
|
699 |
|
700 // FSBASE-SDIOTEST-5 |
|
701 case 'F': // Function Info |
|
702 err = sdioIf.doGetFunctionInfo(*inputOutput); |
|
703 break; |
|
704 |
|
705 case 'Q': // Quit |
|
706 case 0x1b: // Ascii character for Escape key |
|
707 sdioIf.doQuit(); |
|
708 User::FreeLogicalDevice(_L("D_SDIOIF")); |
|
709 quit=ETrue; |
|
710 break; |
|
711 |
|
712 } |
|
713 |
|
714 if (err != KErrNone) |
|
715 inputOutput->Printf(_L("Test Failed! (%d)\n"), err); |
|
716 |
|
717 if (!quit) |
|
718 { |
|
719 inputOutput->Printf(_L("\n\tPress Any Key")); |
|
720 inputOutput->Getch(); |
|
721 } |
|
722 } |
|
723 delete inputOutput; |
|
724 } |
|
725 delete commandLine; |
|
726 |
|
727 return(KErrNone); |
|
728 } |
|
729 |
|