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