📄 fdi_int.h
字号:
typedef struct BLOCK_INFO {
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 */
}
BLOCK_INFO;
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;
}
ENTRY_TABLE;
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;
}
LOGICAL_BLOCK;
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*/
}
DATA_LOCATION;
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 */
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 */
}
OPEN_PARAM;
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)
#define FDI_MAX_FRAG_SIZE (UNIT_GRANULARITY*MAX_NUM_UNITS_PER_FRAG)
#define TO_SEQTBL(x) TO_SIZE(x,MAX_SEQ_ENTRY)
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*/
}
COMMAND;
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 */
/* WORD FDI_MaxGrpUnit; */ /* commented by jjs */
extern WORD FDI_MaxGrpUnit; /* added by jjs */
/* ### 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);
*/
ERR_CODE SearchForIdentifier(const UNIT_HEADER *, DWORD_PTR, WORD, WORD, BYTE);
/*
* 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);
*/
void MemoryMove(BYTE_PTR, const BYTE *, WORD);
/* usage: dest_buff_ptr = MemorySet(&dest_buff, value, size);
*/
BYTE_PTR MemorySet(BYTE_PTR, BYTE, DWORD);
/* usage: equal = MemoryCompare(&dest_buff, &source_buff, size);
*/
BYTE MemoryCompare(const BYTE *, const BYTE *, DWORD);
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 */
/* 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
#define MAX_FRAG_SIZE (UNIT_GRANULARITY*MAX_NUM_UNITS_PER_FRAG)
#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)
extern WORD simulate_accum_free;
extern WORD simulate_accum_dirty;
extern HW_ERROR BKGD_CheckForSpace(COMMAND_PTR, WORD, BYTE,
SPACECHECK_CODE);
extern WORD GetUnitsAvailable (void);
#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*/
#endif /* sentry */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -