📄 inftl.h
字号:
#define UNIT_BAD 0x6B
#define UNIT_MAX_COUNT 0x40 /* Largest valid count */
#define DISCARD 0xAA /* Valid used unit signature */
#define CLEAR_DISCARD 0x0 /* Mark unit as discarded */
#define ANAND_BAD_PERCENTAGE 2 /* Maximum bad units */
/* Parity bits for unit header fields */
#define VU_PARITY_BIT 8 /* virtual Unit number */
#define PU_PARITY_BIT 4 /* previous Unit number */
#define ANAC_PARITY_BIT 2 /* ANAC field */
#define NAC_PARITY_BIT 1 /* NAC field */
#define ALL_PARITY_BITS_OK 0xf /* All parity bits */
#define IS_BAD(u) ( u == UNIT_BAD_MOUNT )
/*#define UNIT_BAD_MARKED 7*/
#define MAX_UNIT_SIZE_BITS 15
#define MORE_UNIT_BITS_MASK 3
#define ANAND_NO_UNIT 0xffff
#define ANAND_BAD_CHAIN_UNIT 0xfffe
#define MAX_UNIT_NUM 32768L
/* Block flags */
#define SECTOR_FREE 0xff
#define SECTOR_USED 0x55
#define SECTOR_IGNORE 0x11
#define SECTOR_DELETED 0x00
/* Debug modes flags */
#define INFTL_FAILED_MOUNT 1
#ifdef NFTL_CACHE
/* values for 2-bit entries in Sector Flags cache */
#define S_CACHE_SECTOR_DELETED 0x00
#define S_CACHE_SECTOR_IGNORE 0x01
#define S_CACHE_SECTOR_USED 0x02
#define S_CACHE_SECTOR_FREE 0x03
#define S_CACHE_4_SECTORS_FREE 0xff
#endif /* NFTL_CACHE */
#ifdef NFTL_CACHE
/* Unit Header cache entry, close relative of struct UnitHeader */
typedef struct {
word virtualUnitNo;
word prevUnitNo;
byte ANAC;
byte NAC;
} ucacheEntry; /* See doc2exb.c uses this value */
#endif /* NFTL_CACHE */
/* erase record */
typedef struct {
LEulong eraseCount;
LEushort eraseMark;
LEushort eraseMark1;
} UnitTailer;
/* unit header */
typedef struct {
LEushort virtualUnitNo;
LEushort prevUnitNo;
byte ANAC;
byte NAC;
byte parityPerField;
byte discarded;
} ANANDUnitHeader;
/* Second copy of unitHeader */
typedef struct {
byte parityPerField;
byte ANAC;
LEushort prevUnitNo;
LEushort virtualUnitNo;
byte NAC;
byte junk; /* alignment filed for int - 2 */
} SecondANANDUnitHeader;
/* Medium Boot Record */
typedef struct {
LEmin bootRecordId[2]; /* "BNAND" */
LEmin noOfBootImageBlocks; /* number of good blocks in the boot image area */
LEmin noOfBinaryPartitions; /* number of binary partitions */
LEmin noOfBDTLPartitions; /* number of BDTL partitions */
LEmin blockMultiplierBits; /* number of bits used to represent the
times a flash erasable block fits inside
an INFTL erasable unit. */
LEmin formatFlags; /* QUICK_MOUNT */
LEmin osakVersion; /* version of osak used to format the media */
LEmin percentUsed;
} BNANDBootRecord;
/* Volume record */
typedef struct {
LEmin virtualUnits; /* Virtual size exported by the trasnaltion layer */
LEmin firstUnit; /* First unit of the partition */
LEmin lastUnit; /* Last unit of the partition */
LEmin flags; /* PROTECTABLE,CHANGEABLE_PROTECTION,INFTL_BINARY,INFTL_BDTL,INFTL_LAST */
LEmin spareUnits; /* Number of spare garanteed units for INFTL partition */
LEmin firstQuickMountUnit; /* first unit used for the quick mount data */
LEmin protectionArea; /* Number of protection area */
} BNANDVolumeHeaderRecord;
#ifndef FL_MALLOC
#define ANAND_HEAP_SIZE (0x100000l / ASSUMED_NFTL_UNIT_SIZE) * (sizeof(ANANDUnitNo) + sizeof(ANANDPhysUnit)) * MAX_VOLUME_MBYTES
#ifdef NFTL_CACHE
#define U_CACHE_SIZE ((MAX_VOLUME_MBYTES * 0x100000l) / ASSUMED_NFTL_UNIT_SIZE)
#define S_CACHE_SIZE ((MAX_VOLUME_MBYTES * 0x100000l) / (SECTOR_SIZE * 4))
#endif
#endif /* FL_MALLOC */
#define WLnow 0xfff0
typedef struct {
word alarm;
ANANDUnitNo currUnit;
} WLdata;
struct tTLrec{
FLFlash *flash; /* Poniter to MTD record */
dword *verifyBuffer; /* Pointer to socket verify buffer */
FLBuffer *buffer; /* Pointer to socket buffer */
ANANDPhysUnit FAR1 *physicalUnits; /* unit table by physical no. */
ANANDUnitNo FAR1 *virtualUnits; /* unit table by logical no. */
const void FAR0 *mappedSector;
#ifdef NFTL_CACHE
ucacheEntry FAR1 *ucache; /* Unit Header cache */
byte FAR1 *scache; /* Sector Flags cache */
#endif
#ifndef FL_MALLOC
char* heap;
#endif /* FL_MALLOC */
CardAddress mappedSectorAddress;
/* Accumulated statistics. */
Sdword sectorsRead,
sectorsWritten,
sectorsDeleted,
parasiteWrites,
unitsFolded;
WLdata wearLevel;
dword eraseSum;
#ifdef NFTL_CACHE
dword firstUnitAddress; /* address of the first unit of the volume */
#endif /* NFTL_CACHE */
ANANDUnitNo firstQuickMountUnit; /* The quick mount first unit */
ANANDUnitNo firstUnit; /* first unit number of the volume */
ANANDUnitNo freeUnits; /* Free units on media */
ANANDUnitNo noOfVirtualUnits; /* No of units exported by the TL */
ANANDUnitNo noOfUnits; /* No of units in the partition */
ANANDUnitNo bootUnits; /* No of boot units of the media */
ANANDUnitNo roverUnit; /* Starting point for allocation search */
ANANDUnitNo countsValid; /* Number of units for which unit count was set */
word sectorsPerUnit; /* Number of 512 bytes in a unit */
word sectorsPerUnitBits; /* Bits used for no of sectors per unit */
word sectorsPerUnitMask; /* Number of 512 bytes in a unit - 1 */
SectorNo virtualSectors; /* No of sectors exported by the TL */
SectorNo mappedSectorNo; /* Currently mapped sector */
#if (defined(VERIFY_WRITE) || defined (VERIFY_VOLUME) || defined(VERIFY_ERASED_SECTOR))
SectorNo verifiedSectorNo; /* Largest sector verified so far */
SectorNo curSectorWrite; /* Current update sector */
#endif /* VERIFY_WRITE || VERIFY_VOLUME || VERIFY_ERASED_SECTOR */
byte flags; /* QUICK_MOUNT or not */
byte socketNo; /* The volumes socket serial number */
byte blockMultiplierBits; /* the number of ersable blocks in */
/* an INFTL unit */
byte erasableBlockSizeBits; /* log2 of erasable block size */
byte unitSizeBits; /* log2 of TL unit size */
FLBoolean firstMediaWrite;
#ifdef CHECK_MOUNT
dword debugState; /* Used for internal debug */
#endif /* CHECK_MOUNT */
ANANDUnitNo quickMountBB;
};
typedef TLrec Bnand;
typedef struct {
dword freeUnits;
dword roverUnit;
dword countsValid;
dword sectorsRead;
dword sectorsWritten;
dword sectorsDeleted;
dword parasiteWrites;
dword unitsFolded;
dword wearLevel_1;
dword wearLevel_2;
dword eraseSum;
dword validate; /* QUICK_MOUNT_VALID_SIGN */
dword checksum; /* checksum of entire quick mount info should be 55 */
dword verifiedSectorNo; /* Largest sector verified so far */
}savedBnand;
#define VALIDATE_OFFSET 11*sizeof(LEmin)
#define inftlBuffer vol.buffer->flData
#endif /* INFTL_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -