📄 davpageinit.c
字号:
RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_RestartTopBlkBkupGroupInReclaim);
status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_RestartTopBlkBkupGroupInReclaim:
/* 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_RatEntryBtmProgressState_RestartTopBlkBkupGroupReclaimComplete */
RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_RestartTopBlkBkupGroupReclaimComplete);
status = RATTBL_WriteRatEntryBtmProgressState(&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_RestartInvalidateOrigObject
###
### DESCRIPTION:
### Invalidate and object that was modified without backup, but
### modification was interrupted by power loss.
###
### PARAMETERS:
### aOrigObjectHandle -- handle to object in page space.
### 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.
###*/
ERR_CODE RECLAIM_PAGE_RestartInvalidateOrigObject(FDI_Handle aOrigObjectHandle,
BOOLEAN restart)
{
ERR_CODE status = ERR_NONE;
SEARCH_CompareInfo compareInfo;
/* Search for the object by object header address in order to get info for invalidation */
FDI_SearchInfo.CurrObj.HeaderAddress = 0;
FDI_SearchInfo.CurrObj.ObjectAddress = 0;
SEARCH_Header2SearchInfo((&FDI_SearchInfo), (&FDI_SearchHeader));
compareInfo.CompareValue = aOrigObjectHandle;
status = SEARCH_GetNextHeader(&FDI_SearchInfo, SEARCH_ByObjectHeaderAddress, &compareInfo, restart);
if (status != ERR_NONE)
{
if (status == ERR_NO_MORE_ENTRIES)
{
status = ERR_NOTEXISTS;
}
ExitOnError(status);
}
status = FHDR_InvalidateHeaderInFlash(FDI_SearchInfo.CurrObj.HeaderAddress,
&(FDI_SearchInfo.HeaderPtr->FHdr));
return status;
}
/*### Global Functions
#########################*/
/*=================================== RECLAIM =============================*/
/*#################################################################
### RECLAIM_PAGE_ModifyUserObjects
###
### DESCRIPTION:
### Backup and, in some cases, modify the object or objects in
### a group and write the modified data to the final location
### of the object as specified by the OTT. Update the RAT
### status as needed. Assumes there is only one backup group
### in memory at any given time. Modification will not
### be performed if an RAT entry specifies backup-only for a
### group. Backups will not be made for the group if the RAT
### entry specifies modify-in-place.
###
### PARAMETERS:
### aRef -- IN: ptr to OTT/RAT
###
### 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_ModifyUserObjects(PAGE_RECLAIM_Address* aRef)
{
ERR_CODE status = ERR_NONE;
FDI_Handle ratEntryHandle = 0;
RATTBL_Entry ratEntry;
RATTBL_Leader ratLeader;
UINT32 ratIndex;
UINT16 ratEntryCount;
/*Fix Start:SCR964 */
UINT16 topBlock;
UINT16 bottomBlock;
/*Fix End:SCR964 */
OTTTBL_EntryPtr ottEntryPtr;
UINT16 ottIndex;
UINT16 ottBtmIndex;
UINT16 ottTopIndex;
UINT32 groupSizeInPages;
UINT32 bkupSizeInPages;
UINT32 topObjectSizeInPages;
UINT32 bottomObjectOffset;
UINT32 topObjectOffset;
FDI_Handle bottomObjectHandle;
FDI_Handle topObjectHandle;
UINT8* bufferPtr = 0;
HDR_ObjectHeader objectHeader;
FDI_Handle unusedHandle;
OTTTBL_Leader ottLeader;
FDI_Handle bkupObjHandle;
FDI_Handle origObjHandle;
UINT32 offset;
/* Is the OTT list in sram? */
if(aRef->sramOttEntries == 0)
{
/* No. Read it in */
status = OTTTBL_ReadTableIntoSRAM(&ottLeader, &unusedHandle,
&aRef->sramOttEntriesList[0], sizeof(aRef->sramOttEntriesList), &aRef->sramOttEntries);
if(status != ERR_NONE)
{
return status;
}
}
else
{
/* Yes. We need the header information for the OTT table */
status = OTTTBL_GetFirstOttEntry(&unusedHandle, &aRef->sramOttEntriesList[0], &ottLeader);
if(status != ERR_NONE)
{
return status;
}
}
/* FULL/PARTIAL DEFRAG AND REALLOCATE OPERATION */
status = RATTBL_GetFirstRatEntry(&ratEntryHandle, &ratEntry, &ratLeader);
ExitOnError(status);
/* Check to see if there is anything to do. */
ratEntryCount = RATTBL_GetNumRows(&ratLeader);
for(ratIndex=0; ratIndex < ratEntryCount; ratIndex++)
{
ottTopIndex = RATTBL_GetRatEntryTopIndex(&ratEntry);
ottEntryPtr = &aRef->sramOttEntriesList[ottTopIndex];
topObjectOffset = OTTTBL_GetOttEntryDestination(ottEntryPtr);
topObjectSizeInPages = OTTTBL_GetOttEntrySize(ottEntryPtr);
topBlock = UTIL_CalcBlockNumberForOffset(topObjectOffset + topObjectSizeInPages);
/* If the topObjectSizeInPages added to its topObjectOffset lands right on a block boundary, then we have to adjust this back to the previous block */
if((topObjectOffset + topObjectSizeInPages) == UTIL_CalcOffsetOfBlocksBoundary(topBlock, enBottomBoundary))
{
topBlock--;
}
topObjectHandle = (topObjectOffset * FDI_PageSize) + FDI_PageSpaceAddressBottom;
ottBtmIndex = RATTBL_GetRatEntryBtmIndex(&ratEntry);
ottEntryPtr = &aRef->sramOttEntriesList[ottBtmIndex];
bottomObjectOffset = OTTTBL_GetOttEntryDestination(ottEntryPtr);
bottomBlock = UTIL_CalcBlockNumberForOffset(bottomObjectOffset);
bottomObjectHandle = (bottomObjectOffset * FDI_PageSize) + FDI_PageSpaceAddressBottom;
groupSizeInPages = 0;
for (ottIndex=ottBtmIndex; ottIndex<=ottTopIndex; ottIndex++)
{
ottEntryPtr = &aRef->sramOttEntriesList[ottIndex];
groupSizeInPages += OTTTBL_GetOttEntrySize(ottEntryPtr);
}
/* Check if we are to do a modify with backups for this group, or a modify in place */
if(RATTBL_GetRatEntryOperation(&ratEntry) == RATTBL_RatEntryOperation_ModifyWithBackup)
{
switch(RATTBL_GetRatEntryBtmProgressState(&ratEntry))
{
case RATTBL_RatEntryBtmProgressState_NoOperationInProgress:
/* set state: RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupInProgress */
RATTBL_SetRatEntryBtmProgressState(&ratEntry, RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupInProgress);
status = RATTBL_WriteRatEntryBtmProgressState(&ratEntryHandle, &ratEntry);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupInProgress:
case RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupInReclaim:
case RATTBL_RatEntryBtmProgressState_RestartBtmBlkBkupGroupReclaimComplete:
case RATTBL_RatEntryBtmProgressState_RestartTopBlkBkupGroupInReclaim:
case RATTBL_RatEntryBtmProgressState_RestartTopBlkBkupGroupReclaimComplete:
/* backup the group of objects delineated by the RAT entry */
status = RECLAIM_PAGE_BackupOriginalGroup(&ratLeader,
ratEntryHandle,
&ratEntry,
topObjectHandle,
groupSizeInPages,
bottomObjectHandle,
aRef->plrRestart);
ExitOnError(status);
/* set state: RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupComplete */
RATTBL_SetRatEntryBtmProgressState(&ratEntry, RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupComplete);
status = RATTBL_WriteRatEntryBtmProgressState(&ratEntryHandle, &ratEntry);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupComplete:
case RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupInReclaim:
case RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupReclaimComplete:
case RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupInReclaim:
status = RECLAIM_PAGE_EraseOriginalGroup(ratEntryHandle,
&ratEntry,
topBlock,
topObjectHandle,
topObjectSizeInPages,
groupSizeInPages,
bottomBlock,
bottomObjectHandle,
aRef->plrRestart);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupReclaimComplete:
/* erase the reclaim block */
status = FLASH_EraseBlock(FDI_ReclaimBlockAddressBottom, FALSE);
ExitOnError(status);
/* set state: RATTBL_RatEntryBtmProgressState_ModifyInProgress */
RATTBL_SetRatEntryBtmProgressState(&ratEntry, RATTBL_RatEntryBtmProgressState_ModifyInProgress);
status = RATTBL_WriteRatEntryBtmProgressState(&ratEntryHandle, &ratEntry);
ExitOnError(status);
/* fall through to next case */
case RATTBL_RatEntryBtmProgressState_ModifyInProgress:
if (RATTBL_GetRatEntryTopProgressState(&ratEntry) == RATTBL_RatEntryTopProgressState_NoOperationInProgress )
{
/* perform the modification on the backup objects */
/* write the modified objects back to the original location */
status = RECLAIM_PAGE_ModifyBackupGroup(aRef,
ratEntryHandle,
&ratEntry,
aRef->plrRestart);
ExitOnError(status);
/* set state: RATTBL_RatEntryBtmProgressState_ModifyComplete */
RATTBL_SetRatEntryTopProgressState(&ratEntry, RATTBL_RatEntryTopProgressState_ModifyComplete);
status = RATTBL_WriteRatEntryTopProgressState(&ratEntryHandle, &ratEntry);
ExitOnError(status);
}
/* fall through to next case; switching over to top progress state at this point */
switch (RATTBL_GetRatEntryTopProgressState(&ratEntry))
{
case RATTBL_RatEntryTopProgressState_NoOperationInProgress:
/* set state: RATTBL_RatEntryBtmProgressState_ModifyComplete */
RATTBL_SetRatEntryTopProgressState(&ratEntry, RATTBL_RatEntryTopProgressState_ModifyComplete);
status = RATTBL_WriteRatEntryTopProgressState(&ratEntryHandle, &
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -