⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fdi_int.h

📁 Flash file system
💻 H
📖 第 1 页 / 共 4 页
字号:

#if (INCLUDE_FRAGMENTED_DATA == TRUE)
/* threshold in bytes = 2688 */
#define  FDI_THRESHOLD ((MAX_THRESHOLD_UNIT*UNIT_GRANULARITY)+\
                   UNIT_GRANULARITY+sizeof(UNIT_HEADER))
                                       /* for replacing wearleveling parameter 
                                        * unit and it's header. This defines 
                                        * the absolute free space limit before 
                                        * the background task pends on reclaim 
                                        */
#else

/* threshold in bytes */
#define  FDI_THRESHOLD (((MAX_NUM_UNITS_PER_FRAG*MAX_DATA_BLOCKS)*\
UNIT_GRANULARITY)+sizeof(UNIT_HEADER)+(UNIT_GRANULARITY+sizeof(UNIT_HEADER)))
#endif /* INCLUDE_FRAGMENTED_DATA */

#endif /* !DATA_STREAM */

#if ((INCLUDE_FRAGMENTED_DATA == TRUE) && (DATA_STREAM == FALSE))
#define MAX_DATA_SIZE (((MAX_MEDIA_FRAG-MAX_SEQ_UNIT-FDI_MaxGrpUnit)*\
UNIT_GRANULARITY)-FDI_THRESHOLD)
#endif

#if ((INCLUDE_FRAGMENTED_DATA == TRUE) && (DATA_STREAM == TRUE))
#define MAX_DATA_SIZE ((MAX_MEDIA_FRAG-MAX_SEQ_UNIT-FDI_MaxGrpUnit)*\
UNIT_GRANULARITY)
#endif

#if (INCLUDE_FRAGMENTED_DATA == FALSE)
#define MAX_DATA_SIZE (MAX_MEDIA_SIZE-FDI_THRESHOLD)
#endif


#define  MAX_HEADERS    ((FDV_BLOCK_SIZE - sizeof(BLOCK_INFO)) / \
                         sizeof(UNIT_HEADER))

/* make sure if the block lock support is disabled all defines are false */
#if (BLOCK_LOCK_SUPPORT == FALSE)
#undef ENABLE_NONFDI_BLOCKLOCKING
#undef ENABLE_FDI_BLOCKLOCKING
#define ENABLE_NONFDI_BLOCKLOCKING  FALSE
#define ENABLE_FDI_BLOCKLOCKING     FALSE
#endif /* BLOCK_LOCK_SUPPORT */

/* 
 * unit header status types. Changed for ISF to take bits down from right 
   to left
 */
#define  HDR_EMPTY                0xFFFF
#define  HDR_ALLOCATING           0xFFFC
#define  HDR_VALID_HDR            0xFFF0
#define  HDR_ALLOCATED            0xFFC0
#define  HDR_VALID                0xFF00
#define  HDR_INVALIDATING         0xFC00
#define  HDR_INVALID              0xF000

#define  HDR_CORRUPT(status)      ((((status) & HDR_INVALID) != HDR_INVALID) ? 1:0 )
#define  INVALIDATE_HDR           0xF3FF
#define  INVALID_HDR(status)      (((status) & 0x0800) == 0)

/* HDR_READ_MASK is used to mask the higher status bit of each status cell
 * during status read.  HDR_STATE returns 1 if the status is in this state,
 * otherwise 0. */
#define  HDR_READ_MASK                      0xFAAA
#define  HDR_STATE(state, status)           (((status) & HDR_READ_MASK) == \
                                             ((state) & HDR_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'.
 * HDR_INTERMEDIATE_MASK is used to mask the exclusive-or'd cell status bits
 * from the shift.  HDR_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 HDR_FIX_INTERMEDIATE with status to return the fixed status. */
#define  HDR_INTERMEDIATE_MASK               0x0AAA
#define  HDR_INTERMEDIATE(status)            (((status) ^ ((status) << 1)) & \
                                              HDR_INTERMEDIATE_MASK)
#define  HDR_FIX_INTERMEDIATE(inter, status) ((~((inter) | ((inter) >> 1))) \
                                              & (status))

/* 
 * sequence table status types
 */
#define  SEQ_EMPTY                0xFF
#define  SEQ_ALLOCATING           0xFC
#define  SEQ_VALID_ENTRY          0xF0
#define  SEQ_VALID                0xC0
#define  SEQ_INVALID              0x00
#define  GRP_EMPTY                SEQ_EMPTY
#define  GRP_ALLOCATING           SEQ_ALLOCATING
#define  GRP_VALID_ENTRY          SEQ_VALID_ENTRY
#define  GRP_VALID                SEQ_VALID
#define  GRP_INVALID              SEQ_INVALID

#define  INVALIDATE_ENTRY         0x3F
#define  INVALID_ENTRY(status)    (((status) & 0x80) == 0)

/* ENTRY_READ_MASK is used to mask the higher status bit of each status cell
 * during status read.  ENTRY_STATE returns 1 if the status is in this state,
 * otherwise 0. */
#define  ENTRY_READ_MASK                    0xAA
#define  ENTRY_STATE(state, status)         (((status) & ENTRY_READ_MASK) == \
                                             ((state) & ENTRY_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'.
 * ENTRY_INTERMEDIATE_MASK is used to mask the exclusive-or'd cell status bits
 * from the shift.  ENTRY_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 ENTRY_FIX_INTERMEDIATE with status to return the fixed status. */
#define  ENTRY_INTERMEDIATE_MASK               0xAA
#define  ENTRY_INTERMEDIATE(status)            (((status) ^ ((status) << 1)) & \
                                                ENTRY_INTERMEDIATE_MASK)
#define  ENTRY_FIX_INTERMEDIATE(inter, status) ((~((inter) | ((inter) >> 1))) \
                                                & (status))

/*
 * Mask to check the reclamation status and queue status. 
 */
#define  RECLAIM_PENDING          0x01
#define  QUEUE_PENDING            0x02

/*
 * 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))

/*
 * 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)))


/* ### Data Type Definitions:                             
 * ######################################################################## */

/* 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 */
}
CORRUPT_HDR;

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 */
}
RECL_INFO;

/* Reclamation State Enumerations
 */
typedef enum {
   RECL_DISABLED = 0,
   RECL_ENABLED,
   RECL_BLK_FOUND,
   RECL_RECOVERING,
   RECL_ERASING,
   RECL_DONE,
   RECL_BAILED
} RECL_STATES;


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
                                        */
#if (CONSISTENT_ACCESS_TIME == TRUE)
   BYTE pad1, pad2;                    /* for DWORD alignment */
#endif
}
DATA_LOOKUP;
typedef DATA_LOOKUP * DATA_LOOKUP_PTR;

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 */
}
UNIT_HEADER;

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 */
}
MULTI_INSTANCE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -