📄 drvflash.h
字号:
/* Sleep mode support -- may need to be removed to internal RAM when DCM is enabled */
DWORD processedBankAddr;
DWORD processedBlock;
DWORD processedEraseCount;
kal_bool IsEraseSuspended;
DWORD IdleReclaimBlockID;
DWORD ProgramFailBuffer[512/sizeof(DWORD)];
#endif /* __SINGLE_BANK_NOR_FLASH_SUPPORT__ */
} NOR_FLASH_DRV_Data;
#ifdef __MTK_TARGET__
extern kal_mutexid fdm_reclaim_mutex;
extern kal_eventgrpid nor_egid;
#define NOR_BRECL_EVENT 0x1
#define NOR_FRECL_EVENT 0x2
#define NOR_DMAN_EVENT 0x4
#endif
/* Flash Bank Info */
typedef struct {
DWORD BankSize;
DWORD Banks;
} NORBankInfo;
#define EndBankInfo {0, 0}
/* Flash Layout Info */
typedef struct {
DWORD TotalLSMT;
DWORD BlkSize;
DWORD PageSize;
NORBankInfo *BankInfo;
WORD TblEntrys;
WORD TotalBlks;
} NORLayoutInfo;
typedef struct {
DWORD Signature;
BYTE * BaseAddr;
NORLayoutInfo * LayoutInfo;
#ifndef __MTK_TARGET__
const char *FileName;
void *flash_device;
BYTE *rootMTDcache;
BYTE *MTDcache;
DWORD modify; //first time, don't need to write to file
DWORD last_WinAddr; // next address calling mapwindow
DWORD last_region; //next region calling mapwindow
#endif
} NOR_MTD_DATA;
typedef ONE_BYTE_ALIGN_ADS struct
{
DWORD MSCount;
DWORD LogPageID[MSTABLE_ENTRY_NUM];
WORD NewEntryID[MSTABLE_ENTRY_NUM];
WORD OldEntryID[MSTABLE_ENTRY_NUM];
}MS_TABLE;
typedef ONE_BYTE_ALIGN_ADS struct {
WORD LogBlkID;
WORD TblIDInBlk;
}LSMGEntry;
//flash driver data for FDM5.0
typedef ONE_BYTE_ALIGN_ADS struct {
DWORD TotalFATSectors;
NOR_MTD_Driver * MTDDriver;
void * MTDData;
int (* DiscardSectors) (void * DriveData, UINT Sector, UINT Sectors);
void (*ReclaimBlock) (void* DriveData, kal_bool isBackground);
DWORD SecondPartitionSectors;
DWORD HeaderSize[2]; //HeaderSize[0]: data block header size
//HeaderSize[1]: table block header size
DWORD *InvalidEntryInTblBlk; //valid entry in table block
DWORD TotalAvail[2]; // TotalAvail[0]: total available pages in data block
//TotalAvail[0]: total available tables in table block
//not include empty block (2 spare block)
DWORD TotalInvalid[2]; // TotalInvalid[0]: total invalid pages in data block
//TotalInvalid[0]: total invalid tables in table block
DWORD ReclHighThreshold[2]; //unit ReclHighThreshold[0]: Pages ReclHighThreshold[1]: Tables
DWORD ReclLowThreshold[2];
DWORD SystemThreshold[2];
kal_bool NeedResumeFlag;
kal_bool NeedFRecl;
LSMGEntry *LSMG; // logical sector mapping group table
WORD ReclType;
WORD *LBM; //logical block mapping table
WORD *AvailInBlk; //available page in data block, available table in table block
WORD *InvalidInBlk; //valid page in data block, valid table in table block
WORD ActiveBlk[2]; // ActiveBlk[0]: active data block
//ActiveBlk[1]: active table block
WORD ReclLogBlkID; //ReclLogBlkID == INVALID_BLOCK_ID means no block need reclamation
WORD ErasingPhyBlk;
WORD ReclToPhyBlkID;
WORD ReclFromPhyBlkID;
WORD PageSizeShift;
WORD BlkIDShift;
WORD TblSizeShift;
WORD TblIDShift;
WORD PagesPerBlk;
WORD TblsPerBlk;
WORD TblBlks;
WORD SetTblBlks;
WORD DataBlks;
MS_TABLE MSTable;
BYTE *Buffer;
BYTE *CopyBuffer;
} NOR_FTL_DATA;
#ifndef __MTK_TARGET__
#pragma pack()
#endif
typedef struct {
DWORD Blocks;
DWORD BlockSize;
DWORD EraseCountMax;
DWORD EraseCountMin;
DWORD EraseCountAverage;
DWORD SectorsInUse;
DWORD SectorsDeleted;
DWORD SectorsAvail;
} NORFlashInfo;
/*from here added by hjz for zte-nj*/
typedef enum
{
SPANSION_PL_J,
SPANSION_PL_N,
SPANSION_WS_N,
AMD_SERIES,
TOSHIBA,
TOSHIBA_TV,
TOSHIBA_TY
}FLASH_TYPE;
typedef struct{
WORD manufacture_code;
WORD dev_code;
WORD ext_dev_code1;
WORD ext_dev_code2;
} Flashid;
typedef struct{
Flashid id_code;
DWORD EXTSRAM_SIZE;
DWORD CS0_SETTING;
DWORD CS1_SETTING;
} Flash_timing;
typedef struct{
Flashid id_code;
BYTE page_buffer_size;
DWORD Fatbase_addr;
DWORD Fat_size;
DWORD Extsram_size;
FLASH_TYPE flash_series;
FlashRegionInfo region_infor[3];
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__) && defined(__MULTI_BANK_NOR_DEVICE__)
FlashBankInfo bank_infor[3];
#endif
} Flash_setting_info;
/*end*/
/* Definition for power loss test */
#if defined(FLASH_DISKDRV_DEBUG) && defined(POWERLOSS_TEST)
#include <setjmp.h>
extern jmp_buf mark;
extern int Test_CD_Value;
#ifndef __NOR_FDM5__
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__)
enum
{
/* 1*/WriteSector_SECTOR_WRITING = 1,
/* 2*/WriteSector_SECTOR_WRITTEN,
/* 3*/WriteSector_SECTOR_DELETED,
/* 4*/WriteSector_SECTOR_VALID,
/* 5*/WriteSector_SECTOR_MS_WRITTEN,
/* 6*/ReclaimBlock_pre_BLOCK_RECLAIMING,
/* 7*/ReclaimBlock_pre_BLOCK_RECLAIMED,
/* 8*/ReclaimBlock_pre_BLOCK_VIRGINE,
/* 9*/ReclaimBlock_post_BLOCK_EMPTY,
/*10*/SetActiveBlock_BLOCK_FULL,
/*11*/SetActiveBlock_BLOCK_ACTIVE,
/*12*/ResumeSectorStates_SECTOR_MS_BEINGVALIDATED,
/*13*/WriteSector_SECTOR_MOVING,
/*14*/WriteSectors_Validate_MS_Sector,
/*15*/WriteSectors_Validate_MS_VALID_Sector,
/*16*/ReclaimEraseQueueItem_BLOCK_VIRGINE,
/*17*/IdleReclaimBlocks_BLOCK_RECLAIMING,
/*18*/IdleReclaimBlocks_BLOCK_RECLAIMING_COPYSECTOR,
/*19*/IdleReclaimBlocks_BLOCK_VIRGINE,
/*20*/IdleReclaimBlocks_RECALIM_ONE_MORE_BLOCK,
/*21*/IdleReclaimBlocks_BLOCK_RECLAIMED
};
#define TEST_POINT(a)\
{\
switch(a)\
{\
case WriteSector_SECTOR_MS_WRITTEN:\
case ReclaimBlock_pre_BLOCK_RECLAIMING:\
case ReclaimBlock_pre_BLOCK_RECLAIMED:\
case ReclaimBlock_pre_BLOCK_VIRGINE:\
case ReclaimBlock_post_BLOCK_EMPTY:\
case SetActiveBlock_BLOCK_FULL:\
case SetActiveBlock_BLOCK_ACTIVE:\
case WriteSectors_Validate_MS_Sector:\
Test_CD_Value -= 50;\
break;\
case ResumeSectorStates_SECTOR_MS_BEINGVALIDATED:\
Test_CD_Value -= 50;\
break;\
case IdleReclaimBlocks_BLOCK_RECLAIMING:\
case IdleReclaimBlocks_BLOCK_RECLAIMING_COPYSECTOR:\
case IdleReclaimBlocks_BLOCK_VIRGINE:\
case IdleReclaimBlocks_RECALIM_ONE_MORE_BLOCK:\
case IdleReclaimBlocks_BLOCK_RECLAIMED:\
Test_CD_Value -= 50;\
break;\
case WriteSectors_Validate_MS_Sector:\
case WriteSectors_Validate_MS_VALID_Sector:\
Test_CD_Value -= 50;\
break;\
default:\
Test_CD_Value--;\
break;\
}\
if(Test_CD_Value <= 0)\
longjmp(mark, a);\
}
#else /*!__SINGLE_BANK_NOR_FLASH_SUPPORT__*/
enum
{
/* 1*/WriteSector_SECTOR_WRITING = 1,
/* 2*/WriteSector_SECTOR_WRITTEN,
/* 3*/WriteSector_SECTOR_DELETED,
/* 4*/WriteSector_SECTOR_VALID,
/* 5*/WriteSector_SECTOR_MS_WRITTEN,
/* 6*/ReclaimBlock_pre_BLOCK_RECLAIM,
/* 7*/ReclaimBlock_pre_BLOCK_VIRGINE,
/* 8*/ReclaimBlock_post_BLOCK_EMPTY,
/* 9*/SetActiveBlock_BLOCK_FULL,
/*10*/SetActiveBlock_BLOCK_ACTIVE,
/*11*/ResumeSectorStates_SECTOR_MS_BEINGVALIDATED,
/*12*/WriteSector_SECTOR_MOVING,
/*13*/WriteSectors_Validate_MS_Sector
};
#define TEST_POINT(a)\
{\
switch(a)\
{\
case WriteSector_SECTOR_MS_WRITTEN:\
case ReclaimBlock_pre_BLOCK_RECLAIM:\
case ReclaimBlock_pre_BLOCK_VIRGINE:\
case ReclaimBlock_post_BLOCK_EMPTY:\
case SetActiveBlock_BLOCK_FULL:\
case SetActiveBlock_BLOCK_ACTIVE:\
case WriteSectors_Validate_MS_Sector:\
Test_CD_Value -= 50;\
break;\
case ResumeSectorStates_SECTOR_MS_BEINGVALIDATED:\
Test_CD_Value -= 50;\
break;\
default:\
Test_CD_Value--;\
break;\
}\
if(Test_CD_Value <= 0)\
longjmp(mark, a);\
}
#endif /*__SINGLE_BANK_NOR_FLASH_SUPPORT__*/
#else /*FDM5*/
enum
{
/* 1*/ReclaimBlock_MARK_BLOCK_RECLAIM = 1,
/* 2*/ReclaimBlock_MARK_BLOCK_COPYING,
/* 3*/ReclaimBlock_TABLE_BLOCK_COPYING,
/* 4*/ReclaimBlock_DATA_BLOCK_COPYING,
/* 5*/ReclaimBlock_MARK_BLOCK_ERASING,
/* 6*/ReclaimBlock_AFTER_ERASED,
/* 7*/CopyTable_MARK_COPYING,
/* 8*/CopyTable_MARK_ALLOCATING,
/* 9*/CopyTable_MARK_VALID,
/*10*/WritePage_MARK_TABLE_ENTRY_WRITING,
/*11*/WritePage_MARK_TABLE_ENTRY_WRITTEN,
/*12*/WritePage_MARK_PAGE_VALID,
/*13*/WritePage_MARD_TABLE_ENTRY_MS_WRITING,
/*14*/WritePage_MARD_TABLE_ENTRY_MS_BEGIN_VALID,
/*15*/SetActiveBlock_BLOCK_FULL,
/*16*/SetActiveBlock_BLOCK_ACTIVE
};
#define TEST_POINT(a)\
{\
switch(a)\
{\
case ReclaimBlock_MARK_BLOCK_RECLAIM:\
case ReclaimBlock_MARK_BLOCK_COPYING:\
case ReclaimBlock_TABLE_BLOCK_COPYING:\
case ReclaimBlock_DATA_BLOCK_COPYING:\
case ReclaimBlock_MARK_BLOCK_ERASING:\
case ReclaimBlock_AFTER_ERASED:\
case CopyTable_MARK_COPYING:\
case CopyTable_MARK_ALLOCATING:\
case CopyTable_MARK_VALID:\
case WritePage_MARK_TABLE_ENTRY_WRITING:\
case WritePage_MARK_TABLE_ENTRY_WRITTEN:\
case WritePage_MARK_PAGE_VALID:\
case WritePage_MARD_TABLE_ENTRY_MS_WRITING:\
case WritePage_MARD_TABLE_ENTRY_MS_BEGIN_VALID:\
case SetActiveBlock_BLOCK_FULL:\
case SetActiveBlock_BLOCK_ACTIVE:\
Test_CD_Value -= 50;\
break;\
default:\
Test_CD_Value--;\
break;\
}\
if(Test_CD_Value <= 0)\
longjmp(mark, a);\
}
#endif /*__NOR_FDM5__*/
#define START_POINT setjmp(mark)
#else
#define TEST_POINT(a)
#define START_POINT
#endif /* FLASH_DISKDRV_DEBUG */
/* Function Prototype */
int NOR_MountDevice(void * DriveData, int DeviceNumber, int DeviceType, DWORD Flags);
int NOR_ShutDown(void * DriveData);
int NOR_ReadSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int NOR_WriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int NOR_MediaChanged(void * DriveData);
int NOR_DiscardSectors(void * DriveData, DWORD Sector, UINT Sectors);
int NOR_GetDiskGeometry(void * DriveData, FS_PartitionRecord * DiskGeometry, BYTE * MediaDescriptor);
int NOR_LowLevelFormat(void * DriveData, const char * DeviceName, FS_FormatCallback Progress, DWORD Flags);
int NOR_NonBlockWriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int NOR_RecoverableWriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int NOR_ResumeSectorStates(void * DriveData);
int SIB_MountDevice(void * DriveData, int DeviceNumber, int DeviceType, DWORD Flags);
int SIB_ReadSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int SIB_WriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int SIB_DiscardSectors(void * DriveData, DWORD Sector, UINT Sectors);
int SIB_GetDiskGeometry(void * DriveData, FS_PartitionRecord * DiskGeometry, BYTE * MediaDescriptor);
int SIB_LowLevelFormat(void * DriveData, const char * DeviceName, FS_FormatCallback Progress, DWORD Flags);
int SIB_NonBlockWriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int SIB_RecoverableWriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int SIB_ResumeSectorStates(void * DriveData);
int nNOR_MountDevice(void * DriveData, int DeviceNumber, int DeviceType, DWORD Flags);
int nNOR_ReadSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int nNOR_WriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int nNOR_MediaChanged(void * DriveData);
int nNOR_DiscardSectors(void * DriveData, DWORD Sector, UINT Sectors);
int nNOR_LowLevelFormat(void * DriveData, const char * DeviceName, FS_FormatCallback Progress, DWORD Flags);
int nNOR_NonBlockWriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int nNOR_RecoverableWriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int nNOR_ResumeSectorStates(void * DriveData);
void nNOR_ReclaimBlock(void* DriveData, kal_bool isBackground);
int nSIB_MountDevice(void * DriveData, int DeviceNumber, int DeviceType, DWORD Flags);
int nSIB_ReadSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int nSIB_WriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int nSIB_DiscardSectors(void * DriveData, DWORD Sector, UINT Sectors);
int nGetDiskGeometry(void * DriveData, FS_PartitionRecord * DiskGeometry, BYTE * MediaDescriptor);
int nSIB_LowLevelFormat(void * DriveData, const char * DeviceName, FS_FormatCallback Progress, DWORD Flags);
int nSIB_NonBlockWriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int nSIB_RecoverableWriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
int nSIB_ResumeSectorStates(void * DriveData);
void nSIB_ReclaimBlock(void* DriveData, kal_bool isBackground);
int nShutDown(void * DriveData);
int OTPAccess(void * DriveData, int accesstype, UINT Offset, void * BufferPtr, UINT Length);
int OTPQueryLength(void * DriveData, UINT *Length);
/* internal helper function */
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__)
int NOR_EraseQueueItems(void * DriveData);
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -