nftl.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Defines for NAND Flash Translation Layer */
  2. /* (c) 1999 Machine Vision Holdings, Inc. */
  3. /* Author: David Woodhouse <dwmw2@mvhi.com> */
  4. /* $Id: nftl.h,v 1.10 2000/12/29 00:25:38 dwmw2 Exp $ */
  5. #ifndef __MTD_NFTL_H__
  6. #define __MTD_NFTL_H__
  7. /* Block Control Information */
  8. struct nftl_bci {
  9. unsigned char ECCSig[6];
  10. __u8 Status;
  11. __u8 Status1;
  12. }__attribute__((packed));
  13. /* Unit Control Information */
  14. struct nftl_uci0 {
  15. __u16 VirtUnitNum;
  16. __u16 ReplUnitNum;
  17. __u16 SpareVirtUnitNum;
  18. __u16 SpareReplUnitNum;
  19. } __attribute__((packed));
  20. struct nftl_uci1 {
  21. __u32 WearInfo;
  22. __u16 EraseMark;
  23. __u16 EraseMark1;
  24. } __attribute__((packed));
  25. struct nftl_uci2 {
  26. __u16 FoldMark;
  27. __u16 FoldMark1;
  28. __u32 unused;
  29. } __attribute__((packed));
  30. union nftl_uci {
  31. struct nftl_uci0 a;
  32. struct nftl_uci1 b;
  33. struct nftl_uci2 c;
  34. };
  35. struct nftl_oob {
  36. struct nftl_bci b;
  37. union nftl_uci u;
  38. };
  39. /* NFTL Media Header */
  40. struct NFTLMediaHeader {
  41. char DataOrgID[6];
  42. __u16 NumEraseUnits;
  43. __u16 FirstPhysicalEUN;
  44. __u32 FormattedSize;
  45. unsigned char UnitSizeFactor;
  46. } __attribute__((packed));
  47. #define MAX_ERASE_ZONES (8192 - 512)
  48. #define ERASE_MARK 0x3c69
  49. #define SECTOR_FREE 0xff
  50. #define SECTOR_USED 0x55
  51. #define SECTOR_IGNORE 0x11
  52. #define SECTOR_DELETED 0x00
  53. #define FOLD_MARK_IN_PROGRESS 0x5555
  54. #define ZONE_GOOD 0xff
  55. #define ZONE_BAD_ORIGINAL 0
  56. #define ZONE_BAD_MARKED 7
  57. /* these info are used in ReplUnitTable */
  58. #define BLOCK_NIL 0xffff /* last block of a chain */
  59. #define BLOCK_FREE 0xfffe /* free block */
  60. #define BLOCK_NOTEXPLORED 0xfffd /* non explored block, only used during mounting */
  61. #define BLOCK_RESERVED 0xfffc /* bios block or bad block */
  62. struct NFTLrecord {
  63. struct DiskOnChip *mtd;
  64. __u16 MediaUnit, SpareMediaUnit;
  65. __u32 EraseSize;
  66. struct NFTLMediaHeader MediaHdr;
  67. int usecount;
  68. unsigned char heads;
  69. unsigned char sectors;
  70. unsigned short cylinders;
  71. __u16 numvunits;
  72. __u16 lastEUN; /* should be suppressed */
  73. __u16 numfreeEUNs;
  74. __u16 LastFreeEUN; /* To speed up finding a free EUN */
  75. __u32 nr_sects;
  76. int head,sect,cyl;
  77. __u16 *EUNtable; /* [numvunits]: First EUN for each virtual unit */
  78. __u16 *ReplUnitTable; /* [numEUNs]: ReplUnitNumber for each */
  79. unsigned int nb_blocks; /* number of physical blocks */
  80. unsigned int nb_boot_blocks; /* number of blocks used by the bios */
  81. };
  82. #define MAX_NFTLS 16
  83. #define MAX_SECTORS_PER_UNIT 32
  84. #define NFTL_PARTN_BITS 4
  85. #endif /* __MTD_NFTL_H__ */