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

📄 davhdr.c

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

/* ###########################################################################
###  HEADER
###
###  Module: header.c - Header module
###
###  $Workfile: davhdr.c $
###  $Revision: 63 $
###  $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.                             
 *****************************************************************
 */
 

/*### Include Files
#########################*/
#include "DavLib.h"

#if (DIRECT_ACCESS_VOLUME == TRUE)

#include "davhdr.h"
#include "davext.h"

/*### Local Declarations
#########################*/

/*### Global Declarations
#########################*/

/*### Local Functions
#########################*/

#define ExitOnError(status) \
   if (status != ERR_NONE) \
   {  return status;  }

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


/*#################################################################
  ### HDR_CreateNextFixedHeaderEntry
  ### 
  ### DESCRIPTION:
  ###   This function creates an entry in the header table at 
  ###   the location pointed to by the handle, 
  ###   aParaHandlePtr.  It does not check for memory 
  ###   availability and expects there to be enough free space 
  ###   available, but does create the header in a known 
  ###   recoverable way.  Information from the header
  ###   pointed to by "aHeaderPtr" is used to create the header. 
  ### 
  ### PARAMETERS:   
  ###   aHandlePtr    - IN:  not used.
  ###                   OUT: Contains a pointer to the new header 
  ###                         handle.
  ###   aHeaderPtr    - IN:  The header should be filled with the 
  ###                         information to be stored in the 
  ###                         new entry.
  ###                   OUT: not used.
  ### 
  ### RETURNS:
  ###   When this function passes with no errors a value of 0 is
  ###   returned otherwise, it returns a status of type ERR_CODE.
  ###*/
ERR_CODE HDR_CreateNextFixedHeaderEntry(FDI_HandlePtr aHandlePtr,
                                        HDR_FixedHeaderPtr aHeaderPtr)
{
ERR_CODE status = ERR_NONE;

   *aHandlePtr = FDI_NextFreeHeaderEntry;
   
   /* Tracks the last object header */
   FDI_LastHeaderEntry = *aHandlePtr;                    

   /* Set next free header pointer below name field */
   FDI_NextFreeHeaderEntry -= FHDR_CalcHeaderSize();

   /* Write fixed header, then write fixed header status */
   status = FHDR_CreateFixedHeader(*aHandlePtr, aHeaderPtr);
   ExitOnError(status);

   return(status);   
} 

/*#################################################################
  ### HDR_CreateNextFixedHeaderEntryFree
  ### 
  ### DESCRIPTION:
  ###   This function creates an entry for a free chunk in the 
  ###   header table at the location pointed to by the handle, 
  ###   aParaHandlePtr.  It does not check for memory 
  ###   availability and expects there to be enough free space 
  ###   available, but does create the header in a known 
  ###   recoverable way.  Information from the header
  ###   pointed to by "aHeaderPtr" is used to create the header. 
  ### 
  ### PARAMETERS:   
  ###   aHandlePtr    - IN:  not used.
  ###                   OUT: Contains a pointer to the new header 
  ###                         handle.
  ###   aHeaderPtr    - IN:  The header should be filled with the 
  ###                         information to be stored in the 
  ###                         new entry.
  ###                   OUT: not used.
  ### 
  ### RETURNS:
  ###   When this function passes with no errors a value of 0 is
  ###   returned otherwise, it returns a status of type ERR_CODE.
  ###*/
ERR_CODE HDR_CreateNextFixedHeaderEntryFree(FDI_HandlePtr aHandlePtr,
                                            HDR_FixedHeaderPtr aHeaderPtr)
{
ERR_CODE status = ERR_NONE;

   *aHandlePtr = FDI_NextFreeHeaderEntry;
   
   /* Tracks the last object header */
   FDI_LastHeaderEntry = *aHandlePtr;                    

   /* Set next free header pointer below name field */
   FDI_NextFreeHeaderEntry -= FHDR_CalcHeaderSize();

   /* Write fixed header, then write fixed header status */
   status = FHDR_CreateFreeChunkHeader(*aHandlePtr,
                                       FHDR_GetHeaderIndexOffset(aHeaderPtr),
                                       FHDR_GetSize(aHeaderPtr));
   ExitOnError(status);

   return(status);   
} 


/*#################################################################
 ### HDR_ReadFullHeader
 ### 
 ### DESCRIPTION:
 ###   This function will load "aHeaderPtr" with all header 
 ###   data pointed to in flash by "handle", including the
 ###   object leader header and the name field.
 ### 
 ### PARAMETERS:   
 ###   handle     - Contains handle(address) of header to 
 ###                 read from flash.
 ###   aHeaderPtr - IN:  Must point to a valid header structure.
 ###                OUT: Header is loaded with complete header 
 ###                      information, including leader and name.
 ### 
 ### RETURNS:
 ###   ERR_CODE.
 ###*/ 
ERR_CODE HDR_ReadFullHeader(FDI_Handle aHandle,
                            HDR_HeaderPtr aHeaderPtr, 
							       BOOLEAN restart)
{
ERR_CODE status = ERR_NONE;

   /* Read fixed header from flash */
   status = FHDR_ReadFixedHeader(aHandle, &(aHeaderPtr->FHdr), restart);
   ExitOnError(status);

   /* Read the fixed object header from flash */
   aHandle = FHDR_CalcObjectHandle(&(aHeaderPtr->FHdr));

   /* read fixed object header with name if valid object */
   if ((FHDR_GetType(&(aHeaderPtr->FHdr)) == FDI_HT_NormalObject) &&
	       (FHDR_GetAllocationStatus(&(aHeaderPtr->FHdr)) == HDR_ALLOC_VALID))
   {
      status = OHDR_ReadObjectHeader(aHandle, &(aHeaderPtr->OHdr), TRUE);
   }
   else
   {
      status = OHDR_ReadObjectHeader(aHandle, &(aHeaderPtr->OHdr), FALSE);
   }
   ExitOnError(status);

   return status;                                            
}

#endif /* DIRECT_ACCESS_VOLUME */

⌨️ 快捷键说明

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