davfhdr.c
来自「FDI Intel开发的FLASH文件系统,功能很强大」· C语言 代码 · 共 1,522 行 · 第 1/4 页
C
1,522 行
### absorbed.
###
### RETURNS:
### None.
###*/
ERR_CODE FHDR_AbsorbingHeaderInFlash(FDI_Handle aHandle,
HDR_FixedHeaderPtr aHeaderPtr)
{
ERR_CODE status = ERR_NONE;
/* read the entire fixed header from flash */
status = FLASH_ReadBuffer((UINT32)aHandle,
(UINT8*)aHeaderPtr,
sizeof(HDR_FixedHeader));
ExitOnError(status);
/* Set absorb status to absorbing in returned fixed header */
FHDR_SetAbsorbStatus(aHeaderPtr, HDR_ABSORBING);
/* Write the absorb status back to flash */
/* E5.5.979 START */
status = FLASH_WriteBuffer((UINT32)&(((HDR_FixedHeaderPtr)aHandle)->Attr2),
(UINT8*)&(aHeaderPtr->Attr2),
sizeof(aHeaderPtr->Attr2));
/* E5.5.979 END */
ExitOnError(status);
return status;
}
/*#################################################################
### FHDR_AbsorbedHeaderInFlash
###
### DESCRIPTION:
### This function will change the header in flash, pointed to
### by handle, to absorbed.
###
### PARAMETERS:
### aHandle - Handle to a header in flash.
### aHeaderPtr - IN: Pointer to a header that must have the
### valid existing attributes field.
### OUT: The absorb status will be modified to
### absorbed.
###
### RETURNS:
### None.
###*/
ERR_CODE FHDR_AbsorbedHeaderInFlash(FDI_Handle aHandle,
HDR_FixedHeaderPtr aHeaderPtr)
{
ERR_CODE status = ERR_NONE;
/* read the entire fixed header from flash */
status = FLASH_ReadBuffer((UINT32)aHandle,
(UINT8*)aHeaderPtr,
sizeof(HDR_FixedHeader));
ExitOnError(status);
/* Set absorb status to absorbed in returned fixed header */
FHDR_SetAbsorbStatus(aHeaderPtr, HDR_ABSORBED);
/* Write the absorb status back to flash */
/* E5.5.979 START */
status = FLASH_WriteBuffer((UINT32)&(((HDR_FixedHeaderPtr)aHandle)->Attr2),
(UINT8*)&(aHeaderPtr->Attr2),
sizeof(aHeaderPtr->Attr2));
/* E5.5.979 END */
ExitOnError(status);
return status;
}
/*#################################################################
### FHDR_AuthenticateHeader
###
### DESCRIPTION:
### This function will check the header referenced in the
### obj_info structure, check it, and determine its state to
### see if it is header.
###
### PARAMETERS:
### aHeaderPtr - IN: header to authenticate
### OUT: Same as in.
###
### RETURNS:
### The status of the header based on the contents.
###*/
HDR_Status FHDR_AuthenticateHeader(HDR_FixedHeaderPtr aHeaderPtr)
{
HDR_Status status = HDR_STATUS_NoHeader;
if (aHeaderPtr->Attr1 != 0xFFFFFFFF || aHeaderPtr->Attr2 != 0xFFFFFFFF)
{
status = HDR_STATUS_FixedHeaderUsed;
if (FHDR_GetHeaderStatus(aHeaderPtr) == HDR_HEADER_VALID)
{
status = HDR_STATUS_FixedHeaderComplete;
/* if the header allocation status is not in a bad state */
if (FHDR_GetAllocationStatus(aHeaderPtr) != HDR_ALLOC_BAD)
{
status = HDR_STATUS_Authentic;
}
}
}
return(status);
}
/*#################################################################
### FHDR_SetHeaderIndexOffset
###
### DESCRIPTION:
### This function will set the header index offset in the
### fixed header to the specified value.
###
### PARAMETERS:
### aHeaderPtr - IN: aHeaderPtr to fixed header
### OUT: aHeaderPtr with header index offset set
### value - IN: value of header index offset
###
### RETURNS:
### None.
###*/
void FHDR_SetHeaderIndexOffset(HDR_FixedHeaderPtr aHeaderPtr,
UINT32 value)
{
aHeaderPtr->Attr1 = HDR_SetHeaderIndexOffset(aHeaderPtr->Attr1, value);
}
/*#################################################################
### FHDR_GetHeaderIndexOffset
###
### DESCRIPTION:
### This function will return the header index offset from the
### fixed header.
###
### PARAMETERS:
### aHeaderPtr - IN: aHeaderPtr to fixed header
### OUT: header index offset
###
### RETURNS:
### None.
###*/
UINT32 FHDR_GetHeaderIndexOffset(HDR_FixedHeaderPtr aHeaderPtr)
{
return HDR_GetHeaderIndexOffset(aHeaderPtr->Attr1);
}
/*#################################################################
### FHDR_SetReallocationStatus
###
### DESCRIPTION:
### This function will set the reallocation status in the
### fixed header to the specified value.
###
### PARAMETERS:
### aHeaderPtr - IN: aHeaderPtr to fixed header
### OUT: aHeaderPtr with reallocation status set
### value - IN: value of reallocation status
###
### RETURNS:
### None.
###*/
void FHDR_SetReallocationStatus(HDR_FixedHeaderPtr aHeaderPtr,
HDR_ReallocationStatusEnum value)
{
aHeaderPtr->Attr1 = HDR_SetReallocationStatus(aHeaderPtr->Attr1, value);
}
/*#################################################################
### FHDR_GetReallocationStatus
###
### DESCRIPTION:
### This function will return the reallocation status from the
### fixed header.
###
### PARAMETERS:
### aHeaderPtr - IN: aHeaderPtr to fixed header
### OUT: header index offset
###
### RETURNS:
### None.
###*/
HDR_ReallocationStatusEnum FHDR_GetReallocationStatus(HDR_FixedHeaderPtr aHeaderPtr)
{
return HDR_GetReallocationStatus(aHeaderPtr->Attr1);
}
/*#################################################################
### FHDR_SetAllocationStatus
###
### DESCRIPTION:
### This function will set the allocation status to value
### in the fixed header.
###
### PARAMETERS:
### obj_info_ptr - IN: aHeaderPtr to fixed header
### OUT: aHeaderPtr with allocation status set
### value - IN: value of allocation status
###
### RETURNS:
### None.
###*/
void FHDR_SetAllocationStatus(HDR_FixedHeaderPtr aHeaderPtr,
HDR_AllocationStatusEnum value)
{
aHeaderPtr->Attr1 = HDR_SetAllocationStatus(aHeaderPtr->Attr1, value);
}
/*#################################################################
### FHDR_GetHeaderIndexOffset
###
### DESCRIPTION:
### This function will return the header index offset from the
### fixed header.
###
### PARAMETERS:
### aHeaderPtr - IN: aHeaderPtr to fixed header
### OUT: header index offset
###
### RETURNS:
### None.
###*/
HDR_AllocationStatusEnum FHDR_GetAllocationStatus(HDR_FixedHeaderPtr aHeaderPtr)
{
return HDR_GetAllocationStatus(aHeaderPtr->Attr1);
}
/*#################################################################
### FHDR_SetSize
###
### DESCRIPTION:
### This function will set the object size in the
### fixed header to the specified value.
###
### PARAMETERS:
### obj_info_ptr - IN: aHeaderPtr to fixed header
### OUT: aHeaderPtr with object size set
### value - IN: value of object size (in pages)
###
### RETURNS:
### None.
###*/
void FHDR_SetSize(HDR_FixedHeaderPtr aHeaderPtr,
UINT32 value)
{
aHeaderPtr->Attr2 = HDR_SetSize(aHeaderPtr->Attr2, value);
}
/*#################################################################
### FHDR_GetHeaderIndexOffset
###
### DESCRIPTION:
### This function will return the header index offset from the
### fixed header.
###
### PARAMETERS:
### aHeaderPtr - IN: aHeaderPtr to fixed header
### OUT: header index offset
###
### RETURNS:
### None.
###*/
UINT32 FHDR_GetSize(HDR_FixedHeaderPtr aHeaderPtr)
{
return HDR_GetSize(aHeaderPtr->Attr2);
}
/*#################################################################
### FHDR_SetType
###
### DESCRIPTION:
### This function will set the type in the
### fixed header to the specified value.
###
### PARAMETERS:
### obj_info_ptr - IN: aHeaderPtr to fixed header
### OUT: aHeaderPtr with type set
### value - IN: value of type
###
### RETURNS:
### None.
###*/
void FHDR_SetType(HDR_FixedHeaderPtr aHeaderPtr,
FDI_HT_ObjectTypeEnum value)
{
aHeaderPtr->Attr2 = HDR_SetType(aHeaderPtr->Attr2, value);
}
/*#################################################################
### FHDR_GetHeaderIndexOffset
###
### DESCRIPTION:
### This function will return the header index offset from the
### fixed header.
###
### PARAMETERS:
### aHeaderPtr - IN: aHeaderPtr to fixed header
### OUT: header index offset
###
### RETURNS:
### None.
###*/
FDI_HT_ObjectTypeEnum FHDR_GetType(HDR_FixedHeaderPtr aHeaderPtr)
{
return HDR_GetType(aHeaderPtr->Attr2);
}
/*#################################################################
### FHDR_SetAbsorbStatus
###
### DESCRIPTION:
### This function will set the absorb status in the
### fixed header to the specified value.
###
### PARAMETERS:
### obj_info_ptr - IN: aHeaderPtr to fixed header
### OUT: aHeaderPtr with header status set
### value - IN: value of header status
###
### RETURNS:
### None.
###*/
void FHDR_SetAbsorbStatus(HDR_FixedHeaderPtr aHeaderPtr, HDR_AbsorbStatusEnum value)
{
aHeaderPtr->Attr2 = HDR_SetAbsorbStatus(aHeaderPtr->Attr2, value);
}
/*#################################################################
### FHDR_GetAbsorbStatus
###
### DESCRIPTION:
### This function will return the header status from the
### fixed header.
###
### PARAMETERS:
### aHeaderPtr - IN: aHeaderPtr to fixed header
### OUT: header index offset
###
### RETURNS:
### None.
###*/
HDR_AbsorbStatusEnum FHDR_GetAbsorbStatus(HDR_FixedHeaderPtr aHeaderPtr)
{
return HDR_GetAbsorbStatus(aHeaderPtr->Attr2);
}
/*#################################################################
### FHDR_SetHeaderStatus
###
### DESCRIPTION:
### This function will set the header status in the
### fixed header to the specified value.
###
### PARAMETERS:
### obj_info_ptr - IN: aHeaderPtr to fixed header
### OUT: aHeaderPtr with header status set
### value - IN: value of header status
###
### RETURNS:
### None.
###*/
void FHDR_SetHeaderStatus(HDR_FixedHeaderPtr aHeaderPtr,
HDR_HeaderStatusEnum value)
{
aHeaderPtr->Attr2 = HDR_SetHeaderStatus(aHeaderPtr->Attr2, value);
}
/*#################################################################
### FHDR_GetHeaderStatus
###
### DESCRIPTION:
### This function will return the header status from the
### fixed header.
###
### PARAMETERS:
### aHeaderPtr - IN: aHeaderPtr to fixed header
### OUT: header index offset
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?