|
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 // e32\include\drivers\flash_media.h |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #ifndef __FLASH_MEDIA_H__ |
|
24 #define __FLASH_MEDIA_H__ |
|
25 #include <drivers/locmedia.h> |
|
26 #include <platform.h> |
|
27 |
|
28 GLREF_C TDfcQue FlashDfcQ; |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 /** |
|
34 @publishedPartner |
|
35 @released |
|
36 |
|
37 Base class for the LFFS media driver. |
|
38 |
|
39 The class provides an implementation for the generic layer of |
|
40 the LFFS media driver. |
|
41 Code that is specifc to a flash device is implemented as a class |
|
42 derived from this. |
|
43 */ |
|
44 class DMediaDriverFlash : public DMediaDriver |
|
45 { |
|
46 public: |
|
47 /** |
|
48 Defines a set of values that are passed to Complete() |
|
49 informing the generic layer about the type of request |
|
50 that is being completed. |
|
51 */ |
|
52 enum TRequest { |
|
53 /** |
|
54 Indicates that a read request is being completed. |
|
55 */ |
|
56 EReqRead=0, |
|
57 |
|
58 /** |
|
59 Indicates that a write request is being completed. |
|
60 */ |
|
61 EReqWrite=1, |
|
62 |
|
63 /** |
|
64 Indicates that an erase request is being completed. |
|
65 */ |
|
66 EReqErase=2}; |
|
67 public: |
|
68 /** |
|
69 Creates an instance of the LFFS media driver. |
|
70 |
|
71 Although declared in this class, this function is not implemented by |
|
72 Symbian OS, but must be implemented by the port. |
|
73 |
|
74 It should return an instance of the class derived from DMediaDriverFlash. |
|
75 The following is an example taken from the Lubbock reference platform: |
|
76 @code |
|
77 DMediaDriverFlash* DMediaDriverFlash::New(TInt aMediaId) |
|
78 { |
|
79 return new DMediaDriverFlashLA(aMediaId); |
|
80 } |
|
81 @endcode |
|
82 |
|
83 @param aMediaId The unique media ID specifed when the media driver was registered. |
|
84 This value is just propagated through. |
|
85 |
|
86 @return An instance of a class derived from DMediaDriverFlash |
|
87 */ |
|
88 static DMediaDriverFlash* New(TInt aMediaId); |
|
89 |
|
90 DMediaDriverFlash(TInt aMediaId); |
|
91 public: |
|
92 // replacing pure virtual |
|
93 |
|
94 virtual TInt Request(TLocDrvRequest& aRequest); |
|
95 |
|
96 virtual TInt PartitionInfo(TPartitionInfo& anInfo); |
|
97 |
|
98 virtual void NotifyPowerDown(); |
|
99 |
|
100 virtual void NotifyEmergencyPowerDown(); |
|
101 |
|
102 public: |
|
103 // pure virtual - FLASH device specific stuff |
|
104 |
|
105 /** |
|
106 Called by the generic layer of the LFFS media driver, and implemented by |
|
107 the specific layer to perform any initialisation required by |
|
108 the specific layer. |
|
109 |
|
110 @return KErrNone, if successful; otherwise one of the other system |
|
111 wide error codes. |
|
112 */ |
|
113 virtual TInt Initialise()=0; |
|
114 |
|
115 |
|
116 |
|
117 /** |
|
118 Called by the generic layer of the LFFS media driver, and implemented by |
|
119 the specific layer to get the size of the flash erase block. |
|
120 |
|
121 @return The size of the flash erase block, in bytes. |
|
122 */ |
|
123 virtual TUint32 EraseBlockSize()=0; |
|
124 |
|
125 |
|
126 |
|
127 /** |
|
128 Called by the generic layer of the LFFS media driver, and implemented by |
|
129 the specific layer to get the total size of the flash. |
|
130 |
|
131 @return The total size of the flash, in bytes. |
|
132 */ |
|
133 virtual TUint32 TotalSize()=0; |
|
134 |
|
135 |
|
136 |
|
137 /** |
|
138 Called by the generic layer of the LFFS media driver, and implemented by |
|
139 the specific layer to start a read request. |
|
140 |
|
141 The information for the request is in iReadReq. |
|
142 |
|
143 If the read operation cannot be started immediately, then this function |
|
144 should return KMediaDriverDeferRequest; this asks the generic layer |
|
145 to defer the request and re-start it later. A read request might be |
|
146 deferred, for example, if there is a write or an erase operation |
|
147 already in progress. |
|
148 |
|
149 Note that this an asynchronous request, i.e. it starts the operation; |
|
150 the driver must call: |
|
151 @code |
|
152 Complete(EReqRead, result); |
|
153 @endcode |
|
154 when the operation is complete, where result is KErrNone if sucessful, or |
|
155 one of the system-wide error codes, otherwise. |
|
156 |
|
157 @return KErrNone, if the request has been sucessfully initiated; |
|
158 KErrNotSupported, if the request cannot be handled by the device; |
|
159 KMediaDriverDeferRequest, if the request cannot be handled |
|
160 immediately because of an outstanding request |
|
161 |
|
162 @see iReadReq |
|
163 @see DMediaDriverFlash::Complete() |
|
164 */ |
|
165 virtual TInt DoRead()=0; |
|
166 |
|
167 |
|
168 |
|
169 /** |
|
170 Called by the generic layer of the LFFS media driver, and implemented by |
|
171 the specific layer to start a write request. |
|
172 |
|
173 The information for the request is in iWriteReq. |
|
174 |
|
175 If the write operation cannot be started immediately, then this function |
|
176 should return KMediaDriverDeferRequest; this asks the generic layer |
|
177 to defer the request and re-start it later. A write request might be |
|
178 deferred, for example, if there is a read or an erase operation |
|
179 already in progress. |
|
180 |
|
181 Note that this an asynchronous request, i.e. it starts the operation; |
|
182 the driver must call: |
|
183 @code |
|
184 Complete(EReqWrite, result); |
|
185 @endcode |
|
186 when the operation is complete, where result is KErrNone if sucessful, or |
|
187 one of the system-wide error codes, otherwise. |
|
188 |
|
189 @return KErrNone, if the request has been sucessfully initiated; |
|
190 KErrNotSupported, if the request cannot be handled by the device; |
|
191 KMediaDriverDeferRequest, if the request cannot be handled |
|
192 immediately because of an outstanding request |
|
193 |
|
194 @see iWriteReq |
|
195 @see DMediaDriverFlash::Complete() |
|
196 */ |
|
197 virtual TInt DoWrite()=0; |
|
198 |
|
199 |
|
200 |
|
201 /** |
|
202 Called by the generic layer of the LFFS media driver, and implemented by |
|
203 the specific layer to start a block erase request. |
|
204 |
|
205 The information for the request is in iEraseReq. |
|
206 |
|
207 If the erase operation cannot be started immediately, then this function |
|
208 should return KMediaDriverDeferRequest; this asks the generic layer |
|
209 to defer the request and re-start it later. An erase request might be |
|
210 deferred, for example, if there is a read or a write operation |
|
211 already in progress. |
|
212 |
|
213 Note that this an asynchronous request, i.e. it starts the operation; |
|
214 the driver must call: |
|
215 @code |
|
216 Complete(EReqErase, result); |
|
217 @endcode |
|
218 when the operation is complete, where result is KErrNone if sucessful, or |
|
219 one of the system-wide error codes, otherwise. |
|
220 |
|
221 @return KErrNone, if the request has been sucessfully initiated; |
|
222 KErrNotSupported, if the request cannot be handled by the device; |
|
223 KMediaDriverDeferRequest, if the request cannot be handled |
|
224 immediately because of an outstanding request |
|
225 |
|
226 @see iEraseReq |
|
227 @see DMediaDriverFlash::Complete() |
|
228 */ |
|
229 virtual TInt DoErase()=0; |
|
230 public: |
|
231 TInt DoCreate(TInt aMediaId); |
|
232 |
|
233 virtual TInt Caps(TLocalDriveCapsV2& aCaps); |
|
234 |
|
235 void Complete(TInt aRequest, TInt aResult); |
|
236 public: |
|
237 |
|
238 |
|
239 /** |
|
240 Location for request information. |
|
241 |
|
242 An array of three entries to contain request information for read, |
|
243 write and erase requests respectively. |
|
244 |
|
245 NB Do not access this array directly; instead use the macro definitions: |
|
246 iReadReq, iWriteReq and iEraseReq. These ensure that you access the correct |
|
247 TLocDrvRequest items within the array. |
|
248 |
|
249 @see iReadReq |
|
250 @see iWriteReq |
|
251 @see iEraseReq |
|
252 @see TLocDrvRequest |
|
253 */ |
|
254 TLocDrvRequest* iRequests[3]; |
|
255 }; |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 /** |
|
261 Read request information for LFFS media drivers. |
|
262 |
|
263 @see TLocDrvRequest |
|
264 @see DMediaDriverFlash |
|
265 @see DMediaDriverFlash::iRequests |
|
266 */ |
|
267 #define iReadReq iRequests[EReqRead] |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 /** |
|
273 Write request information for LFFS media drivers. |
|
274 |
|
275 @see TLocDrvRequest |
|
276 @see DMediaDriverFlash |
|
277 @see DMediaDriverFlash::iRequests |
|
278 */ |
|
279 #define iWriteReq iRequests[EReqWrite] |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 /** |
|
285 Erase request information for LFFS media drivers. |
|
286 |
|
287 @see TLocDrvRequest |
|
288 @see DMediaDriverFlash |
|
289 @see DMediaDriverFlash::iRequests |
|
290 */ |
|
291 #define iEraseReq iRequests[EReqErase] |
|
292 |
|
293 |
|
294 |
|
295 #endif |