kernel/eka/include/drivers/crashflashnand.h
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2004-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\crashflashnand.h
       
    15 // 
       
    16 // WARNING: This file contains some APIs which are internal and are subject
       
    17 //          to change without notice. Such APIs should therefore not be used
       
    18 //          outside the Kernel and Hardware Services package.
       
    19 //
       
    20 
       
    21 #ifndef __CRASHFLASHNAND_H__
       
    22 #define __CRASHFLASHNAND_H__
       
    23 #include <crashflash.h>
       
    24 
       
    25 class TPib;
       
    26 class TPibExtension;
       
    27 
       
    28 /**
       
    29 The maximum number of bytes in a nand flash main array
       
    30 @internalTechnology
       
    31 */
       
    32 const TUint KCFNandMaxBytesMain = 512;
       
    33 
       
    34 /**
       
    35 An implementation of the CrashFlash interface for nand flash.
       
    36 @internalTechnology
       
    37 */
       
    38 class CrashFlashNand : public CrashFlash
       
    39 	{
       
    40 public:
       
    41 	//From CrashFlash
       
    42 	virtual TInt Initialise();
       
    43 	virtual void StartTransaction();
       
    44 	virtual void EndTransaction();
       
    45 	virtual void Write(const TDesC8& aDes);
       
    46 	virtual void WriteSignature(const TDesC8& aDes);
       
    47 	virtual void Read(TDes8& aDes);
       
    48 	virtual void SetReadPos(TUint aPos);
       
    49 	virtual void SetWritePos(const TUint aPos);
       
    50 	virtual void EraseLogArea();
       
    51 	virtual void EraseFlashBlock(const TUint aBlock);
       
    52 	virtual TUint BytesWritten();
       
    53 #ifdef _CRASHLOG_COMPR	
       
    54 	virtual TUint GetOutputLimit(void);
       
    55 	virtual TUint GetLogOffset(void);
       
    56 #endif
       
    57 
       
    58 public:
       
    59 	/** @publishedPartner
       
    60 	@released */
       
    61 	virtual TInt GetDeviceId(TUint8& aDeviceId, TUint8& aManufacturerId)=0;
       
    62 	/** @publishedPartner
       
    63 	@released */
       
    64 	virtual TInt DeviceRead(const TUint aPageAddress, TAny* aBuf, const TUint aLength)=0;
       
    65 	/** @publishedPartner
       
    66 	@released */
       
    67 	virtual TInt DeviceWrite(const TUint aPageAddress, TAny* aBuf, const TUint aLength)=0;
       
    68 	/** @publishedPartner
       
    69 	@released */
       
    70 	virtual TInt DeviceErase(const TUint aBlockAddress)=0;
       
    71 public:
       
    72 	/** @publishedPartner
       
    73 	@released */
       
    74 	TUint iNumPagesPerBlock;
       
    75 	/** @publishedPartner
       
    76 	@released */
       
    77 	TUint iNumBytesMain;
       
    78 	/** @publishedPartner
       
    79 	@released */
       
    80 	TUint iNumBytesSpare;
       
    81 	/** @publishedPartner
       
    82 	@released */
       
    83 	TUint iNumReservoirBlocks;
       
    84 	/** @publishedPartner
       
    85 	@released */
       
    86 	TUint iNumBlocks;
       
    87 	/** @publishedPartner
       
    88 	@released */
       
    89 	TUint iNumBytesPage;
       
    90 
       
    91 protected:
       
    92 	/** @publishedPartner
       
    93 	@released */
       
    94 	virtual TInt VariantInitialise()=0;
       
    95 
       
    96 private:
       
    97 	TInt InitialiseFlashParameters(const TUint8 aDevId, const TUint8 aManId);
       
    98 	TInt ReadPib(TPib& aPib, TPibExtension& aPibExtension, TUint& aLastGoodBlock);
       
    99 	TInt ParsePib(TPib& aPib, TPibExtension& aPibExt);
       
   100 	void DoWriteRead();	
       
   101 	void DoWrite();
       
   102 	void DoRead();
       
   103 private:
       
   104 	TBool iIs16Bit;
       
   105 	TUint8 iLogWordSize;
       
   106 
       
   107 	TUint iCrashLogStartBlock;
       
   108 	TUint iNumCrashLogBlocks;
       
   109 
       
   110 	TUint iWriteBufIndex;
       
   111 	TUint iReadBufIndex;
       
   112 	TUint iWritePageIndex;
       
   113 	TUint iReadPageIndex;
       
   114 	TUint iWriteTotal;
       
   115 
       
   116 	TUint8 iWriteBuf[KCFNandMaxBytesMain];
       
   117 	TUint8 iReadBuf[KCFNandMaxBytesMain];
       
   118 	};
       
   119 
       
   120 #endif