author | hgs |
Mon, 26 Jul 2010 10:52:56 +0100 | |
changeset 231 | 75252ea6123b |
parent 176 | af6ec97d9189 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1998-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\locmedia.h |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#ifndef LOCMEDIA_H |
|
19 |
#define LOCMEDIA_H |
|
20 |
#include <plat_priv.h> |
|
21 |
#include <d32locd.h> |
|
22 |
||
23 |
#if defined(_DEBUG) && defined(__DEMAND_PAGING__) |
|
24 |
#define __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
25 |
#endif |
|
121 | 26 |
#ifdef __DEMAND_PAGING__ |
0 | 27 |
#define __DEMAND_PAGING_BENCHMARKS__ |
28 |
#endif |
|
29 |
||
30 |
#ifdef __WINS__ |
|
31 |
#define __EMULATOR_DMA_SUMULATION__ |
|
32 |
#endif |
|
33 |
||
34 |
/** |
|
35 |
@publishedPartner |
|
36 |
@released |
|
37 |
||
38 |
A media driver priority value. |
|
39 |
||
40 |
The value can be returned by a media driver's PDD factory Info() function, |
|
41 |
and allows Symbian OS to decide the order in which media drivers are to be opened. |
|
42 |
||
43 |
The value is relative to the other media driver priority values. |
|
44 |
||
45 |
@see DPhysicalDevice::Info() |
|
46 |
*/ |
|
47 |
const TInt KMediaDriverPriorityHigh=2; |
|
48 |
||
49 |
||
50 |
||
51 |
||
52 |
/** |
|
53 |
@publishedPartner |
|
54 |
@released |
|
55 |
||
56 |
A media driver priority value. |
|
57 |
||
58 |
The value can be returned by a media driver's PDD factory Info() function, |
|
59 |
and allows Symbian OS to decide the order in which media drivers are to be opened. |
|
60 |
||
61 |
The value is relative to the other media driver priority values, and is |
|
62 |
the one most commonly used. |
|
63 |
||
64 |
@see DPhysicalDevice::Info() |
|
65 |
*/ |
|
66 |
const TInt KMediaDriverPriorityNormal=1; |
|
67 |
||
68 |
||
69 |
||
70 |
||
71 |
/** |
|
72 |
@publishedPartner |
|
73 |
@released |
|
74 |
||
75 |
A media driver priority value. |
|
76 |
||
77 |
The value can be returned by a media driver's PDD factory Info() function, |
|
78 |
and allows Symbian OS to decide the order in which media drivers are to be opened. |
|
79 |
||
80 |
The value is relative to the other media driver priority values. |
|
81 |
||
82 |
@see DPhysicalDevice::Info() |
|
83 |
*/ |
|
84 |
const TInt KMediaDriverPriorityLow=0; |
|
85 |
||
86 |
||
87 |
||
88 |
||
89 |
/** |
|
90 |
@publishedPartner |
|
91 |
@released |
|
92 |
||
93 |
Media driver interface major version number. |
|
94 |
*/ |
|
95 |
const TInt KMediaDriverInterfaceMajorVersion=1; |
|
96 |
||
97 |
||
98 |
||
99 |
||
100 |
/** |
|
101 |
@publishedPartner |
|
102 |
@released |
|
103 |
||
104 |
Media driver interface minor version number. |
|
105 |
*/ |
|
106 |
const TInt KMediaDriverInterfaceMinorVersion=0; |
|
107 |
||
108 |
||
109 |
||
110 |
||
111 |
||
112 |
/** |
|
113 |
@publishedPartner |
|
114 |
@released |
|
115 |
||
116 |
Media driver interface build number. |
|
117 |
*/ |
|
118 |
const TInt KMediaDriverInterfaceBuildVersion=160; |
|
119 |
||
120 |
||
121 |
||
122 |
||
123 |
/** |
|
124 |
@publishedPartner |
|
125 |
@released |
|
126 |
*/ |
|
127 |
const TInt KMediaDriverDeferRequest=1; |
|
128 |
||
129 |
||
130 |
||
131 |
||
132 |
/** |
|
133 |
@internalTechnology |
|
134 |
*/ |
|
135 |
#define __TRACE_TIMING(x) |
|
136 |
//#define __TRACE_TIMING(x) *(TInt*)0x63000ff0=x |
|
137 |
||
138 |
/** |
|
139 |
@internalComponent |
|
140 |
*/ |
|
141 |
NONSHARABLE_CLASS(DLocalDriveFactory) : public DLogicalDevice |
|
142 |
{ |
|
143 |
public: |
|
144 |
DLocalDriveFactory(); |
|
145 |
virtual TInt Install(); |
|
146 |
virtual void GetCaps(TDes8 &aDes) const; |
|
147 |
virtual TInt Create(DLogicalChannelBase*& aChannel); |
|
148 |
}; |
|
149 |
||
150 |
class TLocDrv; |
|
151 |
class DLocalDrive; |
|
152 |
||
153 |
/** |
|
154 |
@internalComponent |
|
155 |
*/ |
|
156 |
NONSHARABLE_CLASS(TLocalDriveCleanup) : public TThreadCleanup |
|
157 |
{ |
|
158 |
public: |
|
159 |
TLocalDriveCleanup(); |
|
160 |
virtual void Cleanup(); |
|
161 |
inline DLocalDrive& LocalDrive(); |
|
162 |
}; |
|
163 |
||
164 |
||
165 |
||
166 |
class TLocDrvRequest; |
|
167 |
class DPrimaryMediaBase; |
|
168 |
||
123 | 169 |
/* |
170 |
TCallBackLink |
|
171 |
||
172 |
@internalComponent |
|
173 |
||
174 |
Internal class which allows a list of callbacks to be linked together. |
|
175 |
*/ |
|
176 |
||
177 |
NONSHARABLE_CLASS(TCallBackLink) |
|
178 |
{ |
|
179 |
public: |
|
180 |
enum TObjectType |
|
181 |
{ |
|
182 |
EDLocalDriveObject, // object containing this TCallBackLink is a DLocalDrive |
|
183 |
ETLocDrvObject, // object containing this TCallBackLink is a TLocDrv |
|
184 |
}; |
|
185 |
||
186 |
public: |
|
187 |
TCallBackLink(); |
|
188 |
TCallBackLink(TInt (*aFunction)(TAny* aPtr, TInt aParam),TAny* aPtr, TObjectType aObjectType); |
|
189 |
TInt CallBack(TInt aParam) const; |
|
190 |
public: |
|
191 |
/** |
|
192 |
A pointer to the callback function. |
|
193 |
*/ |
|
194 |
TInt (*iFunction)(TAny* aPtr, TInt aParam); |
|
195 |
||
196 |
||
197 |
/** |
|
198 |
A pointer that is passed to the callback function when |
|
199 |
the function is called. |
|
200 |
*/ |
|
201 |
TAny* iPtr; |
|
202 |
||
203 |
TObjectType iObjectType; |
|
204 |
||
205 |
SDblQueLink iLink; |
|
206 |
}; |
|
207 |
||
208 |
||
0 | 209 |
/** |
210 |
@publishedPartner |
|
211 |
@released |
|
212 |
||
213 |
This class is strictly internal to Symbian; the only part of this class that |
|
214 |
is publicly exposed to partners is the TRequestId enum. |
|
215 |
||
216 |
@see DLocalDrive::TRequestId |
|
217 |
*/ |
|
218 |
NONSHARABLE_CLASS(DLocalDrive) : public DLogicalChannelBase |
|
219 |
{ |
|
220 |
public: |
|
221 |
/** |
|
222 |
Identifies the specific local drive operation. |
|
223 |
*/ |
|
224 |
enum TRequestId |
|
225 |
{ |
|
226 |
/** |
|
227 |
Requests information about the size, type, and attributes of the media. |
|
228 |
*/ |
|
229 |
ECaps=0, |
|
230 |
||
231 |
/** |
|
232 |
Requests an asynchronous read from the media device. |
|
233 |
*/ |
|
234 |
ERead=1, |
|
235 |
||
236 |
/** |
|
237 |
Requests an asynchronous write to the media device. |
|
238 |
*/ |
|
239 |
EWrite=2, |
|
240 |
||
241 |
/** |
|
242 |
Requests the formatting of a section of the media |
|
243 |
*/ |
|
244 |
EFormat=3, |
|
245 |
||
246 |
/** |
|
247 |
A request to expand the total size of the media. |
|
248 |
*/ |
|
249 |
EEnlarge=4, |
|
250 |
||
251 |
/** |
|
252 |
A request to reduce the total size of the media. |
|
253 |
*/ |
|
254 |
EReduce=5, |
|
255 |
||
256 |
/** |
|
257 |
A request to force a remount of the media. |
|
258 |
*/ |
|
259 |
EForceMediaChange=6, |
|
260 |
||
261 |
/** |
|
262 |
Requests an attempt to lock the media with a password. |
|
263 |
*/ |
|
264 |
EPasswordLock=7, |
|
265 |
||
266 |
/** |
|
267 |
Requests an attempt to unlock the media. |
|
268 |
*/ |
|
269 |
EPasswordUnlock=8, |
|
270 |
||
271 |
/** |
|
272 |
Requests an attempt to remove the password from the media. |
|
273 |
*/ |
|
274 |
EPasswordClear=9, |
|
275 |
||
276 |
/** |
|
277 |
Requests an read of the password store. |
|
278 |
*/ |
|
279 |
EReadPasswordStore=10, |
|
280 |
||
281 |
/** |
|
282 |
Requests a write of the password store. |
|
283 |
*/ |
|
284 |
EWritePasswordStore=11, |
|
285 |
||
286 |
/** |
|
287 |
A request to get the length of the password store. |
|
288 |
*/ |
|
289 |
EPasswordStoreLengthInBytes=12, |
|
290 |
/** |
|
291 |
A Control IO request |
|
292 |
*/ |
|
293 |
EControlIO=13, |
|
294 |
/** |
|
295 |
A request to force an erase of the password from the media |
|
296 |
*/ |
|
297 |
EPasswordErase=14, |
|
298 |
||
299 |
/** |
|
300 |
A delete notification from the file system |
|
301 |
*/ |
|
302 |
EDeleteNotify=15, |
|
303 |
||
304 |
/** |
|
305 |
A request for information on the last error |
|
306 |
*/ |
|
307 |
EGetLastErrorInfo=16, |
|
308 |
||
309 |
EFirstReqNumberReservedForPaging=17, |
|
310 |
// DO NOT REUSE ANY OF THE REQUEST NUMBERS BETWEEN THIS AND THE LAST RESERVED REQ NUMBER |
|
311 |
// ALSO DO NOT INSERT ANY REQUEST NUMBERS BEFORE THIS, AS THIS WILL BE A COMPATIBILITY BREEAK |
|
312 |
ELastReqNumberReservedForPaging=31, |
|
313 |
||
314 |
/** |
|
315 |
Query device |
|
316 |
*/ |
|
317 |
EQueryDevice=32, |
|
318 |
}; |
|
319 |
public: |
|
320 |
DLocalDrive(); |
|
321 |
~DLocalDrive(); |
|
123 | 322 |
|
0 | 323 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); /**< @internalComponent */ |
324 |
virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); /**< @internalComponent */ |
|
123 | 325 |
|
326 |
void NotifyChange(); |
|
327 |
||
0 | 328 |
inline void Deque(); /**< @internalComponent */ |
329 |
||
123 | 330 |
static TInt MediaChangeCallback(TAny* aLocalDrive, TInt aNotifyType); /**< @internalComponent */ |
331 |
||
332 |
IMPORT_C static TInt Caps(TInt aDriveNumber, TDes8& aCaps); |
|
333 |
||
0 | 334 |
private: |
335 |
#ifdef __DEMAND_PAGING__ |
|
336 |
TInt LockMountInfo(DPrimaryMediaBase& aPrimaryMedia, TLocDrvRequest& aReq); |
|
337 |
void UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia); |
|
338 |
#endif |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
339 |
TInt ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd); |
0 | 340 |
|
341 |
public: |
|
123 | 342 |
TLocDrv* iDrive; /**< @internalComponent */ |
343 |
TCallBackLink iMediaChangeObserver; /**< @internalComponent */ |
|
0 | 344 |
TClientDataRequest<TBool>* iNotifyChangeRequest; /**< @internalComponent */ |
123 | 345 |
TLocalDriveCleanup iCleanup; /**< @internalComponent */ |
0 | 346 |
}; |
347 |
||
348 |
/** |
|
349 |
@internalComponent |
|
350 |
*/ |
|
351 |
inline DLocalDrive& TLocalDriveCleanup::LocalDrive() |
|
352 |
{ return *_LOFF(this,DLocalDrive,iCleanup); } |
|
353 |
||
354 |
||
355 |
||
356 |
||
357 |
/** |
|
358 |
@publishedPartner |
|
359 |
@released |
|
360 |
||
361 |
A class that encapsulates the request information received from the client, |
|
362 |
and gives the media driver access to the request ID and other associated |
|
363 |
parameters, such as the request length, offset, the requesting thread, |
|
364 |
source and destination address etc. |
|
365 |
||
366 |
An object of this type is passed to DMediaDriver::Request(). |
|
367 |
||
368 |
@see DMediaDriver::Request() |
|
369 |
*/ |
|
370 |
class TLocDrvRequest : public TThreadMessage |
|
371 |
{ |
|
372 |
public: |
|
373 |
||
374 |
/** |
|
375 |
@internalComponent |
|
376 |
*/ |
|
377 |
enum TFlags |
|
378 |
{ |
|
379 |
EWholeMedia=1, |
|
380 |
EAdjusted=2, |
|
381 |
EPhysAddr=0x04, |
|
382 |
EPaging=0x08, // a paging request |
|
383 |
EBackgroundPaging=0x10, // a background paging request. @see DMediaPagingDevice::Write() |
|
384 |
ECodePaging=0x20, // a code paging request |
|
385 |
EDataPaging=0x40, // a data paging request |
|
386 |
ETClientBuffer=0x80, // RemoteDes() points to a TClientBuffer |
|
123 | 387 |
EKernelBuffer=0x100, // RemoteDes() points to a kernel-side buffer : set for all paging requests and media extension requests |
176 | 388 |
EPhysAddrOnly=0x200, // No virtual address is available. Data Paging requests Only. |
0 | 389 |
}; |
390 |
public: |
|
391 |
||
392 |
/** |
|
393 |
Gets a reference to the object containing the request information. |
|
394 |
||
395 |
@return The request information. |
|
396 |
*/ |
|
397 |
inline static TLocDrvRequest& Get() |
|
398 |
{return (TLocDrvRequest&)Kern::Message();} |
|
399 |
||
400 |
||
401 |
/** |
|
402 |
Gets the request ID. |
|
403 |
||
404 |
For media drivers, this is one of the DLocalDrive::TRequestId enumerated values. |
|
405 |
||
406 |
@return The request ID. |
|
407 |
||
408 |
@see DLocalDrive::TRequestId |
|
409 |
*/ |
|
410 |
inline TInt& Id() |
|
411 |
{return *(TInt*)&iValue;} |
|
412 |
||
413 |
||
414 |
/** |
|
415 |
Gets the position on the media on which the request operates. |
|
416 |
||
417 |
This applies to operations ERead, EWrite and EFormat. |
|
418 |
||
419 |
Note that the partition offset is taken into account by the underlying |
|
420 |
local media subsystem. |
|
421 |
||
422 |
@return The position on the media. |
|
423 |
||
424 |
@see TRequestId::ERead |
|
425 |
@see TRequestId::EWrite |
|
426 |
@see TRequestId::EFormat |
|
427 |
*/ |
|
428 |
inline Int64& Pos() |
|
429 |
{return *(Int64*)&iArg[0];} |
|
430 |
||
431 |
||
432 |
/** |
|
433 |
Gets the length associated with the operation. |
|
434 |
||
435 |
This is the number of bytes associated with the media request. |
|
436 |
It applies to operations ERead, EWrite and EFormat. |
|
437 |
||
438 |
@return The length, in bytes. |
|
439 |
||
440 |
@see TRequestId::ERead |
|
441 |
@see TRequestId::EWrite |
|
442 |
@see TRequestId::EFormat |
|
443 |
*/ |
|
444 |
inline Int64& Length() |
|
445 |
{return *(Int64*)&iArg[2];} |
|
446 |
||
447 |
||
448 |
/** |
|
449 |
Gets a pointer to the remote thread that requested the operation. |
|
450 |
||
451 |
This may be used to access the data to be read from the remote thread's process, |
|
452 |
or the area to which data is to be written in the remote thread's process. |
|
453 |
However, it is recommended that such operations be performed |
|
454 |
using ReadRemote() and WriteRemote() |
|
455 |
||
456 |
@return A reference to a pointer to the remote thread. |
|
457 |
||
458 |
@see TLocDrvRequest::ReadRemote() |
|
459 |
@see TLocDrvRequest::WriteRemote() |
|
460 |
*/ |
|
461 |
inline DThread*& RemoteThread() |
|
462 |
{return *(DThread**)&iArg[4];} |
|
463 |
||
464 |
||
465 |
/** |
|
466 |
Gets a pointer to the descriptor in the remote thread's process that |
|
467 |
contains the data to be read, or is the target for data to be written. |
|
468 |
||
469 |
However, it is recommended that such read or write operations be performed |
|
470 |
using ReadRemote() and WriteRemote(). |
|
471 |
||
472 |
@return A reference to a pointer to the remote descriptor. |
|
473 |
||
474 |
@see TLocDrvRequest::ReadRemote() |
|
475 |
@see TLocDrvRequest::WriteRemote() |
|
476 |
*/ |
|
477 |
inline TAny*& RemoteDes() |
|
478 |
{return *(TAny**)&iArg[5];} |
|
479 |
||
480 |
||
481 |
/** |
|
482 |
Gets the offset within the descriptor in the remote thread's process. |
|
483 |
||
484 |
@return The offset within the descriptor. |
|
485 |
*/ |
|
486 |
inline TInt& RemoteDesOffset() |
|
487 |
{return *(TInt*)&iArg[6];} |
|
488 |
||
489 |
||
490 |
/** |
|
491 |
@internalComponent |
|
492 |
*/ |
|
493 |
inline TInt& Flags() |
|
494 |
{return *(TInt*)&iArg[7];} |
|
495 |
||
496 |
||
497 |
/** |
|
498 |
@internalComponent |
|
499 |
*/ |
|
500 |
inline TLocDrv*& Drive() |
|
501 |
{return *(TLocDrv**)&iArg[8];} |
|
502 |
||
503 |
||
504 |
/** |
|
505 |
@internalComponent |
|
506 |
*/ |
|
507 |
inline TInt& DriverFlags() |
|
508 |
{return *(TInt*)&iArg[9];} |
|
509 |
||
510 |
||
511 |
/** |
|
512 |
Returns true if Physical memory addresses are available for this TLocDrvRequest. |
|
513 |
@return ETrue if a physical memory address is available. |
|
514 |
*/ |
|
515 |
inline TBool IsPhysicalAddress() |
|
516 |
{return Flags() & EPhysAddr;} |
|
517 |
public: |
|
518 |
TInt ProcessMessageData(TAny* args); |
|
519 |
void CloseRemoteThread(); |
|
520 |
IMPORT_C TInt ReadRemote(TDes8* aDes, TInt anOffset); |
|
521 |
IMPORT_C TInt ReadRemote(const TAny* aSrc, TDes8* aDes); |
|
522 |
IMPORT_C TInt ReadRemoteRaw(TAny* aDes, TInt aSize); |
|
523 |
IMPORT_C TInt WriteRemote(const TDesC8* aDes, TInt anOffset); |
|
524 |
IMPORT_C TInt WriteRemoteRaw(const TAny* aSrc, TInt aSize); |
|
525 |
IMPORT_C TInt CheckAndAdjustForPartition(); |
|
526 |
#if !defined(__WINS__) |
|
527 |
IMPORT_C TInt WriteToPageHandler(const TAny* aSrc, TInt aSize, TInt anOffset); |
|
528 |
IMPORT_C TInt ReadFromPageHandler(TAny* aDst, TInt aSize, TInt anOffset); |
|
529 |
#endif // __WINS__ |
|
530 |
IMPORT_C TInt GetNextPhysicalAddress(TPhysAddr& aPhysAddr, TInt& aLength); |
|
531 |
}; |
|
532 |
||
533 |
||
534 |
||
535 |
||
536 |
/** |
|
537 |
@internalComponent |
|
538 |
*/ |
|
539 |
inline void DLocalDrive::Deque() |
|
123 | 540 |
{ iMediaChangeObserver.iLink.Deque(); } |
0 | 541 |
|
542 |
||
543 |
||
544 |
||
545 |
/** |
|
546 |
@publishedPartner |
|
547 |
@released |
|
548 |
||
549 |
Defines a structure used to contain information that describes an individual |
|
550 |
partition. |
|
551 |
||
552 |
There is one of these for each partition that exists on a media device. |
|
553 |
||
554 |
@see TPartitionInfo |
|
555 |
*/ |
|
556 |
class TPartitionEntry |
|
557 |
{ |
|
558 |
public: |
|
559 |
||
560 |
/** |
|
561 |
The start address of the partition, described as a relative offset, |
|
562 |
in bytes, from the start of the media. |
|
563 |
||
564 |
This value is used by the local media subsystem to calculate |
|
565 |
the absolute address on the media whenever an access such as a Read, |
|
566 |
Write or Format request is made. |
|
567 |
*/ |
|
568 |
Int64 iPartitionBaseAddr; |
|
569 |
||
570 |
||
571 |
/** |
|
572 |
The length of the partition, in bytes. |
|
573 |
*/ |
|
574 |
Int64 iPartitionLen; |
|
575 |
||
576 |
||
577 |
/** |
|
578 |
The Boot Indicator record, as described in the Master Boot Record on |
|
579 |
FAT Partitioned devices. |
|
580 |
||
581 |
This is currently unused by the local media subsystem. |
|
582 |
*/ |
|
583 |
TUint16 iBootIndicator; |
|
584 |
||
585 |
||
586 |
/** |
|
587 |
Describes the type of partition. |
|
588 |
||
589 |
The File Server uses this to decide the type of filesystem to be mounted |
|
590 |
on the partition. |
|
591 |
||
592 |
Symbian OS supports many partition types, as defined in partitions.h. |
|
593 |
You are, however, free to invent your own partition type, on which |
|
594 |
you could, for example, mount your own filesystem. However, make sure |
|
595 |
that your partition type does not clash with an existing partition type. |
|
596 |
||
597 |
Note that a media driver does not does not have to verify that |
|
598 |
the partition actually contains a file system of this type; it just sets |
|
599 |
this value to indicate the intended use for this partition. |
|
600 |
*/ |
|
601 |
TUint16 iPartitionType; |
|
602 |
}; |
|
603 |
||
604 |
||
605 |
||
606 |
||
607 |
/** |
|
608 |
@publishedPartner |
|
609 |
@released |
|
610 |
||
611 |
A constant that defines the maximum number of partitions that can exist on |
|
612 |
a media device. |
|
613 |
||
614 |
@see TPartitionInfo::iPartitionCount |
|
615 |
*/ |
|
616 |
const TInt KMaxPartitionEntries=0x10; |
|
617 |
||
618 |
||
619 |
||
620 |
||
621 |
/** |
|
622 |
@publishedPartner |
|
623 |
@released |
|
624 |
||
625 |
Contains partition information for a media device. |
|
626 |
||
627 |
An object of this type is passed to the media driver's implementation of |
|
628 |
DMediaDriver::PartitionInfo() to be filled in. |
|
629 |
||
630 |
@see DMediaDriver::PartitionInfo() |
|
631 |
*/ |
|
632 |
class TPartitionInfo |
|
633 |
{ |
|
634 |
public: |
|
635 |
||
636 |
/** |
|
637 |
Default constructor that clears this object's memory to binary zeroes. |
|
638 |
*/ |
|
639 |
TPartitionInfo(); |
|
640 |
public: |
|
641 |
||
642 |
/** |
|
643 |
The total size of the media, in bytes. |
|
644 |
*/ |
|
645 |
Int64 iMediaSizeInBytes; |
|
646 |
||
647 |
||
648 |
/** |
|
649 |
The total number of partitions that exist on the media. |
|
650 |
||
651 |
This is always less than or equal to KMaxPartitionEntries. |
|
652 |
||
653 |
@see KMaxPartitionEntries |
|
654 |
*/ |
|
655 |
TInt iPartitionCount; |
|
656 |
||
657 |
||
658 |
/** |
|
659 |
Information that describes each individual partition on the device. |
|
660 |
||
661 |
Each partition is represented by an array of TPartitionEntry objects. |
|
662 |
Each entry must be created in the order of the start offset, so that |
|
663 |
iEntry[0] specifies the partition with |
|
664 |
the smallest iPartitionBaseAddr value. |
|
665 |
||
666 |
@see TPartitionEntry::iPartitionBaseAddr |
|
667 |
@see TPartitionEntry |
|
668 |
*/ |
|
669 |
TPartitionEntry iEntry[KMaxPartitionEntries]; |
|
670 |
}; |
|
671 |
||
672 |
||
673 |
||
674 |
||
675 |
class DMedia; |
|
676 |
class DPrimaryMediaBase; |
|
677 |
class DMediaDriver; |
|
678 |
#ifdef __DEMAND_PAGING__ |
|
679 |
class DFragmentationPagingLock; |
|
680 |
#endif |
|
681 |
class DDmaHelper; |
|
682 |
||
683 |
/** |
|
684 |
@internalComponent |
|
685 |
*/ |
|
686 |
class TLocDrv : public TPartitionEntry |
|
687 |
{ |
|
688 |
public: |
|
689 |
TLocDrv(TInt aDriveNumber); |
|
690 |
public: |
|
691 |
inline TInt Connect(DLocalDrive* aLocalDrive); |
|
692 |
inline void Disconnect(DLocalDrive* aLocalDrive); |
|
693 |
inline TInt Request(TLocDrvRequest& aRequest); |
|
123 | 694 |
static TInt MediaChangeCallback(TAny* aLocDrv, TInt aNotifyType); |
0 | 695 |
public: |
696 |
TInt iDriveNumber; |
|
697 |
DMedia* iMedia; |
|
698 |
DPrimaryMediaBase* iPrimaryMedia; |
|
699 |
TInt iPartitionNumber; |
|
700 |
TErrorInfo iLastErrorInfo; |
|
701 |
#ifdef __DEMAND_PAGING__ |
|
702 |
TInt iSpare0; |
|
703 |
TUint8 iPagingDrv; |
|
704 |
TUint8 iSpare1; |
|
705 |
TUint8 iSpare2; |
|
706 |
TUint8 iSpare3; |
|
707 |
#endif |
|
708 |
DDmaHelper* iDmaHelper; |
|
123 | 709 |
|
710 |
// Media extension stuff: |
|
711 |
||
712 |
/** ptr to the next TLocDrv object in the chain. Null if not a media extension */ |
|
713 |
TLocDrv* iNextDrive; |
|
714 |
||
715 |
/** media change callback - called when the next media in the chain has a media change */ |
|
716 |
TCallBackLink iMediaChangeObserver; |
|
0 | 717 |
}; |
718 |
||
719 |
/** |
|
720 |
@publishedPartner |
|
721 |
@released |
|
722 |
||
723 |
Kernel-side representation of a media entity. A DMedia object instantiates a |
|
724 |
media driver to provide access to the physical media. |
|
725 |
||
726 |
Multiple DMedia objects may be required by some devices, e.g. multi-media cards |
|
727 |
with combined SRAM and Flash or cards containing user and protected areas. |
|
728 |
*/ |
|
729 |
class DMedia : public DBase |
|
730 |
{ |
|
731 |
public: |
|
732 |
/** |
|
733 |
Declaration of all legal states for the media driver. |
|
734 |
*/ |
|
735 |
enum TMediaState |
|
736 |
{ |
|
737 |
/** |
|
738 |
Media is powered down and the media drivers are closed. This is the |
|
739 |
initial state when a media driver is created and the final state when |
|
740 |
the driver is closed. |
|
741 |
*/ |
|
742 |
EClosed=0, |
|
743 |
||
744 |
/** Media driver has started powerup sequence. */ |
|
745 |
EPoweringUp1=1, |
|
746 |
||
747 |
/** Media is being opened. */ |
|
748 |
EOpening=2, |
|
749 |
||
750 |
/** Media is open and the partition information is being read. */ |
|
751 |
EReadPartitionInfo=3, |
|
752 |
||
753 |
/** The media driver is open and ready to accept commands. */ |
|
754 |
EReady=4, |
|
755 |
||
756 |
/** Not used. */ |
|
757 |
EAborted=5, |
|
758 |
||
759 |
/** Powering up with media drivers open. */ |
|
760 |
EPoweringUp2=6, |
|
761 |
||
762 |
/** Not used. */ |
|
763 |
ERecovering=7, |
|
764 |
||
765 |
/** The media is powered down, but the media driver still exists. */ |
|
766 |
EPoweredDown=8 // powered down with media drivers open |
|
767 |
}; |
|
768 |
||
769 |
public: |
|
770 |
IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt); |
|
771 |
void Close(); |
|
772 |
public: |
|
773 |
inline Int64 MediaLenInBytes(); |
|
774 |
inline TMediaDevice DeviceType(); |
|
775 |
inline TInt PartitionCount(); |
|
776 |
inline Int64 PartitionBaseAddr(TInt aPartition); |
|
777 |
inline Int64 PartitionLen(TInt aPartition); |
|
778 |
public: |
|
779 |
/** Not used. */ |
|
780 |
static TInt MediaCallBack(TAny *aPtr); |
|
781 |
public: |
|
782 |
/** |
|
783 |
The unique ID associated with this media entity. |
|
784 |
ID allocated when the media is first created. |
|
785 |
||
786 |
@see LocDrv::RegisterMediaDevice |
|
787 |
*/ |
|
788 |
TInt iMediaId; |
|
789 |
||
790 |
/** |
|
791 |
The unique ID for the device. |
|
792 |
||
793 |
@see TMediaDevice |
|
794 |
*/ |
|
795 |
TMediaDevice iDevice; |
|
796 |
||
797 |
/** |
|
798 |
Partition information for the media device. |
|
799 |
||
800 |
@see TPartitionInfo |
|
801 |
*/ |
|
802 |
TPartitionInfo iPartitionInfo; |
|
803 |
||
804 |
/** |
|
805 |
The media's physical device driver. |
|
806 |
||
807 |
@see DMediaDriver |
|
808 |
*/ |
|
809 |
DMediaDriver *iDriver; |
|
810 |
||
811 |
/** |
|
812 |
Mount information for the media device. |
|
813 |
||
814 |
@see TMountInfoData |
|
815 |
*/ |
|
816 |
TMountInfoData iMountInfo; |
|
817 |
}; |
|
818 |
||
819 |
#ifdef __DEMAND_PAGING__ |
|
820 |
class DFragmentationPagingLock; |
|
821 |
class DMediaPagingDevice; |
|
822 |
#endif |
|
823 |
||
824 |
||
825 |
/** |
|
826 |
@publishedPartner |
|
827 |
@released |
|
828 |
The DPrimaryMedia base class which is derived from DMedia class is responsible for controlling the overall state of the media |
|
829 |
(for example whether the power is applied or the partition information has been determined and so on). |
|
830 |
Each media driver or extension that registers for a set of local drives also has to register for a set of DMedia objects at the same time. |
|
831 |
This media set must contain just one primary media object. |
|
832 |
The driver that performs drive registration is responsible for creating the primary media object itself, |
|
833 |
which it then passes over to the local media sub-system for ownership. |
|
834 |
If further media objects are specified in the set, then the local media sub-system itself creates DMedia instances for these on behalf of the driver. |
|
835 |
*/ |
|
836 |
class DPrimaryMediaBase : public DMedia |
|
837 |
{ |
|
838 |
public: |
|
839 |
enum TMsgId |
|
840 |
{ |
|
841 |
EConnect=-1, |
|
842 |
EDisconnect=-2, |
|
843 |
}; |
|
844 |
||
845 |
enum TForceMediaChangeFlags |
|
846 |
{ |
|
847 |
/** |
|
848 |
Specifying zero as the flag for DPrimaryMediaBase::ForceMediaChange(), |
|
849 |
results in all media drivers associated with the primary media being |
|
850 |
closed and reopened. |
|
851 |
All pending requests on all logical drives associated with the primary |
|
852 |
media will be cancelled. |
|
853 |
||
854 |
@see DPrimaryMediaBase::ForceMediaChange() |
|
855 |
@see RLocalDrive::ForceMediaChange() |
|
856 |
*/ |
|
857 |
KForceMediaChangeReOpenAllMediaDrivers = 0, |
|
858 |
/** |
|
859 |
This flag is used to simulate ejecting and re-inserting the media. |
|
860 |
All pending requests on all logical drives associated with the primary |
|
861 |
media will be cancelled. |
|
862 |
N.B. This is asynchronous in behaviour i.e. the caller will need to wait |
|
863 |
for (two) media change notifications before the drive is ready for use |
|
864 |
||
865 |
@see DPBusPrimaryMedia::ForceMediaChange() |
|
866 |
@see RLocalDrive::ForceMediaChange() |
|
867 |
*/ |
|
868 |
KMediaRemountForceMediaChange = 0x00000001, |
|
869 |
/** |
|
870 |
This flag is used to force the media driver for the specified logical |
|
871 |
drive to be closed and reopened. |
|
872 |
It should not affect any pending requests on other logical drives |
|
873 |
associated with the primary media. |
|
874 |
||
875 |
@see DPrimaryMediaBase::ForceMediaChange() |
|
876 |
@see RLocalDrive::ForceMediaChange() |
|
877 |
*/ |
|
878 |
KForceMediaChangeReOpenMediaDriver = 0x80000000 |
|
879 |
}; |
|
880 |
||
881 |
public: |
|
882 |
IMPORT_C DPrimaryMediaBase(); |
|
123 | 883 |
|
0 | 884 |
// provided by implementation |
885 |
IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId); |
|
886 |
IMPORT_C virtual TInt Connect(DLocalDrive* aLocalDrive); |
|
887 |
IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive); |
|
888 |
IMPORT_C virtual TInt Request(TLocDrvRequest& aRequest); |
|
889 |
IMPORT_C virtual TInt QuickCheckStatus(); |
|
890 |
IMPORT_C virtual TInt ForceMediaChange(TInt aMode); |
|
891 |
IMPORT_C virtual TInt InitiatePowerUp(); |
|
892 |
IMPORT_C virtual TInt DoInCritical(); |
|
893 |
IMPORT_C virtual void DoEndInCritical(); |
|
894 |
IMPORT_C virtual void DeltaCurrentConsumption(TInt aCurrent); |
|
895 |
IMPORT_C virtual void DefaultDriveCaps(TLocalDriveCapsV2& aCaps); |
|
896 |
IMPORT_C virtual TBool IsRemovableDevice(TInt& aSocketNum); |
|
123 | 897 |
|
0 | 898 |
// used by implementation |
899 |
IMPORT_C void NotifyMediaChange(); |
|
900 |
IMPORT_C void NotifyPowerDown(); |
|
901 |
IMPORT_C void NotifyEmergencyPowerDown(); |
|
902 |
IMPORT_C void NotifyPsuFault(TInt anError); |
|
903 |
IMPORT_C void NotifyMediaPresent(); |
|
904 |
IMPORT_C void PowerUpComplete(TInt anError); |
|
123 | 905 |
|
0 | 906 |
IMPORT_C virtual void HandleMsg(TLocDrvRequest& aRequest); |
907 |
IMPORT_C virtual TInt DoRequest(TLocDrvRequest& aRequest); |
|
908 |
TInt OpenMediaDriver(); |
|
909 |
void CloseMediaDrivers(DMedia* aMedia = NULL); |
|
910 |
void StartOpenMediaDrivers(); |
|
911 |
void OpenNextMediaDriver(); |
|
912 |
void DoOpenMediaDriverComplete(TInt anError); |
|
913 |
void DoPartitionInfoComplete(TInt anError); |
|
914 |
void CompleteCurrent(TInt anError); |
|
915 |
void CompleteRequest(TLocDrvRequest& aMsg, TInt aResult); |
|
916 |
IMPORT_C void RunDeferred(); |
|
917 |
void SetClosed(TInt anError); |
|
123 | 918 |
|
919 |
enum TNotifyType {EMediaChange, EMediaPresent}; |
|
920 |
void NotifyClients(TNotifyType aNotifyType, TLocDrv* aLocDrv=NULL); |
|
921 |
||
0 | 922 |
TInt InCritical(); |
923 |
void EndInCritical(); |
|
924 |
void UpdatePartitionInfo(); |
|
925 |
void MediaReadyHandleRequest(); |
|
926 |
TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress = NULL); |
|
927 |
||
928 |
#ifdef __DEMAND_PAGING__ |
|
929 |
TInt PinSendReceive(TLocDrvRequest& aReq, TLinAddr aStart = NULL); |
|
930 |
TInt PinFragmentSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress, TInt aLength); |
|
931 |
||
932 |
TBool PagingMediaPinAddress(TLinAddr aLinAddress, TInt aSize); |
|
933 |
void PagingMediaUnpinAddress(); |
|
934 |
#endif |
|
935 |
||
936 |
#ifdef __DEMAND_PAGING__ |
|
937 |
void RequestCountInc(); |
|
938 |
void RequestCountDec(); |
|
939 |
#endif |
|
940 |
||
123 | 941 |
// called by LocDrv::RegisterMediaDevice() for media extensions |
942 |
TInt Connect(TLocDrv* aLocDrv); |
|
943 |
||
944 |
void MediaChange(); |
|
945 |
TInt HandleMediaNotPresent(TLocDrvRequest& aReq); |
|
946 |
||
947 |
||
0 | 948 |
public: |
949 |
TInt iLastMediaId; /**< @internalComponent */ |
|
950 |
TMessageQue iMsgQ; |
|
951 |
TDfcQue* iDfcQ; |
|
952 |
SDblQue iConnectionQ; /**< @internalComponent */ |
|
953 |
TMessageQue iDeferred; /**< @internalComponent */ |
|
954 |
TMessageQue iWaitMedChg; /**< @internalComponent */ |
|
955 |
TInt iState; /**< @internalComponent */ |
|
956 |
TInt iCritical; /**< @internalComponent */ |
|
957 |
TLocDrvRequest* iCurrentReq; |
|
958 |
TDfc iAsyncDfc; /**< @internalComponent */ |
|
959 |
TInt iAsyncErrorCode; /**< @internalComponent */ |
|
960 |
RPhysicalDeviceArray iPhysDevArray; /**< @internalComponent */ |
|
961 |
||
962 |
class DBody; |
|
963 |
DBody* iBody; /**< @internalComponent */ |
|
964 |
||
965 |
TInt iNextMediaId; /**< @internalComponent */ |
|
966 |
TInt iTotalPartitionsOpened; /**< @internalComponent */ |
|
967 |
TInt iMediaDriversOpened; /**< @internalComponent */ |
|
968 |
DMediaDriver* iNextMediaDriver; /**< @internalComponent */ |
|
969 |
||
970 |
||
971 |
#ifdef __DEMAND_PAGING__ |
|
972 |
// keep the size of class as it is used as base for PBus and may not want to bother building DP specific version. |
|
973 |
TUint8 iPagingMedia; /**< @internalComponent */ |
|
974 |
TUint8 iDataPagingMedia; /**< @internalComponent */ |
|
975 |
TUint8 iRomPagingMedia; /**< @internalComponent */ |
|
976 |
TUint8 iRunningDeferred; /**< @internalComponent */ |
|
977 |
#else |
|
978 |
TInt iRunningDeferred; /**< @internalComponent */ |
|
979 |
#endif |
|
980 |
}; |
|
981 |
||
982 |
#ifdef __DEMAND_PAGING__ |
|
983 |
||
984 |
/** |
|
985 |
@internalComponent |
|
986 |
@prototype |
|
987 |
*/ |
|
988 |
NONSHARABLE_CLASS(DMediaPagingDevice) : public DPagingDevice |
|
989 |
{ |
|
990 |
public: |
|
991 |
enum TPagingRequestId |
|
992 |
{ |
|
993 |
/** |
|
994 |
Identifies any middle fragment of a Write request on a partition of a media that supports paging. |
|
995 |
@deprecated |
|
996 |
*/ |
|
997 |
EWriteRequestFragment = DLocalDrive::EFirstReqNumberReservedForPaging, |
|
998 |
||
999 |
/** |
|
1000 |
Identifies the last fragment of a Write request on a partition of a media that supports paging. |
|
1001 |
@deprecated |
|
1002 |
*/ |
|
1003 |
EWriteRequestFragmentLast = DLocalDrive::EFirstReqNumberReservedForPaging+1, |
|
1004 |
||
1005 |
/** |
|
1006 |
Request for paging in (read) data from the ROM store area. |
|
1007 |
*/ |
|
1008 |
ERomPageInRequest = DLocalDrive::EFirstReqNumberReservedForPaging+2, |
|
1009 |
||
1010 |
/** |
|
1011 |
Request for paging in (read) data from the code store area. |
|
1012 |
*/ |
|
1013 |
ECodePageInRequest = DLocalDrive::EFirstReqNumberReservedForPaging+3, |
|
1014 |
||
1015 |
/** |
|
1016 |
Provided to allow the following compile time assert. |
|
1017 |
*/ |
|
1018 |
EPagingRequestHighWaterMark |
|
1019 |
}; |
|
1020 |
__ASSERT_COMPILE(EPagingRequestHighWaterMark <= DLocalDrive::ELastReqNumberReservedForPaging + 1); |
|
1021 |
||
1022 |
enum TQueue |
|
1023 |
{ |
|
1024 |
EMainQ = 0x01, |
|
1025 |
EDeferredQ=0x02 |
|
1026 |
}; |
|
1027 |
||
1028 |
public: |
|
1029 |
DMediaPagingDevice(DPrimaryMediaBase* aPtr); |
|
1030 |
virtual ~DMediaPagingDevice(); |
|
1031 |
||
1032 |
// from DPagingDevice |
|
1033 |
virtual TInt Read(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber); |
|
1034 |
virtual TInt Write(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize, TBool aBackground); |
|
1035 |
virtual TInt DeleteNotify(TThreadMessage* aReq,TUint aOffset,TUint aSize); |
|
1036 |
||
1037 |
void CompleteRequest(TThreadMessage* aMsg, TInt aResult); |
|
1038 |
void SendToMainQueueDfcAndBlock(TThreadMessage* aMsg); |
|
1039 |
void SendToDeferredQ(TThreadMessage* aMsg); |
|
1040 |
inline static TBool PageInRequest(TLocDrvRequest& aReq); |
|
1041 |
inline static TBool PageOutRequest(TLocDrvRequest& aReq); |
|
1042 |
inline static TBool PagingRequest(TLocDrvRequest& aReq); |
|
176 | 1043 |
|
1044 |
virtual TInt WritePhysical(TThreadMessage* aReq, TPhysAddr* aPageArray, TUint aPageCount, TUint aOffset, TBool aBackground); |
|
1045 |
virtual TInt ReadPhysical(TThreadMessage* aReq, TPhysAddr* aPageArray, TUint aPageCount, TUint aOffset, TInt aDrvNumber); |
|
1046 |
private: |
|
1047 |
virtual TInt BaseRead(TThreadMessage* aReq,TUint32 aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber,TBool aPhysAddr); |
|
1048 |
virtual TInt BaseWrite(TThreadMessage* aReq,TUint32 aBuffer,TUint aOffset,TUint aSize, TBool aBackground,TBool aPhysAddr); |
|
0 | 1049 |
public: |
1050 |
TMessageQue iMainQ; |
|
1051 |
TMessageQue iDeferredQ; |
|
1052 |
DPrimaryMediaBase* iPrimaryMedia; |
|
1053 |
||
1054 |
TUint8 iEmptyingQ; |
|
1055 |
TUint8 iDeleteNotifyNotSupported; |
|
1056 |
TUint8 iSpare1; |
|
1057 |
TUint8 iSpare2; |
|
1058 |
||
1059 |
TAny* iMountInfoDataLock; |
|
1060 |
TAny* iMountInfoDescHdrLock; |
|
1061 |
TAny* iMountInfoDescLenLock; |
|
1062 |
||
1063 |
TInt iFirstLocalDriveNumber; |
|
1064 |
TInt iRomPagingDriveNumber; |
|
1065 |
TInt iDataPagingDriveNumber; |
|
1066 |
||
1067 |
NFastMutex iInstrumentationLock; // To protect instrumentation data |
|
1068 |
||
1069 |
#ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ |
|
1070 |
TUint8 iServicingROM; |
|
1071 |
TUint8 iServicingCode; |
|
1072 |
TUint8 iServicingDataIn; |
|
1073 |
TUint8 iServicingDataOut; |
|
1074 |
||
1075 |
SMediaROMPagingConcurrencyInfo iROMStats; |
|
1076 |
SMediaCodePagingConcurrencyInfo iCodeStats; |
|
1077 |
SMediaDataPagingConcurrencyInfo iDataStats; |
|
1078 |
#endif |
|
1079 |
||
1080 |
#ifdef __DEMAND_PAGING_BENCHMARKS__ |
|
1081 |
SPagingBenchmarkInfo iROMBenchmarkData; |
|
1082 |
SPagingBenchmarkInfo iCodeBenchmarkData; |
|
1083 |
SPagingBenchmarkInfo iDataInBenchmarkData; |
|
1084 |
SPagingBenchmarkInfo iDataOutBenchmarkData; |
|
1085 |
SMediaPagingInfo iMediaPagingInfo; |
|
1086 |
#endif |
|
1087 |
}; |
|
1088 |
||
1089 |
inline TBool DMediaPagingDevice::PageInRequest(TLocDrvRequest& aReq) |
|
1090 |
{ |
|
1091 |
return |
|
1092 |
(aReq.Flags() & TLocDrvRequest::EPaging) && |
|
1093 |
(aReq.Id() == ERomPageInRequest || |
|
1094 |
aReq.Id() == ECodePageInRequest || |
|
1095 |
aReq.Id() == DLocalDrive::ERead);} |
|
1096 |
||
1097 |
inline TBool DMediaPagingDevice::PageOutRequest(TLocDrvRequest& aReq) |
|
1098 |
{ |
|
1099 |
return |
|
1100 |
(aReq.Flags() & TLocDrvRequest::EPaging) && |
|
1101 |
(aReq.Id() == DLocalDrive::EWrite);} |
|
1102 |
||
1103 |
inline TBool DMediaPagingDevice::PagingRequest(TLocDrvRequest& aReq) |
|
1104 |
{ |
|
1105 |
return (aReq.Flags() & TLocDrvRequest::EPaging); |
|
1106 |
} |
|
1107 |
||
1108 |
||
1109 |
/** |
|
1110 |
@internalComponent |
|
1111 |
@prototype |
|
1112 |
*/ |
|
1113 |
class DFragmentationPagingLock: public DDemandPagingLock |
|
1114 |
{ |
|
1115 |
public: |
|
1116 |
TInt Construct(TUint aNumPages); |
|
1117 |
void Cleanup(); |
|
1118 |
void LockFragmentation() |
|
1119 |
{ |
|
1120 |
__ASSERT_CRITICAL; |
|
1121 |
__ASSERT_DEBUG(iFragmentationMutex, Kern::Fault("LOCMEDIA_H",__LINE__)); |
|
1122 |
// called in CS |
|
1123 |
Kern::MutexWait(*iFragmentationMutex); |
|
1124 |
} |
|
1125 |
void UnlockFragmentation() |
|
1126 |
{ |
|
1127 |
__ASSERT_CRITICAL; |
|
1128 |
__ASSERT_DEBUG(iFragmentationMutex, Kern::Fault("LOCMEDIA_H",__LINE__)); |
|
1129 |
// called in CS |
|
1130 |
Kern::MutexSignal(*iFragmentationMutex); |
|
1131 |
} |
|
1132 |
||
1133 |
||
1134 |
public: |
|
1135 |
TUint iFragmentGranularity; |
|
1136 |
private: |
|
1137 |
DMutex* iFragmentationMutex; // to protect Kernel memory locking |
|
1138 |
}; |
|
1139 |
#endif //__DEMAND_PAGING__ |
|
1140 |
||
1141 |
/** |
|
1142 |
@publishedPartner |
|
1143 |
@released |
|
1144 |
||
1145 |
An abstract base class for all media drivers in the local drive system. |
|
1146 |
||
1147 |
All media drivers, whether associated with fixed media, such as the internal |
|
1148 |
drive, or removable media, such as a PC Card or MultiMediaCard, must define |
|
1149 |
and implement a class derived from this one. |
|
1150 |
||
1151 |
An instance of this class is created by the media driver's PDD factory, |
|
1152 |
an instance of a class derived from DPhysicalDevice. |
|
1153 |
||
1154 |
@see DPhysicalDevice::Create() |
|
1155 |
@see DPhysicalDevice |
|
1156 |
*/ |
|
1157 |
class DMediaDriver : public DBase |
|
1158 |
{ |
|
1159 |
public: |
|
1160 |
IMPORT_C DMediaDriver(TInt aMediaId); |
|
1161 |
IMPORT_C virtual ~DMediaDriver(); |
|
1162 |
IMPORT_C virtual void Close(); |
|
1163 |
// Pure virtual |
|
1164 |
IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive, TThreadMessage* aMsg); |
|
1165 |
||
1166 |
/** |
|
1167 |
A function called by the local media subsystem to deal with a request, |
|
1168 |
and which must be implemented by the media driver. |
|
1169 |
||
1170 |
@param aRequest An object that encapsulates information about the request. |
|
1171 |
||
1172 |
@return A value indicating the result: |
|
1173 |
KErrNone, if the request has been sucessfully initiated; |
|
1174 |
KErrNotSupported, if the request cannot be handled by the device; |
|
1175 |
KMediaDriverDeferRequest, if the request cannot be handled |
|
1176 |
immediately because of an outstanding request (this request will be |
|
1177 |
deferred until the outstanding request has completed); |
|
1178 |
otherwise one of the other system-wide error codes. |
|
1179 |
*/ |
|
1180 |
virtual TInt Request(TLocDrvRequest& aRequest)=0; |
|
1181 |
||
1182 |
/** |
|
1183 |
A function called by the local media subsystem to get partition information |
|
1184 |
for the media device. |
|
1185 |
||
1186 |
It is called once the subsystem has been notified that the media driver |
|
1187 |
is open and has been succesfully initialised. |
|
1188 |
||
1189 |
This function must be implemented by the media driver. |
|
1190 |
||
1191 |
@param anInfo An object that, on successful return, contains |
|
1192 |
the partition information. |
|
1193 |
||
1194 |
@return KErrNone, if retrieval of partition information is to be |
|
1195 |
done asynchronously; |
|
1196 |
KErrCompletion, if retrieval of partition information has been |
|
1197 |
done synchronously, and successfully; |
|
1198 |
one of the other system-wide error codes, if retrieval of partition |
|
1199 |
information has been done synchronously, but unsuccessfully. |
|
1200 |
*/ |
|
1201 |
virtual TInt PartitionInfo(TPartitionInfo &anInfo)=0; |
|
1202 |
||
1203 |
/** |
|
1204 |
A function called by the local media subsystem to inform the media driver |
|
1205 |
that the device should power down. |
|
1206 |
||
1207 |
This function must be implemented by the media driver. |
|
1208 |
*/ |
|
1209 |
virtual void NotifyPowerDown()=0; |
|
1210 |
||
1211 |
/** |
|
1212 |
A function called by the local media subsystem to inform the media driver |
|
1213 |
that the device is to be immediately powered down. |
|
1214 |
||
1215 |
This function must be implemented by the media driver. |
|
1216 |
*/ |
|
1217 |
virtual void NotifyEmergencyPowerDown()=0; |
|
1218 |
public: |
|
1219 |
IMPORT_C void SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv=NULL); |
|
123 | 1220 |
IMPORT_C void SetTotalSizeInBytes(TLocalDriveCapsV4& aCaps); |
0 | 1221 |
IMPORT_C Int64 TotalSizeInBytes(); |
1222 |
IMPORT_C void SetCurrentConsumption(TInt aValue); |
|
1223 |
IMPORT_C TInt InCritical(); |
|
1224 |
IMPORT_C void EndInCritical(); |
|
1225 |
IMPORT_C void Complete(TLocDrvRequest& aRequest, TInt aResult); |
|
1226 |
IMPORT_C void OpenMediaDriverComplete(TInt anError); |
|
1227 |
IMPORT_C void PartitionInfoComplete(TInt anError); |
|
1228 |
public: |
|
1229 |
DPhysicalDevice* iPhysicalDevice;/**< @internalComponent */ |
|
1230 |
Int64 iTotalSizeInBytes; /**< @internalComponent */ |
|
1231 |
TInt iCurrentConsumption; /**< @internalComponent */ |
|
1232 |
DPrimaryMediaBase* iPrimaryMedia;/**< @internalComponent */ |
|
1233 |
TBool iCritical; /**< @internalComponent */ |
|
1234 |
TMountInfoData* iMountInfo; /**< @internalComponent */ |
|
1235 |
}; |
|
1236 |
||
1237 |
||
123 | 1238 |
/** |
1239 |
@internalTechnology |
|
1240 |
@prototype |
|
1241 |
||
1242 |
An abstract base class for media driver 'extensions' within the local media subsystem |
|
1243 |
*/ |
|
1244 |
class DMediaDriverExtension : public DMediaDriver |
|
1245 |
{ |
|
1246 |
public: |
|
1247 |
IMPORT_C DMediaDriverExtension(TInt aMediaId); |
|
1248 |
IMPORT_C virtual ~DMediaDriverExtension(); |
|
1249 |
IMPORT_C virtual void Close(); |
|
1250 |
||
1251 |
virtual TInt Request(TLocDrvRequest& aRequest) = 0; |
|
1252 |
||
1253 |
virtual TInt PartitionInfo(TPartitionInfo &anInfo) = 0; |
|
1254 |
||
1255 |
IMPORT_C virtual void NotifyPowerDown(); |
|
1256 |
||
1257 |
IMPORT_C virtual void NotifyEmergencyPowerDown(); |
|
1258 |
||
1259 |
/** |
|
1260 |
Retrieve partition info from all the attached drives |
|
1261 |
*/ |
|
1262 |
IMPORT_C TInt DoDrivePartitionInfo(TPartitionInfo &anInfo); |
|
1263 |
/** |
|
1264 |
Forward a request to the next attached drive |
|
1265 |
*/ |
|
1266 |
IMPORT_C TInt ForwardRequest(TLocDrvRequest& aRequest); |
|
1267 |
||
1268 |
/** |
|
1269 |
Read from the specified attached drive |
|
1270 |
*/ |
|
1271 |
IMPORT_C TInt Read(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1272 |
||
1273 |
/** |
|
1274 |
Write to the specified attached drive |
|
1275 |
*/ |
|
1276 |
IMPORT_C TInt Write(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1277 |
||
1278 |
/** |
|
1279 |
Get the Caps from the specified attached drive |
|
1280 |
*/ |
|
1281 |
IMPORT_C TInt Caps(TInt aDriveNumber, TDes8& aCaps); |
|
1282 |
||
1283 |
/** |
|
1284 |
Return whether the media is busy i.e. if it has any pending requests or DFCs |
|
1285 |
*/ |
|
1286 |
IMPORT_C TBool MediaBusy(TInt aDriveNumber); |
|
1287 |
||
1288 |
#ifdef __DEMAND_PAGING__ |
|
1289 |
/** |
|
1290 |
Send a paging read request to the specified attached drive |
|
1291 |
*/ |
|
1292 |
IMPORT_C TInt ReadPaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1293 |
||
1294 |
/** |
|
1295 |
Send a paging write request to the specified attached drive |
|
1296 |
*/ |
|
1297 |
IMPORT_C TInt WritePaged(TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1298 |
#endif |
|
1299 |
||
1300 |
private: |
|
1301 |
TInt SendRequest(TInt aReqId, TBool aPagingRequest, TInt aDriveNumber, TInt64 aPos, TLinAddr aData, TUint aLen); |
|
1302 |
||
1303 |
}; |
|
1304 |
||
1305 |
||
0 | 1306 |
|
1307 |
||
1308 |
/** |
|
1309 |
@publishedPartner |
|
1310 |
@released |
|
1311 |
||
1312 |
A structure that a media driver may find useful in its implementation, |
|
1313 |
and is used to contain the information required when registering |
|
1314 |
the media driver with the Local Media Subsystem. |
|
1315 |
||
1316 |
@see LocDrv::RegisterMediaDevice() |
|
1317 |
*/ |
|
1318 |
struct SMediaDeviceInfo |
|
1319 |
{ |
|
1320 |
||
1321 |
/** |
|
1322 |
The unique Media ID for a device. |
|
1323 |
||
1324 |
This can take one of the enumerated values defined |
|
1325 |
by the TMediaDevice enum. |
|
1326 |
*/ |
|
1327 |
TMediaDevice iDevice; |
|
1328 |
||
1329 |
||
1330 |
/** |
|
1331 |
Specifies the number of local drive objects to be assigned to the media driver. |
|
1332 |
||
1333 |
Drives that support more than one partition must specify a number greater than 1. |
|
1334 |
*/ |
|
1335 |
TInt iDriveCount; |
|
1336 |
||
1337 |
||
1338 |
/** |
|
1339 |
A pointer to an array of TInt values, which define the drive numbers that |
|
1340 |
are to be allocated to each partition. |
|
1341 |
||
1342 |
0 signifies Drive C, 1 signifies drive D, etc. For example, to allocate |
|
1343 |
drive letters J and K, specify an array containing the values [7,8]. |
|
1344 |
Note that the size of this array must be the same as the value specified |
|
1345 |
by iDriveCount. |
|
1346 |
*/ |
|
1347 |
const TInt* iDriveList; |
|
1348 |
||
1349 |
||
1350 |
/** |
|
1351 |
Specifies the total number of DMedia objects to be associated with |
|
1352 |
the media driver. |
|
1353 |
||
1354 |
This number includes the primary DPrimaryMedia object, plus all of |
|
1355 |
the DMedia objects that are created for each additional drive, and |
|
1356 |
which hold basic information about partitions. |
|
1357 |
*/ |
|
1358 |
TInt iNumMedia; |
|
1359 |
||
1360 |
||
1361 |
/** |
|
1362 |
A pointer to a descriptor containing the name of the media driver, |
|
1363 |
for example: PCCard |
|
1364 |
*/ |
|
1365 |
const TDesC* iDeviceName; |
|
1366 |
}; |
|
1367 |
||
1368 |
||
1369 |
||
1370 |
||
1371 |
/** |
|
1372 |
@publishedPartner |
|
1373 |
@released |
|
1374 |
||
1375 |
A set of utility functions used in the management of local media drivers. |
|
1376 |
*/ |
|
1377 |
class LocDrv |
|
1378 |
{ |
|
1379 |
public: |
|
1380 |
IMPORT_C static TInt RegisterMediaDevice(TMediaDevice aDevice, TInt aDriveCount, const TInt* aDriveList, DPrimaryMediaBase* aPrimaryMedia, TInt aNumMedia, const TDesC& aName); |
|
1381 |
IMPORT_C static TInt RegisterPasswordStore(TPasswordStore* aStore); |
|
1382 |
IMPORT_C static TPasswordStore* PasswordStore(); |
|
1383 |
#if !defined(__WINS__) |
|
1384 |
IMPORT_C static TInt RegisterPagingDevice(DPrimaryMediaBase* aPrimaryMedia, const TInt* aPagingDriveList, TInt aDriveCount, TUint aPagingType, TInt aReadShift, TUint aNumPages); |
|
1385 |
#endif // __WINS__ |
|
1386 |
IMPORT_C static TInt RegisterDmaDevice(DPrimaryMediaBase* aPrimaryMedia, |
|
1387 |
TInt aMediaBlockSize, |
|
1388 |
TInt aDmaMaxAddressable, |
|
1389 |
TInt aDmaAlignment); |
|
1390 |
}; |
|
1391 |
||
1392 |
/** |
|
1393 |
@internalComponent |
|
1394 |
*/ |
|
1395 |
inline TInt TLocDrv::Connect(DLocalDrive* aLocalDrive) |
|
1396 |
{ return iPrimaryMedia->Connect(aLocalDrive); } |
|
1397 |
||
1398 |
/** |
|
1399 |
@internalComponent |
|
1400 |
*/ |
|
1401 |
inline void TLocDrv::Disconnect(DLocalDrive* aLocalDrive) |
|
1402 |
{ iPrimaryMedia->Disconnect(aLocalDrive); } |
|
1403 |
||
1404 |
/** |
|
1405 |
@internalComponent |
|
1406 |
*/ |
|
1407 |
inline TInt TLocDrv::Request(TLocDrvRequest& aRequest) |
|
1408 |
{ return iPrimaryMedia->Request(aRequest); } |
|
1409 |
||
1410 |
/** |
|
1411 |
Returns the length of the media, in bytes, according to the partition information. |
|
1412 |
||
1413 |
@return Total length of the media, in bytes. |
|
1414 |
||
1415 |
@see TPartitionInfo |
|
1416 |
*/ |
|
1417 |
inline Int64 DMedia::MediaLenInBytes() |
|
1418 |
{return(iPartitionInfo.iMediaSizeInBytes);} |
|
1419 |
||
1420 |
/** |
|
1421 |
Returns the unique media ID for this device. |
|
1422 |
||
1423 |
@return The device ID that was set in the call to DMedia::Create(). |
|
1424 |
The return value will be one of the enumerators declared in TMediaDevice |
|
1425 |
||
1426 |
@see TMediaDevice |
|
1427 |
*/ |
|
1428 |
inline TMediaDevice DMedia::DeviceType() |
|
1429 |
{return(iDevice);} |
|
1430 |
||
1431 |
/** |
|
1432 |
Returns the total number of partitions that exist on the media according to the |
|
1433 |
partition information. |
|
1434 |
||
1435 |
This will always be less than or equal to KMaxPartitionEntries. |
|
1436 |
||
1437 |
@return Number of partitions that exist on the media. |
|
1438 |
||
1439 |
@see KMaxPartitionEntries |
|
1440 |
@see TPartitionInfo |
|
1441 |
*/ |
|
1442 |
inline TInt DMedia::PartitionCount() |
|
1443 |
{return(iPartitionInfo.iPartitionCount);} |
|
1444 |
||
1445 |
/** |
|
1446 |
The start address of the partition, described as a relative offset, in bytes, |
|
1447 |
from the start of the media. |
|
1448 |
||
1449 |
This value is used by the local media subsystem to calculate the absolute |
|
1450 |
address on the media whenever an access such as a Read, Write or Format request |
|
1451 |
is made. |
|
1452 |
||
1453 |
@param aPartition The partition whose start address is to be returned. |
|
1454 |
||
1455 |
@return The start address of the partition. |
|
1456 |
||
1457 |
@see TPartitionEntry |
|
1458 |
@see TPartitionInfo |
|
1459 |
*/ |
|
1460 |
inline Int64 DMedia::PartitionBaseAddr(TInt aPartition) |
|
1461 |
{return(iPartitionInfo.iEntry[aPartition].iPartitionBaseAddr);} |
|
1462 |
||
1463 |
/** |
|
1464 |
Returns the length of the partition, in bytes. |
|
1465 |
||
1466 |
@param aPartition The partition whose length is to be returned. |
|
1467 |
||
1468 |
@return The length of the partition. |
|
1469 |
||
1470 |
@see TPartitionEntry |
|
1471 |
@see TPartitionInfo |
|
1472 |
*/ |
|
1473 |
inline Int64 DMedia::PartitionLen(TInt aPartition) |
|
1474 |
{return(iPartitionInfo.iEntry[aPartition].iPartitionLen);} |
|
1475 |
||
1476 |
||
1477 |
/** |
|
1478 |
@internalTechnology |
|
1479 |
||
1480 |
A utility class for scanning MBR/EBR partition tables. |
|
1481 |
*/ |
|
1482 |
class TPartitionTableScanner |
|
1483 |
{ |
|
1484 |
public: |
|
1485 |
enum {ESectorShift=9, ESectorSize=512}; |
|
1486 |
enum {EMaxNest=4}; |
|
1487 |
struct SPart |
|
1488 |
{ |
|
1489 |
SPart(const TUint8* a); |
|
1490 |
TUint8 iBootInd; |
|
1491 |
TUint8 iType; |
|
1492 |
TUint32 iRSS; |
|
1493 |
TUint32 iSectors; |
|
1494 |
}; |
|
1495 |
struct SEBR |
|
1496 |
{ |
|
1497 |
TInt64 iRSS; |
|
1498 |
TInt64 iSectors; |
|
1499 |
}; |
|
1500 |
public: |
|
1501 |
IMPORT_C void Set(TUint8* aSectorBuffer, TPartitionEntry* aEntry, TInt aMaxPartitions, TInt64 aMediaSize); |
|
1502 |
IMPORT_C TInt64 NextLBA(); |
|
1503 |
IMPORT_C TInt NumberOfPartitionsFound() const; |
|
1504 |
TInt MakeEntry(const SPart& aP); |
|
1505 |
public: |
|
1506 |
TInt64 iMediaSize; // Total media size in sectors |
|
1507 |
TInt64 iLBA; // LBA currently in sector buffer |
|
1508 |
TInt64 iFirstEBR; // LBA of first EBR if any |
|
1509 |
SEBR iStack[EMaxNest]; |
|
1510 |
TInt iStackPointer; |
|
1511 |
TUint8* iSectorBuffer; // Pointer to 512 byte area where sector data is stored |
|
1512 |
TPartitionEntry* iFirstEntry; // Where first scanned partition is stored |
|
1513 |
TPartitionEntry* iNextEntry; // Where next scanned partition will be stored |
|
1514 |
TPartitionEntry* iLimit; // iFirstEntry + max partitions |
|
1515 |
}; |
|
1516 |
||
1517 |
||
1518 |
||
1519 |
#endif |