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

📄 davdaloc.c

📁 Flash file system
💻 C
📖 第 1 页 / 共 2 页
字号:
 _______________________________________________________
 
  Please return COMPLETELY filled out to:

    Intel Corporation         FAX: 916-356-2803
    Intel Flash Software Marketing  
    FM3-163
    1900 Prairie City Road
    Folsom, CA 95630

    Atten: Flash S/W License

Intel reserves the right to use and/or include Your name in 
public relations activities and marketing material and may 
request You to submit endorsements for the Software.  If You 
wish to discuss participation in this program, please send a 
fax to 916-356-2803 attn: "Software Marketing" with contact 
information and an Intel representative will contact You.

Revised: 02/16/01
***************************************************************************/ 

/*### Include Files
#########################*/
#include "dav.h"
#if (DIRECT_ACCESS_VOLUME == TRUE)

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

/*### Global Declarations
#########################*/
extern HDR_SearchInfo FDI_SearchInfo;
extern HDR_Header     FDI_SearchHeader;

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

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

/*##################################################################
  ### FDI_DeAllocateFlash
  ###
  ### DESCRIPTION:
  ###   This function deallocates memory associated with the object 
  ###   by modifying the status field to Invalid.  The memory is
  ###   erased by reclaim later on.
  ###
  ### PARAMETERS:
  ###   obj_name    - Name of object.
  ###   name_size   - Length of the name field in bytes.
  ###   obj_type    - Type of the object.
  ###
  ### 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 FDI_DeAllocateFlash( const UINT8 *obj_name, UINT8 name_size, UINT32 obj_type )
{
ERR_CODE        status = ERR_NONE;
UINT32          obj_size;
UINT16          header_size;
HDR_CompareInfo compare_info;

   /* Multitasking API exclusivity.  (This may not be necessary to the
      full extent as it is done here, but for now it is the safest way.) */
   /* Check range of ObjectType */
   if(obj_type < MIN_DAV_TYPE)
   {
      return ERR_PARAM;
   }
   
   FDI_APILock();

/* A WIP object exists, do not allow allocation or
    * reallocation until the object is complete.      
    */
   if (FDI_LockoutObjectAllocation)
   {
      FDI_APIUnlock();
      return ERR_WIP;
   }

   /* Clear Global flag for System State */
   ClrSystemState(FDI_SystemState, FDI_ST_ReclaimFlag);

   /* Make sure that the interface cannot delete any system objects. */
   if (obj_type <= FDI_HT_EndReservedTypes)
   {
      FDI_APIUnlock();
      return ERR_PARAM;
   }
   
   /* Search for header with specified type.              */
   /* Assumption: Only one header with the specified type */
   /* will exist when DeAllocateFlash is called.          */
   HDR_InitSearchInfo((&FDI_SearchInfo), (&FDI_SearchHeader));
   compare_info.CompareValue = obj_type;
   compare_info.NamePtr = (HDR_NamePtr)(obj_name);
   compare_info.NameSize = name_size;
   status = GetNextHeader(&FDI_SearchInfo, HDR_ByNameType, &compare_info, FALSE);
   if (status != ERR_NONE)
   {
      if (status == ERR_NO_MORE_ENTRIES)
      {
         FDI_APIUnlock();
         return ERR_NOTEXISTS;
      }
      else
      {
         FDI_APIUnlock();
         return status;
      }
   }

   /* Modify the status bit field to invalid only if       */
   /* the header is currently valid.  Otherwise, return    */
   /* ERR_NOTEXISTS because not valid object was found to */
   /* invalidate.                                          */
/* CJS TEMP - Don't allow deallocation of WIP objects */
/*   if (HDR_GetStatusAttr((FDI_SearchInfo.HeaderPtr->Attr)) != HDR_HA_Invalid)*/
   if (HDR_GetStatusAttr((FDI_SearchInfo.HeaderPtr->Attr16)) == HDR_HA_Valid)
/* CJS TEMP - Don't allow deallocation of WIP objects */
   {
      /* Mark Header in flash to Invalid */
      status = HDR_InvalidateHeader(FDI_SearchInfo.CurrObj.HeaderAddress, 
                                                   FDI_SearchInfo.HeaderPtr);
      if (status != ERR_NONE)
      {
         FDI_APIUnlock();
         return status;
      }
      
      /* Update the reserves tracking variables.  Only update */
      /*  if the object deallocated used reserves.            */
      if (HDR_GetReservesAttr((FDI_SearchInfo.HeaderPtr->Attr8)) == 
                                                        HDR_HA_UseReserves)
      {
         status = HDR_CalcMemoryStatistics(FALSE);
         if ((status != ERR_NONE) && (status != ERR_NO_MORE_ENTRIES))
         {
            FDI_APIUnlock();
            return(status);
         }
      }
      else
      {
         obj_size = FDI_SearchInfo.CurrObj.ObjectSize;
         header_size = HDR_CalcHeaderSize(FDI_SearchInfo.HeaderPtr);

         /* The global tracking variables must be updated  */
         /* based on their alignment.                      */
         switch (HDR_GetAlignmentAttr((FDI_SearchInfo.HeaderPtr->Attr16)))
         {
            case HDR_HA_AlignPage:  /* Page Aligned Object */
                /* convert obj_size to bytes */
                FDI_MemUsage.PageSpace.Invalid += obj_size;
                FDI_MemUsage.PageSpace.Valid   -= obj_size;
                FDI_MemUsage.PageOverhead.Invalid += header_size;
                FDI_MemUsage.PageOverhead.Valid   -= header_size;
            break;
                
            case HDR_HA_AlignPara:  /* Paragraph Aligned Object */
                /* convert obj_size to bytes */
                FDI_MemUsage.ParaSpace.Invalid += obj_size;
                FDI_MemUsage.ParaSpace.Valid   -= obj_size;
                FDI_MemUsage.ParaOverhead.Invalid += header_size;
                FDI_MemUsage.ParaOverhead.Valid   -= header_size;
            break;
                
            /* Hooks for future alignment options. */
            case HDR_HA_AlignRFU1:
            case HDR_HA_AlignRFU2:
            default: {};
         }
      }
   }
   else 
   {
      status = ERR_NOTEXISTS;
   }
   
   if (status == ERR_NO_MORE_ENTRIES)
   {
      status = ERR_NONE;
   }

   if (status)
   {
      FDI_APIUnlock();
      return(status);
   }

   /* Perform Reclaim Level Check */
   status = DAVSRECL_CheckReclaimLevel();

   /* Decrement the number of existing page object headers in flash */
   if (!status)
   {
      FDI_PageObjectCounter--;
   }

   FDI_APIUnlock();
   return status;

}

#endif /* DIRECT_ACCESS_VOLUME */

⌨️ 快捷键说明

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