📄 davpagerecl.c
字号:
return status;
}
/* Copy the reclaim block to the erased page block */
status = FLASH_CopyFlash(FDI_ReclaimBlockAddressBottom, UTIL_CalcHandleOfBlockBottomBoundary(rtIndex), DAV_BLOCK_SIZE);
if(status != ERR_NONE)
{
return status;
}
case RTTBL_RtEntryProgressState_EraseReclaimBlockInProgress:
RTTBL_SetRtEntryProgressState(&rtEntry, RTTBL_RtEntryProgressState_EraseReclaimBlockInProgress);
status = RTTBL_WriteRtEntryProgressState(&rtEntryHandle, &rtEntry);
if(status != ERR_NONE)
{
return status;
}
/* Erase the reclaim block */
status = FLASH_EraseBlock(FDI_ReclaimBlockAddressBottom, TRUE);
if(status != ERR_NONE)
{
return status;
}
break;
case RTTBL_RtEntryProgressState_OperationComplete:
break;
case RTTBL_RtEntryProgressState_NoOperationRequired:
/* Skip all OTT entries related to this block */
/* The state was filled set by the RtInit. */
/* There are no objects in this block that will be moved. There are */
/* objects above and below this block that require work. */
ottIndex = 0;
/*Fix Start:SCR964 */
status = OTTTBL_CalcOttIndexToBlock((rtIndex+1),
&aRef->sramOttEntriesList[0],
aRef->sramOttEntries,
&ottIndex);
/*Fix End:SCR964 */
if(status != ERR_NONE)
{
if(status != ERR_NO_MORE_ENTRIES)
{
return status;
}
status = ERR_NONE;
}
break;
default:
status = ERR_STATE;
break;
} /* switch */
/* Block Complete */
if(RTTBL_GetRtEntryOpr(&rtEntry) != RTTBL_RtEntryOpr_NotUsed)
{
RTTBL_SetRtEntryProgressState(&rtEntry, RTTBL_RtEntryProgressState_OperationComplete);
status = RTTBL_WriteRtEntryProgressState(&rtEntryHandle, &rtEntry);
if(status != ERR_NONE)
{
return status;
}
}
else
{
/* Why did we not write objects? */
/* - Operation not required */
/* - A last OTT page erase */
/* - At the very end */
rtWriteCnt = 0;
}
/* Get the next block */
if(rtReads < RTTBL_GetNumRows(&rtLeader))
{
status = RTTBL_GetNextRtEntry(&rtEntryHandle, &rtEntry, &rtEntryHandle);
if(status != ERR_NONE)
{
return status;
}
rtReads++;
}
} /* for */
return status;
}
/*#################################################################
### RECLAIM_PAGE_InitializeOttRtTableForPageReclaim
###
### DESCRIPTION:
### This function creates the ott and rt table for the reclaim
### operation.
###
### PARAMETERS:
### aRef - IN: Parameter used throughout the page reclaim.
###
### 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 RECLAIM_PAGE_InitializeOttRtTableForPageReclaim(PAGE_RECLAIM_Address* aRef)
{
ERR_CODE status;
status = RECLAIM_PAGE_InitializeOttTable(aRef);
if(status != ERR_NONE)
{
return status;
}
status = RECLAIM_PAGE_InitializeRtTable(aRef);
if(status != ERR_NONE)
{
return status;
}
return status;
}
/*#################################################################
### RECLAIM_Page_ValidateSystemResources
###
### DESCRIPTION:
### This function validates that there is enough system resources
### based on the type of operation being performed.
###
### PARAMETERS:
### aRef - IN: Parameter used throughout the page reclaim.
###
### 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 RECLAIM_Page_ValidateSystemResources(PAGE_RECLAIM_Address* aRef)
{
ERR_CODE status = ERR_NONE;
/* The resources required are depends on the type of defrag we are doing */
switch(aRef->reclaimType)
{
case enPageReallocate:
/* Reallocate does backups */
status = RECLAIM_PAGE_ValidateBackupSpace(aRef);
if(status != ERR_NONE)
{
return status;
}
break;
case enPageReclaimInPlace:
/* We must have the reallocate object and backup handles */
if(aRef->relocObjHandle == 0)
return ERR_STATE;
if(aRef->bkupObjHandle == 0)
return ERR_STATE;
break;
case enPageReclaimFull:
case enPageReclaimPartial:
/* If the last object is a free object, do an absorb on these headers */
status = RECLAIM_PAGE_RemoveAllFreeChunckAtTopOfMemory(aRef);
if(status != ERR_NONE)
{
return status;
}
/* Validate if we have at least 1 valid header */
status = RECLAIM_PAGE_AnyFreeOrDirtyOrWipHeaders(aRef);
if(status != ERR_NONE)
{
return status;
}
break;
} /* switch */
/* Create a CT entry (a paragraph reclaim is triggered if no more entries) */
status = CFGTBL_Allocate_PAGE_RECLAIM();
if(status != ERR_NONE)
{
return status;
}
return status;
}
/* =========================== Public Functions =============================*/
/*#################################################################
### RECLAIM_PAGE_StartReclaim
###
### DESCRIPTION:
### This function start the real page reclaim based on
### parameters sent with the call.
###
### PARAMETERS
### aRef -- Parameter used throughout the paragraph reclaim.
###
### 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 RECLAIM_PAGE_StartReclaim(PAGE_RECLAIM_Address* aRefPtr)
{
ERR_CODE status = ERR_STATE;
/* If we are not starting from the very top, then we are recovering from a powerloss */
aRefPtr->sramOttEntries = 0;
if(aRefPtr->startOperation != enStartOfPageReclaim)
{
aRefPtr->plrRestart = TRUE;
}
else
{
aRefPtr->plrRestart = FALSE;
}
/* Start the page reclaim operation */
switch(aRefPtr->startOperation)
{
case enStartOfPageReclaim:
status = RECLAIM_Page_ValidateSystemResources(aRefPtr);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
case enInitializeOttRtTables:
status = CFGTBL_WritePageProgressState(CFGTBL_CtProgressState_InitializeInProgress);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
status = RECLAIM_PAGE_InitializeOttRtTableForPageReclaim(aRefPtr);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
case enMoveUserObjects:
status = CFGTBL_WritePageProgressState(CFGTBL_CtProgressState_MoveInProgress);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
status = RECLAIM_PAGE_MoveUserObjects(aRefPtr);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
case enRelocateHeaders:
status = CFGTBL_WritePageProgressState(CFGTBL_CtProgressState_RelocateHeadersInProgress);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
switch(aRefPtr->reclaimType)
{
case enPageReallocate:
case enPageReclaimInPlace:
break;
default:
/* Relocate all headers */
status = RECLAIM_PARAGRAPH_PerformReclaim(enPerformHeaderRelocate, FALSE);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
} /* switch */
case enInitializeRatTable:
status = CFGTBL_WritePageProgressState(CFGTBL_CtProgressState_InitializeRatInProgress);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
status = RECLAIM_PAGE_InitializeRatTable(aRefPtr);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
case enModifyUserObjects:
status = CFGTBL_WritePageProgressState(CFGTBL_CtProgressState_ModifyInProgress);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
status = RECLAIM_PAGE_ModifyUserObjects(aRefPtr);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
case enPageReclaimOperationComplete:
status = CFGTBL_WritePageProgressState(CFTTBL_CtProgressState_DefragComplete);
if(status != ERR_NONE)
{
CFGTBL_DeAllocatePageTables(enAbortedDefragCleanupState, status, aRefPtr->plrRestart);
break;
}
status = CFGTBL_DeAllocatePageTables(enCompletedDefragCleanupState, status, aRefPtr->plrRestart);
if(status != ERR_NONE)
{
break;
}
status = ERR_NONE;
break;
default:
status = ERR_STATE;
break;
} /* switch */
return status;
}
#endif /* DIRECT_ACCESS_VOLUME */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -