|
1 // Copyright (c) 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 // |
|
15 |
|
16 |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #ifndef CBLOCKDEVICETESTER_H |
|
24 #define CBLOCKDEVICETESTER_H |
|
25 |
|
26 static const TInt KBlockSize = 0x200; |
|
27 |
|
28 static const TInt KSizeInBlocks = 0x20; |
|
29 static const TInt KSize = (KSizeInBlocks * KBlockSize); |
|
30 |
|
31 |
|
32 typedef TUint TLba; |
|
33 typedef TInt64 TPos; |
|
34 |
|
35 |
|
36 class TLocalBuffer |
|
37 { |
|
38 public: |
|
39 void Init(); |
|
40 TPtrC8 Buffer() const {return iBuffer;} |
|
41 void Update(TInt aPos, TUint aLen); |
|
42 |
|
43 public: |
|
44 TBuf8<KSize> iBuffer; |
|
45 }; |
|
46 |
|
47 |
|
48 class TLbaUtils |
|
49 { |
|
50 public: |
|
51 static TPos Pos(TLba aLba); |
|
52 static TUint32 Length(TLba aBlocks); |
|
53 }; |
|
54 |
|
55 |
|
56 class RTargetMedia |
|
57 { |
|
58 public: |
|
59 RTargetMedia(TInt aDriveNumber); |
|
60 void OpenL(); |
|
61 void Close(); |
|
62 |
|
63 TInt MediaRawWrite(TPos aPos, const TDesC8& aData); |
|
64 TInt MediaRawRead(TPos aPos, TUint32 aLen, TDes8& aData); |
|
65 |
|
66 protected: |
|
67 RRawDisk iRawDisk; |
|
68 TInt iDriveNumber; |
|
69 }; |
|
70 |
|
71 |
|
72 |
|
73 class RBlockTargetMedia: public RTargetMedia |
|
74 { |
|
75 public: |
|
76 RBlockTargetMedia(TInt aDriveNumber); |
|
77 void OpenL(); |
|
78 TInt WriteBlock(TLba aLba); |
|
79 TInt ReadBlock(TLba aLba); |
|
80 |
|
81 private: |
|
82 TBuf8<KBlockSize> iBlockData; |
|
83 }; |
|
84 |
|
85 |
|
86 class TTargetTestArea |
|
87 { |
|
88 public: |
|
89 TTargetTestArea(RTargetMedia& aMedia); |
|
90 void CreateControlFile(); |
|
91 void RemoveControlFile(); |
|
92 void FindBlockStartL(); |
|
93 |
|
94 TInt WriteBlockL(TBuf8<KBlockSize>& aBlock); |
|
95 TInt ReadBlockL(TBuf8<KBlockSize>& aBlock); |
|
96 private: |
|
97 RTargetMedia& iTargetMedia; |
|
98 TInt iStartLba; |
|
99 }; |
|
100 |
|
101 |
|
102 |
|
103 class RTargetDrive: public RTargetMedia |
|
104 { |
|
105 public: |
|
106 RTargetDrive(TInt aDriveNumber); |
|
107 TInt OpenTestAreaL(const TDesC8& aData); |
|
108 |
|
109 TInt Verify(); |
|
110 TInt VerifyBlock(TLba aLba, TLba aBlocks); |
|
111 TInt Verify(TInt aPos, TUint aLen); |
|
112 |
|
113 TInt Update(TInt aPos, TUint aLen); |
|
114 |
|
115 private: |
|
116 TPos StartPos() const; |
|
117 TPos TargetPos(TInt aPos) const; |
|
118 |
|
119 private: |
|
120 TLba iStartLba; |
|
121 TPtrC8 iSource; |
|
122 TBuf8<KSize> iTmpBuffer; |
|
123 }; |
|
124 |
|
125 |
|
126 class CBlockDeviceTester: public CBase |
|
127 { |
|
128 public: |
|
129 static CBlockDeviceTester* NewL(TInt aDriveNumber); |
|
130 ~CBlockDeviceTester(); |
|
131 protected: |
|
132 void ConstructL(); |
|
133 CBlockDeviceTester(TInt aDriveNumber); |
|
134 |
|
135 public: |
|
136 void OpenDriveL(); |
|
137 void CloseDrive(); |
|
138 |
|
139 TInt Update(TPos aPos, TUint aLen); |
|
140 TInt UpdateBlock(TLba aLba, TLba aBlocks); |
|
141 |
|
142 TInt VerifyDrive(); |
|
143 TInt Verify(TPos aPos, TUint aLen); |
|
144 TInt VerifyBlock(TLba aLba, TLba aBlocks); |
|
145 |
|
146 protected: |
|
147 // The drive parameters |
|
148 TInt iDriveNumber; |
|
149 TInt iDriveSizeInBlocks; |
|
150 |
|
151 // Local buffer |
|
152 TLocalBuffer iLocalBuffer; |
|
153 // The buffer on remote drive |
|
154 RTargetDrive iTargetDrive; |
|
155 }; |
|
156 |
|
157 |
|
158 |
|
159 class CBotTester: public CBlockDeviceTester |
|
160 { |
|
161 public: |
|
162 enum TTestCase |
|
163 { |
|
164 ETestCaseTagMismatch = 1, |
|
165 ETestCaseInvalidSignature = 2, |
|
166 // No Data |
|
167 ETestCaseNoDataStallCsw = 3, |
|
168 ETestCaseNoDataPhaseError = 4, |
|
169 // Data OUT |
|
170 ETestCaseDoStallCsw = 5, |
|
171 ETestCaseDoStallData = 6, |
|
172 ETestCaseDoPhaseError = 7, |
|
173 ETestCaseDoResidue = 8, |
|
174 // Data IN |
|
175 ETestCaseDiStallCsw = 9, |
|
176 ETestCaseDiStallData = 0xA, |
|
177 ETestCaseDiPhaseError = 0xB, |
|
178 ETestCaseDiResidue = 0xC, |
|
179 // End |
|
180 ETestCaseNotSet |
|
181 }; |
|
182 |
|
183 static const TPos KSetTestPos = 0x1000; |
|
184 static const TPos KWriteEnableFilePos = 0x2000; |
|
185 static const TPos KReadEnableFilePos = 0x3000; |
|
186 static const TPos KSenseErrorFile = 0x4000; |
|
187 |
|
188 public: |
|
189 static CBotTester* NewL(TInt aDriveNumber); |
|
190 virtual ~CBotTester(); |
|
191 private: |
|
192 void ConstructL(); |
|
193 CBotTester(TInt aDriveNumber); |
|
194 |
|
195 public: |
|
196 TInt SetTest(TTestCase aTestCase); |
|
197 TInt WriteEnableFile(); |
|
198 TInt InitReadEnableFile(); |
|
199 TInt ReadEnableFile(); |
|
200 |
|
201 private: |
|
202 /** |
|
203 Place this buffer on block boundary and make buffers multiple of block size |
|
204 to avoid crossing block boundary |
|
205 */ |
|
206 static const TInt KCmdBufferSize = KBlockSize; |
|
207 static const TInt KOutEnableBufferSize = KBlockSize * 4; |
|
208 static const TInt KInEnableBufferSize = KBlockSize * 4; |
|
209 |
|
210 TBuf8<KCmdBufferSize> iCmdBuffer; |
|
211 TBuf8<KOutEnableBufferSize> iOutEnableBuffer; |
|
212 TBuf8<KInEnableBufferSize> iInEnableBuffer; |
|
213 }; |
|
214 |
|
215 |
|
216 class CSbcErrTester: public CBlockDeviceTester |
|
217 { |
|
218 public: |
|
219 enum TTestSenseError |
|
220 { |
|
221 ETestSenseErrorNoSense = 0, |
|
222 ETestSenseErrorMediaNotPresent = 1, |
|
223 ETestSenseErrorUnitAttention = 2 |
|
224 }; |
|
225 |
|
226 |
|
227 static const TPos KSetTestPos = 0x1000; |
|
228 static const TPos KWriteTestFilePos = 0x2000; |
|
229 static const TPos KReadTestFilePos = 0x3000; |
|
230 static const TPos KSenseErrorFile = 0x4000; |
|
231 |
|
232 public: |
|
233 static CSbcErrTester* NewL(TInt aDriveNumber); |
|
234 virtual ~CSbcErrTester(); |
|
235 private: |
|
236 void ConstructL(); |
|
237 CSbcErrTester(TInt aDriveNumber); |
|
238 |
|
239 public: |
|
240 TInt WriteTestFile(); |
|
241 TInt ReadTestFile(); |
|
242 |
|
243 TInt WriteSenseErrorFile(TTestSenseError aTestSenseError); |
|
244 |
|
245 private: |
|
246 /** |
|
247 Place this buffer on block boundary and make buffers multiple of block size |
|
248 to avoid block overlap |
|
249 */ |
|
250 static const TInt KCmdBufferSize = KBlockSize; |
|
251 static const TInt KEnableBufferSize = KBlockSize * 4; |
|
252 static const TInt KSenseErrorBufferSize = KBlockSize * 4; |
|
253 |
|
254 TBuf8<KCmdBufferSize> iCmdBuffer; |
|
255 TBuf8<KEnableBufferSize> iEnableBuffer; |
|
256 TBuf8<KSenseErrorBufferSize> iSenseErrorBuffer; |
|
257 }; |
|
258 |
|
259 |
|
260 |
|
261 class CWrPrTester: public CBase |
|
262 { |
|
263 public: |
|
264 static CWrPrTester* NewL(TInt aDriveNumber); |
|
265 virtual ~CWrPrTester(); |
|
266 private: |
|
267 void ConstructL(); |
|
268 CWrPrTester(TInt aDriveNumber); |
|
269 |
|
270 public: |
|
271 void SetWriteProtectL(); |
|
272 void ClrWriteProtectL(); |
|
273 TInt SetRemovableL(); |
|
274 TInt ClrRemovableL(); |
|
275 TInt WriteReadTestL(); |
|
276 |
|
277 private: |
|
278 enum TTestConfig |
|
279 { |
|
280 // Configure Media Write Protect Bit |
|
281 ETestConfigMediaWpClr = 1, |
|
282 ETestConfigMediaWpSet = 2, |
|
283 // Configure Media Removable flag |
|
284 ETestConfigMediaRmbClr = 3, |
|
285 ETestConfigMediaRmbSet = 4 |
|
286 }; |
|
287 |
|
288 private: |
|
289 static const TPos KCmdPos = 0; |
|
290 static const TInt KCmdBufferSize = KBlockSize; |
|
291 TBuf8<KCmdBufferSize> iCmdBuffer; |
|
292 TBuf8<KCmdBufferSize> iInCmdBuffer; |
|
293 |
|
294 RTargetMedia iTargetMedia; |
|
295 |
|
296 TTargetTestArea iTargetTestArea; |
|
297 }; |
|
298 |
|
299 |
|
300 #include "cblockdevicetester.inl" |
|
301 |
|
302 #ifdef XXX |
|
303 inline TPos TLocalBuffer::TargetStartPos() const |
|
304 { |
|
305 return static_cast<TInt64>(iStartLba) * KBlockSize; |
|
306 } |
|
307 |
|
308 inline TPos TLocalBuffer::TargetPos(TPos aPos) const |
|
309 { |
|
310 return TargetStartPos() + aPos; |
|
311 } |
|
312 #endif |
|
313 |
|
314 #endif // CBLOCKDEVICETESTER_H |