fdi_int.h
来自「FDI Intel开发的FLASH文件系统,功能很强大」· C头文件 代码 · 共 1,171 行 · 第 1/4 页
H
1,171 行
/*
* multiple instance status types
*/
#define INST_EMPTY 0xFF
#define INST_ALLOCATING 0xFC
#define INST_VALID 0xF0
#define INST_INVALID 0xC0
#define INVALIDATE_INST 0xCF
#define INVALID_INST(status) (((status) & 0x20) == 0)
/* INST_READ_MASK is used to mask the higher status bit of each status cell
* during status read. INST_STATE returns 1 if the status is in this state,
* otherwise 0. */
#define INST_READ_MASK 0xAA
#define INST_STATE(state, status) (((status) & INST_READ_MASK) == \
((state) & INST_READ_MASK))
/* To determine if a status is in an intermediate state, the status can be
* shifted 1 bit and exclusive-or'd with itself to overlay each cell's bits
* over each other to determine if the cell was '10' or '01'.
* INST_INTERMEDIATE_MASK is used to mask the exclusive-or'd cell status bits
* from the shift. INST_INTERMEDIATE returns a non-zero value if the status
* is in an intermediate state. The non-zero return value can be passed as
* inter into INST_FIX_INTERMEDIATE with status to return the fixed status. */
#define INST_INTERMEDIATE_MASK 0xAA
#define INST_INTERMEDIATE(status) (((status) ^ ((status) << 1)) & \
INST_INTERMEDIATE_MASK)
#define INST_FIX_INTERMEDIATE(inter, status) ((~((inter) | ((inter) >> 1))) \
& (status))
#define GetBitStatus(data, bit) (data & (1 << bit))
#define SetBitStatus(data, bit) (data = (data | (1 << bit)))
#define ClearBitStatus(data, bit) (data = (data & ~(1 << bit)))
/*
* block status types
*/
#define BLK_ERASED 0xFF
#define BLK_RECOVER 0xFC
#define BLK_ERASING 0xF0
#define BLK_UPDATING 0xC0
#define BLK_WRITE 0x00
/* BLK_READ_MASK is used to mask the higher status bit of each status cell
* during status read. BLK_STATE returns 1 if the status is in this state,
* otherwise 0. */
#define BLK_READ_MASK 0xAA
#define BLK_STATE(state, status) (((status) & BLK_READ_MASK) == \
((state) & BLK_READ_MASK))
/* To determine if a status is in an intermediate state, the status can be
* shifted 1 bit and exclusive-or'd with itself to overlay each cell's bits
* over each other to determine if the cell was '10' or '01'.
* BLK_INTERMEDIATE_MASK is used to mask the exclusive-or'd cell status bits
* from the shift. BLK_INTERMEDIATE returns a non-zero value if the status
* is in an intermediate state. The non-zero return value can be passed as
* inter into BLK_FIX_INTERMEDIATE with status to return the fixed status. */
#define BLK_INTERMEDIATE_MASK 0xAA
#define BLK_INTERMEDIATE(status) (((status) ^ ((status) << 1)) & \
BLK_INTERMEDIATE_MASK)
#define BLK_FIX_INTERMEDIATE(inter, status) ((~((inter) | ((inter) >> 1))) \
& (status))
/*
* unit header type_attribute attributes
*/
#define ATTR_MULTI_INST 0x0c
#define ATTR_SEQ_TABLE 0x00
#define ATTR_GRP_TABLE 0x0d
#define ATTR_SINGL_INST 0x0e
#define ATTR_DATA_FRAG 0x02
/*
* Attribute mask
*/
#define ATTRIBUTE_MASK 0x0f
/*
* erase count identifier
*/
#define ERASE_COUNT_ID (NUM_TYPE14_PARMS)
#define ERASE_COUNT_TYPE 14
/* additions for write commands */
#define WRITE_DELETE 4 /* delete the data from FDI */
/* commands for FindInstance function */
#define FIND_INSTANCE 0
#define FIND_LAST_HEADER 1
/* To indicate that power loss recovery occurred during initialization. */
#define DELETE_IN_PROG 0x01
#define WRITE_IN_PROG 0x02
#define HDR_VALIDATION_IN_PROG 0x04
#define RECL_COPY_IN_PROG 0x08
#define RECL_ERASE_IN_PROG 0x10
#define UPDATE_IN_PROG 0x12
#define READ_DATA 0x01
#define MODIFY_DATA 0x02
#define DATA_BOTTOM ((DWORD)(FDV_BLOCK_SIZE - sizeof(BLOCK_INFO)))
#define INITIAL_FREE ((DWORD)(DATA_BOTTOM - sizeof(UNIT_HEADER) - \
FIRST_HEADER_OFFSET));
#define BLKINFO (DATA_BOTTOM)
#define BLKINFO_STATUS ((DWORD)(DATA_BOTTOM + offsetof(BLOCK_INFO, status)))
#define BLKINFO_STATE ((DWORD)(DATA_BOTTOM + offsetof(BLOCK_INFO, current_state)))
#define BLKINFO_PHYCPY ((DWORD)(DATA_BOTTOM + offsetof(BLOCK_INFO, physical_copy)))
#define BLKINFO_LOGBLK ((DWORD)(DATA_BOTTOM + offsetof(BLOCK_INFO, logical_block_number)))
#define BLKINFO_ERASCNT ((DWORD)(DATA_BOTTOM + offsetof(BLOCK_INFO, erase_count)))
#define BLKINFO_PHYSCNT ((DWORD)(DATA_BOTTOM + offsetof(BLOCK_INFO, physical_erase_count)))
/* Default Table Number Defines */
#define SEQUENCE_HDR_TABLE_NUMBER 0
/* First Instance Number Count */
#define FIRST_INSTANCE_NUMBER 1
/* ### Data Type Definitions:
* ######################################################################## */
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
/* Header corruption structure */
typedef struct CORRUPT_HDR {
WORD Id; /* Header's identifier field */
WORD Block; /* Header logical block number */
WORD Index; /* Header index into block */
WORD TblNum; /* Header's table number field */
BYTE TypAttr; /* Header's type/attribute field */
BYTE Exists; /* Corruption counter */
BYTE Valid; /* True if a valid header is found w/ same identity */
BYTE Rescan; /* Header scan control */
}
FDI_PACKED(CORRUPT_HDR);
/* E.5.0.708 END */
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct RECL_INFO {
DWORD erase_cnt; /* Erase count of block in updating state. */
DWORD erase_hdr_addr; /* Erase count header address. */
DWORD updating_blk_addr; /* Block found in reclaim updating state */
}
FDI_PACKED(RECL_INFO);
/* E.5.0.708 END */
/* Reclamation State Enumerations
*/
typedef enum {
RECL_DISABLED = 0,
RECL_ENABLED,
RECL_BLK_FOUND,
RECL_RECOVERING,
RECL_ERASING,
RECL_DONE,
RECL_BAILED
} RECL_STATES;
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct DATA_LOOKUP {
WORD logical_blk_num; /* logical block number of the data */
#if (CONSISTENT_ACCESS_TIME == TRUE)
WORD hdr_index; /* index number for the header of
* the data */
#endif
BYTE open_stream_index; /* index of FDI_OpenParam table */
BYTE paraExist; /* 0: the data exists;
* other value: the data doesn't exist */
BYTE delete_pending; /* flag to indicate a background delete */
#if (CONSISTENT_ACCESS_TIME == TRUE)
BYTE pad1; /* for DWORD alignment */
#else
BYTE pad1, pad2, pad3;
#endif
}
FDI_PACKED(DATA_LOOKUP);
/* E.5.0.708 END */
typedef DATA_LOOKUP * DATA_LOOKUP_PTR;
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct UNIT_HEADER {
WORD identifier; /* unique identity per parameter */
WORD table_number; /* sequence table number of instance */
WORD g_unit_size; /* in multiples of granularity */
WORD g_unit_offset_bottom; /* in granularities from top of the
* block information */
BYTE type_attribute; /* data type and unit attribute:
* multiple instance, single instance,
* sequence table, etc. */
BYTE pad1; /* 1 byte-expansion of type and
* attribute
* to separate bytes */
WORD status; /* power loss recovery status field
* expanded to a word */
}
FDI_PACKED(UNIT_HEADER);
/* E.5.0.708 END */
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct MULTI_INSTANCE {
WORD size_of_instance; /* size of this instance of the data */
WORD number_of_instances; /* number of data instances available
* in this unit */
}
FDI_PACKED(MULTI_INSTANCE);
/* E.5.0.708 END */
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct BLOCK_INFO {
/* E.5.5.937 Begin */
#if (BUFFER_SIZE > 0)
BYTE pad1[BUFFER_SIZE-16];
#endif
/* E.5.5.937 End */
DWORD erase_count; /* number of times erased */
DWORD physical_erase_count; /* number of times the reclaim block is
* erased */
WORD logical_block_number; /* allows for movable spare block */
WORD physical_copy; /* physical block number being
* copied during reclamation */
WORD current_state; /* this will demonstrate block
* integrity */
BYTE status; /* reclamation information */
BYTE reserved_byte; /* padding for data alignment */
}
FDI_PACKED(BLOCK_INFO);
/* E.5.0.708 END */
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct ENTRY_TABLE {
WORD block_number; /* virtual block number */
WORD entry_instance; /* the instance of this frag/table */
WORD old_entry_block; /* replaced entry's logical block # */
WORD physical_index; /* the physical unit header index of
* the header that needs to be
* invalidated. */
WORD entry_size; /* in multiples of granularity */
BYTE entry_status; /* table entry status byte - POR */
BYTE pad1;
}
FDI_PACKED(ENTRY_TABLE);
/* E.5.0.708 END */
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct LOGICAL_BLOCK {
DWORD free_space; /* the amount of free space in the
* physical block in multiple DWORDs */
DWORD dirty_space; /* the amount of invalid space in the
* physical block in multiple DWORDs */
WORD physical_block_number; /* physical block identifier */
WORD last_header_offset;
}
FDI_PACKED(LOGICAL_BLOCK);
/* E.5.0.708 END */
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct DATA_LOCATION {
IDTYPE identifier; /* identity of data accessed */
BYTE type_attribute; /* data and unit type / attributes
* accessed */
BYTE pad1; /*pad to make the structure DWORD alligned*/
}
FDI_PACKED(DATA_LOCATION);
/* E.5.0.708 END */
/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct OPEN_PARAM { /*MOF*/
DWORD block_addr; /* the first address of the block */
DWORD tabl_block_addr; /* first address of block containing
* the sequence table unit */
DWORD frag_block_addr; /* first address of block containing
* fragment */
DWORD b_total_size; /* number of bytes written total */
DWORD b_unit_size; /* data unit size in terms of bytes */
DWORD b_hdr_offset; /* offset of the unit header */
DWORD b_tabl_hdr_offset; /* byte offset of seq table header */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?