sl@0
|
1 |
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\pccd\t_crrdrv.cpp
|
sl@0
|
15 |
// Test the Compact Rom (Programmable) card media driver
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32test.h>
|
sl@0
|
20 |
#include <e32svr.h>
|
sl@0
|
21 |
#include <e32uid.h>
|
sl@0
|
22 |
#define TWOMEG
|
sl@0
|
23 |
|
sl@0
|
24 |
LOCAL_D RTest test(_L("T_CRRDRV"));
|
sl@0
|
25 |
|
sl@0
|
26 |
#if defined (__MARM__)
|
sl@0
|
27 |
|
sl@0
|
28 |
const TInt KTestBufLen=0x100;
|
sl@0
|
29 |
|
sl@0
|
30 |
#define PDD_NAME _L("MEDCRR")
|
sl@0
|
31 |
const TInt KDriveNumber=1; // D:
|
sl@0
|
32 |
#if defined (TWOMEG)
|
sl@0
|
33 |
const TInt KMaxDriveLen=0x00200000; // 2M
|
sl@0
|
34 |
#else
|
sl@0
|
35 |
const TInt KMaxDriveLen=0x00600000; // 6M
|
sl@0
|
36 |
#endif
|
sl@0
|
37 |
const TUint16 KMagicSum=0x1234;
|
sl@0
|
38 |
const TInt KCRomPrivateAreaLen=0x800; // 1st 2K of CRom contains CIS
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
const TInt KCRomCisDataLength=0xD0;
|
sl@0
|
42 |
|
sl@0
|
43 |
LOCAL_D TBuf8<KTestBufLen> wrBuf,rdBuf;
|
sl@0
|
44 |
#if defined (TWOMEG)
|
sl@0
|
45 |
LOCAL_D const TText8 CompactRomCisData[KCRomCisDataLength]={
|
sl@0
|
46 |
0x01,0xff,0x03,0xff,0x1c,0xff,0x01,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff,
|
sl@0
|
47 |
0x1b,0xff,0x01,0xff,0xff,0xff,0x20,0xff,0x04,0xff,0x00,0xff,0x00,0xff,0x00,0xff,
|
sl@0
|
48 |
0x00,0xff,0x15,0xff,0x24,0xff,0x05,0xff,0x00,0xff,0x50,0xff,0x73,0xff,0x69,0xff,
|
sl@0
|
49 |
0x6f,0xff,0x6e,0xff,0x20,0xff,0x50,0xff,0x4c,0xff,0x43,0xff,0x00,0xff,0x43,0xff,
|
sl@0
|
50 |
0x6f,0xff,0x6d,0xff,0x70,0xff,0x61,0xff,0x63,0xff,0x74,0xff,0x20,0xff,0x52,0xff,
|
sl@0
|
51 |
0x6f,0xff,0x6d,0xff,0x20,0xff,0x43,0xff,0x61,0xff,0x72,0xff,0x64,0xff,0x00,0xff,
|
sl@0
|
52 |
0x56,0xff,0x30,0xff,0x2e,0xff,0x30,0xff,0x30,0xff,0x00,0xff,0xff,0xff,0x80,0xff,
|
sl@0
|
53 |
0x03,0xff,0x58,0xff,0x06,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x01,0xff,0x00,0xff,
|
sl@0
|
54 |
0x40,0xff,0x0b,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x08,0xff,0x00,0xff,0x00,0xff,
|
sl@0
|
55 |
0x00,0xff,0x00,0xff,0x01,0xff,0x00,0xff,0x00,0xff,0x41,0xff,0x0a,0xff,0x01,0xff,
|
sl@0
|
56 |
0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xf8,0xff,0x1f,0xff,
|
sl@0
|
57 |
0x00,0xff,0x14,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
sl@0
|
58 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
sl@0
|
59 |
};
|
sl@0
|
60 |
#else
|
sl@0
|
61 |
LOCAL_D const TText8 CompactRomCisData[KCRomCisDataLength]={
|
sl@0
|
62 |
0x01,0xff,0x03,0xff,0x1c,0xff,0x01,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff,
|
sl@0
|
63 |
0x1b,0xff,0x01,0xff,0xff,0xff,0x20,0xff,0x04,0xff,0x00,0xff,0x00,0xff,0x00,0xff,
|
sl@0
|
64 |
0x00,0xff,0x15,0xff,0x24,0xff,0x05,0xff,0x00,0xff,0x50,0xff,0x73,0xff,0x69,0xff,
|
sl@0
|
65 |
0x6f,0xff,0x6e,0xff,0x20,0xff,0x50,0xff,0x4c,0xff,0x43,0xff,0x00,0xff,0x43,0xff,
|
sl@0
|
66 |
0x6f,0xff,0x6d,0xff,0x70,0xff,0x61,0xff,0x63,0xff,0x74,0xff,0x20,0xff,0x52,0xff,
|
sl@0
|
67 |
0x6f,0xff,0x6d,0xff,0x20,0xff,0x43,0xff,0x61,0xff,0x72,0xff,0x64,0xff,0x00,0xff,
|
sl@0
|
68 |
0x56,0xff,0x30,0xff,0x2e,0xff,0x30,0xff,0x30,0xff,0x00,0xff,0xff,0xff,0x80,0xff,
|
sl@0
|
69 |
0x0b,0xff,0x58,0xff,0x06,0xff,0x08,0xff,0x76,0xff,0x58,0xff,0x06,0xff,0x08,0xff,
|
sl@0
|
70 |
0x76,0xff,0x58,0xff,0x06,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x01,0xff,0x00,0xff,
|
sl@0
|
71 |
0x40,0xff,0x0b,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x08,0xff,0x00,0xff,0x00,0xff,
|
sl@0
|
72 |
0x00,0xff,0x00,0xff,0x01,0xff,0x00,0xff,0x00,0xff,0x41,0xff,0x0a,0xff,0x01,0xff,
|
sl@0
|
73 |
0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xf8,0xff,0x5f,0xff,
|
sl@0
|
74 |
0x00,0xff,0x14,0xff,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
sl@0
|
75 |
};
|
sl@0
|
76 |
#endif
|
sl@0
|
77 |
|
sl@0
|
78 |
/* A sample multifunction CIS to test out tuple parsing by blowing onto CRom card.
|
sl@0
|
79 |
const TInt KMfcCisDataLen=0x180;
|
sl@0
|
80 |
LOCAL_D const TText8 MfcCisData[KMfcCisDataLen]={
|
sl@0
|
81 |
0x13,0xff,0x03,0xff,0x43,0xff,0x49,0xff,0x53,0xff,0x06,0xff,0x10,0xff,0x03,0xff,
|
sl@0
|
82 |
0x00,0xff,0x30,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x60,0xff,0x00,0xff,
|
sl@0
|
83 |
0x00,0xff,0x00,0xff,0x00,0xff,0x90,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0xff,0xff,
|
sl@0
|
84 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
sl@0
|
85 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
sl@0
|
86 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
sl@0
|
87 |
0x01,0xff,0x03,0xff,0xda,0xff,0x00,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff,
|
sl@0
|
88 |
0xda,0xff,0x00,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x02,0xff,0x00,0xff,0x1a,0xff,
|
sl@0
|
89 |
0x05,0xff,0x01,0xff,0x01,0xff,0x00,0xff,0x02,0xff,0x0f,0xff,0x1b,0xff,0x07,0xff,
|
sl@0
|
90 |
0xc1,0xff,0x41,0xff,0x09,0xff,0x01,0xff,0xb5,0xff,0x1e,0xff,0x49,0xff,0x14,0xff,
|
sl@0
|
91 |
0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
sl@0
|
92 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
sl@0
|
93 |
0x01,0xff,0x03,0xff,0xda,0xff,0x00,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff,
|
sl@0
|
94 |
0xda,0xff,0x00,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x06,0xff,0x00,0xff,0x1a,0xff,
|
sl@0
|
95 |
0x05,0xff,0x01,0xff,0x02,0xff,0x00,0xff,0x04,0xff,0x0f,0xff,0x1b,0xff,0x06,0xff,
|
sl@0
|
96 |
0xc2,0xff,0x41,0xff,0x09,0xff,0x01,0xff,0x55,0xff,0x49,0xff,0x14,0xff,0x00,0xff,
|
sl@0
|
97 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
sl@0
|
98 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
sl@0
|
99 |
0x01,0xff,0x03,0xff,0xda,0xff,0x00,0xff,0xff,0xff,0x1c,0xff,0x04,0xff,0x02,0xff,
|
sl@0
|
100 |
0xda,0xff,0x00,0xff,0xff,0xff,0x21,0xff,0x02,0xff,0x03,0xff,0x00,0xff,0x1a,0xff,
|
sl@0
|
101 |
0x05,0xff,0x01,0xff,0x03,0xff,0x00,0xff,0x06,0xff,0x0f,0xff,0x1b,0xff,0x06,0xff,
|
sl@0
|
102 |
0xc3,0xff,0x41,0xff,0x09,0xff,0x01,0xff,0x55,0xff,0x49,0xff,0x14,0xff,0x00,0xff,
|
sl@0
|
103 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
sl@0
|
104 |
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
sl@0
|
105 |
}; */
|
sl@0
|
106 |
|
sl@0
|
107 |
|
sl@0
|
108 |
LOCAL_C void ProgressBar(TInt aPos,TInt anEndPos,TInt anXPos)
|
sl@0
|
109 |
//
|
sl@0
|
110 |
// Display progress of local drive operation on screen (1-16 dots)
|
sl@0
|
111 |
//
|
sl@0
|
112 |
{
|
sl@0
|
113 |
static TInt prev;
|
sl@0
|
114 |
TInt curr;
|
sl@0
|
115 |
if ((curr=(aPos-1)/(anEndPos>>4))>prev)
|
sl@0
|
116 |
{ // Update progress bar
|
sl@0
|
117 |
test.Console()->SetPos(anXPos);
|
sl@0
|
118 |
for (TInt i=curr;i>=0;i--)
|
sl@0
|
119 |
test.Printf(_L("."));
|
sl@0
|
120 |
}
|
sl@0
|
121 |
prev=curr;
|
sl@0
|
122 |
}
|
sl@0
|
123 |
|
sl@0
|
124 |
GLDEF_C TInt E32Main()
|
sl@0
|
125 |
{
|
sl@0
|
126 |
TInt i;
|
sl@0
|
127 |
TBuf<32> b;
|
sl@0
|
128 |
|
sl@0
|
129 |
test.Title();
|
sl@0
|
130 |
|
sl@0
|
131 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change (in case normal CROM driver open on target).
|
sl@0
|
132 |
User::After(300000); // Allow 0.3s for controller to detect door closed.
|
sl@0
|
133 |
|
sl@0
|
134 |
test.Start(_L("Load CROM(repro) Media Driver"));
|
sl@0
|
135 |
TInt r=User::LoadPhysicalDevice(PDD_NAME);
|
sl@0
|
136 |
test(r==KErrNone||r==KErrAlreadyExists);
|
sl@0
|
137 |
|
sl@0
|
138 |
b.Format(_L("Connect to local drive (%c:)"),KDriveNumber+'C');
|
sl@0
|
139 |
test.Next(b);
|
sl@0
|
140 |
TBusLocalDrive theCRomDrive;
|
sl@0
|
141 |
TBool changeFlag=FALSE;
|
sl@0
|
142 |
test(theCRomDrive.Connect(KDriveNumber,changeFlag)==KErrNone);
|
sl@0
|
143 |
|
sl@0
|
144 |
test.Next(_L("CROM drive: capabilities"));
|
sl@0
|
145 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change (in case normal CROM driver open on target).
|
sl@0
|
146 |
User::After(300000); // Allow 0.3s for controller to detect door closed.
|
sl@0
|
147 |
TLocalDriveCapsV2Buf info;
|
sl@0
|
148 |
test(theCRomDrive.Caps(info)==KErrNone);
|
sl@0
|
149 |
test(info().iSize==(TInt64)KMaxDriveLen);
|
sl@0
|
150 |
test(info().iType==EMediaFlash);
|
sl@0
|
151 |
test(info().iConnectionBusType==EConnectionBusInternal);
|
sl@0
|
152 |
test(info().iDriveAtt==(KDriveAttLocal|KDriveAttRemovable));
|
sl@0
|
153 |
test(info().iMediaAtt==KMediaAttFormattable);
|
sl@0
|
154 |
test(info().iFileSystemId==KDriveFileSysFAT);
|
sl@0
|
155 |
|
sl@0
|
156 |
test.Next(_L("CROM drive: format"));
|
sl@0
|
157 |
TFormatInfo fi;
|
sl@0
|
158 |
test.Printf(_L("Formatting "));
|
sl@0
|
159 |
TInt ret;
|
sl@0
|
160 |
while((ret=theCRomDrive.Format(fi))!=KErrEof)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
ProgressBar((fi.i512ByteSectorsFormatted<<9),KMaxDriveLen,11);
|
sl@0
|
163 |
test(ret==KErrNone);
|
sl@0
|
164 |
}
|
sl@0
|
165 |
test.Printf(_L("\r\nReading "));
|
sl@0
|
166 |
TInt len;
|
sl@0
|
167 |
TInt msgHandle = KLocalMessageHandle;
|
sl@0
|
168 |
for (i=0;i<KMaxDriveLen;i+=len)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
ProgressBar(i,KMaxDriveLen,11);
|
sl@0
|
171 |
len=Min(KTestBufLen,(KMaxDriveLen-i));
|
sl@0
|
172 |
rdBuf.Fill(0x55,len); // Sets length too
|
sl@0
|
173 |
test(theCRomDrive.Read(i,len,&rdBuf,msgHandle,0)==KErrNone);
|
sl@0
|
174 |
wrBuf.Fill(0xFF,len); // Sets length too
|
sl@0
|
175 |
if ((ret=rdBuf.Compare(wrBuf))!=0)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
test.Printf(_L(" (C:%d@%xH)\r\n"),ret,i);
|
sl@0
|
178 |
test(0);
|
sl@0
|
179 |
}
|
sl@0
|
180 |
}
|
sl@0
|
181 |
test.Printf(_L("\r\n"));
|
sl@0
|
182 |
|
sl@0
|
183 |
wrBuf.SetLength(KTestBufLen);
|
sl@0
|
184 |
for (i=0;i<KTestBufLen;i++)
|
sl@0
|
185 |
wrBuf[i]=(TUint8)i;
|
sl@0
|
186 |
/*
|
sl@0
|
187 |
test.Next(_L("CROM drive: Write at start of Drive"));
|
sl@0
|
188 |
test(theCRomDrive.Write(0,KTestBufLen,&wrBuf,msgHandle,0)==KErrNone);
|
sl@0
|
189 |
rdBuf.Fill(0,KTestBufLen);
|
sl@0
|
190 |
test(theCRomDrive.Read(0,KTestBufLen,&rdBuf,msgHandle,0)==KErrNone);
|
sl@0
|
191 |
test(rdBuf.Compare(wrBuf)==0);
|
sl@0
|
192 |
|
sl@0
|
193 |
test.Next(_L("CROM drive: Write at end of Drive"));
|
sl@0
|
194 |
test(theCRomDrive.Write(KMaxDriveLen-KTestBufLen,KTestBufLen,&wrBuf,msgHandle,0)==KErrNone);
|
sl@0
|
195 |
rdBuf.Fill(0,KTestBufLen);
|
sl@0
|
196 |
test(theCRomDrive.Read(KMaxDriveLen-KTestBufLen,KTestBufLen,&rdBuf,msgHandle,0)==KErrNone);
|
sl@0
|
197 |
test(rdBuf.Compare(wrBuf)==0);
|
sl@0
|
198 |
|
sl@0
|
199 |
test.Next(_L("CROM drive: Write across 64K block boundary"));
|
sl@0
|
200 |
test(theCRomDrive.Write((0x10000-(KTestBufLen>>1)),KTestBufLen,&wrBuf,msgHandle,0)==KErrNone);
|
sl@0
|
201 |
rdBuf.Fill(0,KTestBufLen);
|
sl@0
|
202 |
test(theCRomDrive.Read((0x10000-(KTestBufLen>>1)),KTestBufLen,&rdBuf,msgHandle,0)==KErrNone);
|
sl@0
|
203 |
test(rdBuf.Compare(wrBuf)==0);
|
sl@0
|
204 |
|
sl@0
|
205 |
test.Next(_L("CROM drive: Write across 28F016 device boundary"));
|
sl@0
|
206 |
test(theCRomDrive.Write((0x200000-(KTestBufLen>>1)),KTestBufLen,&wrBuf,msgHandle,0)==KErrNone);
|
sl@0
|
207 |
rdBuf.Fill(0,KTestBufLen);
|
sl@0
|
208 |
test(theCRomDrive.Read((0x200000-(KTestBufLen>>1)),KTestBufLen,&rdBuf,msgHandle,0)==KErrNone);
|
sl@0
|
209 |
test(rdBuf.Compare(wrBuf)==0);
|
sl@0
|
210 |
*/
|
sl@0
|
211 |
test.Next(_L("CROM drive: Write/Read the entire disk"));
|
sl@0
|
212 |
TInt rdwrTestLen=(KTestBufLen-3); // Test it works off word boundary
|
sl@0
|
213 |
TUint *p=(TUint*)&wrBuf[0];
|
sl@0
|
214 |
TInt j;
|
sl@0
|
215 |
test.Printf(_L("Writing "));
|
sl@0
|
216 |
for (i=0,j=0;i<KMaxDriveLen;i+=len,j++)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
ProgressBar(i,KMaxDriveLen,11);
|
sl@0
|
219 |
len=Min(rdwrTestLen,(KMaxDriveLen-i));
|
sl@0
|
220 |
(*p)=j;
|
sl@0
|
221 |
test(theCRomDrive.Write(i,len,&wrBuf,msgHandle,0)==KErrNone);
|
sl@0
|
222 |
}
|
sl@0
|
223 |
test.Printf(_L("\r\nReading "));
|
sl@0
|
224 |
for (i=0,j=0;i<KMaxDriveLen;i+=len,j++)
|
sl@0
|
225 |
{
|
sl@0
|
226 |
ProgressBar(i,KMaxDriveLen,11);
|
sl@0
|
227 |
len=Min(rdwrTestLen,(KMaxDriveLen-i));
|
sl@0
|
228 |
rdBuf.Fill(0,len);
|
sl@0
|
229 |
if ((ret=theCRomDrive.Read(i,len,&rdBuf,msgHandle,0))!=KErrNone)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
test.Printf(_L(" (R:%d@%xH)\r\n"),ret,j);
|
sl@0
|
232 |
test(0);
|
sl@0
|
233 |
}
|
sl@0
|
234 |
(*p)=j;
|
sl@0
|
235 |
wrBuf.SetLength(len);
|
sl@0
|
236 |
if ((ret=rdBuf.Compare(wrBuf))!=0)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
test.Printf(_L(" (C:%d@%xH)\r\n"),ret,j);
|
sl@0
|
239 |
test(0);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
}
|
sl@0
|
242 |
test.Printf(_L("\r\n"));
|
sl@0
|
243 |
|
sl@0
|
244 |
test.Next(_L("CROM drive: Re-format"));
|
sl@0
|
245 |
test.Printf(_L("Formatting "));
|
sl@0
|
246 |
while((ret=theCRomDrive.Format(fi))!=KErrEof)
|
sl@0
|
247 |
{
|
sl@0
|
248 |
ProgressBar((fi.i512ByteSectorsFormatted<<9),KMaxDriveLen,11);
|
sl@0
|
249 |
test(ret==KErrNone);
|
sl@0
|
250 |
}
|
sl@0
|
251 |
test.Printf(_L("\r\n"));
|
sl@0
|
252 |
|
sl@0
|
253 |
test.Next(_L("CROM drive: Write CIS at start of Drive"));
|
sl@0
|
254 |
TPtrC8 buf(&CompactRomCisData[0],KCRomCisDataLength);
|
sl@0
|
255 |
// TPtrC8 buf(&MfcCisData[0],KMfcCisDataLen); // ???
|
sl@0
|
256 |
test(theCRomDrive.Write(0,buf)==KErrNone);
|
sl@0
|
257 |
|
sl@0
|
258 |
rdBuf.Fill(0,KTestBufLen);
|
sl@0
|
259 |
test(theCRomDrive.Read(0,KCRomCisDataLength,rdBuf)==KErrNone);
|
sl@0
|
260 |
test(rdBuf.Compare(buf)==0);
|
sl@0
|
261 |
|
sl@0
|
262 |
test.Next(_L("Calculating & writing checksum"));
|
sl@0
|
263 |
TUint16 checksum=0; // 16bit arithmetic
|
sl@0
|
264 |
test.Printf(_L("Reading"));
|
sl@0
|
265 |
for (i=0;i<KMaxDriveLen;i+=len)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
ProgressBar(i,KMaxDriveLen,11);
|
sl@0
|
268 |
len=Min(KTestBufLen,(KMaxDriveLen-i));
|
sl@0
|
269 |
test(theCRomDrive.Read(i,len,rdBuf)==KErrNone);
|
sl@0
|
270 |
test((len%2)==0); // 16bit checksum - length must never be odd
|
sl@0
|
271 |
for (TInt j=0;j<len;j+=2)
|
sl@0
|
272 |
checksum+=*(TUint16*)(rdBuf.Ptr()+j);
|
sl@0
|
273 |
}
|
sl@0
|
274 |
checksum-=0xFFFF; // Subtract for checksum itself
|
sl@0
|
275 |
TUint16 adjust=KMagicSum-checksum;
|
sl@0
|
276 |
test.Printf(_L("\r\n (CS:%xH)\r\n"),adjust);
|
sl@0
|
277 |
TPtrC8 cs((TUint8*)&adjust,2);
|
sl@0
|
278 |
test(theCRomDrive.Write(KCRomPrivateAreaLen-2,cs)==KErrNone);
|
sl@0
|
279 |
|
sl@0
|
280 |
test.Next(_L("CROM drive: Caps following media change"));
|
sl@0
|
281 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change
|
sl@0
|
282 |
User::After(300000); // Allow 0.3s after power down for controller to detect door closed.
|
sl@0
|
283 |
test(changeFlag!=FALSE);
|
sl@0
|
284 |
test(theCRomDrive.Caps(info)==KErrNone);
|
sl@0
|
285 |
test(info().iSize==(TInt64)KMaxDriveLen);
|
sl@0
|
286 |
test(info().iType==EMediaFlash);
|
sl@0
|
287 |
|
sl@0
|
288 |
b.Format(_L("Disconnect from local drive (%c:)"),KDriveNumber+'C');
|
sl@0
|
289 |
test.Next(b);
|
sl@0
|
290 |
theCRomDrive.Disconnect();
|
sl@0
|
291 |
|
sl@0
|
292 |
TFindPhysicalDevice fDr;
|
sl@0
|
293 |
test.Next(_L("Unload CROM(prog) Media Driver"));
|
sl@0
|
294 |
TFullName drivName;
|
sl@0
|
295 |
fDr.Find(_L("Media.RomPrg"));
|
sl@0
|
296 |
test(fDr.Next(drivName)==KErrNone);
|
sl@0
|
297 |
test(User::FreePhysicalDevice(drivName)==KErrNone);
|
sl@0
|
298 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change (allow normal CROM driver on next target access).
|
sl@0
|
299 |
|
sl@0
|
300 |
test.End();
|
sl@0
|
301 |
return(0);
|
sl@0
|
302 |
}
|
sl@0
|
303 |
|
sl@0
|
304 |
#else
|
sl@0
|
305 |
TInt E32Main()
|
sl@0
|
306 |
{
|
sl@0
|
307 |
test.Title();
|
sl@0
|
308 |
test.Start(_L("T_CRRDRV only runs under ARM build."));
|
sl@0
|
309 |
test.End();
|
sl@0
|
310 |
return(KErrNone);
|
sl@0
|
311 |
}
|
sl@0
|
312 |
#endif
|
sl@0
|
313 |
|