sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\include\drivers\locmedia.h sl@0: // sl@0: // sl@0: sl@0: #ifndef LOCMEDIA_H sl@0: #define LOCMEDIA_H sl@0: #include sl@0: #include sl@0: sl@0: #if defined(_DEBUG) && defined(__DEMAND_PAGING__) sl@0: #define __CONCURRENT_PAGING_INSTRUMENTATION__ sl@0: #endif sl@0: #if defined(_DEBUG) && defined(__DEMAND_PAGING__) sl@0: #define __DEMAND_PAGING_BENCHMARKS__ sl@0: #endif sl@0: sl@0: #ifdef __WINS__ sl@0: #define __EMULATOR_DMA_SUMULATION__ sl@0: #endif sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: A media driver priority value. sl@0: sl@0: The value can be returned by a media driver's PDD factory Info() function, sl@0: and allows Symbian OS to decide the order in which media drivers are to be opened. sl@0: sl@0: The value is relative to the other media driver priority values. sl@0: sl@0: @see DPhysicalDevice::Info() sl@0: */ sl@0: const TInt KMediaDriverPriorityHigh=2; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: A media driver priority value. sl@0: sl@0: The value can be returned by a media driver's PDD factory Info() function, sl@0: and allows Symbian OS to decide the order in which media drivers are to be opened. sl@0: sl@0: The value is relative to the other media driver priority values, and is sl@0: the one most commonly used. sl@0: sl@0: @see DPhysicalDevice::Info() sl@0: */ sl@0: const TInt KMediaDriverPriorityNormal=1; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: A media driver priority value. sl@0: sl@0: The value can be returned by a media driver's PDD factory Info() function, sl@0: and allows Symbian OS to decide the order in which media drivers are to be opened. sl@0: sl@0: The value is relative to the other media driver priority values. sl@0: sl@0: @see DPhysicalDevice::Info() sl@0: */ sl@0: const TInt KMediaDriverPriorityLow=0; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: Media driver interface major version number. sl@0: */ sl@0: const TInt KMediaDriverInterfaceMajorVersion=1; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: Media driver interface minor version number. sl@0: */ sl@0: const TInt KMediaDriverInterfaceMinorVersion=0; sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: Media driver interface build number. sl@0: */ sl@0: const TInt KMediaDriverInterfaceBuildVersion=160; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: */ sl@0: const TInt KMediaDriverDeferRequest=1; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @internalTechnology sl@0: */ sl@0: #define __TRACE_TIMING(x) sl@0: //#define __TRACE_TIMING(x) *(TInt*)0x63000ff0=x sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(DLocalDriveFactory) : public DLogicalDevice sl@0: { sl@0: public: sl@0: DLocalDriveFactory(); sl@0: virtual TInt Install(); sl@0: virtual void GetCaps(TDes8 &aDes) const; sl@0: virtual TInt Create(DLogicalChannelBase*& aChannel); sl@0: }; sl@0: sl@0: class TLocDrv; sl@0: class DLocalDrive; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(TLocalDriveCleanup) : public TThreadCleanup sl@0: { sl@0: public: sl@0: TLocalDriveCleanup(); sl@0: virtual void Cleanup(); sl@0: inline DLocalDrive& LocalDrive(); sl@0: }; sl@0: sl@0: sl@0: sl@0: class TLocDrvRequest; sl@0: class DPrimaryMediaBase; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: This class is strictly internal to Symbian; the only part of this class that sl@0: is publicly exposed to partners is the TRequestId enum. sl@0: sl@0: @see DLocalDrive::TRequestId sl@0: */ sl@0: NONSHARABLE_CLASS(DLocalDrive) : public DLogicalChannelBase sl@0: { sl@0: public: sl@0: /** sl@0: Identifies the specific local drive operation. sl@0: */ sl@0: enum TRequestId sl@0: { sl@0: /** sl@0: Requests information about the size, type, and attributes of the media. sl@0: */ sl@0: ECaps=0, sl@0: sl@0: /** sl@0: Requests an asynchronous read from the media device. sl@0: */ sl@0: ERead=1, sl@0: sl@0: /** sl@0: Requests an asynchronous write to the media device. sl@0: */ sl@0: EWrite=2, sl@0: sl@0: /** sl@0: Requests the formatting of a section of the media sl@0: */ sl@0: EFormat=3, sl@0: sl@0: /** sl@0: A request to expand the total size of the media. sl@0: */ sl@0: EEnlarge=4, sl@0: sl@0: /** sl@0: A request to reduce the total size of the media. sl@0: */ sl@0: EReduce=5, sl@0: sl@0: /** sl@0: A request to force a remount of the media. sl@0: */ sl@0: EForceMediaChange=6, sl@0: sl@0: /** sl@0: Requests an attempt to lock the media with a password. sl@0: */ sl@0: EPasswordLock=7, sl@0: sl@0: /** sl@0: Requests an attempt to unlock the media. sl@0: */ sl@0: EPasswordUnlock=8, sl@0: sl@0: /** sl@0: Requests an attempt to remove the password from the media. sl@0: */ sl@0: EPasswordClear=9, sl@0: sl@0: /** sl@0: Requests an read of the password store. sl@0: */ sl@0: EReadPasswordStore=10, sl@0: sl@0: /** sl@0: Requests a write of the password store. sl@0: */ sl@0: EWritePasswordStore=11, sl@0: sl@0: /** sl@0: A request to get the length of the password store. sl@0: */ sl@0: EPasswordStoreLengthInBytes=12, sl@0: /** sl@0: A Control IO request sl@0: */ sl@0: EControlIO=13, sl@0: /** sl@0: A request to force an erase of the password from the media sl@0: */ sl@0: EPasswordErase=14, sl@0: sl@0: /** sl@0: A delete notification from the file system sl@0: */ sl@0: EDeleteNotify=15, sl@0: sl@0: /** sl@0: A request for information on the last error sl@0: */ sl@0: EGetLastErrorInfo=16, sl@0: sl@0: EFirstReqNumberReservedForPaging=17, sl@0: // DO NOT REUSE ANY OF THE REQUEST NUMBERS BETWEEN THIS AND THE LAST RESERVED REQ NUMBER sl@0: // ALSO DO NOT INSERT ANY REQUEST NUMBERS BEFORE THIS, AS THIS WILL BE A COMPATIBILITY BREEAK sl@0: ELastReqNumberReservedForPaging=31, sl@0: sl@0: /** sl@0: Query device sl@0: */ sl@0: EQueryDevice=32, sl@0: sl@0: }; sl@0: public: sl@0: DLocalDrive(); sl@0: ~DLocalDrive(); sl@0: public: sl@0: virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); /**< @internalComponent */ sl@0: virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); /**< @internalComponent */ sl@0: public: sl@0: void NotifyChange(DPrimaryMediaBase& aPrimaryMedia, TBool aMediaChange); sl@0: public: sl@0: inline void Deque(); /**< @internalComponent */ sl@0: sl@0: private: sl@0: #ifdef __DEMAND_PAGING__ sl@0: TInt LockMountInfo(DPrimaryMediaBase& aPrimaryMedia, TLocDrvRequest& aReq); sl@0: void UnlockMountInfo(DPrimaryMediaBase& aPrimaryMedia); sl@0: #endif sl@0: TInt ReadPasswordData(TLocDrvRequest& aReq, TLocalDrivePasswordData& aPswData, TMediaPassword& aOldPasswd, TMediaPassword& aNewPasswd); sl@0: sl@0: public: sl@0: TLocDrv* iDrive; /**< @internalComponent */ sl@0: SDblQueLink iLink; /**< @internalComponent */ sl@0: TClientDataRequest* iNotifyChangeRequest; /**< @internalComponent */ sl@0: TLocalDriveCleanup iCleanup; /**< @internalComponent */ sl@0: }; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: inline DLocalDrive& TLocalDriveCleanup::LocalDrive() sl@0: { return *_LOFF(this,DLocalDrive,iCleanup); } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: A class that encapsulates the request information received from the client, sl@0: and gives the media driver access to the request ID and other associated sl@0: parameters, such as the request length, offset, the requesting thread, sl@0: source and destination address etc. sl@0: sl@0: An object of this type is passed to DMediaDriver::Request(). sl@0: sl@0: @see DMediaDriver::Request() sl@0: */ sl@0: class TLocDrvRequest : public TThreadMessage sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: enum TFlags sl@0: { sl@0: EWholeMedia=1, sl@0: EAdjusted=2, sl@0: EPhysAddr=0x04, sl@0: EPaging=0x08, // a paging request sl@0: EBackgroundPaging=0x10, // a background paging request. @see DMediaPagingDevice::Write() sl@0: ECodePaging=0x20, // a code paging request sl@0: EDataPaging=0x40, // a data paging request sl@0: ETClientBuffer=0x80, // RemoteDes() points to a TClientBuffer sl@0: EKernelBuffer=0x100, // RemoteDes() points to a kernel-side buffer sl@0: }; sl@0: public: sl@0: sl@0: /** sl@0: Gets a reference to the object containing the request information. sl@0: sl@0: @return The request information. sl@0: */ sl@0: inline static TLocDrvRequest& Get() sl@0: {return (TLocDrvRequest&)Kern::Message();} sl@0: sl@0: sl@0: /** sl@0: Gets the request ID. sl@0: sl@0: For media drivers, this is one of the DLocalDrive::TRequestId enumerated values. sl@0: sl@0: @return The request ID. sl@0: sl@0: @see DLocalDrive::TRequestId sl@0: */ sl@0: inline TInt& Id() sl@0: {return *(TInt*)&iValue;} sl@0: sl@0: sl@0: /** sl@0: Gets the position on the media on which the request operates. sl@0: sl@0: This applies to operations ERead, EWrite and EFormat. sl@0: sl@0: Note that the partition offset is taken into account by the underlying sl@0: local media subsystem. sl@0: sl@0: @return The position on the media. sl@0: sl@0: @see TRequestId::ERead sl@0: @see TRequestId::EWrite sl@0: @see TRequestId::EFormat sl@0: */ sl@0: inline Int64& Pos() sl@0: {return *(Int64*)&iArg[0];} sl@0: sl@0: sl@0: /** sl@0: Gets the length associated with the operation. sl@0: sl@0: This is the number of bytes associated with the media request. sl@0: It applies to operations ERead, EWrite and EFormat. sl@0: sl@0: @return The length, in bytes. sl@0: sl@0: @see TRequestId::ERead sl@0: @see TRequestId::EWrite sl@0: @see TRequestId::EFormat sl@0: */ sl@0: inline Int64& Length() sl@0: {return *(Int64*)&iArg[2];} sl@0: sl@0: sl@0: /** sl@0: Gets a pointer to the remote thread that requested the operation. sl@0: sl@0: This may be used to access the data to be read from the remote thread's process, sl@0: or the area to which data is to be written in the remote thread's process. sl@0: However, it is recommended that such operations be performed sl@0: using ReadRemote() and WriteRemote() sl@0: sl@0: @return A reference to a pointer to the remote thread. sl@0: sl@0: @see TLocDrvRequest::ReadRemote() sl@0: @see TLocDrvRequest::WriteRemote() sl@0: */ sl@0: inline DThread*& RemoteThread() sl@0: {return *(DThread**)&iArg[4];} sl@0: sl@0: sl@0: /** sl@0: Gets a pointer to the descriptor in the remote thread's process that sl@0: contains the data to be read, or is the target for data to be written. sl@0: sl@0: However, it is recommended that such read or write operations be performed sl@0: using ReadRemote() and WriteRemote(). sl@0: sl@0: @return A reference to a pointer to the remote descriptor. sl@0: sl@0: @see TLocDrvRequest::ReadRemote() sl@0: @see TLocDrvRequest::WriteRemote() sl@0: */ sl@0: inline TAny*& RemoteDes() sl@0: {return *(TAny**)&iArg[5];} sl@0: sl@0: sl@0: /** sl@0: Gets the offset within the descriptor in the remote thread's process. sl@0: sl@0: @return The offset within the descriptor. sl@0: */ sl@0: inline TInt& RemoteDesOffset() sl@0: {return *(TInt*)&iArg[6];} sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: inline TInt& Flags() sl@0: {return *(TInt*)&iArg[7];} sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: inline TLocDrv*& Drive() sl@0: {return *(TLocDrv**)&iArg[8];} sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: inline TInt& DriverFlags() sl@0: {return *(TInt*)&iArg[9];} sl@0: sl@0: sl@0: /** sl@0: Returns true if Physical memory addresses are available for this TLocDrvRequest. sl@0: @return ETrue if a physical memory address is available. sl@0: */ sl@0: inline TBool IsPhysicalAddress() sl@0: {return Flags() & EPhysAddr;} sl@0: public: sl@0: TInt ProcessMessageData(TAny* args); sl@0: void CloseRemoteThread(); sl@0: IMPORT_C TInt ReadRemote(TDes8* aDes, TInt anOffset); sl@0: IMPORT_C TInt ReadRemote(const TAny* aSrc, TDes8* aDes); sl@0: IMPORT_C TInt ReadRemoteRaw(TAny* aDes, TInt aSize); sl@0: IMPORT_C TInt WriteRemote(const TDesC8* aDes, TInt anOffset); sl@0: IMPORT_C TInt WriteRemoteRaw(const TAny* aSrc, TInt aSize); sl@0: IMPORT_C TInt CheckAndAdjustForPartition(); sl@0: #if !defined(__WINS__) sl@0: IMPORT_C TInt WriteToPageHandler(const TAny* aSrc, TInt aSize, TInt anOffset); sl@0: IMPORT_C TInt ReadFromPageHandler(TAny* aDst, TInt aSize, TInt anOffset); sl@0: #endif // __WINS__ sl@0: IMPORT_C TInt GetNextPhysicalAddress(TPhysAddr& aPhysAddr, TInt& aLength); sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: inline void DLocalDrive::Deque() sl@0: { iLink.Deque(); } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: Defines a structure used to contain information that describes an individual sl@0: partition. sl@0: sl@0: There is one of these for each partition that exists on a media device. sl@0: sl@0: @see TPartitionInfo sl@0: */ sl@0: class TPartitionEntry sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: The start address of the partition, described as a relative offset, sl@0: in bytes, from the start of the media. sl@0: sl@0: This value is used by the local media subsystem to calculate sl@0: the absolute address on the media whenever an access such as a Read, sl@0: Write or Format request is made. sl@0: */ sl@0: Int64 iPartitionBaseAddr; sl@0: sl@0: sl@0: /** sl@0: The length of the partition, in bytes. sl@0: */ sl@0: Int64 iPartitionLen; sl@0: sl@0: sl@0: /** sl@0: The Boot Indicator record, as described in the Master Boot Record on sl@0: FAT Partitioned devices. sl@0: sl@0: This is currently unused by the local media subsystem. sl@0: */ sl@0: TUint16 iBootIndicator; sl@0: sl@0: sl@0: /** sl@0: Describes the type of partition. sl@0: sl@0: The File Server uses this to decide the type of filesystem to be mounted sl@0: on the partition. sl@0: sl@0: Symbian OS supports many partition types, as defined in partitions.h. sl@0: You are, however, free to invent your own partition type, on which sl@0: you could, for example, mount your own filesystem. However, make sure sl@0: that your partition type does not clash with an existing partition type. sl@0: sl@0: Note that a media driver does not does not have to verify that sl@0: the partition actually contains a file system of this type; it just sets sl@0: this value to indicate the intended use for this partition. sl@0: */ sl@0: TUint16 iPartitionType; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: A constant that defines the maximum number of partitions that can exist on sl@0: a media device. sl@0: sl@0: @see TPartitionInfo::iPartitionCount sl@0: */ sl@0: const TInt KMaxPartitionEntries=0x10; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: Contains partition information for a media device. sl@0: sl@0: An object of this type is passed to the media driver's implementation of sl@0: DMediaDriver::PartitionInfo() to be filled in. sl@0: sl@0: @see DMediaDriver::PartitionInfo() sl@0: */ sl@0: class TPartitionInfo sl@0: { sl@0: public: sl@0: sl@0: /** sl@0: Default constructor that clears this object's memory to binary zeroes. sl@0: */ sl@0: TPartitionInfo(); sl@0: public: sl@0: sl@0: /** sl@0: The total size of the media, in bytes. sl@0: */ sl@0: Int64 iMediaSizeInBytes; sl@0: sl@0: sl@0: /** sl@0: The total number of partitions that exist on the media. sl@0: sl@0: This is always less than or equal to KMaxPartitionEntries. sl@0: sl@0: @see KMaxPartitionEntries sl@0: */ sl@0: TInt iPartitionCount; sl@0: sl@0: sl@0: /** sl@0: Information that describes each individual partition on the device. sl@0: sl@0: Each partition is represented by an array of TPartitionEntry objects. sl@0: Each entry must be created in the order of the start offset, so that sl@0: iEntry[0] specifies the partition with sl@0: the smallest iPartitionBaseAddr value. sl@0: sl@0: @see TPartitionEntry::iPartitionBaseAddr sl@0: @see TPartitionEntry sl@0: */ sl@0: TPartitionEntry iEntry[KMaxPartitionEntries]; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: class DMedia; sl@0: class DPrimaryMediaBase; sl@0: class DMediaDriver; sl@0: #ifdef __DEMAND_PAGING__ sl@0: class DFragmentationPagingLock; sl@0: #endif sl@0: class DDmaHelper; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: class TLocDrv : public TPartitionEntry sl@0: { sl@0: public: sl@0: TLocDrv(TInt aDriveNumber); sl@0: public: sl@0: inline TInt Connect(DLocalDrive* aLocalDrive); sl@0: inline void Disconnect(DLocalDrive* aLocalDrive); sl@0: inline TInt Request(TLocDrvRequest& aRequest); sl@0: public: sl@0: TInt iDriveNumber; sl@0: DMedia* iMedia; sl@0: DPrimaryMediaBase* iPrimaryMedia; sl@0: TInt iPartitionNumber; sl@0: TErrorInfo iLastErrorInfo; sl@0: #ifdef __DEMAND_PAGING__ sl@0: TInt iSpare0; sl@0: TUint8 iPagingDrv; sl@0: TUint8 iSpare1; sl@0: TUint8 iSpare2; sl@0: TUint8 iSpare3; sl@0: #endif sl@0: DDmaHelper* iDmaHelper; sl@0: }; sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: Kernel-side representation of a media entity. A DMedia object instantiates a sl@0: media driver to provide access to the physical media. sl@0: sl@0: Multiple DMedia objects may be required by some devices, e.g. multi-media cards sl@0: with combined SRAM and Flash or cards containing user and protected areas. sl@0: */ sl@0: class DMedia : public DBase sl@0: { sl@0: public: sl@0: /** sl@0: Declaration of all legal states for the media driver. sl@0: */ sl@0: enum TMediaState sl@0: { sl@0: /** sl@0: Media is powered down and the media drivers are closed. This is the sl@0: initial state when a media driver is created and the final state when sl@0: the driver is closed. sl@0: */ sl@0: EClosed=0, sl@0: sl@0: /** Media driver has started powerup sequence. */ sl@0: EPoweringUp1=1, sl@0: sl@0: /** Media is being opened. */ sl@0: EOpening=2, sl@0: sl@0: /** Media is open and the partition information is being read. */ sl@0: EReadPartitionInfo=3, sl@0: sl@0: /** The media driver is open and ready to accept commands. */ sl@0: EReady=4, sl@0: sl@0: /** Not used. */ sl@0: EAborted=5, sl@0: sl@0: /** Powering up with media drivers open. */ sl@0: EPoweringUp2=6, sl@0: sl@0: /** Not used. */ sl@0: ERecovering=7, sl@0: sl@0: /** The media is powered down, but the media driver still exists. */ sl@0: EPoweredDown=8 // powered down with media drivers open sl@0: }; sl@0: sl@0: public: sl@0: IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt); sl@0: void Close(); sl@0: public: sl@0: inline Int64 MediaLenInBytes(); sl@0: inline TMediaDevice DeviceType(); sl@0: inline TInt PartitionCount(); sl@0: inline Int64 PartitionBaseAddr(TInt aPartition); sl@0: inline Int64 PartitionLen(TInt aPartition); sl@0: public: sl@0: /** Not used. */ sl@0: static TInt MediaCallBack(TAny *aPtr); sl@0: public: sl@0: /** sl@0: The unique ID associated with this media entity. sl@0: ID allocated when the media is first created. sl@0: sl@0: @see LocDrv::RegisterMediaDevice sl@0: */ sl@0: TInt iMediaId; sl@0: sl@0: /** sl@0: The unique ID for the device. sl@0: sl@0: @see TMediaDevice sl@0: */ sl@0: TMediaDevice iDevice; sl@0: sl@0: /** sl@0: Partition information for the media device. sl@0: sl@0: @see TPartitionInfo sl@0: */ sl@0: TPartitionInfo iPartitionInfo; sl@0: sl@0: /** sl@0: The media's physical device driver. sl@0: sl@0: @see DMediaDriver sl@0: */ sl@0: DMediaDriver *iDriver; sl@0: sl@0: /** sl@0: Mount information for the media device. sl@0: sl@0: @see TMountInfoData sl@0: */ sl@0: TMountInfoData iMountInfo; sl@0: }; sl@0: sl@0: #ifdef __DEMAND_PAGING__ sl@0: class DFragmentationPagingLock; sl@0: class DMediaPagingDevice; sl@0: #endif sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: The DPrimaryMedia base class which is derived from DMedia class is responsible for controlling the overall state of the media sl@0: (for example whether the power is applied or the partition information has been determined and so on). sl@0: 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. sl@0: This media set must contain just one primary media object. sl@0: The driver that performs drive registration is responsible for creating the primary media object itself, sl@0: which it then passes over to the local media sub-system for ownership. sl@0: 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. sl@0: */ sl@0: class DPrimaryMediaBase : public DMedia sl@0: { sl@0: public: sl@0: enum TMsgId sl@0: { sl@0: EConnect=-1, sl@0: EDisconnect=-2, sl@0: }; sl@0: sl@0: enum TForceMediaChangeFlags sl@0: { sl@0: /** sl@0: Specifying zero as the flag for DPrimaryMediaBase::ForceMediaChange(), sl@0: results in all media drivers associated with the primary media being sl@0: closed and reopened. sl@0: All pending requests on all logical drives associated with the primary sl@0: media will be cancelled. sl@0: sl@0: @see DPrimaryMediaBase::ForceMediaChange() sl@0: @see RLocalDrive::ForceMediaChange() sl@0: */ sl@0: KForceMediaChangeReOpenAllMediaDrivers = 0, sl@0: /** sl@0: This flag is used to simulate ejecting and re-inserting the media. sl@0: All pending requests on all logical drives associated with the primary sl@0: media will be cancelled. sl@0: N.B. This is asynchronous in behaviour i.e. the caller will need to wait sl@0: for (two) media change notifications before the drive is ready for use sl@0: sl@0: @see DPBusPrimaryMedia::ForceMediaChange() sl@0: @see RLocalDrive::ForceMediaChange() sl@0: */ sl@0: KMediaRemountForceMediaChange = 0x00000001, sl@0: /** sl@0: This flag is used to force the media driver for the specified logical sl@0: drive to be closed and reopened. sl@0: It should not affect any pending requests on other logical drives sl@0: associated with the primary media. sl@0: sl@0: @see DPrimaryMediaBase::ForceMediaChange() sl@0: @see RLocalDrive::ForceMediaChange() sl@0: */ sl@0: KForceMediaChangeReOpenMediaDriver = 0x80000000 sl@0: }; sl@0: sl@0: public: sl@0: IMPORT_C DPrimaryMediaBase(); sl@0: public: sl@0: // provided by implementation sl@0: IMPORT_C virtual TInt Create(TMediaDevice aDevice, TInt aMediaId, TInt aLastMediaId); sl@0: IMPORT_C virtual TInt Connect(DLocalDrive* aLocalDrive); sl@0: IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive); sl@0: IMPORT_C virtual TInt Request(TLocDrvRequest& aRequest); sl@0: IMPORT_C virtual TInt QuickCheckStatus(); sl@0: IMPORT_C virtual TInt ForceMediaChange(TInt aMode); sl@0: IMPORT_C virtual TInt InitiatePowerUp(); sl@0: IMPORT_C virtual TInt DoInCritical(); sl@0: IMPORT_C virtual void DoEndInCritical(); sl@0: IMPORT_C virtual void DeltaCurrentConsumption(TInt aCurrent); sl@0: IMPORT_C virtual void DefaultDriveCaps(TLocalDriveCapsV2& aCaps); sl@0: IMPORT_C virtual TBool IsRemovableDevice(TInt& aSocketNum); sl@0: public: sl@0: // used by implementation sl@0: IMPORT_C void NotifyMediaChange(); sl@0: IMPORT_C void NotifyPowerDown(); sl@0: IMPORT_C void NotifyEmergencyPowerDown(); sl@0: IMPORT_C void NotifyPsuFault(TInt anError); sl@0: IMPORT_C void NotifyMediaPresent(); sl@0: IMPORT_C void PowerUpComplete(TInt anError); sl@0: public: sl@0: IMPORT_C virtual void HandleMsg(TLocDrvRequest& aRequest); sl@0: IMPORT_C virtual TInt DoRequest(TLocDrvRequest& aRequest); sl@0: TInt OpenMediaDriver(); sl@0: void CloseMediaDrivers(DMedia* aMedia = NULL); sl@0: void StartOpenMediaDrivers(); sl@0: void OpenNextMediaDriver(); sl@0: void DoOpenMediaDriverComplete(TInt anError); sl@0: void DoPartitionInfoComplete(TInt anError); sl@0: void CompleteCurrent(TInt anError); sl@0: void CompleteRequest(TLocDrvRequest& aMsg, TInt aResult); sl@0: IMPORT_C void RunDeferred(); sl@0: void SetClosed(TInt anError); sl@0: void NotifyClients(TBool aMediaChange,TLocDrv* aLocDrv=NULL); sl@0: TInt InCritical(); sl@0: void EndInCritical(); sl@0: void UpdatePartitionInfo(); sl@0: void MediaReadyHandleRequest(); sl@0: TInt SendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress = NULL); sl@0: sl@0: #ifdef __DEMAND_PAGING__ sl@0: TInt PinSendReceive(TLocDrvRequest& aReq, TLinAddr aStart = NULL); sl@0: TInt PinFragmentSendReceive(TLocDrvRequest& aReq, TLinAddr aLinAddress, TInt aLength); sl@0: sl@0: TBool PagingMediaPinAddress(TLinAddr aLinAddress, TInt aSize); sl@0: void PagingMediaUnpinAddress(); sl@0: #endif sl@0: sl@0: #ifdef __DEMAND_PAGING__ sl@0: void RequestCountInc(); sl@0: void RequestCountDec(); sl@0: #endif sl@0: sl@0: public: sl@0: TInt iLastMediaId; /**< @internalComponent */ sl@0: TMessageQue iMsgQ; sl@0: TDfcQue* iDfcQ; sl@0: SDblQue iConnectionQ; /**< @internalComponent */ sl@0: TMessageQue iDeferred; /**< @internalComponent */ sl@0: TMessageQue iWaitMedChg; /**< @internalComponent */ sl@0: TInt iState; /**< @internalComponent */ sl@0: TInt iCritical; /**< @internalComponent */ sl@0: TLocDrvRequest* iCurrentReq; sl@0: TDfc iAsyncDfc; /**< @internalComponent */ sl@0: TInt iAsyncErrorCode; /**< @internalComponent */ sl@0: RPhysicalDeviceArray iPhysDevArray; /**< @internalComponent */ sl@0: sl@0: class DBody; sl@0: DBody* iBody; /**< @internalComponent */ sl@0: sl@0: TInt iNextMediaId; /**< @internalComponent */ sl@0: TInt iTotalPartitionsOpened; /**< @internalComponent */ sl@0: TInt iMediaDriversOpened; /**< @internalComponent */ sl@0: DMediaDriver* iNextMediaDriver; /**< @internalComponent */ sl@0: sl@0: sl@0: #ifdef __DEMAND_PAGING__ sl@0: // keep the size of class as it is used as base for PBus and may not want to bother building DP specific version. sl@0: TUint8 iPagingMedia; /**< @internalComponent */ sl@0: TUint8 iDataPagingMedia; /**< @internalComponent */ sl@0: TUint8 iRomPagingMedia; /**< @internalComponent */ sl@0: TUint8 iRunningDeferred; /**< @internalComponent */ sl@0: #else sl@0: TInt iRunningDeferred; /**< @internalComponent */ sl@0: #endif sl@0: }; sl@0: sl@0: #ifdef __DEMAND_PAGING__ sl@0: sl@0: /** sl@0: @internalComponent sl@0: @prototype sl@0: */ sl@0: NONSHARABLE_CLASS(DMediaPagingDevice) : public DPagingDevice sl@0: { sl@0: public: sl@0: enum TPagingRequestId sl@0: { sl@0: /** sl@0: Identifies any middle fragment of a Write request on a partition of a media that supports paging. sl@0: @deprecated sl@0: */ sl@0: EWriteRequestFragment = DLocalDrive::EFirstReqNumberReservedForPaging, sl@0: sl@0: /** sl@0: Identifies the last fragment of a Write request on a partition of a media that supports paging. sl@0: @deprecated sl@0: */ sl@0: EWriteRequestFragmentLast = DLocalDrive::EFirstReqNumberReservedForPaging+1, sl@0: sl@0: /** sl@0: Request for paging in (read) data from the ROM store area. sl@0: */ sl@0: ERomPageInRequest = DLocalDrive::EFirstReqNumberReservedForPaging+2, sl@0: sl@0: /** sl@0: Request for paging in (read) data from the code store area. sl@0: */ sl@0: ECodePageInRequest = DLocalDrive::EFirstReqNumberReservedForPaging+3, sl@0: sl@0: /** sl@0: Provided to allow the following compile time assert. sl@0: */ sl@0: EPagingRequestHighWaterMark sl@0: }; sl@0: __ASSERT_COMPILE(EPagingRequestHighWaterMark <= DLocalDrive::ELastReqNumberReservedForPaging + 1); sl@0: sl@0: enum TQueue sl@0: { sl@0: EMainQ = 0x01, sl@0: EDeferredQ=0x02 sl@0: }; sl@0: sl@0: public: sl@0: DMediaPagingDevice(DPrimaryMediaBase* aPtr); sl@0: virtual ~DMediaPagingDevice(); sl@0: sl@0: // from DPagingDevice sl@0: virtual TInt Read(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize,TInt aDrvNumber); sl@0: virtual TInt Write(TThreadMessage* aReq,TLinAddr aBuffer,TUint aOffset,TUint aSize, TBool aBackground); sl@0: virtual TInt DeleteNotify(TThreadMessage* aReq,TUint aOffset,TUint aSize); sl@0: sl@0: void CompleteRequest(TThreadMessage* aMsg, TInt aResult); sl@0: void SendToMainQueueDfcAndBlock(TThreadMessage* aMsg); sl@0: void SendToDeferredQ(TThreadMessage* aMsg); sl@0: inline static TBool PageInRequest(TLocDrvRequest& aReq); sl@0: inline static TBool PageOutRequest(TLocDrvRequest& aReq); sl@0: inline static TBool PagingRequest(TLocDrvRequest& aReq); sl@0: public: sl@0: TMessageQue iMainQ; sl@0: TMessageQue iDeferredQ; sl@0: DPrimaryMediaBase* iPrimaryMedia; sl@0: sl@0: TUint8 iEmptyingQ; sl@0: TUint8 iDeleteNotifyNotSupported; sl@0: TUint8 iSpare1; sl@0: TUint8 iSpare2; sl@0: sl@0: TAny* iMountInfoDataLock; sl@0: TAny* iMountInfoDescHdrLock; sl@0: TAny* iMountInfoDescLenLock; sl@0: sl@0: TInt iFirstLocalDriveNumber; sl@0: TInt iRomPagingDriveNumber; sl@0: TInt iDataPagingDriveNumber; sl@0: sl@0: NFastMutex iInstrumentationLock; // To protect instrumentation data sl@0: sl@0: #ifdef __CONCURRENT_PAGING_INSTRUMENTATION__ sl@0: TUint8 iServicingROM; sl@0: TUint8 iServicingCode; sl@0: TUint8 iServicingDataIn; sl@0: TUint8 iServicingDataOut; sl@0: sl@0: SMediaROMPagingConcurrencyInfo iROMStats; sl@0: SMediaCodePagingConcurrencyInfo iCodeStats; sl@0: SMediaDataPagingConcurrencyInfo iDataStats; sl@0: #endif sl@0: sl@0: #ifdef __DEMAND_PAGING_BENCHMARKS__ sl@0: SPagingBenchmarkInfo iROMBenchmarkData; sl@0: SPagingBenchmarkInfo iCodeBenchmarkData; sl@0: SPagingBenchmarkInfo iDataInBenchmarkData; sl@0: SPagingBenchmarkInfo iDataOutBenchmarkData; sl@0: SMediaPagingInfo iMediaPagingInfo; sl@0: #endif sl@0: }; sl@0: sl@0: inline TBool DMediaPagingDevice::PageInRequest(TLocDrvRequest& aReq) sl@0: { sl@0: return sl@0: (aReq.Flags() & TLocDrvRequest::EPaging) && sl@0: (aReq.Id() == ERomPageInRequest || sl@0: aReq.Id() == ECodePageInRequest || sl@0: aReq.Id() == DLocalDrive::ERead);} sl@0: sl@0: inline TBool DMediaPagingDevice::PageOutRequest(TLocDrvRequest& aReq) sl@0: { sl@0: return sl@0: (aReq.Flags() & TLocDrvRequest::EPaging) && sl@0: (aReq.Id() == DLocalDrive::EWrite);} sl@0: sl@0: inline TBool DMediaPagingDevice::PagingRequest(TLocDrvRequest& aReq) sl@0: { sl@0: return (aReq.Flags() & TLocDrvRequest::EPaging); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @internalComponent sl@0: @prototype sl@0: */ sl@0: class DFragmentationPagingLock: public DDemandPagingLock sl@0: { sl@0: public: sl@0: TInt Construct(TUint aNumPages); sl@0: void Cleanup(); sl@0: void LockFragmentation() sl@0: { sl@0: __ASSERT_CRITICAL; sl@0: __ASSERT_DEBUG(iFragmentationMutex, Kern::Fault("LOCMEDIA_H",__LINE__)); sl@0: // called in CS sl@0: Kern::MutexWait(*iFragmentationMutex); sl@0: } sl@0: void UnlockFragmentation() sl@0: { sl@0: __ASSERT_CRITICAL; sl@0: __ASSERT_DEBUG(iFragmentationMutex, Kern::Fault("LOCMEDIA_H",__LINE__)); sl@0: // called in CS sl@0: Kern::MutexSignal(*iFragmentationMutex); sl@0: } sl@0: sl@0: sl@0: public: sl@0: TUint iFragmentGranularity; sl@0: private: sl@0: DMutex* iFragmentationMutex; // to protect Kernel memory locking sl@0: }; sl@0: #endif //__DEMAND_PAGING__ sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: An abstract base class for all media drivers in the local drive system. sl@0: sl@0: All media drivers, whether associated with fixed media, such as the internal sl@0: drive, or removable media, such as a PC Card or MultiMediaCard, must define sl@0: and implement a class derived from this one. sl@0: sl@0: An instance of this class is created by the media driver's PDD factory, sl@0: an instance of a class derived from DPhysicalDevice. sl@0: sl@0: @see DPhysicalDevice::Create() sl@0: @see DPhysicalDevice sl@0: */ sl@0: class DMediaDriver : public DBase sl@0: { sl@0: public: sl@0: IMPORT_C DMediaDriver(TInt aMediaId); sl@0: IMPORT_C virtual ~DMediaDriver(); sl@0: IMPORT_C virtual void Close(); sl@0: // Pure virtual sl@0: IMPORT_C virtual void Disconnect(DLocalDrive* aLocalDrive, TThreadMessage* aMsg); sl@0: sl@0: /** sl@0: A function called by the local media subsystem to deal with a request, sl@0: and which must be implemented by the media driver. sl@0: sl@0: @param aRequest An object that encapsulates information about the request. sl@0: sl@0: @return A value indicating the result: sl@0: KErrNone, if the request has been sucessfully initiated; sl@0: KErrNotSupported, if the request cannot be handled by the device; sl@0: KMediaDriverDeferRequest, if the request cannot be handled sl@0: immediately because of an outstanding request (this request will be sl@0: deferred until the outstanding request has completed); sl@0: otherwise one of the other system-wide error codes. sl@0: */ sl@0: virtual TInt Request(TLocDrvRequest& aRequest)=0; sl@0: sl@0: /** sl@0: A function called by the local media subsystem to get partition information sl@0: for the media device. sl@0: sl@0: It is called once the subsystem has been notified that the media driver sl@0: is open and has been succesfully initialised. sl@0: sl@0: This function must be implemented by the media driver. sl@0: sl@0: @param anInfo An object that, on successful return, contains sl@0: the partition information. sl@0: sl@0: @return KErrNone, if retrieval of partition information is to be sl@0: done asynchronously; sl@0: KErrCompletion, if retrieval of partition information has been sl@0: done synchronously, and successfully; sl@0: one of the other system-wide error codes, if retrieval of partition sl@0: information has been done synchronously, but unsuccessfully. sl@0: */ sl@0: virtual TInt PartitionInfo(TPartitionInfo &anInfo)=0; sl@0: sl@0: /** sl@0: A function called by the local media subsystem to inform the media driver sl@0: that the device should power down. sl@0: sl@0: This function must be implemented by the media driver. sl@0: */ sl@0: virtual void NotifyPowerDown()=0; sl@0: sl@0: /** sl@0: A function called by the local media subsystem to inform the media driver sl@0: that the device is to be immediately powered down. sl@0: sl@0: This function must be implemented by the media driver. sl@0: */ sl@0: virtual void NotifyEmergencyPowerDown()=0; sl@0: public: sl@0: IMPORT_C void SetTotalSizeInBytes(Int64 aTotalSizeInBytes, TLocDrv* aLocDrv=NULL); sl@0: IMPORT_C Int64 TotalSizeInBytes(); sl@0: IMPORT_C void SetCurrentConsumption(TInt aValue); sl@0: IMPORT_C TInt InCritical(); sl@0: IMPORT_C void EndInCritical(); sl@0: IMPORT_C void Complete(TLocDrvRequest& aRequest, TInt aResult); sl@0: IMPORT_C void OpenMediaDriverComplete(TInt anError); sl@0: IMPORT_C void PartitionInfoComplete(TInt anError); sl@0: public: sl@0: DPhysicalDevice* iPhysicalDevice;/**< @internalComponent */ sl@0: Int64 iTotalSizeInBytes; /**< @internalComponent */ sl@0: TInt iCurrentConsumption; /**< @internalComponent */ sl@0: DPrimaryMediaBase* iPrimaryMedia;/**< @internalComponent */ sl@0: TBool iCritical; /**< @internalComponent */ sl@0: TMountInfoData* iMountInfo; /**< @internalComponent */ sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: A structure that a media driver may find useful in its implementation, sl@0: and is used to contain the information required when registering sl@0: the media driver with the Local Media Subsystem. sl@0: sl@0: @see LocDrv::RegisterMediaDevice() sl@0: */ sl@0: struct SMediaDeviceInfo sl@0: { sl@0: sl@0: /** sl@0: The unique Media ID for a device. sl@0: sl@0: This can take one of the enumerated values defined sl@0: by the TMediaDevice enum. sl@0: */ sl@0: TMediaDevice iDevice; sl@0: sl@0: sl@0: /** sl@0: Specifies the number of local drive objects to be assigned to the media driver. sl@0: sl@0: Drives that support more than one partition must specify a number greater than 1. sl@0: */ sl@0: TInt iDriveCount; sl@0: sl@0: sl@0: /** sl@0: A pointer to an array of TInt values, which define the drive numbers that sl@0: are to be allocated to each partition. sl@0: sl@0: 0 signifies Drive C, 1 signifies drive D, etc. For example, to allocate sl@0: drive letters J and K, specify an array containing the values [7,8]. sl@0: Note that the size of this array must be the same as the value specified sl@0: by iDriveCount. sl@0: */ sl@0: const TInt* iDriveList; sl@0: sl@0: sl@0: /** sl@0: Specifies the total number of DMedia objects to be associated with sl@0: the media driver. sl@0: sl@0: This number includes the primary DPrimaryMedia object, plus all of sl@0: the DMedia objects that are created for each additional drive, and sl@0: which hold basic information about partitions. sl@0: */ sl@0: TInt iNumMedia; sl@0: sl@0: sl@0: /** sl@0: A pointer to a descriptor containing the name of the media driver, sl@0: for example: PCCard sl@0: */ sl@0: const TDesC* iDeviceName; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: A set of utility functions used in the management of local media drivers. sl@0: */ sl@0: class LocDrv sl@0: { sl@0: public: sl@0: IMPORT_C static TInt RegisterMediaDevice(TMediaDevice aDevice, TInt aDriveCount, const TInt* aDriveList, DPrimaryMediaBase* aPrimaryMedia, TInt aNumMedia, const TDesC& aName); sl@0: IMPORT_C static TInt RegisterPasswordStore(TPasswordStore* aStore); sl@0: IMPORT_C static TPasswordStore* PasswordStore(); sl@0: #if !defined(__WINS__) sl@0: IMPORT_C static TInt RegisterPagingDevice(DPrimaryMediaBase* aPrimaryMedia, const TInt* aPagingDriveList, TInt aDriveCount, TUint aPagingType, TInt aReadShift, TUint aNumPages); sl@0: #endif // __WINS__ sl@0: IMPORT_C static TInt RegisterDmaDevice(DPrimaryMediaBase* aPrimaryMedia, sl@0: TInt aMediaBlockSize, sl@0: TInt aDmaMaxAddressable, sl@0: TInt aDmaAlignment); sl@0: }; sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: inline TInt TLocDrv::Connect(DLocalDrive* aLocalDrive) sl@0: { return iPrimaryMedia->Connect(aLocalDrive); } sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: inline void TLocDrv::Disconnect(DLocalDrive* aLocalDrive) sl@0: { iPrimaryMedia->Disconnect(aLocalDrive); } sl@0: sl@0: /** sl@0: @internalComponent sl@0: */ sl@0: inline TInt TLocDrv::Request(TLocDrvRequest& aRequest) sl@0: { return iPrimaryMedia->Request(aRequest); } sl@0: sl@0: /** sl@0: Returns the length of the media, in bytes, according to the partition information. sl@0: sl@0: @return Total length of the media, in bytes. sl@0: sl@0: @see TPartitionInfo sl@0: */ sl@0: inline Int64 DMedia::MediaLenInBytes() sl@0: {return(iPartitionInfo.iMediaSizeInBytes);} sl@0: sl@0: /** sl@0: Returns the unique media ID for this device. sl@0: sl@0: @return The device ID that was set in the call to DMedia::Create(). sl@0: The return value will be one of the enumerators declared in TMediaDevice sl@0: sl@0: @see TMediaDevice sl@0: */ sl@0: inline TMediaDevice DMedia::DeviceType() sl@0: {return(iDevice);} sl@0: sl@0: /** sl@0: Returns the total number of partitions that exist on the media according to the sl@0: partition information. sl@0: sl@0: This will always be less than or equal to KMaxPartitionEntries. sl@0: sl@0: @return Number of partitions that exist on the media. sl@0: sl@0: @see KMaxPartitionEntries sl@0: @see TPartitionInfo sl@0: */ sl@0: inline TInt DMedia::PartitionCount() sl@0: {return(iPartitionInfo.iPartitionCount);} sl@0: sl@0: /** sl@0: The start address of the partition, described as a relative offset, in bytes, sl@0: from the start of the media. sl@0: sl@0: This value is used by the local media subsystem to calculate the absolute sl@0: address on the media whenever an access such as a Read, Write or Format request sl@0: is made. sl@0: sl@0: @param aPartition The partition whose start address is to be returned. sl@0: sl@0: @return The start address of the partition. sl@0: sl@0: @see TPartitionEntry sl@0: @see TPartitionInfo sl@0: */ sl@0: inline Int64 DMedia::PartitionBaseAddr(TInt aPartition) sl@0: {return(iPartitionInfo.iEntry[aPartition].iPartitionBaseAddr);} sl@0: sl@0: /** sl@0: Returns the length of the partition, in bytes. sl@0: sl@0: @param aPartition The partition whose length is to be returned. sl@0: sl@0: @return The length of the partition. sl@0: sl@0: @see TPartitionEntry sl@0: @see TPartitionInfo sl@0: */ sl@0: inline Int64 DMedia::PartitionLen(TInt aPartition) sl@0: {return(iPartitionInfo.iEntry[aPartition].iPartitionLen);} sl@0: sl@0: sl@0: /** sl@0: @internalTechnology sl@0: sl@0: A utility class for scanning MBR/EBR partition tables. sl@0: */ sl@0: class TPartitionTableScanner sl@0: { sl@0: public: sl@0: enum {ESectorShift=9, ESectorSize=512}; sl@0: enum {EMaxNest=4}; sl@0: struct SPart sl@0: { sl@0: SPart(const TUint8* a); sl@0: TUint8 iBootInd; sl@0: TUint8 iType; sl@0: TUint32 iRSS; sl@0: TUint32 iSectors; sl@0: }; sl@0: struct SEBR sl@0: { sl@0: TInt64 iRSS; sl@0: TInt64 iSectors; sl@0: }; sl@0: public: sl@0: IMPORT_C void Set(TUint8* aSectorBuffer, TPartitionEntry* aEntry, TInt aMaxPartitions, TInt64 aMediaSize); sl@0: IMPORT_C TInt64 NextLBA(); sl@0: IMPORT_C TInt NumberOfPartitionsFound() const; sl@0: TInt MakeEntry(const SPart& aP); sl@0: public: sl@0: TInt64 iMediaSize; // Total media size in sectors sl@0: TInt64 iLBA; // LBA currently in sector buffer sl@0: TInt64 iFirstEBR; // LBA of first EBR if any sl@0: SEBR iStack[EMaxNest]; sl@0: TInt iStackPointer; sl@0: TUint8* iSectorBuffer; // Pointer to 512 byte area where sector data is stored sl@0: TPartitionEntry* iFirstEntry; // Where first scanned partition is stored sl@0: TPartitionEntry* iNextEntry; // Where next scanned partition will be stored sl@0: TPartitionEntry* iLimit; // iFirstEntry + max partitions sl@0: }; sl@0: sl@0: sl@0: sl@0: #endif