📄 davpageinit.c
字号:
status = FLASH_CopyFlash(bottomBlockLowerBoundary, FDI_ReclaimBlockAddressBottom, copySize);
ExitOnError(status);
}
/* set state: RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupInReclaim */
RATTBL_SetRatEntryTopProgressState(aRatEntryPtr, RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupInReclaim);
status = RATTBL_WriteRatEntryTopProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupInReclaim:
/* erase the btm block */
/* copy btm block valid objects from reclaim to btm block */
/* Erase the block */
status = FLASH_EraseBlock(bottomBlockLowerBoundary, FALSE);
ExitOnError(status);
/* If any data was indeed copied up to the reclaim block, then copy it all back down from the reclaim block to the original block */
status = FLASH_CopyFlash(FDI_ReclaimBlockAddressBottom, bottomBlockLowerBoundary, FDI_BlockSize);
ExitOnError(status);
/* set state: RATTBL_RatEntryTopProgressState_TopBlkBkupGroupReclaimComplete */
/* note: since top block is same as bottom, we're setting top block reclaim complete here */
RATTBL_SetRatEntryTopProgressState(aRatEntryPtr, RATTBL_RatEntryTopProgressState_TopBlkBkupGroupReclaimComplete);
status = RATTBL_WriteRatEntryTopProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupReclaimComplete:
/* fall through to next case */
case RATTBL_RatEntryTopProgressState_TopBlkBkupGroupInReclaim:
/* fall through to next case */
break;
} /* end switch */
}
else /* the group spans more than one block */
{
switch(RATTBL_GetRatEntryTopProgressState(aRatEntryPtr))
{
case RATTBL_RatEntryTopProgressState_ModifyComplete:
/* Copy data between the bottom address of the group and the bottom address of the block to the reclaim block at the same offset */
copySize = aBottomObjectHandle - bottomBlockLowerBoundary;
if(copySize > 0)
{
status = FLASH_CopyFlash(bottomBlockLowerBoundary, FDI_ReclaimBlockAddressBottom, copySize);
ExitOnError(status);
}
/* set state: RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupInReclaim */
RATTBL_SetRatEntryTopProgressState(aRatEntryPtr, RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupInReclaim);
status = RATTBL_WriteRatEntryTopProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupInReclaim:
/* Erase the block */
status = FLASH_EraseBlock(bottomBlockLowerBoundary, FALSE);
ExitOnError(status);
/* If any data was indeed copied up to the reclaim block, then copy it all back down from the reclaim block to the original block */
FLASH_CopyFlash(FDI_ReclaimBlockAddressBottom, bottomBlockLowerBoundary, FDI_BlockSize);
ExitOnError(status);
/* set state: RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupReclaimComplete */
RATTBL_SetRatEntryTopProgressState(aRatEntryPtr, RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupReclaimComplete);
status = RATTBL_WriteRatEntryTopProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryTopProgressState_BtmBlkBkupGroupReclaimComplete:
/* erase the reclaim block */
status = FLASH_EraseBlock(FDI_ReclaimBlockAddressBottom, FALSE);
ExitOnError(status);
/* erase intervening blocks */
for (index = aBottomBlock + 1; index < aTopBlock; index++)
{
/* Erase the block */
status = FLASH_EraseBlock((index * FDI_BlockSize) + FDI_PageSpaceAddressBottom, FALSE);
ExitOnError(status);
}
/* copy top block valid objects from top block to reclaim */
/* Copy data between the top address of the group and the top address of the block to the reclaim block at the same offset */
copySize = topBlockUpperBoundary - (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize)) + 1;
if(copySize > 0)
{
status = FLASH_CopyFlash(aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize), FDI_ReclaimBlockAddressBottom + (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize) - topBlockLowerBoundary), copySize);
ExitOnError(status);
}
/* set state: RATTBL_RatEntryTopProgressState_TopBlkBkupGroupInReclaim */
RATTBL_SetRatEntryTopProgressState(aRatEntryPtr, RATTBL_RatEntryTopProgressState_TopBlkBkupGroupInReclaim);
status = RATTBL_WriteRatEntryTopProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryTopProgressState_TopBlkBkupGroupInReclaim:
/* erase the top block */
status = FLASH_EraseBlock(topBlockLowerBoundary, FALSE);
ExitOnError(status);
/* copy top block valid objects from reclaim to top block */
status = FLASH_CopyFlash(FDI_ReclaimBlockAddressBottom, topBlockLowerBoundary, FDI_BlockSize);
ExitOnError(status);
/* set state: RATTBL_RatEntryTopProgressState_TopBlkBkupGroupReclaimComplete */
RATTBL_SetRatEntryTopProgressState(aRatEntryPtr, RATTBL_RatEntryTopProgressState_TopBlkBkupGroupReclaimComplete);
status = RATTBL_WriteRatEntryTopProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
} /* end switch */
} /* end else group spans more than one block */
/* this function ends without erasing the reclaim; must be done by next state */
return status;
}
/*#################################################################
### RECLAIM_PAGE_RestartEraseBackupGroup
###
### DESCRIPTION:
### Erase a group of backup objects during PLR.
### Modify the RAT as needed.
###
### PARAMETERS:
### aRatEntryPtr -- IN/OUT: ptr to RAT entry for the group.
### aTopBlock -- IN: top block intersecting with group
### aTopObjectHandle -- IN: handle of top object in group
### aTopObjectSizeInPages -- IN: size of top object in pages
### aGroupSizeInPages -- IN: group size in pages.
### aBottomBlock -- IN: bottom block intersecting with group
### aBottomObjectHandle -- IN/OUT: handle to btm object in group
### restart -- IN: Flag used for PLR.
###
### RETURNS:
### When this function passes with no errors a value of 0 is
### returned otherwise, it returns a status of type ERR_CODE.
###*/
/*Fix Start:SCR964 */
ERR_CODE RECLAIM_PAGE_RestartEraseBackupGroup(FDI_Handle aRatEntryHandle,
RATTBL_EntryPtr aRatEntryPtr,
UINT16 aTopBlock,
FDI_Handle aTopObjectHandle,
UINT32 aTopObjectSizeInPages,
UINT32 aGroupSizeInPages,
UINT16 aBottomBlock,
FDI_Handle aBottomObjectHandle,
BOOLEAN restart)
/*Fix End:SCR964 */
{
ERR_CODE status = ERR_NONE;
UINT32 copySize;
FDI_Handle topBlockUpperBoundary;
FDI_Handle topBlockLowerBoundary;
FDI_Handle bottomBlockUpperBoundary;
FDI_Handle bottomBlockLowerBoundary;
UINT16 index;
topBlockUpperBoundary = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aTopBlock, enTopBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom - 1);
topBlockLowerBoundary = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aTopBlock, enBottomBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom);
bottomBlockUpperBoundary = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aBottomBlock, enTopBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom - 1);
bottomBlockLowerBoundary = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aBottomBlock, enBottomBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom);
if(aTopBlock == aBottomBlock)
{
switch(RATTBL_GetRatEntryBtmProgressState(aRatEntryPtr))
{
case RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupInProgress:
/* erase the backup group */
/* copy btm block valid objects from btm block to reclaim */
/* Copy data between the top address of the group and the top address of the block to the reclaim block at the same offset */
copySize = topBlockUpperBoundary - (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize)) + 1;
if(copySize > 0)
{
status = FLASH_CopyFlash(aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize), FDI_ReclaimBlockAddressBottom + (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize) - topBlockLowerBoundary), copySize);
ExitOnError(status);
}
/* Copy data between the bottom address of the group and the bottom address of the block to the reclaim block at the same offset */
copySize = aBottomObjectHandle - bottomBlockLowerBoundary;
if(copySize > 0)
{
status = FLASH_CopyFlash(bottomBlockLowerBoundary, FDI_ReclaimBlockAddressBottom, copySize);
ExitOnError(status);
}
/* set state: RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupInReclaim */
RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupInReclaim);
status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupInReclaim:
/* erase the btm block */
/* copy btm block valid objects from reclaim to btm block */
/* Erase the block */
status = FLASH_EraseBlock(bottomBlockLowerBoundary, FALSE);
ExitOnError(status);
/* If any data was indeed copied up to the reclaim block, then copy it all back down from the reclaim block to the original block */
FLASH_CopyFlash(FDI_ReclaimBlockAddressBottom, bottomBlockLowerBoundary, FDI_BlockSize);
ExitOnError(status);
/* set state: RATTBL_RatEntryBtmProgressState_RestartTopBlkBkupGroupReclaimComplete */
/* note: since top block is same as bottom, we're setting top block reclaim complete here */
RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_RestartTopBlkBkupGroupReclaimComplete);
status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupReclaimComplete:
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_RestartTopBlkBkupGroupInReclaim:
/* fall through to next case */
break;
} /* end switch */
}
else /* the group spans more than one block */
{
switch(RATTBL_GetRatEntryBtmProgressState(aRatEntryPtr))
{
case RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupInProgress:
/* Copy data between the bottom address of the group and the bottom address of the block to the reclaim block at the same offset */
copySize = aBottomObjectHandle - bottomBlockLowerBoundary;
if(copySize > 0)
{
status = FLASH_CopyFlash(bottomBlockLowerBoundary, FDI_ReclaimBlockAddressBottom, copySize);
ExitOnError(status);
}
/* set state: RATTBL_RatEntryBtmProgressState_BtmBlkBkupGroupInReclaim */
RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupInReclaim);
status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupInReclaim:
/* Erase the block */
status = FLASH_EraseBlock(bottomBlockLowerBoundary, FALSE);
ExitOnError(status);
/* If any data was indeed copied up to the reclaim block, then copy it all back down from the reclaim block to the original block */
FLASH_CopyFlash(FDI_ReclaimBlockAddressBottom, bottomBlockLowerBoundary, FDI_BlockSize);
ExitOnError(status);
/* set state: RATTBL_RatEntryBtmProgressState_BtmBlkBkupGroupReclaimComplete */
RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupReclaimComplete);
status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupReclaimComplete:
/* erase the reclaim block */
status = FLASH_EraseBlock(FDI_ReclaimBlockAddressBottom, FALSE);
ExitOnError(status);
/* erase intervening blocks */
for (index = aBottomBlock + 1; index < aTopBlock; index++)
{
/* Erase the block */
status = FLASH_EraseBlock((index * FDI_BlockSize) + FDI_PageSpaceAddressBottom, FALSE);
ExitOnError(status);
}
/* copy top block valid objects from top block to reclaim */
/* Copy data between the top address of the group and the top address of the block to the reclaim block at the same offset */
copySize = topBlockUpperBoundary - (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize)) + 1;
if(copySize > 0)
{
status = FLASH_CopyFlash(aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize), FDI_ReclaimBlockAddressBottom + (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize) - topBlockLowerBoundary), copySize);
ExitOnError(status);
}
/* set state: RATTBL_RatEntryBtmProgressState_RestartTopBlkBkupGroupInReclaim */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -