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

📄 davgnxob.c

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

/* ###########################################################################
###  DAV - Direct Access Volume Enhancement to FDI
###
###  Module: dav_gnxob.c - DAV Interface Function: Object Search Module
###
###  $Workfile: davgnxob.c $
###  $Revision: 72 $
###  $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 "davext.h"

/*### Local Declarations
#########################*/
static SEARCH_SearchInfo LocalSearchInfo;
static HDR_Header        LocalSearchHeader;
static FDI_Handle        prev_hdr_addr;

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

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

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

/* E5.5.962 Begin */   
#define CleanupAndExitOnError(status)   \
   if(status != ERR_NONE)               \
   {                                    \
      FDI_APIUnlock();                  \
      mDEBUG_CHECK_ERRCODE(status)      \
      MEM_CalcMemoryStatistics(FALSE);  \
      return status;                    \
  }
/* E5.5.962 End */

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

/*#################################################################
  ### FDI_GetObjectHeader
  ###
  ### DESCRIPTION:
  ###   This function will return information about the next object
  ###   in the header table, calculate the address of the object and 
  ###   keep track of the search state using the obj_info_ptr.  
  ###   The FDI_ObjectInfoPtr must contain a name and/or
  ###   type depending on the desired method of search.
  ###   The name and/or type will be used to determine the starting
  ###   point of the search.  Once the start point is found then the
  ###   next object that matches (see method below) will be returned 
  ###   in the FDI_ObjectInfoPtr.  The restart parameter is used to 
  ###   start from the first object in the header table.
  ###
  ###   Information such as the object address, alignment, size in 
  ###   bytes, and security key are returned only if an object is 
  ###   found.  If the object is not found, then the values will 
  ###   not be valid and will contain zeroes.
  ###
  ### PARAMETERS:
  ###   obj_info_ptr - 
  ###    IN:  The name and type fields of the structure are used to
  ###         determine the search starting point when restart is
  ###         false.  The name and/or type is also used to qualify 
  ###         the search.  See method for more info.
  ###
  ###    OUT: All of the header information is translated to the
  ###         equivalent values in the structure.
  ###
  ###   method  - return the next object with the following 
  ###             qualities:
  ###           
  ###    SearchByNextObject - the next object in the header table.
  ###    SearchByType       - the next object with the specified 
  ###                         type.
  ###    SearchByName       - the next object with the specified 
  ###                         name.
  ###    SearchByNameType   - the next object with the specified 
  ###                         name & type.
  ###
  ###   restart - TRUE  - Start search from the beginning of the 
  ###                     header table including the first object.
  ###             FALSE - Start search from the name & type 
  ###                     specified in the info_struct.
  ###
  ### RETURNS:
  ###   When this function passes with no errors a value of 0 is
  ###   returned otherwise, it returns a status of type ERR_CODE.
  ###
  ###   ERR_NONE       - Entry was found and the obj_info_ptr contains
  ###                   valid header information.
  ###
  ###   ERR_NO_MORE_ENTRIES - The entry was not found after searching
  ###                   the entire header table.
  ###
*/
ERR_CODE FDI_GetObjectHeader(FDI_ObjectInfoPtr obj_info_ptr,
                             FDI_SearchMethod  method,
                             BOOLEAN           restart)
{
UINT32                   ii;
ERR_CODE                 status;
SEARCH_SearchMethodEnum  search_method;
SEARCH_CompareInfo       compare_info;

   /* Do not check type if search method is next object */
   if((method != SearchByNextObject) && (method != SearchByName))
   {
      if( obj_info_ptr->ObjectType < FDI_HT_BeginUserTypes )
      {
         return ERR_PARAM;
      }
   }

   if((obj_info_ptr->Name) == NULL)
   {
      return ERR_PARAM;
   }
   if((method == SearchByName) || (method == SearchByNameType))
   {
     if(obj_info_ptr->NameSize == 0)
     {
        return ERR_PARAM;
     }
   }

   FDI_APILock();

   /* set Alignment and RecoveryLevel to the default values. If there are any input
      values for these fields, they are ignored */
   switch (method)
   {
      case SearchByNextObject:
         search_method = SEARCH_ByNextValidPageObject;
      break;
      
      case SearchByType:
         search_method = SEARCH_ByValidType;
      break;
      
      case SearchByName:
         search_method = SEARCH_ByName;
      break;
      
      case SearchByNameType:
         search_method = SEARCH_ByNameType;
      break;
      default:
         FDI_APIUnlock();
         return ERR_NOTEXISTS;
   }
   
   if (restart)
   {
      SEARCH_Header2SearchInfo((&LocalSearchInfo), (&LocalSearchHeader));
      prev_hdr_addr = 0;
   }
   else
   {
      
      LocalSearchInfo.CurrObj.HeaderAddress = prev_hdr_addr;
   }
   
   /* Setup compare info for the search engine and locate */
   /*  the next object.                                   */
   compare_info.NamePtr      = (HDR_NamePtr)(obj_info_ptr->Name);
   compare_info.NameSize     = obj_info_ptr->NameSize;
   compare_info.CompareValue = obj_info_ptr->ObjectType;
   
   for (;;)
   {
      status = SEARCH_GetNextHeader(&LocalSearchInfo, search_method, &compare_info, restart);
      if (!status)
      {
         /* Make sure that the interface cannot see any system objects. */
         if (FHDR_GetType(&(LocalSearchInfo.HeaderPtr->FHdr)) == FDI_HT_NormalObject)
         {
            break;
         }
      }
      else
      {
         break;
      }
   }
   
   if (!status)
   {
      /* Need to read full headers for the following */ 
      /* types (Not done in GetNextHeader).          */
      /*switch (search_method)      */
      /* Need to switch on method, not search_method */
      switch (method)
      {
         case SearchByType:
         case SearchByNextObject:
            /* Need to read full header for this type of search */
            status = HDR_ReadFullHeader(LocalSearchInfo.CurrObj.HeaderAddress, 
                                        LocalSearchInfo.HeaderPtr, 
                                        restart);
            ExitOnError(status);
            break;
         case SearchByName:
         case SearchByNameType:
         default:
         {};
      }
      /* Found the object, now translate the object information to */
      /*  the interface function equivalent.                       */
      SEARCH_SearchInfo2ObjectInfo(obj_info_ptr, &LocalSearchInfo);
      
      prev_hdr_addr = LocalSearchInfo.CurrObj.HeaderAddress;
   }
   else
   {
      /* Clear entries when an object is not found or an error occurs. */
      for (ii = 0; ii < FDI_MaxNameLength; ii++)
      {
         obj_info_ptr->Name[ii] = 0;
      }
      
      obj_info_ptr->NameSize       = 0;
      obj_info_ptr->ObjectType     = 0; 
      obj_info_ptr->ObjectAddress  = 0; 
      obj_info_ptr->ObjectSize     = 0;
      obj_info_ptr->RFU32          = 0;
      obj_info_ptr->SecurityKey    = 0;
      
      /* Add ability to detect WIP vs. Valid object */
      obj_info_ptr->WriteStatus    = FDI_WriteStatusValid;
      prev_hdr_addr = 0;
   }
   
   if (status == ERR_NO_MORE_ENTRIES)
   {
      status = ERR_NOTEXISTS;
   }

   FDI_APIUnlock();
   return status;
}

#endif /* DIRECT_ACCESS_VOLUME */



⌨️ 快捷键说明

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