davdaloc.c
来自「FDI Intel开发的FLASH文件系统,功能很强大」· C语言 代码 · 共 177 行
C
177 行
/* Copyright (c) 1995-2004 Intel Corporation */
/* Intel Confidential */
/* ###########################################################################
### DAV - Direct Access Volume Enhancement to FDI
###
### Module: dav_daloc.c - DAV Interface Function: DeAllocate Flash Module
###
### $Workfile: davdaloc.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"
#include "davfhdr.h"
#include "davhdr.h"
#include "davsearch.h"
#include "davpin.h"
#include "davmem.h"
#include "davdaloc.h"
/*### Local Declarations
#########################*/
#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 Declarations
#########################*/
/*### 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(UINT8 *obj_name, UINT8 name_size, UINT32 obj_type )
{
ERR_CODE status = ERR_NONE;
SEARCH_CompareInfo compare_info;
/* Check range of ObjectType */
if(obj_type < FDI_HT_BeginUserTypes)
{
return ERR_PARAM;
}
/* Check for Namesize passed in as zero and if the Name pointer is pointing to NULL*/
if((name_size == 0) || (obj_name == 0))
{
return ERR_PARAM;
}
/* 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.) */
FDI_APILock();
/* A WIP object exists, do not allow allocation or
* reallocation until the object is complete.
*/
if (FDI_LockoutObjectAllocation)
{
status = ERR_WIP;
ExitOnError(status);
}
/* 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)
{
status = ERR_PARAM;
ExitOnError(status);
}
/* Search for header with specified type. */
/* Assumption: Only one header with the specified type */
/* will exist when DeAllocateFlash is called. */
SEARCH_Header2SearchInfo(&FDI_SearchInfo, &FDI_SearchHeader);
compare_info.CompareValue = obj_type;
compare_info.NamePtr = (HDR_NamePtr)(obj_name);
compare_info.NameSize = name_size;
status = SEARCH_GetNextHeader(&FDI_SearchInfo, SEARCH_ByNameType, &compare_info, FALSE);
if (status != ERR_NONE)
{
if (status == ERR_NO_MORE_ENTRIES)
{
status = ERR_NOTEXISTS;
}
ExitOnError(status);
}
/* Check to see if this object is pinned. We will not */
/* allow pinned objects to be deallocated. */
if (PIN_LIST_IsObjectInList(FHDR_GetHeaderIndexOffset(&(FDI_SearchInfo.HeaderPtr->FHdr))))
{
status = ERR_PINNED;
ExitOnError(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. */
/* Don't allow deallocation of WIP objects */
if (FHDR_GetAllocationStatus(&(FDI_SearchInfo.HeaderPtr->FHdr)) == HDR_ALLOC_VALID)
{
/* set allocation status for header in flash to invalid (dirty) */
status = FHDR_InvalidateHeaderInFlash(FDI_SearchInfo.CurrObj.HeaderAddress,
&(FDI_SearchInfo.HeaderPtr->FHdr));
}
else
{
status = ERR_WIP;
}
CleanupAndExitOnError(status);
status = MEM_CalcMemoryStatistics(FALSE);
FDI_APIUnlock();
return status;
}
#endif /* DIRECT_ACCESS_VOLUME */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?