📄 davrcvpr.c
字号:
###
### 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
### =================================================================
### UsePrevHeader | (A) 1,2 ------- -------
### UseCurrObject | (B) 5 (C) 1,2,4 (D) 3
### UseDummyObject | ------- (E) 1 -------
###
### PARAMETERS:
### none.
###
### RETURNS:
### ERR_NONE - When operation is successful.
*/
ERR_CODE RCVRPARA_SetupForParaReclaimRestart(BOOLEAN restart)
{
/* TO & FROM Address Calculation Methods */
enum
{
UsePrevHeader,
UseCurrObject,
UseNextObject,
UseDummyObject,
UseNoObject
} to_addr_method = UseNoObject, from_addr_method = UseNoObject;
/* DAV- added initial values above for to_addr_method, from_addr_method */
int in_block;
UINT32 pre_block_bytes;
FDI_Handle fhl_hdr_addr;
FDI_Handle top_of_from_block;
ERR_CODE status = ERR_NONE;
/* Misc. local calculations to save time */
fhl_hdr_addr =
RECTBL_GetFirstHeaderLocation((RecoverState.FHLReclaimStatus),
RecoverState.FHLBlock);
top_of_from_block = Block2Handle((RecoverState.FROMBlock + 1)) - 1;
in_block = IsInBlock(RecoverState.TOObject.ObjectAddress,
top_of_from_block, RecoverState.FROMBlock);
ReclaimState.SingleSkipRead = TRUE;
ReclaimState.MarkHeaderCopyComplete = TRUE;
/* Obtain the FROMInput and TOInput values for the lookup table. */
status = LocateLastTOObject(&SearchInfo, restart);
if (!status)
{
status = LocateLastFROMObject(&SearchInfo, restart);
}
if (status)
{
return status;
}
/*************************************************/
/* Calculate the appropriate lookup table inputs */
/*************************************************/
if (RecoverState.FROMInput == HDR_ST_Normal)
{
RecoverState.FROMInput = FROM_ObjectNormal;
}
else
{
RecoverState.FROMInput = FROM_ObjectReclaimInProgress;
}
if (RecoverState.TOInput == HDR_ST_Normal)
{
RecoverState.TOInput = TO_ObjectNormal;
}
else
{
if (RecoverState.TOInput == HDR_ST_CopyInProgress)
{
RecoverState.TOInput = TO_ObjectCopyInProgress;
}
else
{
RecoverState.TOInput = TO_NoObject;
}
}
#ifdef PRINT_ON
printf(" RESTART STATE MACH: ");
#endif
/*************************************************/
/*** TO & FROM Address Lookup Table ***/
/*************************************************/
/*************************************************/
/*** (1) Normal/Normal ***/
/*************************************************/
if ((RecoverState.FROMInput | RecoverState.TOInput) ==
(FROM_ObjectNormal | TO_ObjectNormal))
{
#ifdef PRINT_ON
printf("(1) Norm/Norm");
#endif
/* Theres a possibility that the FROM object is invalid */
/* in which we create a dummy object, or, that its valid, */
/* and we need to re-copy it. */
EVT_CountOccurance(EVT_RECRCVR_State1);
from_addr_method = UseCurrObject;
to_addr_method = UseNextObject;
if (RecoverState.FROMObject.HeaderAddress == fhl_hdr_addr)
{
if (RECTBL_IsPreviousValidObject(RecoverState.FHLReclaimStatus))
{
/* The TO Object refers to an object that has a header before */
/* the first block but a portion of that object resides in */
/* a block under reclaim. */
if ((in_block == 0) && (RecoverState.FHLBlock ==
ReclaimState.TableInfo.FirstBlock))
{
EVT_CountOccurance(EVT_RECRCVR_State1_a);
from_addr_method = UsePrevHeader;
to_addr_method = UseCurrObject;
}
}
else
{
if (RecoverState.FHLBlock != RecoverState.FROMBlock)
{
EVT_CountOccurance(EVT_RECRCVR_State1_b);
from_addr_method = UseDummyObject;
}
}
}
}
/*************************************************/
/*** (2) Normal/CIP ***/
/*************************************************/
if ((RecoverState.FROMInput | RecoverState.TOInput) ==
(FROM_ObjectNormal | TO_ObjectCopyInProgress))
{
#ifdef PRINT_ON
printf("(2) Norm/CIP");
#endif
/* Determine if there is any object prior to the from */
/* object that hasn't been copied. */
EVT_CountOccurance(EVT_RECRCVR_State2);
from_addr_method = UseCurrObject;
to_addr_method = UseNextObject;
if ((RecoverState.FROMObject.HeaderAddress == fhl_hdr_addr) &&
RECTBL_IsPreviousValidObject(RecoverState.FHLReclaimStatus)
&& (in_block == 0))
{
/* If there was a previous valid object, then finish copying */
/* it by calculating where the original header resided and */
/* reading the object information stored in the TO object. */
EVT_CountOccurance(EVT_RECRCVR_State2_a);
from_addr_method = UsePrevHeader;
to_addr_method = UseCurrObject;
}
if (to_addr_method == UseNextObject)
{
/* Mark the TOObject header to Normal...Its already been */
/* copied. */
EVT_CountOccurance(EVT_RECRCVR_State2_b);
TempHeader.HeaderId = HDR_ID_Normal;
status =
FLASH_WriteBuffer(RecoverState.TOObject.HeaderAddress,
(MemBufferPtr)&TempHeader.HeaderId,
sizeof(TempHeader.HeaderId));
if (status)
{
return status;
}
}
}
/*************************************************/
/*** (3) Normal/NoHdr RIP/NoHdr ***/
/*************************************************/
if (((RecoverState.FROMInput | RecoverState.TOInput) ==
(FROM_ObjectNormal | TO_NoObject)) ||
((RecoverState.FROMInput | RecoverState.TOInput) ==
(FROM_ObjectReclaimInProgress | TO_NoObject)))
{
#ifdef PRINT_ON
printf("(3) Norm/NoObj, RIP/NoObj");
#endif
EVT_CountOccurance(EVT_RECRCVR_State3);
/* Processing the first object (special case) start */
/* back at the beginning. */
from_addr_method = UseCurrObject;
to_addr_method = UseNoObject;
}
/*************************************************/
/*** (4) RIP/Normal ***/
/*************************************************/
if ((RecoverState.FROMInput | RecoverState.TOInput) ==
(FROM_ObjectReclaimInProgress | TO_ObjectNormal))
{
#ifdef PRINT_ON
printf("(4) RIP/Norm");
#endif
EVT_CountOccurance(EVT_RECRCVR_State4);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -