davfhdr.h
来自「FDI Intel开发的FLASH文件系统,功能很强大」· C头文件 代码 · 共 320 行
H
320 行
/* Copyright (c) 1995-2004 Intel Corporation */
/* Intel Confidential */
/* ###########################################################################
### DAV - Direct Access Volume Enhancement to FDI
###
### Module: davfhdr.h - DAV Header Types & Macros Include File
###
### $Workfile: davfhdr.h $
### $Revision: 7 $
### $NoKeywords: $
########################################################################### */
/*
*****************************************************************
* NOTICE OF LICENSE AGREEMENT
*
* This code is provided by Intel Corp., and the use is governed
* under the terms of a license agreement. See license agreement
* for complete terms of license.
*
* YOU MAY ONLY USE THE SOFTWARE WITH INTEL FLASH PRODUCTS. YOUR
* USE OF THE SOFTWARE WITH ANY OTHER FLASH PRODUCTS IS EXPRESSLY
* PROHIBITED UNLESS AND UNTIL YOU APPLY FOR, AND ARE GRANTED IN
* INTEL'S SOLE DISCRETION, A SEPARATE WRITTEN SOFTWARE LICENSE
* FROM INTEL LICENSING ANY SUCH USE.
*****************************************************************
*/
#ifndef __dav_fixed_header_h /* sentry header */
#define __dav_fixed_header_h
#if (DIRECT_ACCESS_VOLUME == TRUE)
/*########################################################################*/
/*### Fixed Header macros and types */
#define HDR_InitHeaderAttr1(attr1) (attr1 = 0xFFFFFFFF)
#define HDR_InitHeaderAttr2(attr2) (attr2 = 0xFFFFFFFF)
/* VALUES, MASKS, AND MACROS FOR ATTR1 IN FIXED HEADER */
/* Attr1: header index/offset (22 bits), reallocation status (2 bits), allocation status (8 bits) */
/* values for header index/offset */
typedef enum
{
HDR_INDEX_OFFSET_UNUSED = 0xFFFFFF
} HDR_HeaderIndexOffsetEnum;
/* mask for header index/offset */
#define HDR_MASK_HeaderIndexOffset ((UINT32)(0xFFFFFC00))
/* macros to set/get header index/offset */
#define HDR_GetHeaderIndexOffset(Attr1) \
((Attr1 & HDR_MASK_HeaderIndexOffset) >> 10)
#define HDR_SetHeaderIndexOffset(Attr1, value) \
((Attr1 & ~HDR_MASK_HeaderIndexOffset) | (value << 10))
/* values for reallocation status */
typedef enum
{
HDR_REALLOC_BACKUP_NOT_COMPLETE = 3,
HDR_REALLOC_BACKUP_COMPLETE = 0
} HDR_ReallocationStatusEnum;
/* mask for reallocation status */
#define HDR_MASK_ReallocationStatus ((UINT32)(0x00000300))
/* macros to set/get reallocation status */
#define HDR_GetReallocationStatus(Attr1) \
((Attr1 & HDR_MASK_ReallocationStatus) >> 8)
#define HDR_SetReallocationStatus(Attr1, value) \
((Attr1 & ~HDR_MASK_ReallocationStatus) | (value << 8))
/* values for allocation status */
typedef enum
{
HDR_ALLOC_EMPTY = 0xFF,
HDR_ALLOC_WRITE_IN_PROGRESS =0x3F,
HDR_ALLOC_VALID = 0xF,
HDR_ALLOC_BAD = 0x3,
HDR_ALLOC_INVALID = 0x0
} HDR_AllocationStatusEnum;
/* mask for allocation status */
#define HDR_MASK_AllocationStatus ((UINT32)(0x000000FF))
/* macros to set/get allocation status */
#define HDR_GetAllocationStatus(Attr1) \
(Attr1 & HDR_MASK_AllocationStatus)
#define HDR_SetAllocationStatus(Attr1, value) \
((Attr1 & ~HDR_MASK_AllocationStatus) | value)
/* VALUES, MASKS, AND MACROS FOR ATTR2 IN FIXED HEADER */
/* Attr2: object size (20 bits), type (4 bits), rfu1 (4 bits), header status (4 bits) */
/* values for size */
typedef enum
{
HDR_OBJECT_SIZE_UNUSED = 0xFFFFFF
} HDR_ObjectSizeEnum;
/* mask for object size */
#define HDR_MASK_ObjectSize ((UINT32)(0xFFFFF000))
/* macros to set/get object size */
#define HDR_GetSize(Attr2) \
((Attr2 & HDR_MASK_ObjectSize) >> 12)
#define HDR_SetSize(Attr2, value) \
((Attr2 & ~HDR_MASK_ObjectSize) | (value << 12))
/* values for type--see enumeration in davlib.h for FDI_HT_... types */
/* mask for type */
#define HDR_MASK_Type ((UINT32)(0x00000F00))
/* macros to set/get type */
#define HDR_GetType(Attr2) \
((Attr2 & HDR_MASK_Type) >> 8)
#define HDR_SetType(Attr2, value) \
((Attr2 & ~HDR_MASK_Type) | (value << 8))
/* values for RFU1 */
typedef enum
{
HDR_NOT_ABSORBED = 0xF,
HDR_ABSORBING = 0xC,
HDR_ABSORBED = 0x0
} HDR_AbsorbStatusEnum;
/* mask for header status */
#define HDR_MASK_AbsorbStatus ((UINT32)(0x000000F0))
/* macros to set/get header status */
#define HDR_GetAbsorbStatus(Attr2) \
((Attr2 & HDR_MASK_AbsorbStatus) >> 4)
#define HDR_SetAbsorbStatus(Attr2, value) \
((Attr2 & ~HDR_MASK_AbsorbStatus) | (value << 4))
/* values for header status */
typedef enum
{
HDR_HEADER_UNUSED = 0xF,
HDR_HEADER_ALLOCATING = 0xC,
HDR_HEADER_VALID = 0x0
} HDR_HeaderStatusEnum;
/* mask for header status */
#define HDR_MASK_HeaderStatus ((UINT32)(0x0000000F))
/* macros to set/get header status */
#define HDR_GetHeaderStatus(Attr2) \
(Attr2 & HDR_MASK_HeaderStatus)
#define HDR_SetHeaderStatus(Attr2, value) \
((Attr2 & ~HDR_MASK_HeaderStatus) | value)
#define HDR_IsBackupComplete(Attr1) \
((HDR_GetReallocationStatus(Attr1)) == HDR_REALLOC_BACKUP_COMPLETE)
/*### THIS FIXED HEADER SHOULD BE THE SAME ###*/
/*### AS THE PORTION IN THE STANDARD HEADER ###*/
/*### See HDR_Header for standard header. ###*/
/*
// HDR_FixedHeader (8 bytes)
// 3 2 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 <- Bits ( 4 Bytes)
// +-----------------------------------------------+---+-----------+
// 0 | Index/Offset | RA| Alloc |
// +---------------------------------------+-------+---+---+-------+
// 1 | Object Size | Type | Abs |Status |
// +---------------+---------------+-------+-------+-------+-------+
// | 0 | 1 | 2 | 3 | <- Byte
*/
/* Fixed Header (object header from paragraph space) */
typedef struct
{
UINT32 Attr1; /* header index/offset (22 bits), reallocation status (2 bits), allocation status (8 bits) */
UINT32 Attr2; /* object size (20 bits), type (4 bits), AbsorbStatus (4 bits), header status (4 bits) */
} HDR_FixedHeader, __FAR_ * HDR_FixedHeaderPtr;
/* Status for header authentication routines */
typedef enum
{
HDR_STATUS_NoHeader = 0,
HDR_STATUS_FixedHeaderUsed,
HDR_STATUS_FixedHeaderComplete,
HDR_STATUS_Authentic
} HDR_Status;
/*### Global Macros
#########################*/
#define FHDR_CalcHeaderSize() \
(sizeof(HDR_FixedHeader))
/*### Global Functions
#########################*/
ERR_CODE FHDR_Attr1_FixISF_PLR(UINT32* uint32_ptr,
UINT32 flash_address,
BOOLEAN restart);
ERR_CODE FHDR_Attr2_FixISF_PLR(UINT32* uint32_ptr,
UINT32 flash_address,
BOOLEAN restart);
ERR_CODE FHDR_CreateFixedHeader(FDI_Handle aHandle,
HDR_FixedHeaderPtr aHeaderPtr);
ERR_CODE FHDR_CreateFixedHeaderBackup(FDI_Handle aHandle,
HDR_FixedHeaderPtr aHeaderPtr);
ERR_CODE FHDR_CreateInternalObjectHeader(FDI_Handle aHandle,
FDI_HT_ObjectTypeEnum aType,
UINT32 offsetInBytes,
UINT32 sizeInBytes);
ERR_CODE FHDR_CreateUserObjectHeader(FDI_Handle aHandle,
UINT32 offsetInPages,
UINT32 sizeInPages);
ERR_CODE FHDR_CreateFreeChunkHeader(FDI_Handle aHandle,
UINT32 offsetInPages,
UINT32 sizeInPages);
ERR_CODE FHDR_CreateDirtyChunkHeader(FDI_Handle aHandle,
UINT32 offsetInPages,
UINT32 sizeInPages);
ERR_CODE FHDR_ReadFixedHeader(FDI_Handle aHandle,
HDR_FixedHeaderPtr aHeaderPtr,
BOOLEAN restart);
ERR_CODE FHDR_ValidateHeaderInFlash(FDI_Handle aHeaderHandle,
HDR_FixedHeaderPtr aHeaderPtr);
ERR_CODE FHDR_InvalidateHeaderInFlash(FDI_Handle aHandle,
HDR_FixedHeaderPtr aHeaderPtr);
ERR_CODE FHDR_AbsorbingHeaderInFlash(FDI_Handle aHandle,
HDR_FixedHeaderPtr aHeaderPtr);
ERR_CODE FHDR_AbsorbedHeaderInFlash(FDI_Handle aHandle,
HDR_FixedHeaderPtr aHeaderPtr);
HDR_Status FHDR_AuthenticateHeader(HDR_FixedHeaderPtr aHeaderPtr);
void FHDR_SetHeaderIndexOffset(HDR_FixedHeaderPtr aHeaderPtr,
UINT32 value);
UINT32 FHDR_GetHeaderIndexOffset(HDR_FixedHeaderPtr aHeaderPtr);
void FHDR_SetReallocationStatus(HDR_FixedHeaderPtr aHeaderPtr,
HDR_ReallocationStatusEnum value);
HDR_ReallocationStatusEnum FHDR_GetReallocationStatus(HDR_FixedHeaderPtr aHeaderPtr);
void FHDR_SetAllocationStatus(HDR_FixedHeaderPtr aHeaderPtr,
HDR_AllocationStatusEnum value);
HDR_AllocationStatusEnum FHDR_GetAllocationStatus(HDR_FixedHeaderPtr aHeaderPtr);
void FHDR_SetSize(HDR_FixedHeaderPtr aHeaderPtr,
UINT32 value);
UINT32 FHDR_GetSize(HDR_FixedHeaderPtr aHeaderPtr);
void FHDR_SetType(HDR_FixedHeaderPtr aHeaderPtr,
FDI_HT_ObjectTypeEnum value);
FDI_HT_ObjectTypeEnum FHDR_GetType(HDR_FixedHeaderPtr aHeaderPtr);
void FHDR_SetAbsorbStatus(HDR_FixedHeaderPtr aHeaderPtr,
HDR_AbsorbStatusEnum value);
HDR_AbsorbStatusEnum FHDR_GetAbsorbStatus(HDR_FixedHeaderPtr aHeaderPtr);
void FHDR_SetHeaderStatus(HDR_FixedHeaderPtr aHeaderPtr,
HDR_HeaderStatusEnum value);
HDR_HeaderStatusEnum FHDR_GetHeaderStatus(HDR_FixedHeaderPtr aHeaderPtr);
FDI_Handle FHDR_CalcObjectHandle(HDR_FixedHeaderPtr aHeaderPtr);
/*Fix Start:SCR964 */
UINT16 FHDR_CalcStartBlock(HDR_FixedHeaderPtr aHeaderPtr);
UINT16 FHDR_CalcEndBlock(HDR_FixedHeaderPtr aHeaderPtr);
/*Fix End:SCR964 */
UINT32 FHDR_CalcObjectOffset(FDI_Handle aHandle);
UINT32 FHDR_CalcObjectSize(HDR_FixedHeaderPtr aHeaderPtr);
BOOLEAN FHDR_IsParaObject(HDR_FixedHeaderPtr aHeaderPtr);
BOOLEAN FHDR_IsPageObject(HDR_FixedHeaderPtr aHeaderPtr);
BOOLEAN FHDR_IsDirtyChunk (HDR_FixedHeaderPtr aHeaderPtr);
BOOLEAN FHDR_IsFreeChunk (HDR_FixedHeaderPtr aHeaderPtr);
BOOLEAN FHDR_IsUserChunk (HDR_FixedHeaderPtr aHeaderPtr);
BOOLEAN FHDR_IsSystemChunk(HDR_FixedHeaderPtr aHeaderPtr);
ERR_CODE FHDR_RepairHeader(FDI_Handle aHandle,
HDR_FixedHeaderPtr aHeaderPtr);
ERR_CODE FHDR_UINT8_FixISF_PLR(UINT8 *uint8_ptr,
UINT32 flash_address,
BOOLEAN restart);
#endif /* DIRECT_ACCESS_VOLUME */
#endif /* sentry */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?