📄 davrdobj.c
字号:
/* Copyright (c) 1995-2004 Intel Corporation */
/* Intel Confidential */
/* ###########################################################################
### DAV - Direct Access Volume Enhancement to FDI
###
### Module: davrdobj.c - DAV Interface Function: Read Object Module
###
### $Workfile: davrdobj.c $
### $Revision: 65 $
### $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 "davrdobj.h"
/*### Local Declarations
#########################*/
/*### 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_ReadObject
###
### DESCRIPTION:
### This function reads data from the object space of the
### object specified by obj_name and obj_type. The number
### of bytes specified by byte_count beginning from offset
### are read to the buffer pointed to by buffer_ptr. During
### a reallocate it is possible to have two headers with the
### same name and type. The select parameter is used to
### determine which object to read from, the first or the
### second occurrence.
###
### PARAMETERS:
### obj_name - Name of object.
### name_size - Length of the name field in bytes.
### obj_type - Type of the object.
### buffer_ptr - IN: Physical address pointing to the beginning
### of the buffer where the data will be placed.
### OUT: buffer will be filled with data from object space
### byte_count - Number of bytes to read from the object to
### the buffer.
### offset - Offset from the beginning of the object in
### object space to begin reading from.
### select - Which object to read from.
### FDI_SELECT_FIRST = 1st object,
### FDI_SELECT_SECOND = 2nd 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_ReadObject(UINT8* obj_name,
UINT8 name_size,
UINT32 obj_type,
UINT8* buffer_ptr,
UINT32 byte_count,
UINT32 offset,
UINT8 select )
{
UINT32 object_size;
ERR_CODE status;
FDI_Handle read_address;
SEARCH_CompareInfo compare_info;
/* Check range of ObjectType */
if(obj_type < FDI_HT_BeginUserTypes )
{
return ERR_PARAM;
}
/* Check for invalid Namesize and if the Name pointer is pointing to NULL */
if((name_size <= 0 ) ||
(name_size > FDI_MaxNameLength ) ||
(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();
/* Search for the object from the beginning of the */
/* header table. */
SEARCH_Header2SearchInfo((&FDI_SearchInfo), (&FDI_SearchHeader));
/* Search for the object and calculate the base address OF THE OBJECT DATA */
compare_info.NamePtr = (HDR_NamePtr)(obj_name);
compare_info.NameSize = name_size;
compare_info.CompareValue = obj_type;
status = SEARCH_GetNextHeader(&FDI_SearchInfo, SEARCH_ByNameType, &compare_info, FALSE);
if (status == ERR_NONE)
{
/* object data begins after the object header */
read_address = FDI_SearchInfo.CurrObj.ObjectAddress + sizeof(HDR_ObjectHeader);
object_size = FDI_SearchInfo.CurrObj.ObjectSize - sizeof(HDR_ObjectHeader);
if (select == FDI_SELECT_SECOND)
{
status = SEARCH_GetNextHeader(&FDI_SearchInfo, SEARCH_ByNameType, &compare_info, FALSE);
if ((status != ERR_NONE) &&
(status != ERR_NO_MORE_ENTRIES) &&
(status != ERR_PARAM))
{
ExitOnError(status);
}
if (status == ERR_NONE)
{
/* object data begins after the object header */
read_address = FDI_SearchInfo.CurrObj.ObjectAddress + sizeof(HDR_ObjectHeader);
object_size = FDI_SearchInfo.CurrObj.ObjectSize - sizeof(HDR_ObjectHeader);
}
else
{
status = ERR_NOTEXISTS;
ExitOnError(status);
}
}
/* Check upper bounds of the read, if it goes beyond the */
/* size of the object then return an error. */
if ((offset + byte_count) > object_size)
{
status = ERR_PARAM;
ExitOnError(status);
}
/* read the object data from flash */
status = OBJ_ReadObjectData(read_address+offset, buffer_ptr, byte_count);
ExitOnError(status);
}
/* If the object does not exist, a value of ERR_NOTEXISTS is returned. */
if (status == ERR_NO_MORE_ENTRIES)
{
status = ERR_NOTEXISTS;
ExitOnError(status);
}
FDI_APIUnlock();
return status;
}
#endif /* DIRECT_ACCESS_VOLUME */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -