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

📄 davlib.h

📁 FDI Intel开发的FLASH文件系统,功能很强大
💻 H
字号:
/* Copyright (c) 1995-2004 Intel Corporation */
/* Intel Confidential                        */

/* ###########################################################################
###  DAVLIB - Direct Access Volume Enhancement to FDI
###
###  Module: davlib.h - Library include file
###
###  $Workfile: davlib.h $
###  $Revision: 80 $
###  $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_lib_h
#define __dav_lib_h

#ifdef __DAV_WIN32__ /* CPU */
#define CPU ARM810       /* VxWorks ARM7TDMI(NO), ARM810(YES), CPU32(NO) */
#endif

/*### Include Files
//#########################*/
#include "davtpdef.h"    /* FDI_TYPE.h, DIRECT_ACCESS_VOLUME */

#if (DIRECT_ACCESS_VOLUME == TRUE)

#include "fdi_err.h"     /* ERR_CODE */

#ifndef __DAV_WIN32__ /* fdi_mutx.h */
#include "fdi_mutx.h"
#endif

#define  DWORDMAX       0xffffffff
#define  WORDMAX        0xffff
#define  BYTEMAX        0xff
#define  FNIBBLEMAX     0xf0
#define  SNIBBLEMAX     0x0f

/*### Data Sizes & Limits
#########################*/
/* Define memory parameters */
#define FDI_ParagraphLength          0x10      /* 16 Bytes               */
/* Reduce page granularity */
/* #define FDI_PageSize              0x1000 */   /* 4KB                    */
#define FDI_PageSize                 0x100       /* 256(256MB max file size*/
#define FDI_MaxNameLength            240
#define FDI_MaxPageSize              0x100000  /* 20-bits maximum (4GB)  */
#define FDI_MaxParagraphSize         0x100000  /* 20-bits maximum (16MB) */
#define FDI_MaxAllocUnits            0x100000  /* 20-bits */

#define FDI_BlockSizeInPages         (FDI_BlockSize/FDI_PageSize)

/*### Interface Properties
#########################*/
#define FDI_InitialReclaimLevel     0 

/*### DAV Object Type Ranges
############################*/
/* Note: That BeginReservedTypes must always start at 0 */
/*       so that repair header can change any header to */
/*       this type (0)                                  */
#define FDI_HT_BeginReservedTypes 0
#define FDI_HT_EndReservedTypes   255


#define FDI_HT_BeginUserTypes     256

#define FDI_HT_EndUserTypes       0xFFFFFFFF

/*### Reserved DAV object types
###############################*/
typedef enum
{
   FDI_HT_RecoveredHeader = FDI_HT_BeginReservedTypes,
   FDI_HT_ReclaimTable    = 0x01, /* Reclaim Table              */
   FDI_HT_ObjTrkTable     = 0x02, /* Object Tracking Table      */
   FDI_HT_ReAllocateTable = 0x03, /* ReAllocate Table           */
   FDI_HT_ConfigHeader    = 0x04, /* Configuration Header Entry */
   FDI_HT_NormalObject    = 0x0F  /* User object                */
} FDI_HT_ObjectTypeEnum;

typedef struct
{
   UINT8     Name[FDI_MaxNameLength];/* Name of the selected object       */
   UINT8     NameSize;        /* Size in bytes of the name                */
   UINT16    word_align;
   UINT32    ObjectType;      /* Type of the selected object              */
   UINT32    ObjectAddress;   /* Base address of the object               */
   UINT32    ObjectSize;      /* Size of object in pages or paragraphs    */
   UINT32    RFU32;           /* Alignment, page or paragraph             */
   UINT32    SecurityKey;     /* Security Key of the selected object      */
   UINT16    WriteStatus;     /* Object write status (WIP vs. Valid)      */
} FDI_ObjectInfo, __FAR_ *FDI_ObjectInfoPtr;

/*### Intf Types/Params
#########################*/

/* Various DAV Object Space Parameters */
#define FDI_ReservedReclaimBlocks        1
#define FDI_ReservedSystemBlocks         1 /* one block reserved for paragraph space and system tables */

#define DAV_MAX_BLOCKS			           (DAV_BLOCKCOUNT - FDI_ReservedSystemBlocks-FDI_ReservedReclaimBlocks)
#define DAV_NUM_CLASS_FILES              254
#define FDI_InvalidObjAddress            0xffffffff

typedef UINT32         FDI_Handle;
#define FDI_HandlePtr  FDI_Handle*

#include "davext.h"
#include "davmem.h"

/*
#######################
### Interface Support
#######################
*/

/*### WriteStatus Detection
#################################*/
#define FDI_WriteStatusValid    0
#define FDI_WriteStatusWIP      1
#define FDI_WriteStatusRsvd     2

/*### System State Support
##########################*/
#define SetSystemState(system_state, field)  \
          (system_state = (system_state | field))

#define ClrSystemState(system_state, field)  \
          (system_state = (system_state & ~field))

#define IsSystemState(system_state, field)  \
          ((system_state & field) == field)

/* System State Bit Fields */
#define FDI_ST_ReclaimFlag       0x0001
#define FDI_ST_ReallocateRecover 0x0002
#define FDI_ST_CfgHdrRecover     0x0004
#define FDI_ST_ReclaimRecover    0x0008
#define FDI_ST_RepairHeader      0x0010
#define FDI_ST_RestoreWIP        0x0020
#define FDI_ST_RFU_Bit6          0x0040
#define FDI_ST_RFU_Bit7          0x0080
#define FDI_ST_RFU_Bit8          0x0100
#define FDI_ST_RFU_Bit9          0x0200
#define FDI_ST_RFU_BitA          0x0400
#define FDI_ST_RFU_BitB          0x0800
#define FDI_ST_RFU_BitC          0x1000
#define FDI_ST_RFU_BitD          0x2000
#define FDI_ST_RFU_BitE          0x4000
#define FDI_ST_RFU_BitF          0x8000

/* Read Object select parameter values */
#define FDI_SELECT_FIRST  0  /* Read first instance of object data */
#define FDI_SELECT_SECOND 1  /* Read second instance               */

#ifndef __DAV_WIN32__ /* Functions */
/* FDI_APILock() is used by FMM to exclusively deal with multiple tasks. */
#define FDI_APILock()    (SEM_MTX_WAIT(SEM_DAVAPILock))
/* FDI_APIUnock() is used by FMM to exclusively deal with multiple tasks. */
#define FDI_APIUnlock()  (SEM_MTX_POST(SEM_DAVAPILock))
#else
#define FDI_APILock()
#define FDI_APIUnlock()
#endif

/*### Global Functions
//#########################*/
#define  PAGE_TO_BYTES(p) (p * FDI_PageSize)


/*Begin ISF defines and Macros*/  

/* UINT8 stuff*/

/*End ISF defines and Macros*/  
#define UTIL_UINT8_EntryISF_MASK    0xAA
#define UTIL_GetUINT8QuasiState(status) \
        ((status ^ (status << 1)) & UTIL_UINT8_EntryISF_MASK)
#define UTIL_FixUINT8QuasiStateTo00(unknown, status) \
        ((~(unknown | (unknown >> 1))) & status)    
#define UTIL_FixUINT8QuasiStateTo11(temp_state, status) \
        ((temp_state | (temp_state >> 1)) | status)

/* end UINT8 stuff*/

/* UINT16 stuff*/

#define UTIL_UINT16_EntryISF_MASK    0xAAAA

#define UTIL_UINT16_HeaderEntryISF_MASK    0x02AA

#define UTIL_UINT16_CfgTblEntryISF_MASK    0x0AAA

#define UTIL_GetUINT16QuasiState(status) \
        ((status ^ (status << 1)) & UTIL_UINT16_EntryISF_MASK)

#define UTIL_GetUINT16HeaderQuasiState(status) \
        ((status ^ (status << 1)) & UTIL_UINT16_HeaderEntryISF_MASK)

#define UTIL_GetUINT16CfgTblQuasiState(status) \
        ((status ^ (status << 1)) & UTIL_UINT16_CfgTblEntryISF_MASK)

#define UTIL_FixUINT16QuasiStateTo00(unknown, status) \
        ((~(unknown | (unknown >> 1))) & status)
    
#define UTIL_FixUINT16QuasiStateTo11(temp_state, status) \
        ((temp_state | (temp_state >> 1)) | status)

/* end UINT16 stuff*/


/* UINT32 stuff*/

#define UTIL_UINT32_EntryISF_MASK    0xAAAAAAAA
#define UTIL_GetUINT32QuasiState(status) \
        ((status ^ (status << 1)) & UTIL_UINT32_EntryISF_MASK)
#define UTIL_FixUINT32QuasiStateTo00(unknown, status) \
        ((~(unknown | (unknown >> 1))) & status)    
#define UTIL_FixUINT32QuasiStateTo11(temp_state, status) \
        ((temp_state | (temp_state >> 1)) | status)

/*end  UINT32 stuff*/

ERR_CODE UTIL_UINT16_FixISF_PLR(UINT16 *uint16_ptr, 
                                       UINT32 flash_address,
                                       BOOLEAN restart);

ERR_CODE UTIL_UINT16_HeaderFixISF_PLR(UINT16 *uint16_ptr, 
                                             UINT32 flash_address,
                                             BOOLEAN restart);
                                    
ERR_CODE UTIL_UINT32_FixISF_PLR(UINT32 *uint32_ptr, 
                                       UINT32 flash_address,
                                       BOOLEAN restart);

/*End ISF defines and Macros*/  

                             



void UTIL_CopyVariable(UINT8* aSrcPtr, UINT8* aDestPtr, UINT32 aSizeInBytes);
void UTIL_ClearVariable(UINT8* aBytePtr, UINT32 aSizeInBytes, UINT8 aValue);
typedef enum
{
   enTopBoundary,
   enBottomBoundary
} EnTopOrBottomBoundary;

/*Fix Start:SCR964 */
UINT32     UTIL_CalcOffsetOfBlocksBoundary(UINT16 aBlockNumber, EnTopOrBottomBoundary aBlockBoundary);
UINT16      UTIL_CalcBlockNumberForOffset (UINT32 aOffsetInPages);
FDI_Handle UTIL_CalcHandleOfBlockBottomBoundary(UINT16 aBlockNumber);
FDI_Handle UTIL_CalcHandleOfBlockTopBoundary(UINT16 aBlockNumber);
/*Fix End:SCR964 */
ERR_CODE   UTIL_Dav_Format();

#ifndef __DAV_WIN32__ /* DavFlash */
#include "davflash.h"
#else
#include "DavFlashWin32.h"
#endif

#endif /* DIRECT_ACCESS_VOLUME */

#endif /* __DAV_LIB_H__ */

⌨️ 快捷键说明

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