📄 davgetnh.c
字号:
/* Copyright (c) 1995-2002 Intel Corporation */
/* Intel Confidential */
/* ###########################################################################
### GETNXH
###
### Module: getnxh.c - Low Level Header Table Search Module
###
### $Workfile: davgetnh.c $
### $Revision: 54 $
###
### $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 "dav.h"
#if (DIRECT_ACCESS_VOLUME == TRUE)
/*### Local Declarations
#########################*/
/*### Global Declarations
#########################*/
/*### Local Functions
#########################*/
/*#################################################################
### IsFound
###
### DESCRIPTION:
### This function is used to locate an object based on the
### method of searching. By adding a comparison to this
### function and the HDR_SearchMethod enum, the GetNextHeader
### function can be extended without modifying the rest
### of the search code.
###
### PARAMETERS:
### srch_info_ptr - Structure containing search information.
### IN: - Must contain valid object information in order
### to carry out the requested search.
### - HeaderPtr points to a valid header for temporary
### use.
###
### OUT: - On a search by HDR_ByName or HDR_ByNameType
###
### compare_method - Search for the next object with the
### desired qualities.
### compare_value - Value to use to compare search depending
### on the type of search.
###
### RETURNS:
### TRUE - If object info matches the requested method.
### FALSE - If not!
###*/
/* E.5.0.652 Begin */
ERR_CODE IsFound(HDR_SearchInfo *srch_info_ptr,
HDR_SearchMethod compare_method,
HDR_CompareInfo *compare_info_ptr,
UINT8 *found_val_ptr,
BOOLEAN restart)
/* E.5.0.652 End */
{
UINT32 ii;
UINT8 found = 0;
UINT16 temp_word;
ERR_CODE status = ERR_NONE;
switch (compare_method)
{
case HDR_ByValidType:
if ((HDR_GetStatusAttr((srch_info_ptr->HeaderPtr->Attr16))
!= HDR_HA_Invalid) &&
(srch_info_ptr->HeaderPtr->ObjectType ==
compare_info_ptr->CompareValue))
{
found = 1;
}
break;
case HDR_ByTypeOnly:
if (srch_info_ptr->HeaderPtr->ObjectType ==
compare_info_ptr->CompareValue)
{
found = 1;
}
break;
case HDR_ByNotReclaimState:
temp_word =
HDR_ID_GetReclaimState((srch_info_ptr->HeaderPtr->HeaderId));
if (temp_word != (UINT16)(compare_info_ptr->CompareValue))
{
found = 1;
}
break;
case HDR_ByHeaderAddress:
if (srch_info_ptr->CurrObj.HeaderAddress ==
compare_info_ptr->CompareValue)
{
found = 1;
}
break;
case HDR_ByNextObject:
found = 1;
break;
case HDR_ByNextWriteInProgressObject:
if (HDR_GetStatusAttr((srch_info_ptr->HeaderPtr->Attr16)) ==
HDR_HA_WriteInProgress)
{
found = 1;
}
break;
case HDR_ByNextInvalidPageObject:
if ((HDR_GetStatusAttr((srch_info_ptr->HeaderPtr->Attr16))
== HDR_HA_Invalid) &&
(HDR_GetAlignmentAttr((srch_info_ptr->HeaderPtr->Attr16)) ==
HDR_HA_AlignPage))
{
found = 1;
}
break;
case HDR_ByNextValidObject:
if ((HDR_GetHdrState(srch_info_ptr->HeaderPtr->Attr16) ==
HDR_HA_STATE_Valid) &&
(HDR_GetStatusAttr(srch_info_ptr->HeaderPtr->Attr16) ==
HDR_HA_Valid))
{
found = 1;
}
break;
case HDR_ByNextPageObject:
if (HDR_GetAlignmentAttr((srch_info_ptr->HeaderPtr->Attr16)) ==
HDR_HA_AlignPage)
{
found = 1;
}
break;
case HDR_ByNameType:
/* Check for matching type and non-invalid object before */
/* checking the name. */
if ((HDR_GetStatusAttr((srch_info_ptr->HeaderPtr->Attr16))
!= HDR_HA_Invalid) &&
(srch_info_ptr->HeaderPtr->ObjectType ==
compare_info_ptr->CompareValue))
{
found = 1;
}
else
{
break;
}
/*lint -fallthrough*/
case HDR_ByName:
/* Read in the header name. */
status = HDR_ReadFullHeader(srch_info_ptr->CurrObj.HeaderAddress,
srch_info_ptr->HeaderPtr, restart);
if(status)
{
return status;
}
/* If the name lengths don't match obviously the names themselves */
/* cannot match. This prevents the problem of a name with */
/* aaaa matching with a name of aaaaa. */
if ((srch_info_ptr->HeaderPtr->NameSize ==
compare_info_ptr->NameSize) &&
((HDR_GetStatusAttr((srch_info_ptr->HeaderPtr->Attr16))
!= HDR_HA_Invalid)))
{
found = 1;
for (ii = 0; ii < compare_info_ptr->NameSize; ii++)
{
if (srch_info_ptr->HeaderPtr->Name[ii] !=
((UINT8_PTR)compare_info_ptr->NamePtr)[ii])
{
found = 0;
break;
}
}
}
else
{
found = 0;
}
break;
case HDR_ByNextParaObject:
default: {};
}
*found_val_ptr = found;
return status;
}
/*#################################################################
### GetNextHeaderHandle
###
### DESCRIPTION:
### This function provides the search routines with a fast method
### of scanning the header table. It only returns only the
### HeaderId and Attributes. The FDI_ReadFullHeader function
### can then be used along with the handle of the header, to
### read the entire header. This loads the srch_info_ptr
### header(partial), object size, and header address.
###
### PARAMETERS:
### srch_info_ptr - Structure containing search information.
### IN: - CurrObj.HeaderAddress references a valid header
### and value of 0 will start the search from the
### beginning of the header table.
### - HeaderPtr points to a valid header for temporary
### use.
###
### OUT: - CurrObj.HeaderAddress will reference the header
### address of the next header matching the type of
### search performed.
### - CurrObj.ObjectSize will contain the size in bytes,
### of the object.
### - HeaderPtr will contain the contents of the
### minimum information necessary to locate any
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -