|
1 // Copyright (c) 1996-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\pccd\t_pccd1.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32test.h> |
|
19 #include <e32svr.h> |
|
20 #include <e32hal.h> |
|
21 #include <e32uid.h> |
|
22 #include <d_pccdif.h> |
|
23 |
|
24 LOCAL_D RTest test(_L("T_PCCD1")); |
|
25 const TSocket KSocket=0; |
|
26 const TInt KFunc=0; |
|
27 |
|
28 GLDEF_C TInt E32Main() |
|
29 { |
|
30 #if defined (__WINS__) |
|
31 // Connect to all the local drives first as will be the case in ARM |
|
32 TBusLocalDrive Drive[KMaxLocalDrives]; |
|
33 TBool ChangedFlag[KMaxLocalDrives]; |
|
34 TInt i; |
|
35 for (i=0;i<KMaxLocalDrives;i++) |
|
36 Drive[i].Connect(i,ChangedFlag[i]); |
|
37 #endif |
|
38 |
|
39 test.Title(); |
|
40 |
|
41 TDriveInfoV1Buf diBuf; |
|
42 UserHal::DriveInfo(diBuf); |
|
43 TDriveInfoV1 &di=diBuf(); |
|
44 test.Printf(_L("SOCKETS PRESENT :%d\r\n"),di.iTotalSockets); |
|
45 test.Printf(_L("1ST SOCKET NAME :%- 16S\r\n"),&di.iSocketName[0]); |
|
46 test.Printf(_L("2ND SOCKET NAME :%- 16S\r\n"),&di.iSocketName[1]); |
|
47 test.Printf(_L("3RD SOCKET NAME :%- 16S\r\n"),&di.iSocketName[2]); |
|
48 test.Printf(_L("4TH SOCKET NAME :%- 16S\r\n"),&di.iSocketName[3]); |
|
49 //test.Printf( _L("Hit a key\r\n")); |
|
50 //test.Getch(); |
|
51 // |
|
52 test.Start(_L("Load/open logical device")); |
|
53 TInt r; |
|
54 r=User::LoadLogicalDevice(_L("D_PCCDIF")); |
|
55 test(r==KErrNone||r==KErrAlreadyExists); |
|
56 RPcCardCntrlIf pccdDrv; |
|
57 r=pccdDrv.Open(KSocket,pccdDrv.VersionRequired()); |
|
58 test(r==KErrNone); |
|
59 |
|
60 test.Next(_L("Power card, check card type.")); |
|
61 UserSvr::ForceRemountMedia(ERemovableMedia0); // Media change - ensures test always starts from same state |
|
62 User::After(300000); // Allow 0.3s after power down for controller to detect door closed. |
|
63 pccdDrv.Reset(); |
|
64 TPcCardStatus s; |
|
65 TSocketSignals ind; |
|
66 test(pccdDrv.SocketInfo(s,ind)==KErrNone); |
|
67 test(s==EPcCardNotReady); |
|
68 test(ind.iCardDetected); |
|
69 #if defined (__WINS__) |
|
70 test(ind.iVoltSense==0x01); |
|
71 #else |
|
72 if(ind.iVoltSense!=0x03) |
|
73 test.Printf(_L("vs=%d"),ind.iVoltSense); |
|
74 test(ind.iVoltSense==0x03); |
|
75 #endif |
|
76 TRequestStatus rs; |
|
77 pccdDrv.PwrUp(&rs); |
|
78 User::WaitForRequest(rs); |
|
79 test(rs.Int()==KErrNone); |
|
80 test(pccdDrv.SocketInfo(s,ind)==KErrNone); |
|
81 test(s==EPcCardReady); |
|
82 TPcCardTypePckg tyBuf; |
|
83 TPcCardType &ty=tyBuf(); |
|
84 test(pccdDrv.CardInfo(&tyBuf)==KErrNone); |
|
85 test(ty.iFuncType[0]==EFFixedDiskCard); |
|
86 test(ty.iFuncCount==1); |
|
87 |
|
88 test.Next(_L("Tuple reading.")); |
|
89 TBuf8<257> tbuf; |
|
90 test(pccdDrv.GetTuple(KFunc,KPccdNonSpecificTuple,&tbuf)==KErrNone); |
|
91 test(tbuf[0]==KCisTupleDevice); |
|
92 test(pccdDrv.GetTuple(KFunc,KCisTupleFuncId,&tbuf)==KErrNone); |
|
93 test(tbuf[0]==KCisTupleFuncId&&tbuf[1]==0x02&&tbuf[2]==0x04&&tbuf[3]==0x01); |
|
94 test(pccdDrv.GetTuple(KFunc,KCisTupleFuncId,&tbuf)==KErrNotFound); |
|
95 test(pccdDrv.ResetCis(KFunc)==KErrNone); |
|
96 test(pccdDrv.GetTuple(KFunc,KCisTupleFuncId,&tbuf)==KErrNone); |
|
97 test(pccdDrv.GetTuple(KFunc,KCisTupleNoLink,&tbuf)==KErrNone); |
|
98 test(tbuf[0]==KCisTupleNoLink&&tbuf[1]==0x00); |
|
99 test(pccdDrv.GetTuple(KFunc,KCisTupleBattery,&tbuf)==KErrNotFound); |
|
100 |
|
101 test.Next(_L("Read card configuration 1.")); |
|
102 TPcCardConfigInfoPckg ciBuf; |
|
103 TPcCardConfigInfo &ci=ciBuf(); |
|
104 test(pccdDrv.GetConfig(KFunc,&ciBuf)==KErrNone); |
|
105 test(ci.iAccessSpeed==EAccSpeed200nS); |
|
106 test(ci.iActiveSignals==(KSignalWaitRequired|KSignalReadyActive)); |
|
107 test(ci.iVccMaxInMilliVolts==5500&&ci.iVccMinInMilliVolts==4500); |
|
108 test(ci.iValidChunks==1); |
|
109 test(ci.iChnk[0].iMemType==EPcCardCommon16Mem&&ci.iChnk[0].iMemBaseAddr==0&&ci.iChnk[0].iMemLen==0x800); // 2K |
|
110 test(ci.iIsIoAndMem==FALSE&&ci.iIsDefault); |
|
111 test(ci.iVppMaxInMilliVolts==0&&ci.iVppMinInMilliVolts==0); |
|
112 test(ci.iPwrDown&&ci.iOperCurrentInMicroAmps==80000&&ci.iPwrDwnCurrentInMicroAmps==0); |
|
113 test(ci.iInterruptInfo==0); |
|
114 test(ci.iConfigOption==0&&ci.iConfigBaseAddr==0x200&&ci.iRegPresent==0x0F); |
|
115 |
|
116 test.Next(_L("Read card configuration 2.")); |
|
117 test(pccdDrv.GetConfig(KFunc,&ciBuf)==KErrNone); |
|
118 test(ci.iAccessSpeed==EAccSpeed200nS); |
|
119 test(ci.iActiveSignals==(KSignalWaitRequired|KSignalReadyActive)); |
|
120 test(ci.iVccMaxInMilliVolts==3465&&ci.iVccMinInMilliVolts==3135); |
|
121 test(ci.iValidChunks==1); |
|
122 test(ci.iChnk[0].iMemType==EPcCardCommon16Mem&&ci.iChnk[0].iMemBaseAddr==0&&ci.iChnk[0].iMemLen==0x800); // 2K |
|
123 test(ci.iIsIoAndMem==FALSE&&ci.iIsDefault==FALSE); |
|
124 test(ci.iVppMaxInMilliVolts==0&&ci.iVppMinInMilliVolts==0); |
|
125 test(ci.iPwrDown&&ci.iOperCurrentInMicroAmps==45000&&ci.iPwrDwnCurrentInMicroAmps==0); |
|
126 test(ci.iInterruptInfo==0); |
|
127 test(ci.iConfigOption==0&&ci.iConfigBaseAddr==0x200&&ci.iRegPresent==0x0F); |
|
128 |
|
129 test.Next(_L("Read card configuration 3.")); |
|
130 test(pccdDrv.GetConfig(KFunc,&ciBuf)==KErrNone); |
|
131 test(ci.iAccessSpeed==EAccSpeed200nS); |
|
132 test(ci.iActiveSignals==KSignalReadyActive); |
|
133 test(ci.iVccMaxInMilliVolts==5500&&ci.iVccMinInMilliVolts==4500); |
|
134 test(ci.iValidChunks==1); |
|
135 test(ci.iChnk[0].iMemType==EPcCardIo16Mem&&ci.iChnk[0].iMemBaseAddr==0&&ci.iChnk[0].iMemLen==0x10); // 16bytes |
|
136 test(ci.iIsIoAndMem&&ci.iIsDefault); |
|
137 test(ci.iVppMaxInMilliVolts==0&&ci.iVppMinInMilliVolts==0); |
|
138 test(ci.iPwrDown&&ci.iOperCurrentInMicroAmps==80000&&ci.iPwrDwnCurrentInMicroAmps==0); |
|
139 test(ci.iInterruptInfo==(KPcCardIntShare|KPcCardIntPulse|KPcCardIntLevel)); |
|
140 test(ci.iConfigOption==1&&ci.iConfigBaseAddr==0x200&&ci.iRegPresent==0x0F); |
|
141 |
|
142 test.Next(_L("Read card configuration 4.")); |
|
143 test(pccdDrv.GetConfig(KFunc,&ciBuf)==KErrNone); |
|
144 test(ci.iAccessSpeed==EAccSpeed200nS); |
|
145 test(ci.iActiveSignals==KSignalReadyActive); |
|
146 test(ci.iVccMaxInMilliVolts==3465&&ci.iVccMinInMilliVolts==3135); |
|
147 test(ci.iValidChunks==1); |
|
148 test(ci.iChnk[0].iMemType==EPcCardIo16Mem&&ci.iChnk[0].iMemBaseAddr==0&&ci.iChnk[0].iMemLen==0x10); // 16bytes |
|
149 test(ci.iIsIoAndMem&&ci.iIsDefault==FALSE); |
|
150 test(ci.iVppMaxInMilliVolts==0&&ci.iVppMinInMilliVolts==0); |
|
151 test(ci.iPwrDown&&ci.iOperCurrentInMicroAmps==45000&&ci.iPwrDwnCurrentInMicroAmps==0); |
|
152 test(ci.iInterruptInfo==(KPcCardIntShare|KPcCardIntPulse|KPcCardIntLevel)); |
|
153 test(ci.iConfigOption==1&&ci.iConfigBaseAddr==0x200&&ci.iRegPresent==0x0F); |
|
154 |
|
155 test.Next(_L("Read card configuration 5.")); |
|
156 test(pccdDrv.GetConfig(KFunc,&ciBuf)==KErrNone); |
|
157 test(ci.iAccessSpeed==EAccSpeed200nS); |
|
158 test(ci.iActiveSignals==KSignalReadyActive); |
|
159 test(ci.iVccMaxInMilliVolts==5500&&ci.iVccMinInMilliVolts==4500); |
|
160 test(ci.iValidChunks==2); |
|
161 test(ci.iChnk[0].iMemType==EPcCardIo16Mem&&ci.iChnk[0].iMemBaseAddr==0x1F0&&ci.iChnk[0].iMemLen==8); // 8bytes |
|
162 test(ci.iChnk[1].iMemType==EPcCardIo16Mem&&ci.iChnk[1].iMemBaseAddr==0x3F6&&ci.iChnk[1].iMemLen==2); // 2bytes |
|
163 test(ci.iIsIoAndMem&&ci.iIsDefault); |
|
164 test(ci.iVppMaxInMilliVolts==0&&ci.iVppMinInMilliVolts==0); |
|
165 test(ci.iPwrDown&&ci.iOperCurrentInMicroAmps==80000&&ci.iPwrDwnCurrentInMicroAmps==0); |
|
166 test(ci.iInterruptInfo==(KPcCardIntShare|KPcCardIntPulse|KPcCardIntLevel)); |
|
167 test(ci.iConfigOption==2&&ci.iConfigBaseAddr==0x200&&ci.iRegPresent==0x0F); |
|
168 |
|
169 test.Next(_L("Read card configuration 6.")); |
|
170 test(pccdDrv.GetConfig(KFunc,&ciBuf)==KErrNone); |
|
171 test(ci.iAccessSpeed==EAccSpeed200nS); |
|
172 test(ci.iActiveSignals==KSignalReadyActive); |
|
173 test(ci.iVccMaxInMilliVolts==3465&&ci.iVccMinInMilliVolts==3135); |
|
174 test(ci.iValidChunks==2); |
|
175 test(ci.iChnk[0].iMemType==EPcCardIo16Mem&&ci.iChnk[0].iMemBaseAddr==0x1F0&&ci.iChnk[0].iMemLen==8); // 8bytes |
|
176 test(ci.iChnk[1].iMemType==EPcCardIo16Mem&&ci.iChnk[1].iMemBaseAddr==0x3F6&&ci.iChnk[1].iMemLen==2); // 2bytes |
|
177 test(ci.iIsIoAndMem&&ci.iIsDefault==FALSE); |
|
178 test(ci.iVppMaxInMilliVolts==0&&ci.iVppMinInMilliVolts==0); |
|
179 test(ci.iPwrDown&&ci.iOperCurrentInMicroAmps==45000&&ci.iPwrDwnCurrentInMicroAmps==0); |
|
180 test(ci.iInterruptInfo==(KPcCardIntShare|KPcCardIntPulse|KPcCardIntLevel)); |
|
181 test(ci.iConfigOption==2&&ci.iConfigBaseAddr==0x200&&ci.iRegPresent==0x0F); |
|
182 |
|
183 test.Next(_L("Read card configuration 7.")); |
|
184 test(pccdDrv.GetConfig(KFunc,&ciBuf)==KErrNone); |
|
185 test(ci.iAccessSpeed==EAccSpeed200nS); |
|
186 test(ci.iActiveSignals==KSignalReadyActive); |
|
187 test(ci.iVccMaxInMilliVolts==5500&&ci.iVccMinInMilliVolts==4500); |
|
188 test(ci.iValidChunks==2); |
|
189 test(ci.iChnk[0].iMemType==EPcCardIo16Mem&&ci.iChnk[0].iMemBaseAddr==0x170&&ci.iChnk[0].iMemLen==8); // 8bytes |
|
190 test(ci.iChnk[1].iMemType==EPcCardIo16Mem&&ci.iChnk[1].iMemBaseAddr==0x376&&ci.iChnk[1].iMemLen==2); // 2bytes |
|
191 test(ci.iIsIoAndMem&&ci.iIsDefault); |
|
192 test(ci.iVppMaxInMilliVolts==0&&ci.iVppMinInMilliVolts==0); |
|
193 test(ci.iPwrDown&&ci.iOperCurrentInMicroAmps==80000&&ci.iPwrDwnCurrentInMicroAmps==0); |
|
194 test(ci.iInterruptInfo==(KPcCardIntShare|KPcCardIntPulse|KPcCardIntLevel)); |
|
195 test(ci.iConfigOption==3&&ci.iConfigBaseAddr==0x200&&ci.iRegPresent==0x0F); |
|
196 |
|
197 test.Next(_L("Read card configuration 8.")); |
|
198 test(pccdDrv.GetConfig(KFunc,&ciBuf)==KErrNone); |
|
199 test(ci.iAccessSpeed==EAccSpeed200nS); |
|
200 test(ci.iActiveSignals==KSignalReadyActive); |
|
201 test(ci.iVccMaxInMilliVolts==3465&&ci.iVccMinInMilliVolts==3135); |
|
202 test(ci.iValidChunks==2); |
|
203 test(ci.iChnk[0].iMemType==EPcCardIo16Mem&&ci.iChnk[0].iMemBaseAddr==0x170&&ci.iChnk[0].iMemLen==8); // 8bytes |
|
204 test(ci.iChnk[1].iMemType==EPcCardIo16Mem&&ci.iChnk[1].iMemBaseAddr==0x376&&ci.iChnk[1].iMemLen==2); // 2bytes |
|
205 test(ci.iIsIoAndMem&&ci.iIsDefault==FALSE); |
|
206 test(ci.iVppMaxInMilliVolts==0&&ci.iVppMinInMilliVolts==0); |
|
207 test(ci.iPwrDown&&ci.iOperCurrentInMicroAmps==45000&&ci.iPwrDwnCurrentInMicroAmps==0); |
|
208 test(ci.iInterruptInfo==(KPcCardIntShare|KPcCardIntPulse|KPcCardIntLevel)); |
|
209 test(ci.iConfigOption==3&&ci.iConfigBaseAddr==0x200&&ci.iRegPresent==0x0F); |
|
210 |
|
211 test(pccdDrv.GetConfig(KFunc,&ciBuf)==KErrNotFound); |
|
212 |
|
213 test.Next(_L("Read card memory regions.")); |
|
214 TPcCardRegionInfoPckg rgBuf; |
|
215 TPcCardRegionInfo &rg=rgBuf(); |
|
216 test.Next(_L("Read card region.")); |
|
217 test(pccdDrv.ResetCis(KFunc)==KErrNone); |
|
218 test(pccdDrv.GetRegion(KFunc,&rgBuf)==KErrNone); |
|
219 #if defined (__WINS__) |
|
220 test(rg.iAccessSpeed==EAccSpeed750nS); |
|
221 test(rg.iExtendedAccSpeedInNanoSecs==700); |
|
222 test(rg.iActiveSignals==0); |
|
223 test(rg.iVcc==EPcCardSocket_5V0); |
|
224 #else |
|
225 test(rg.iAccessSpeed==EAccSpeed250nS); |
|
226 test(rg.iExtendedAccSpeedInNanoSecs==0); |
|
227 test(rg.iActiveSignals==KSignalWaitRequired); |
|
228 test(rg.iVcc==EPcCardSocket_3V3); |
|
229 #endif |
|
230 test(rg.iChnk.iMemType==EPcCardCommon16Mem&&rg.iChnk.iMemBaseAddr==0&&rg.iChnk.iMemLen==0x800); // 2K |
|
231 test(rg.iDeviceType==EMDeviceFunSpec); |
|
232 test(pccdDrv.GetRegion(KFunc,&rgBuf)==KErrNotFound); |
|
233 |
|
234 TInt reg=0; |
|
235 test.Next(_L("Request card configuration.")); |
|
236 test(pccdDrv.ReadConfigReg(KFunc,0,reg)==KErrGeneral); |
|
237 test(pccdDrv.ReqConfig(KFunc,2)==KErrNone); |
|
238 test(pccdDrv.ReadConfigReg(KFunc,0,reg)==KErrNone); |
|
239 test(reg==2); |
|
240 test(pccdDrv.ReqConfig(KFunc,1)==KErrInUse); |
|
241 pccdDrv.Reset(); // Release config |
|
242 test(pccdDrv.ReqConfig(KFunc,1)==KErrNone); |
|
243 |
|
244 test.Next(_L("Configuration register read/write test.")); // Set IoIs8 bit in ConfigAndStatus register |
|
245 test(pccdDrv.ReadConfigReg(KFunc,1,reg)==KErrNone); |
|
246 test.Printf(_L("reg=0x%x"),reg); |
|
247 test((reg&0x20)==0); |
|
248 reg|=0x20; |
|
249 test(pccdDrv.WriteConfigReg(KFunc,1,reg)==KErrNone); |
|
250 TInt newReg=0; |
|
251 test(pccdDrv.ReadConfigReg(KFunc,1,newReg)==KErrNone); |
|
252 if(reg!=newReg) |
|
253 test.Printf(_L("reg=0x%x, new reg=0x%x"),reg,newReg); |
|
254 test(reg==newReg); |
|
255 reg&=0xDF; |
|
256 test(pccdDrv.WriteConfigReg(KFunc,1,reg)==KErrNone); |
|
257 |
|
258 test.Next(_L("Close/free device")); |
|
259 pccdDrv.Close(); |
|
260 r=User::FreeLogicalDevice(_L("PccdIf")); |
|
261 test(r==KErrNone); |
|
262 |
|
263 test.End(); |
|
264 |
|
265 #if defined (__WINS__) |
|
266 for (i=0;i<KMaxLocalDrives;i++) |
|
267 Drive[i].Disconnect(); |
|
268 #endif |
|
269 return(0); |
|
270 } |
|
271 |