📄 davrcvpr.c
字号:
/* Copyright (c) 1995-2002 Intel Corporation */
/* Intel Confidential */
/* ###########################################################################
### RCVRPARA
###
### Module: rcvrpara.c - Paragraph Recovery Module
###
### $Workfile: davrcvpr.c $
### $Revision: 48 $
### $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)
/*
#define PRINT_ON
*/
/*### Local Declarations
//#########################*/
/* Input definitions for TO & FROM Address Lookup Table */
enum
{
FROM_ObjectNormal = 0,
FROM_ObjectReclaimInProgress = 1,
TO_NoObject = 2,
TO_ObjectNormal = 4,
TO_ObjectCopyInProgress = 8
};
/* This header is used to prevent the need to re-search after */
/* using the SearchInfo.HeaderPtr. */
HDR_Header TempHeader;
/*### Global Declarations
//#########################*/
/*### Local Functions
//#########################*/
ERR_CODE LocateLastFROMObject(HDR_SearchInfoPtr obj_info_ptr, BOOLEAN restart);
ERR_CODE LocateLastTOObject(HDR_SearchInfoPtr obj_info_ptr, BOOLEAN restart);
/*########################################################################
### LocateLastFROMObject
###
### DESCRIPTION:
### This function will use the first valid FHL entry in the
### reclaim table to find the first header address that it
### can begin searching from. It will locate the last header
### that does not have a reclaim status of CopyOutComplete.
###
### NOTE: This function requires that the reclaim table entry
### never get marked to CopyOutComplete! It will return
### a fatal error if such a state is encountered.
###
### Once the last header is found, the FROMInput value is
### set to the reclaim state of the header, to be used
### by the TO and FROM Calculation Lookup Table.
###
### PARAMETERS:
### obj_info_ptr - Last from object information.
###
### RETURNS:
### ERR_NONE - When operation is successful.
###
*/
ERR_CODE LocateLastFROMObject(HDR_SearchInfoPtr obj_info_ptr, BOOLEAN restart)
{
ERR_CODE status = ERR_NONE;
HDR_CompareInfo compare_info;
obj_info_ptr->CurrObj.HeaderAddress =
RECTBL_GetFirstHeaderLocation((RecoverState.FHLReclaimStatus),
RecoverState.FHLBlock);
status = GetNextHeaderHandle(obj_info_ptr, GNH_SP_StartAtCurrent, restart);
if ((status != ERR_NONE) && (status != ERR_NO_MORE_ENTRIES) &&
(status != ERR_PARAM))
{
return(status);
}
if (HDR_ID_IsCopyOutComplete((obj_info_ptr->HeaderPtr->HeaderId)))
{
/* The current header must be CopyOutComplete! */
/* Search until the last one is found. */
compare_info.CompareValue = HDR_ST_CopyOutComplete;
status = GetNextHeader(obj_info_ptr,
HDR_ByNotReclaimState, &compare_info, restart);
if (status != ERR_NONE)
{
if ((status == ERR_NO_MORE_ENTRIES) || (status == ERR_PARAM))
{
return ERR_SYSTEM;
}
else
{
return(status);
}
}
}
/* Generate TO & FROM Address Lookup table input */
RecoverState.FROMInput =
HDR_ID_GetReclaimState(obj_info_ptr->HeaderPtr->HeaderId);
RecoverState.FROMObject.HeaderAddress =
obj_info_ptr->CurrObj.HeaderAddress;
HDR_GetObjectSize(obj_info_ptr->HeaderPtr,
&RecoverState.FROMObject.ObjectSize);
return ERR_NONE;
}
/*########################################################################
### LocateLastTOObject
###
### DESCRIPTION:
### This function will search through "TO" space looking for
### the last complete object header. It will also search the
### reclaim block.
###
### Once the object is found the RecoverState.TOInput parameter is set
### to the reclaim status of the header id. This is used to
### lookup the type of address calculation to be performed.
###
### NOTE: There must always be one header (Configuration
### Header).
###
### PARAMETERS:
### obj_info_ptr - Last from object information.
###
### RETURNS:
### ERR_NONE - When operation is successful.
*/
ERR_CODE LocateLastTOObject(HDR_SearchInfoPtr obj_info_ptr, BOOLEAN restart)
{
BOOLEAN search_reclaim_block = FALSE; /* DAV init */
FDI_Handle next_address;
ERR_CODE status = ERR_NONE;
RecoverState.TOObject.HeaderAddress = 0;
RecoverState.TOObject.ConfigEntry.Offset = 0;
RecoverState.TOObject.ConfigEntry.Status = 0;
obj_info_ptr->CurrObj.HeaderAddress = 0;
obj_info_ptr->CurrObj.ConfigEntry.Offset = 0;
obj_info_ptr->CurrObj.ConfigEntry.Status = 0;
if (RecoverState.FROMBlock == RecoverState.TOBlock)
{
/* There may be data in the reclaim block, so take a look! */
if ((RecoverState.TOBlock == ReclaimState.TableInfo.FirstBlock) &&
(ReclaimState.TableInfo.FirstBlock ==
Handle2Block(HDR_FirstHeaderAddr)))
{
/* Not only might there be data in the RB but, it */
/* starts there too. */
obj_info_ptr->CurrObj.HeaderAddress =
(FDI_ReclaimBlockAddress + FDI_BlockSize) - HDR_FixedSizeP;
RecoverState.BlockLimit = Handle2Block(FDI_ReclaimBlockAddress);
}
else
{
search_reclaim_block = TRUE;
RecoverState.BlockLimit = RecoverState.TOBlock + 1;
}
}
else
{
/* There is no data in the reclaim block, so don't bother */
/* searching through it. */
search_reclaim_block = FALSE;
RecoverState.BlockLimit = RecoverState.TOBlock;
}
/* Search for the last object having a complete fixed header. */
do
{
status = GetNextHeaderHandle(obj_info_ptr, GNH_SP_StartAtCurrent, restart);
if ((status != ERR_NONE) && (status != ERR_NO_MORE_ENTRIES) &&
(status != ERR_PARAM))
{
return(status);
}
if (!status)
{
next_address =
HDR_CalcNextHdrAddr(obj_info_ptr->CurrObj.HeaderAddress,
(UINT16)HDR_GetAlignmentAttr((obj_info_ptr->HeaderPtr->Attr16)),
obj_info_ptr->HeaderPtr->NameSize,
obj_info_ptr->CurrObj.ObjectSize);
/* Generate TO & FROM Address Lookup table input */
RecoverState.TOInput =
HDR_ID_GetReclaimState(obj_info_ptr->HeaderPtr->HeaderId);
RecoverState.TOObject.HeaderAddress =
obj_info_ptr->CurrObj.HeaderAddress;
HDR_GetObjectSize(obj_info_ptr->HeaderPtr,
&RecoverState.TOObject.ObjectSize);
/* If the next object goes out of bounds, check to */
/* see if we should search the reclaim block. */
if ((next_address >= Block2Handle(RecoverState.BlockLimit)) &&
(next_address < obj_info_ptr->CurrObj.HeaderAddress))
{
obj_info_ptr->CurrObj.HeaderAddress = next_address;
}
else
{
if ((Handle2Block(obj_info_ptr->CurrObj.HeaderAddress) !=
Handle2Block(FDI_ReclaimBlockAddress)) &&
search_reclaim_block)
{
/* Start searching through the reclaim block as if, */
/* it were following the TO block. */
obj_info_ptr->CurrObj.HeaderAddress =
FDI_ReclaimBlockAddress + (next_address -
BlockAlign(next_address));
RecoverState.BlockLimit =
Handle2Block(FDI_ReclaimBlockAddress);
}
else
{
/* We were already searching the reclaim block or, we */
/* had nothing in it from the start. */
break;
}
}
}
}
while (!status);
return ERR_NONE;
}
/*### Global Functions
//#########################*/
/*########################################################################
### RCVRPARA_SetupForParaReclaimRestart
###
### DESCRIPTION:
### This function will setup the paragraph reclaim state machine
### to re-enter the state machine at the ReadNextObject state.
###
### NOTE: Must have a valid config header entry in
### ReclaimState.RecTblHdrAddr.
###
### TO Method
### FROM Method | UseCurrObject UseNextObject UseNoObject
### =================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -