📄 davrecl.c
字号:
SearchInfo.CurrObj.HeaderAddress = 0;
SearchInfo.CurrObj.ConfigEntry.Status = 0;
SearchInfo.CurrObj.ConfigEntry.Offset = 0;
ReclaimState.CurrentBlock2Reclaim =
ReclaimState.TableInfo.FirstBlock;
ReclaimState.CurrentDoneBlock =
ReclaimState.CurrentBlock2Reclaim;
EVT_Test4Crash(EVT_RECLAIM_StateE);
/*lint -fallthrough*/
case RECRCVR_StartStateMachine:
/* Process each block until the next state = ReclaimComplete. */
while(!status && (ReclaimState.NextState !=
(UINT16)RECLAIM_ST_ReclaimComplete))
{
if(method == ReclaimParagraphObjects)
{
status = RECPARA_SaveValidObjsInCurrBlock(restart);
ReclaimState.CurrentBlock2Reclaim--;
}
else
{
status = RECPAGE_SaveValidObjsInCurrBlock(restart);
ReclaimState.CurrentBlock2Reclaim++;
}
}
/* Bump the block back one due to loop method */
if(method == ReclaimParagraphObjects)
{
ReclaimState.CurrentBlock2Reclaim++;
}
else
{
ReclaimState.CurrentBlock2Reclaim--;
}
if(status)
{
break;
}
/*lint -fallthrough*/
case RECRCVR_RelocateReclaimTable:
/* Move the reclaim table to the reclaim block. */
status = RECLAIM_ReLocateReclaimTable((BOOLEAN)(method == ReclaimParagraphObjects), restart);
if(status)
{
break;
}
/*lint -fallthrough*/
case RECRCVR_FinishRemainingBlocks:
/* Erase the current block & copy back any reclaim block data. */
status = RECLAIM_FinishBlock(ReclaimState.CurrentBlock2Reclaim,
(BOOLEAN)(method == ReclaimParagraphObjects), FALSE, restart);
EVT_Test4Crash(EVT_RECLAIM_StateJ);
if(method == ReclaimParagraphObjects)
{
last_block_2_reclaim = ReclaimState.TableInfo.FirstBlock -
(ReclaimState.TableInfo.TotalBlocks - 1);
}
else
{
last_block_2_reclaim = ReclaimState.TableInfo.FirstBlock +
(ReclaimState.TableInfo.TotalBlocks - 1);
}
/* Erase any blocks that are spanned by the reclaim table. */
while((ReclaimState.CurrentBlock2Reclaim !=
last_block_2_reclaim) && !status)
{
if(method == ReclaimParagraphObjects)
{
if(ReclaimState.CurrentBlock2Reclaim == 0)
{
break;
}
ReclaimState.CurrentBlock2Reclaim--;
}
else
{
ReclaimState.CurrentBlock2Reclaim++;
}
/* If the reclaim table crossed into the next block, */
/* then erase the remaining portion right away. */
status = RECLAIM_EraseBlock(ReclaimState.CurrentBlock2Reclaim,
TRUE, (BOOLEAN)(method == ReclaimParagraphObjects), restart);
}
if(status)
{
break;
}
EVT_Test4Crash(EVT_RECLAIM_StateK);
/*lint -fallthrough*/
case RECRCVR_FinishUpReclaim:
/* Reset the flag that indicates the OTT table needs to be *
* initialized for future deallocates. */
OTT_flag = FALSE;
/*
* Must mark the TableId in the reclaim block to 0 to
* indicate that the reclaim block will be erased.
* Recovery will see that there is no table in the RB
* yet, there is still a reclaim table object, etc, etc.
*/
ReclaimState.TableInfo.TableId = RECTBL_TableDataInvalid;
status = FLASH_WriteBuffer((ReclaimState.RecTblBaseAddr + RECTBL_TableIdOffset),
(MemBufferPtr)&ReclaimState.TableInfo.TableId,
sizeof(ReclaimState.TableInfo.TableId));
if(status)
{
break;
}
if(method == ReclaimParagraphObjects)
{
/* Erase the reclaim block. */
status = FLASH_EraseBlock(FDI_ReclaimBlockAddress, FALSE);
if(status)
{
return status;
}
EVT_Test4Crash(EVT_RECLAIM_StateL);
/* Mark the configuration header entry ReclaimComplete. */
status = CFGHDR_WriteReclaimComplete(ReclaimState.ConfigIndex);
if(status)
{
return status;
}
}
else
{
/* Mark all invalid page header entries to Absorbed. */
status = HDR_AbsorbInvalidHeaders(&SearchInfo, restart);
if(status)
{
return status;
}
/* Erase the reclaim block. */
status = FLASH_EraseBlock(FDI_ReclaimBlockAddress, FALSE);
if(status)
{
return status;
}
EVT_Test4Crash(EVT_RECLAIM_StateL);
/* Mark the reclaim table header to absorbed. */
status = HDR_AbsorbHeader(SearchInfo.CurrObj.HeaderAddress,
SearchInfo.HeaderPtr);
EVT_Test4Crash(EVT_RECLAIM_StateL_SP1);
if(status)
{
return(status);
}
/* Mark the reclaim table header to Invalid. ??? */
status = HDR_InvalidateHeader(SearchInfo.CurrObj.HeaderAddress,
SearchInfo.HeaderPtr);
if(status)
{
return status;
}
}
/*lint -fallthrough*/
case RECRCVR_ModifyMovedObjects:
if(method == ReclaimPageObjects)
{
/* Reset the object counter to 0. */
ReclaimState.CurrentObject2Modify = 0;
/* Read the OTT table. */
status = OTTTBL_GetTableInfo(ReclaimState.OTTTblBaseAddr,
&ReclaimState.OTTTableInfo, restart);
if(status)
{
return status;
}
/* If the src_addr and the dest_addr fields are valid,
* it means that some objects might have to be reallocated.
*/
if((ReclaimState.OTTTableInfo.dest_addr != DWORDMAX) &&
(ReclaimState.OTTTableInfo.src_addr != DWORDMAX))
{
if(restart)
{
/* Read the current object entry. */
status = OTTTBL_ReadTable(ReclaimState.OTTTblBaseAddr,
ReclaimState.CurrentObject2Modify,
&ReclaimState.OTTTblEntry, restart);
if(status != ERR_NONE)
{
return status;
}
/* If OTT entry is finished, update dest and src addresses to point
* to addresses following this object.
*/
while(OTTTBL_IsOTTEntryInvalid(ReclaimState.OTTTblEntry.status))
{
/* Update dest address based on this item's object size */
ReclaimState.OTTTableInfo.dest_addr +=
ReclaimState.OTTTblEntry.objsize;
/* Update src address based on this item's object size */
ReclaimState.OTTTableInfo.src_addr +=
ReclaimState.OTTTblEntry.objsize;
/* Increment the CurrentObject2Modify so that the next scan of the
* OTT table will find the next item.
*/
ReclaimState.CurrentObject2Modify++;
/* Read the next object entry. */
status = OTTTBL_ReadTable(ReclaimState.OTTTblBaseAddr,
ReclaimState.CurrentObject2Modify,
&ReclaimState.OTTTblEntry, restart);
if(status != ERR_NONE)
{
return status;
}
}
}
/* Initialize search information structure */
HDR_InitSearchInfo((&OTT_SearchInfo), (&OTT_SearchHeader));
/* Calculate the source and the destination address of the current object. */
current_dest_addr = ReclaimState.OTTTableInfo.dest_addr;
current_src_addr = ReclaimState.OTTTableInfo.src_addr;
prev_hdr_addr = 0;
prev_hdr_NameSize = 0;
/* Find the header of the first object that needs to be reallocated. */
do
{
/* To do reallocate of the moved objects, we need the object information. */
/* To get this info, do a getnextobject, until the object address matches
the dest_addr. */
for(;;)
{
status = GetNextHeader(&OTT_SearchInfo,
HDR_ByNextPageObject, &compare_info, restart);
if ((status != ERR_NONE) && (status != ERR_NO_MORE_ENTRIES) &&
(status != ERR_PARAM))
{
return(status);
}
if(!status)
{
/* Make sure that the interface cannot see any system objects. */
if(OTT_SearchInfo.HeaderPtr->ObjectType > FDI_HT_EndReservedTypes)
{
break;
}
}
else
{
break;
}
}
if(!status)
{
/* Need to read full header for this type of search */
status = HDR_ReadFullHeader(OTT_SearchInfo.CurrObj.HeaderAddress,
OTT_SearchInfo.HeaderPtr, restart);
if(status)
{
return status;
}
}
else
{
break;
}
/* Found the object, now translate the object information to */
/* the interface function equivalent. */
HDR_SearchInfo2ObjectInfo(&obj_info, &OTT_SearchInfo);
prev_hdr_addr = OTT_SearchInfo.CurrObj.HeaderAddress;
prev_hdr_NameSize = OTT_SearchInfo.HeaderPtr->NameSize;
/* If the dest_addr matches the object address,
then the first object that needs to be reallocated
is found. Hence exit. */
}while(ReclaimState.OTTTableInfo.dest_addr !=
obj_info.ObjectAddress);
if (status == ERR_NO_MORE_ENTRIES)
{
status = ERR_NONE;
}
}
/* end of if((ReclaimState.OTTTableInfo.dest_addr != DWORDMAX) &&
(ReclaimState.OTTTableInfo.src_addr != DWORDMAX)) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -