fdi_int.h

来自「FDI Intel开发的FLASH文件系统,功能很强大」· C头文件 代码 · 共 1,171 行 · 第 1/4 页

H
1,171
字号
   DWORD  b_frag_hdr_offset;           /* byte offset of frag data header */
   DWORD  b_begin_unit_offset;         /* byte offset of beginning of unit */
   DWORD  b_grp_table_entry_offset;    /* offset into the group table unit */
   DWORD  b_begin_tabl_offset;         /* byte offset of beginning of table */
   DWORD  b_seq_table_entry_offset;    /* offset into the seq table unit */
   DWORD  b_current_file_offset;       /* byte offset into the data         
                                        * stream(file) being accessed */
   DWORD  b_remaining_in_unit;         /* bytes remaining in the data unit */
   IDTYPE identifier;                  /* uniquely identifies param/stream */
   WORD   logical_block;               /* logical block number of block_addr */
   WORD   table_number;                /* used for group table entry in hdr */
   BYTE   type_attribute;              /* type and attribute identifier */  
   BYTE   data_streaming;              /* used to indicate if opened for data 
                                        * streaming */
}
FDI_PACKED(OPEN_PARAM);
/* E.5.0.708 END */

typedef struct GRAN_NEEDED {
   WORD        frag_needed;            /* granularity needed by fragment */
   WORD        seq_needed;             /* granularity needed by sequence */
   WORD        grp_needed;             /* granularity needed by GRP table */
   BYTE        pad1, pad2;             /*pads to make the structure DWORD alligned*/  
} GRAN_NEEDED;
#define TOTALGRAN(x)                 (x.frag_needed+x.seq_needed+x.grp_needed)
#define FDI_ONEGRANGRP_MAX_FRAGS     (MAX_SEQ_ENTRY*MAX_SEQ_ENTRY)
/* E.5.1.759 Begin */
/*
#define FDI_MAX_FRAG_SIZE            (UNIT_GRANULARITY*MAX_NUM_UNITS_PER_FRAG)
*/
/* E.5.1.759 End */
#define TO_SEQTBL(x)                 TO_SIZE(x,MAX_SEQ_ENTRY)

/* E.5.0.708 START */
/* change PACKED to FDI_PACKED */
typedef struct COMMAND {
   DWORD       data_offset;            /* beginning byte offset into data */
   GRAN_NEEDED gran_needed;            /* space needed terms of granularity */
   IDTYPE      identifier;             /* identity of data accessed */ 
   BYTE        sub_command;            /* task execution sub command */
   BYTE        type;                   /* command type: either data parameter,
                                        * data stream, etc. */    
   BYTE        priority;               /* */       
   BYTE        pad1, pad2, pad3;       /*pad to make the structure DWORD alligned*/  
}
FDI_PACKED(COMMAND);
/* E.5.0.708 END */


typedef enum {
   FREE_UNITS = 0,
   DIRTY_UNITS
} FDI_SPACE;


typedef DATA_LOCATION *    DATA_LOC_PTR;
typedef OPEN_PARAM *      OPEN_STREAM_PTR;
typedef COMMAND *          COMMAND_PTR;
typedef UNIT_HEADER *      UNIT_HDR_PTR;
typedef MULTI_INSTANCE *   MULTI_INST_PTR;
typedef BLOCK_INFO *       BLK_INFO_PTR;





/* ### Global Variables
 * ################################# */
extern OPEN_PARAM *  FDI_OpenParamPtr;
extern WORD                FDI_SpareBlock;

/* global defined to track max grp tbl size */
/* E.5.0.660 Begin */
extern WORD FDI_MaxGrpUnit;
/* E.5.0.660 End */

/* ### Global Functions
 * ################################# */

/* usage: status = InitUnit();
 */
ERR_CODE InitUnit(void);

/* usage: status = FDI_Terminate();
 */
HW_ERROR FDI_Terminate(void);
 
/* usage: status = DataFind(id, type, command);
 */
ERR_CODE DataFind(IDTYPE, BYTE, BYTE);

/* usage: status = GetDataSize(&size, id, type, priority);
 */
ERR_CODE GetDataSize(DWORD_PTR, IDTYPE, BYTE, BYTE);

/* Validates the unit header and updates the free_space field of the
 * logical block table, if the unit_header_status is valid.  Invalidates the
 * unit header and updates the dirty_space field of the logical block table,
 * if the unit_header_status is invalid.
 */
ERR_CODE WriteUnitHeaderStatus(DWORD, WORD, WORD, WORD, BYTE);

/* If the unit_header_status is allocated or valid, scans the entire media to
 * see if an valid identifier of same type exists, and return it's address 
 * in invalidating_hdr_addr if
 * it exists, or a NULL if it no valid sequence table unit header exists.
 * If the unit_header_status is allocating, scans the entire media to
 * invalidate all the unit headers of matching identifier that are not marked
 * valid. If the unit_header_status is invalidating, scans the entire media
 * and invalidates the matching unit headers that not marked invalid.
 */

/* usage: status = SearchForIdentifier(&new_unit_header,&old_hdr_addr, 
 *               current_unit_index, current_logical_block, init_flag);
 */
/* E.5.0.652 Begin */
/* E.5.3.877 Start */
ERR_CODE SearchForIdentifier(UNIT_HEADER *, DWORD_PTR, DWORD, WORD, WORD, BYTE, BYTE);
/* E.5.3.877 END */
HW_ERROR FlashDevInvalidateInstance(WORD);
/* E.5.0.652 End */

/* 
 * Checks the currently validated header address with the currently 
 * processed header address and returns either BYTEMAX or 0 to indicate if 
 * the free space, and dirty space fields are already updated or not. 
 */
BYTE CheckAddr(DWORD, WORD, WORD);


/* usage: MemoryMove(&dest_buff, &source_buff, size);
 */
/* E.5.0.652 Begin */
void MemoryMove(BYTE_PTR, BYTE *, WORD);
/* E.5.0.652 End */

/* usage: dest_buff_ptr = MemorySet(&dest_buff, value, size);
 */
BYTE_PTR MemorySet(BYTE_PTR, BYTE, DWORD);

/* usage: equal = MemoryCompare(&dest_buff, &source_buff, size);
 */
/* E.5.0.652 Begin */
BYTE MemoryCompare(BYTE *, BYTE *, DWORD);
/* E.5.0.652 End */

HW_ERROR
ReadModify(BYTE_PTR, DWORD_PTR, DWORD, DWORD, IDTYPE, BYTE, BYTE, BYTE);

/* usage: wr_status = WriteData(buf_ptr, offset, id, size, type, sub_cmd);
 */
HW_ERROR WriteData(BYTE_PTR, DWORD, IDTYPE, WORD, BYTE, BYTE);

/* usage: 
 * hw_status = 
 *    FlashDevFindInstance(&block_addr, &header_offset, &unit_offset, identifier, 
 *                      table_number, instance, logical_block, HDR_VALID,
 *                      type, attribute, command);
 */
extern HW_ERROR FlashDevFindInstance(DWORD_PTR , DWORD_PTR ,DWORD_PTR ,IDTYPE ,WORD ,
                      WORD ,WORD ,WORD ,BYTE ,BYTE ,BYTE );
/* usage: recl_status = RECL_Init();
 */
HW_ERROR RECL_Init(void);

/* usage: recl_status = RECL_Terminate();
 */
HW_ERROR RECL_Terminate(void);

/* usage: bkgd_status = BKGD_Init();
 */
HW_ERROR BKGD_Init(void);

/* usage: bkgd_status = BKGD_Terminate();
 */
HW_ERROR BKGD_Terminate(void);

/* usage: total_space = BKGD_GetTotalSpace(field);
 */
DWORD BKGD_GetTotalSpace(FDI_SPACE field);

/* usage: 
 * hw_status = 
 *    LookupToHeader(&block_addr, &unit_addr, &header_offset, &unit_header, 
 *                   &logical_block, identifier, type); 
 */
HW_ERROR LookupToHeader(DWORD_PTR, DWORD_PTR, DWORD_PTR, UNIT_HDR_PTR, 
                        WORD_PTR, IDTYPE, BYTE);
/*
 * usage:
 * status = BKGD_GetTableEntry(&location, &invalid_grp_entries, 
 *                             &invalid_seq_entries, &grp_entries, 
 *                             &seq_entries, offset, 
 *                             grp_table_size / sizeof(ENTRY_TABLE)); 
 */
