sl@0: // Copyright (c) 1996-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\flash_media.h sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef __FLASH_MEDIA_H__ sl@0: #define __FLASH_MEDIA_H__ sl@0: #include sl@0: #include sl@0: sl@0: GLREF_C TDfcQue FlashDfcQ; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @publishedPartner sl@0: @released sl@0: sl@0: Base class for the LFFS media driver. sl@0: sl@0: The class provides an implementation for the generic layer of sl@0: the LFFS media driver. sl@0: Code that is specifc to a flash device is implemented as a class sl@0: derived from this. sl@0: */ sl@0: class DMediaDriverFlash : public DMediaDriver sl@0: { sl@0: public: sl@0: /** sl@0: Defines a set of values that are passed to Complete() sl@0: informing the generic layer about the type of request sl@0: that is being completed. sl@0: */ sl@0: enum TRequest { sl@0: /** sl@0: Indicates that a read request is being completed. sl@0: */ sl@0: EReqRead=0, sl@0: sl@0: /** sl@0: Indicates that a write request is being completed. sl@0: */ sl@0: EReqWrite=1, sl@0: sl@0: /** sl@0: Indicates that an erase request is being completed. sl@0: */ sl@0: EReqErase=2}; sl@0: public: sl@0: /** sl@0: Creates an instance of the LFFS media driver. sl@0: sl@0: Although declared in this class, this function is not implemented by sl@0: Symbian OS, but must be implemented by the port. sl@0: sl@0: It should return an instance of the class derived from DMediaDriverFlash. sl@0: The following is an example taken from the Lubbock reference platform: sl@0: @code sl@0: DMediaDriverFlash* DMediaDriverFlash::New(TInt aMediaId) sl@0: { sl@0: return new DMediaDriverFlashLA(aMediaId); sl@0: } sl@0: @endcode sl@0: sl@0: @param aMediaId The unique media ID specifed when the media driver was registered. sl@0: This value is just propagated through. sl@0: sl@0: @return An instance of a class derived from DMediaDriverFlash sl@0: */ sl@0: static DMediaDriverFlash* New(TInt aMediaId); sl@0: sl@0: DMediaDriverFlash(TInt aMediaId); sl@0: public: sl@0: // replacing pure virtual sl@0: sl@0: virtual TInt Request(TLocDrvRequest& aRequest); sl@0: sl@0: virtual TInt PartitionInfo(TPartitionInfo& anInfo); sl@0: sl@0: virtual void NotifyPowerDown(); sl@0: sl@0: virtual void NotifyEmergencyPowerDown(); sl@0: sl@0: public: sl@0: // pure virtual - FLASH device specific stuff sl@0: sl@0: /** sl@0: Called by the generic layer of the LFFS media driver, and implemented by sl@0: the specific layer to perform any initialisation required by sl@0: the specific layer. sl@0: sl@0: @return KErrNone, if successful; otherwise one of the other system sl@0: wide error codes. sl@0: */ sl@0: virtual TInt Initialise()=0; sl@0: sl@0: sl@0: sl@0: /** sl@0: Called by the generic layer of the LFFS media driver, and implemented by sl@0: the specific layer to get the size of the flash erase block. sl@0: sl@0: @return The size of the flash erase block, in bytes. sl@0: */ sl@0: virtual TUint32 EraseBlockSize()=0; sl@0: sl@0: sl@0: sl@0: /** sl@0: Called by the generic layer of the LFFS media driver, and implemented by sl@0: the specific layer to get the total size of the flash. sl@0: sl@0: @return The total size of the flash, in bytes. sl@0: */ sl@0: virtual TUint32 TotalSize()=0; sl@0: sl@0: sl@0: sl@0: /** sl@0: Called by the generic layer of the LFFS media driver, and implemented by sl@0: the specific layer to start a read request. sl@0: sl@0: The information for the request is in iReadReq. sl@0: sl@0: If the read operation cannot be started immediately, then this function sl@0: should return KMediaDriverDeferRequest; this asks the generic layer sl@0: to defer the request and re-start it later. A read request might be sl@0: deferred, for example, if there is a write or an erase operation sl@0: already in progress. sl@0: sl@0: Note that this an asynchronous request, i.e. it starts the operation; sl@0: the driver must call: sl@0: @code sl@0: Complete(EReqRead, result); sl@0: @endcode sl@0: when the operation is complete, where result is KErrNone if sucessful, or sl@0: one of the system-wide error codes, otherwise. sl@0: sl@0: @return 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 sl@0: sl@0: @see iReadReq sl@0: @see DMediaDriverFlash::Complete() sl@0: */ sl@0: virtual TInt DoRead()=0; sl@0: sl@0: sl@0: sl@0: /** sl@0: Called by the generic layer of the LFFS media driver, and implemented by sl@0: the specific layer to start a write request. sl@0: sl@0: The information for the request is in iWriteReq. sl@0: sl@0: If the write operation cannot be started immediately, then this function sl@0: should return KMediaDriverDeferRequest; this asks the generic layer sl@0: to defer the request and re-start it later. A write request might be sl@0: deferred, for example, if there is a read or an erase operation sl@0: already in progress. sl@0: sl@0: Note that this an asynchronous request, i.e. it starts the operation; sl@0: the driver must call: sl@0: @code sl@0: Complete(EReqWrite, result); sl@0: @endcode sl@0: when the operation is complete, where result is KErrNone if sucessful, or sl@0: one of the system-wide error codes, otherwise. sl@0: sl@0: @return 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 sl@0: sl@0: @see iWriteReq sl@0: @see DMediaDriverFlash::Complete() sl@0: */ sl@0: virtual TInt DoWrite()=0; sl@0: sl@0: sl@0: sl@0: /** sl@0: Called by the generic layer of the LFFS media driver, and implemented by sl@0: the specific layer to start a block erase request. sl@0: sl@0: The information for the request is in iEraseReq. sl@0: sl@0: If the erase operation cannot be started immediately, then this function sl@0: should return KMediaDriverDeferRequest; this asks the generic layer sl@0: to defer the request and re-start it later. An erase request might be sl@0: deferred, for example, if there is a read or a write operation sl@0: already in progress. sl@0: sl@0: Note that this an asynchronous request, i.e. it starts the operation; sl@0: the driver must call: sl@0: @code sl@0: Complete(EReqErase, result); sl@0: @endcode sl@0: when the operation is complete, where result is KErrNone if sucessful, or sl@0: one of the system-wide error codes, otherwise. sl@0: sl@0: @return 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 sl@0: sl@0: @see iEraseReq sl@0: @see DMediaDriverFlash::Complete() sl@0: */ sl@0: virtual TInt DoErase()=0; sl@0: public: sl@0: TInt DoCreate(TInt aMediaId); sl@0: sl@0: virtual TInt Caps(TLocalDriveCapsV2& aCaps); sl@0: sl@0: void Complete(TInt aRequest, TInt aResult); sl@0: public: sl@0: sl@0: sl@0: /** sl@0: Location for request information. sl@0: sl@0: An array of three entries to contain request information for read, sl@0: write and erase requests respectively. sl@0: sl@0: NB Do not access this array directly; instead use the macro definitions: sl@0: iReadReq, iWriteReq and iEraseReq. These ensure that you access the correct sl@0: TLocDrvRequest items within the array. sl@0: sl@0: @see iReadReq sl@0: @see iWriteReq sl@0: @see iEraseReq sl@0: @see TLocDrvRequest sl@0: */ sl@0: TLocDrvRequest* iRequests[3]; sl@0: }; sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Read request information for LFFS media drivers. sl@0: sl@0: @see TLocDrvRequest sl@0: @see DMediaDriverFlash sl@0: @see DMediaDriverFlash::iRequests sl@0: */ sl@0: #define iReadReq iRequests[EReqRead] sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Write request information for LFFS media drivers. sl@0: sl@0: @see TLocDrvRequest sl@0: @see DMediaDriverFlash sl@0: @see DMediaDriverFlash::iRequests sl@0: */ sl@0: #define iWriteReq iRequests[EReqWrite] sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: Erase request information for LFFS media drivers. sl@0: sl@0: @see TLocDrvRequest sl@0: @see DMediaDriverFlash sl@0: @see DMediaDriverFlash::iRequests sl@0: */ sl@0: #define iEraseReq iRequests[EReqErase] sl@0: sl@0: sl@0: sl@0: #endif