os/kernelhwsrv/kernel/eka/include/drivers/flash_media.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/include/drivers/flash_media.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,295 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\include\drivers\flash_media.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @internalComponent
    1.24 +*/
    1.25 +
    1.26 +#ifndef __FLASH_MEDIA_H__
    1.27 +#define __FLASH_MEDIA_H__
    1.28 +#include <drivers/locmedia.h>
    1.29 +#include <platform.h>
    1.30 +
    1.31 +GLREF_C TDfcQue FlashDfcQ;
    1.32 +
    1.33 +
    1.34 +
    1.35 +
    1.36 +/** 
    1.37 +@publishedPartner
    1.38 +@released
    1.39 +
    1.40 +Base class for the LFFS media driver.
    1.41 +
    1.42 +The class provides an implementation for the generic layer of
    1.43 +the LFFS media driver.
    1.44 +Code that is specifc to a flash device is implemented as a class
    1.45 +derived from this.
    1.46 +*/
    1.47 +class DMediaDriverFlash : public DMediaDriver
    1.48 +	{
    1.49 +public:
    1.50 +    /**
    1.51 +    Defines a set of values that are passed to Complete()
    1.52 +    informing the generic layer about the type of request
    1.53 +    that is being completed.
    1.54 +    */
    1.55 +	enum TRequest {
    1.56 +	               /**
    1.57 +	               Indicates that a read request is being completed.
    1.58 +	               */
    1.59 +	               EReqRead=0,
    1.60 +           	       
    1.61 +           	       /**
    1.62 +	               Indicates that a write request is being completed.
    1.63 +	               */
    1.64 +	               EReqWrite=1,
    1.65 +	               
    1.66 +           	       /**
    1.67 +	               Indicates that an erase request is being completed.
    1.68 +	               */
    1.69 +	               EReqErase=2};
    1.70 +public:
    1.71 +    /**
    1.72 +    Creates an instance of the LFFS media driver.
    1.73 +    
    1.74 +    Although declared in this class, this function is not implemented by
    1.75 +    Symbian OS, but must be implemented by the port.
    1.76 +    
    1.77 +    It should return an instance of the class derived from DMediaDriverFlash.
    1.78 +    The following is an example taken from the Lubbock reference platform:
    1.79 +    @code
    1.80 +    DMediaDriverFlash* DMediaDriverFlash::New(TInt aMediaId)
    1.81 +    {
    1.82 +    return new DMediaDriverFlashLA(aMediaId);
    1.83 +    }
    1.84 +    @endcode
    1.85 +    
    1.86 +    @param  aMediaId The unique media ID specifed when the media driver was registered.
    1.87 +                     This value is just propagated through.
    1.88 +    
    1.89 +    @return An instance of a class derived from DMediaDriverFlash
    1.90 +    */
    1.91 +	static DMediaDriverFlash* New(TInt aMediaId);
    1.92 +	
    1.93 +	DMediaDriverFlash(TInt aMediaId);
    1.94 +public:
    1.95 +	// replacing pure virtual
    1.96 +       
    1.97 +	virtual TInt Request(TLocDrvRequest& aRequest);
    1.98 +
    1.99 +	virtual TInt PartitionInfo(TPartitionInfo& anInfo);
   1.100 +    
   1.101 +	virtual void NotifyPowerDown();
   1.102 +
   1.103 +	virtual void NotifyEmergencyPowerDown();
   1.104 +
   1.105 +public:
   1.106 +	// pure virtual - FLASH device specific stuff
   1.107 +
   1.108 +    /** 
   1.109 +    Called by the generic layer of the LFFS media driver, and implemented by
   1.110 +    the specific layer to perform any initialisation required by
   1.111 +    the specific layer.
   1.112 +    
   1.113 +    @return KErrNone, if successful; otherwise one of the other system
   1.114 +            wide error codes.
   1.115 +    */
   1.116 +	virtual TInt Initialise()=0;
   1.117 +
   1.118 +
   1.119 +
   1.120 +    /** 
   1.121 +    Called by the generic layer of the LFFS media driver, and implemented by
   1.122 +    the specific layer to get the size of the flash erase block.
   1.123 +    
   1.124 +    @return The size of the flash erase block, in bytes.
   1.125 +    */
   1.126 +	virtual TUint32 EraseBlockSize()=0;
   1.127 +
   1.128 +
   1.129 +
   1.130 +    /** 
   1.131 +    Called by the generic layer of the LFFS media driver, and implemented by
   1.132 +    the specific layer to get the total size of the flash.
   1.133 +
   1.134 +    @return The total size of the flash, in bytes.
   1.135 +    */
   1.136 +	virtual TUint32 TotalSize()=0;
   1.137 +
   1.138 +
   1.139 +
   1.140 +    /** 
   1.141 +    Called by the generic layer of the LFFS media driver, and implemented by
   1.142 +    the specific layer to start a read request.
   1.143 +    
   1.144 +    The information for the request is in iReadReq.
   1.145 +    
   1.146 +    If the read operation cannot be started immediately, then this function
   1.147 +    should return KMediaDriverDeferRequest; this asks the generic layer
   1.148 +    to defer the request and re-start it later. A read request might be
   1.149 +    deferred, for example, if there is a write or an erase operation
   1.150 +    already in progress.
   1.151 +    
   1.152 +    Note that this an asynchronous request, i.e. it starts the operation;
   1.153 +    the driver must call:
   1.154 +    @code
   1.155 +    Complete(EReqRead, result);
   1.156 +    @endcode
   1.157 +    when the operation is complete, where result is KErrNone if sucessful, or
   1.158 +    one of the system-wide error codes, otherwise.
   1.159 +
   1.160 +    @return KErrNone, if the request has been sucessfully initiated;
   1.161 +            KErrNotSupported, if the request cannot be handled by the device;
   1.162 +            KMediaDriverDeferRequest, if the request cannot be handled
   1.163 +            immediately because of an outstanding request
   1.164 +
   1.165 +    @see iReadReq
   1.166 +    @see DMediaDriverFlash::Complete()
   1.167 +    */
   1.168 +	virtual TInt DoRead()=0;
   1.169 +
   1.170 +
   1.171 +
   1.172 +    /** 
   1.173 +    Called by the generic layer of the LFFS media driver, and implemented by
   1.174 +    the specific layer to start a write request.
   1.175 +
   1.176 +    The information for the request is in iWriteReq.
   1.177 +    
   1.178 +    If the write operation cannot be started immediately, then this function
   1.179 +    should return KMediaDriverDeferRequest; this asks the generic layer
   1.180 +    to defer the request and re-start it later. A write request might be
   1.181 +    deferred, for example, if there is a read or an erase operation
   1.182 +    already in progress.
   1.183 +    
   1.184 +    Note that this an asynchronous request, i.e. it starts the operation;
   1.185 +    the driver must call:
   1.186 +    @code
   1.187 +    Complete(EReqWrite, result);
   1.188 +    @endcode
   1.189 +    when the operation is complete, where result is KErrNone if sucessful, or
   1.190 +    one of the system-wide error codes, otherwise.
   1.191 +
   1.192 +    @return KErrNone, if the request has been sucessfully initiated;
   1.193 +            KErrNotSupported, if the request cannot be handled by the device;
   1.194 +            KMediaDriverDeferRequest, if the request cannot be handled
   1.195 +            immediately because of an outstanding request
   1.196 +
   1.197 +    @see iWriteReq
   1.198 +    @see DMediaDriverFlash::Complete()
   1.199 +    */
   1.200 +	virtual TInt DoWrite()=0;
   1.201 +    
   1.202 +    
   1.203 +    
   1.204 +    /** 
   1.205 +    Called by the generic layer of the LFFS media driver, and implemented by
   1.206 +    the specific layer to start a block erase request.
   1.207 +
   1.208 +    The information for the request is in iEraseReq.
   1.209 +    
   1.210 +    If the erase operation cannot be started immediately, then this function
   1.211 +    should return KMediaDriverDeferRequest; this asks the generic layer
   1.212 +    to defer the request and re-start it later. An erase request might be
   1.213 +    deferred, for example, if there is a read or a write operation
   1.214 +    already in progress.
   1.215 +    
   1.216 +    Note that this an asynchronous request, i.e. it starts the operation;
   1.217 +    the driver must call:
   1.218 +    @code
   1.219 +    Complete(EReqErase, result);
   1.220 +    @endcode
   1.221 +    when the operation is complete, where result is KErrNone if sucessful, or
   1.222 +    one of the system-wide error codes, otherwise.
   1.223 +
   1.224 +    @return KErrNone, if the request has been sucessfully initiated;
   1.225 +            KErrNotSupported, if the request cannot be handled by the device;
   1.226 +            KMediaDriverDeferRequest, if the request cannot be handled
   1.227 +            immediately because of an outstanding request
   1.228 +
   1.229 +    @see iEraseReq
   1.230 +    @see DMediaDriverFlash::Complete()
   1.231 +    */
   1.232 +	virtual TInt DoErase()=0;
   1.233 +public:
   1.234 +	TInt DoCreate(TInt aMediaId);
   1.235 +
   1.236 +	virtual TInt Caps(TLocalDriveCapsV2& aCaps);
   1.237 +
   1.238 +	void Complete(TInt aRequest, TInt aResult);
   1.239 +public:
   1.240 +
   1.241 +
   1.242 +    /**
   1.243 +    Location for request information.
   1.244 +    
   1.245 +    An array of three entries to contain request information for read,
   1.246 +    write and erase requests respectively.
   1.247 +    
   1.248 +    NB Do not access this array directly; instead use the macro definitions:
   1.249 +    iReadReq, iWriteReq and iEraseReq. These ensure that you access the correct
   1.250 +    TLocDrvRequest items within the array.
   1.251 +    
   1.252 +    @see iReadReq
   1.253 +    @see iWriteReq
   1.254 +    @see iEraseReq
   1.255 +    @see TLocDrvRequest
   1.256 +    */
   1.257 +	TLocDrvRequest* iRequests[3];
   1.258 +	};
   1.259 +  
   1.260 +  
   1.261 +  
   1.262 +  
   1.263 +/** 
   1.264 +Read request information for LFFS media drivers.
   1.265 +
   1.266 +@see TLocDrvRequest
   1.267 +@see DMediaDriverFlash
   1.268 +@see DMediaDriverFlash::iRequests
   1.269 +*/
   1.270 +#define iReadReq	iRequests[EReqRead]
   1.271 +
   1.272 +
   1.273 +
   1.274 +
   1.275 +/** 
   1.276 +Write request information for LFFS media drivers.
   1.277 +
   1.278 +@see TLocDrvRequest
   1.279 +@see DMediaDriverFlash
   1.280 +@see DMediaDriverFlash::iRequests
   1.281 +*/
   1.282 +#define iWriteReq	iRequests[EReqWrite]
   1.283 +
   1.284 +
   1.285 +
   1.286 +
   1.287 +/** 
   1.288 +Erase request information for LFFS media drivers.
   1.289 +
   1.290 +@see TLocDrvRequest
   1.291 +@see DMediaDriverFlash
   1.292 +@see DMediaDriverFlash::iRequests
   1.293 +*/
   1.294 +#define iEraseReq	iRequests[EReqErase]
   1.295 +
   1.296 +
   1.297 +
   1.298 +#endif