HW_ERROR BKGD_GetTableEntry(OPEN_STREAM_PTR, WORD_PTR, BYTE_PTR, WORD_PTR, 
                            BYTE_PTR, DWORD, WORD);

/* usage:
 * 
 */
void
FDI_HandleError(HW_ERROR);

/* usage:
 * recl_state = RECL_GetState();
 */
RECL_STATES RECL_GetState(void);

/* usage:
 * reclaim_block_number = RECL_GetBlock();
 */
WORD RECL_GetBlock(void);
      
/* usage:
 * status = BKGD_CheckForSpace(command_struct_ptr, data_size, foregnd_flag); 
 */  
#if (FREE_SPACE_FUNCTIONS == FALSE)
HW_ERROR BKGD_CheckForSpace(COMMAND_PTR, WORD, BYTE);                                           
#endif   /* FREE_SPACE_FUNCTIONS */

#if (INCLUDE_FRAGMENTED_DATA)
/* E.5.3.877 Start */
/* E.5.5.988 Start */
HW_ERROR BKGD_TruncateTable( DWORD, DWORD, DWORD, DWORD, DWORD, IDTYPE,
                            WORD, WORD, BYTE, BYTE, BYTE);
/* E.5.5.988 END */
/* E.5.3.877 END */
#endif

/* usage:
 * status = RIP_Write(data_ptr, header_addr, unit_addr, offset, data_size); 
 */  
HW_ERROR RIP_Write(BYTE_PTR, DWORD, DWORD, DWORD, WORD);                                           

/* usage:
 * status = RIP_Copy(dest_hdr_addr, dest_unit_addr, src_unit_addr, offset, 
 *                   data_size); 
 */  
HW_ERROR RIP_Copy(DWORD, DWORD, DWORD, DWORD, WORD);                                           

/* usage:
 * status = RIP_SetSpace(header_offset, size, DIRTY_UNITS); 
 *
 */  
/*Changed SPACE to FDI_SPACE to eliminate porting problems*/
HW_ERROR RIP_SetSpace(DWORD, DWORD, WORD, FDI_SPACE);
HW_ERROR BKGD_ReplaceMulti(BYTE_PTR, DWORD, DWORD, DWORD, DWORD, IDTYPE,
                           WORD, WORD, BYTE, BYTE);

#if (FREE_SPACE_FUNCTIONS == TRUE)
typedef  enum {
   NORMAL_CALCCHK = 0,
   AVLSP_GRAN_CALC_ONLY,
   AVLSP_CALC_AND_CHECK
}  SPACECHECK_CODE;
#define FREE_SPFUN_QPRIORITY     FDI_MIN_PRIORITY
/* E.5.1.759 Begin */
/*
 #define MAX_FRAG_SIZE  (UNIT_GRANULARITY*MAX_NUM_UNITS_PER_FRAG)
 */
/* E.5.1.759 End */
#define MAX_APPGRAN    (MAX_QUEUE_ITEM_SIZE/UNIT_GRANULARITY)

/* E.5.0.584 Begin */
/*Removed the unused defines*/
/*E.5.0.584.End*/
  #define MAX_AVAIL_IDENTIFIERS  (NUM_STREAMS-1)

/* E.5.0.707 Begin */
/* rename the original simulate_accum_free , simulate_accum_dirty*/
extern WORD SimulateAccumFree;
extern WORD SimulateAccumDirty;
/* E.5.0.707 End */
extern HW_ERROR BKGD_CheckForSpace(COMMAND_PTR, WORD, BYTE,
                                     SPACECHECK_CODE);
extern WORD GetUnitsAvailable ();

#endif   /* FREE_SPACE_FUNCTIONS */
#define  OBJECT_SIZE    (WORD)(UNIT_GRANULARITY + sizeof(UNIT_HEADER))
/*E.5.0.598.START*/
/*Moved TASK_CREATE_DESTROY and SEM_CREATE_DESTROY to Type.h*/
/*E.5.0.598.END*/

/* E.5.0.690 Begin */ 
/*move from fdi_ext.h */
#define FIRST_HEADER_OFFSET         0
/* E.5.0.690 End */ 
#endif                                 /* sentry */


⌨️ 快捷键说明

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