Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 7th, 2013  |  syntax: None  |  size: 5.32 KB  |  views: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /********************************************************************************
  2. *********************************************************************************
  3.                         COPYRIGHT (c)   2004 BY ROCK-CHIP FUZHOU
  4.                                 --  ALL RIGHTS RESERVED  --
  5.  
  6. File Name:  ftl.h
  7. Author:     XUESHAN LIN
  8. Created:    1st Dec 2008
  9. Modified:
  10. Revision:   1.00
  11. ********************************************************************************
  12. ********************************************************************************/
  13. #ifndef _FTL_H
  14. #define _FTL_H
  15.  
  16.  
  17. //1¿ÉÅäÖòÎÊý
  18. //#define     IN_LOADER                       //¶¨Òå±àÒëloaderʱºê¿ª¹Ø, û¶¨ÒåÊÇϵͳÇý¶¯
  19. #ifndef IN_LOADER
  20. #define     SYS_PROTECT                     //¶¨ÒåϵͳÇøд±£»¤Ê¹ÄÜ
  21. #endif
  22. #define   MALLOC_DISABLE
  23. #define     FTL_VERSION             0x0200  //FTL°æ±¾ºÅ, 0x100±íʾver1.00, ÐèÒªµÍ¸ñʱÐÞ¸ÄÖ÷°æ±¾ºÅ, ·ñÔòÖ»ÐèÐ޸Ĵΰ汾ºÅ
  24. #define     MAX_REMAP_TBL           (32768*2)//×î´óµÄÓ³Éä±í, ×Ö½Úµ¥Î», ±ØÐë>=1024
  25. #define     MAX_BAD_BLK_NUM         256     //×î´óµÄµÄ»µ¿é½»Ìæ¿éÊý
  26. #define     MAX_CACHE_BLK_NUM       16      //ÓÃÀ´×÷CACHEµÄ¿éÊý
  27. #define     MAX_EXCH_BLK_NUM        8       //½»»»¿éÊý
  28. #define     MAX_FREE_BLK_NUM        1024    //ÓÃÀ´×÷À©Õ¹¿éµÄÊýÁ¿×î´óÏÞÖÆ
  29. #define     MIN_FREE_BLK_NUM        64      //ÓÃÀ´×÷À©Õ¹¿éµÄÊýÁ¿×îСÏÞÖÆ
  30. #define     MAX_RSVD_BLK_NUM        4       //±£Áô¿éÊý(°üº¬2¸ö»µ¿é±í¼Ç¼¿é)
  31.  
  32. #define     DISK_NAND_CODE          0
  33. #define     DISK_NAND_DATA          1
  34. #define     DISK_NAND_USER          2
  35. #define     DISK_NAND_TOTAL         0xff
  36.  
  37. #define     MAX_CACHE               16      //ÖÁÉÙÒª6Ìõ
  38. #define     MAX_CACHE_CONTINUE_LEN  3
  39.  
  40. #define     FLASH_PROT_MAGIC        0x444e414e  //NAND
  41.  
  42. /*******************************************************************
  43. ºê³£Êý¶¨Òå
  44. *******************************************************************/
  45. #define     FTL_OK                  0
  46. #define     FTL_ERROR               -1
  47.  
  48. #define     SIGN_BAD_BLK            0xf000
  49. #define     SIGN_CACHE_BLK          0xf100
  50. #define     SIGN_DATA_BLK           0xf200
  51. #define     SIGN_RCV_BLK            0xf300
  52.  
  53.  
  54. //1½á¹¹¶¨Òå
  55. typedef struct tagEXCH_BLK_INFO
  56. {
  57.     uint32      Start;
  58.     uint32      End;
  59.     uint32      SrcAddr;                //Ô´BLOCKµØÖ·, ÓÃÓڹرջò»Ö¸´
  60.     uint16  ver;            //°æ±¾ºÅ, ±íʾ×îÐÂÊý¾Ý
  61.     uint8       Count;
  62.     uint8       Valid;
  63. }EXCH_BLK_INFO, *pEXCH_BLK_INFO;
  64.  
  65. typedef struct tagFTL_CACHE
  66. {
  67.     uint32 LBA;
  68.     uint32 Mask;
  69.     uint8 count;
  70.     uint8 Valid;
  71.     uint32 *Buf;
  72. }FTL_CACHE, *pFTL_CACHE;
  73.  
  74. typedef struct tagREMAP_INFO
  75. {
  76.     uint8 num[64];
  77.     uint32 write[2];
  78.     uint16 max;
  79.     uint16 blkAddr;
  80.     uint16 pageAddr;
  81.     uint16 tbl[MAX_REMAP_TBL/2];
  82. }REMAP_INFO, *pREMAP_INFO;
  83.  
  84. typedef struct tagBAD_BLK_INFO
  85. {
  86.     uint16 max;
  87.     uint16 cnt;
  88.     uint16 offset;
  89.     uint16 blkAddr[4];
  90.     uint16 tbl[MAX_BAD_BLK_NUM];
  91. }BAD_BLK_INFO, *pBAD_BLK_INFO;
  92.  
  93. typedef struct tagCACHE_BLK_INFO
  94. {
  95.     uint32 curPageAddr;
  96.     uint32 curBlkAddr;
  97.     uint16 ver;
  98.     uint16 tbl[MAX_CACHE_BLK_NUM];
  99. }CACHE_BLK_INFO, *pCACHE_BLK_INFO;
  100.  
  101. typedef struct tagCIR_QUEUE
  102. {
  103.     uint16 max;
  104.         uint16 front;
  105.         uint16 rear;
  106.         uint16 count;
  107.         uint16 arr[MAX_FREE_BLK_NUM];
  108. }CIR_QUEUE, *pCIR_QUEUE;
  109.  
  110.  
  111. typedef struct tagFTL_INFO
  112. {
  113.     uint8 valid;    //FTLÓÐЧ
  114.     uint16 ftlVer;  //FTL°æ±¾ºÅ
  115.    
  116.     uint8 secPerPage;   //FLASHµÄpage size
  117.     uint16 secPerBlk;   //FLASHµÄblock size
  118.     uint16 startPhyBlk; //FLASH×÷ΪÊý¾ÝÇøµÄÆðʼ¿é
  119.     uint32 maxPhyBlk;   //FLASH×÷ΪÊý¾ÝÇøµÄ×î´ó¿é
  120.     uint16 totalLogicBlk;
  121.  
  122.     REMAP_INFO remapInfo;           //¿éÓ³Éä±í, ËæÈÝÁ¿´óС¶ø±ä, e.g. 32GB/(1MB/blk)=64KB
  123.     BAD_BLK_INFO badBlkInfo;        //»µ¿éÐÅÏ¢
  124.     CACHE_BLK_INFO cacheBlkInfo;    //CACHE¿éÐÅÏ¢
  125.     CIR_QUEUE freeBlkInfo;          //¿Õ¿é±í, µ±´ÅÅÌ¿Õ¼äÂúʱÖÁÉÙ±£Ö¤ÓÐ64¿é¿ÉÒÔ¹ö¶¯
  126.     EXCH_BLK_INFO exchBlk[MAX_EXCH_BLK_NUM];//½»»»¿é
  127.  
  128.     uint8 cacheSortList[MAX_CACHE+1];
  129.     pFTL_CACHE curCache;
  130.     FTL_CACHE cache[MAX_CACHE];
  131. }FTL_INFO, *pFTL_INFO;
  132.  
  133. //1È«¾Ö±äÁ¿
  134. #undef  EXT
  135. #ifdef  IN_FTL
  136. #define EXT
  137. #else
  138. #define EXT             extern
  139. #endif
  140. EXT     FTL_INFO gFtlInfo;
  141. EXT     uint32 gCacheBuf[MAX_CACHE][PAGE_SIZE];
  142. EXT    uint32  CurEraseBlock;
  143.  
  144. //1º¯ÊýÔ­ÐÍÉùÃ÷
  145. //FTL.c
  146. extern  int32   FTLInit(void);
  147. extern  uint16  GetRemapBlk(uint16 LBA, uint16 PBA);
  148. extern  uint32  GetRemap(uint32 LBA, uint8 mod);
  149. extern  uint32  GetUnremap(uint32 PBA);
  150.  
  151. extern  uint32  FlashProgError(uint32 secAddr, void *DataBuf, uint16 nSec);
  152.  
  153. extern  void    FtlCacheDelayHook(void);
  154. extern  uint32  FtlGetCapacity(uint8 LUN);
  155. extern  int32   FtlRead(uint8 LUN, uint32 Index, uint32 nSec, void *buf);
  156. extern  uint32  FtlWritePage(uint32 Index, void *pData);
  157. extern  int32   FtlWrite(uint8 LUN, uint32 Index, uint32 nSec, void *buf);
  158. extern void FtlFlashSysProtSetOn(void);
  159. extern void FtlFlashSysProtSetOff(void);
  160. extern void FtlLowFormatSysDisk(void);
  161.  
  162. //1±í¸ñ¶¨Òå
  163. #ifdef  IN_FTL
  164. #else
  165. #endif
  166. #endif
clone this paste RAW Paste Data