📄 davrttbl.c
字号:
### aPtr - Pointer to the rt entry
### aWord - New value of the operation
###
### RETURNS:
### None.
###*/
void RTTBL_SetRtEntryOpr(RTTBL_EntryPtr aPtr, UINT8 aByte)
{
aPtr->Operation = aByte & BYTEMAX;
}
/*#################################################################
### RTTBL_GetNumRows
###
### DESCRIPTION:
### This function will extract the number of rows from the
### rt leader.
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
###
### RETURNS:
### The number of rows
###*/
/*Fix Start:SCR964 */
UINT16 RTTBL_GetNumRows(RTTBL_LeaderPtr aPtr)
/*Fix End:SCR964 */
{
return aPtr->NumRows;
}
/*#################################################################
### RTTBL_SetNumRows
###
### DESCRIPTION:
### This function will set the number of rows/rt entries that the RTTBL
### contains.
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
### aByte - Number of rows in the table
###
### RETURNS:
### None.
###*/
/*Fix Start:SCR964 */
void RTTBL_SetNumRows(RTTBL_LeaderPtr aPtr, UINT16 aWord)
{
aPtr->NumRows = aWord & WORDMAX;
}
/*Fix End:SCR964 */
/*#################################################################
### RTTBL_GetLastBlock
###
### DESCRIPTION:
### This function will extract the last block referenced
### in the rt table.
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
###
### RETURNS:
### The last referenced block
###*/
/*Fix Start:SCR964 */
UINT16 RTTBL_GetLastBlock(RTTBL_LeaderPtr aPtr)
/*Fix End:SCR964 */
{
return aPtr->LastBlock;
}
/*#################################################################
### RTTBL_SetLastBlock
###
### DESCRIPTION:
### This function will set the last working block referenced
### in the rt table.
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
### aByte - Last working block.
###
### RETURNS:
### None.
###*/
/*Fix Start:SCR964 */
void RTTBL_SetLastBlock(RTTBL_LeaderPtr aPtr, UINT16 aWord)
{
aPtr->LastBlock = aWord & WORDMAX;
}
/*Fix End:SCR964 */
/*#################################################################
### RTTBL_GetBlockNumber
###
### DESCRIPTION:
### This function will extract the number of blocks referenced
### in the rt table.
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
###
### RETURNS:
### The number of blocks
###*/
/*Fix Start:SCR964 */
UINT16 RTTBL_GetBlockNumber(RTTBL_LeaderPtr aPtr)
/*Fix End:SCR964 */
{
return aPtr->NumberBlocks;
}
/*#################################################################
### RTTBL_SetBlockNumber
###
### DESCRIPTION:
### This function will set the number of blocks referenced
### in the rt table. The last block indicate the last block.
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
### aByte - The number of blocks
###
### RETURNS:
### None.
###*/
/*Fix Start:SCR964 */
void RTTBL_SetBlockNumber(RTTBL_LeaderPtr aPtr, UINT16 aWord)
{
aPtr->NumberBlocks = aWord & WORDMAX;
}
/*Fix End:SCR964 */
/*#################################################################
### RTTBL_GetUniqueId1
###
### DESCRIPTION:
### This function will extract the first unique id from the rt
### table leader
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
###
### RETURNS:
### The first unique id
###*/
UINT16 RTTBL_GetUniqueId1(RTTBL_LeaderPtr aPtr)
{
return aPtr->UniqueId1;
}
/*#################################################################
### RTTBL_SetUniqueId1
###
### DESCRIPTION:
### This function will set the first unique id from the
### rt table leader.
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
### aWord - The value of the unique id
###
### RETURNS:
### None.
###*/
void RTTBL_SetUniqueId1(RTTBL_LeaderPtr aPtr, UINT16 aWord)
{
aPtr->UniqueId1 = aWord & WORDMAX;
}
/*#################################################################
### RTTBL_GetUniqueId2
###
### DESCRIPTION:
### This function will extract the second unique id from the
### rt table leader
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
###
### RETURNS:
### The second unique id
###*/
UINT16 RTTBL_GetUniqueId2(RTTBL_LeaderPtr aPtr)
{
return aPtr->UniqueId2;
}
/*#################################################################
### RTTBL_SetUniqueId2
###
### DESCRIPTION:
### This function will set the second unique id from the
### rt table leader.
###
### PARAMETERS:
### aPtr - Pointer to the rt leader
### aWord - The value of the unique id
###
### RETURNS:
### None.
###*/
void RTTBL_SetUniqueId2(RTTBL_LeaderPtr aPtr, UINT16 aWord)
{
aPtr->UniqueId2 = aWord & WORDMAX;
}
/*=============================== SEARCH =============================*/
/*#################################################################
### RTTBL_GetFirstRtEntry
###
### DESCRIPTION:
### This function will retreive the first rt entry along with
### rt table leader.
###
### PARAMETERS:
### aHandlePtr - Handle to the rt entry
### aEntryPtr - Pointer to the rt entry
### aLeaderPtr - Pointer to the rt leader
###
### 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 RTTBL_GetFirstRtEntry(FDI_Handle* aHandlePtr, RTTBL_EntryPtr aEntryPtr, RTTBL_LeaderPtr aLeaderPtr)
{
ERR_CODE status;
HDR_Header allHeaders;
SEARCH_SearchInfo result;
SEARCH_CompareInfo compare_info;
RTTBL_ObjectTablePtr tablePtr = 0; /* Zero, is used to compute offset */
UINT32 offset;
FDI_Handle* aFHDRHandlePtr;
CFGTBL_PgReclaimEntry cfgPageEntry;
FDI_Handle cfgPageHandle;
UINT8 ctIndex;
FDI_Handle ctEntryHandle;
/* Find the fixed header for the table */
result.HeaderPtr = &allHeaders;
result.CurrObj.HeaderAddress = 0;
result.CurrObj.ObjectAddress = 0;
result.CurrObj.ObjectSize = 0;
compare_info.CompareValue = FDI_HT_ReclaimTable; /* RT */
status = SEARCH_GetNextHeader(&result, SEARCH_ByValidType/*SEARCH_ByTypeOnly*/, &compare_info, FALSE);
if(status != ERR_NONE)
{
if(status == ERR_NO_MORE_ENTRIES)
{
/* Fixed Header does not exists */
aFHDRHandlePtr = 0;
UTIL_ClearVariable((UINT8*)aLeaderPtr, sizeof(RTTBL_Leader), 0xFF);
}
else
{
return status;
}
}
else
{
/* A fixed header exists */
/* PERF_FIX Need to find a more efficent means */
aFHDRHandlePtr = (FDI_Handle*)result.CurrObj.HeaderAddress;
UTIL_CopyVariable((UINT8*)&result.HeaderPtr->OHdr, (UINT8*)aLeaderPtr, sizeof(RTTBL_Leader));
}
/* Find a valid Ct Entry for the table */
if(CFGTBL_GetCtEntryByStatus(FDI_ParaSpaceAddressBottom, CFGTBL_CtEntryType_RT, CFGTBL_CtEntryStatus_EntryValid,
&cfgPageEntry, &cfgPageHandle, &ctIndex, &ctEntryHandle) == FALSE)
{
/* Ct entry does not exist */
/* No ct entry handle or first entry to copy */
UTIL_ClearVariable((UINT8*)aEntryPtr, sizeof(RTTBL_Entry), 0xFF);
*aHandlePtr = 0;
status = ERR_NOTEXISTS;
}
else
{
if(CFGTBL_GetCtAllocationStatus(&cfgPageEntry.CtEntry[ctIndex]) == CFGTBL_CtAllocationStatus_Valid)
{
/* Compute and copy the ct entry handle */
offset = (UINT32)&tablePtr->RtEntry[0] - (UINT32)tablePtr;
*aHandlePtr = (UINT32)result.CurrObj.ObjectAddress + (UINT32)offset;
/* Read in the first entry */
status = FLASH_ReadBuffer(*aHandlePtr, (UINT8*)aEntryPtr, sizeof(RTTBL_Entry));
if(status != ERR_NONE)
{
return status;
}
}
else
{
/* Ct entry does not exist */
/* No ct entry handle or first entry to copy */
UTIL_ClearVariable((UINT8*)aEntryPtr, sizeof(RTTBL_Entry), 0xFF);
*aHandlePtr = 0;
status = ERR_NOTEXISTS;
}
}
/* Status of a ct entry that is valid */
/* If a powerloss, it is possible that the ct entry exists, however, the fixed header does not */
return status;
}
/*#################################################################
### RTTBL_GetNextRtEntry
###
### DESCRIPTION:
### This function will retreive the next rt entry with respect
### to the current rt entry handle.
###
### PARAMETERS:
### aFlashNextPtr - Upon return, handle to the next rt entry
### aEntryPtr - Upon return, pointer to the rt entry
### aFlashCurrentPtr - Handle to the a rt entry
###
### 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 RTTBL_GetNextRtEntry(FDI_Handle* aFlashNextPtr, RTTBL_EntryPtr aEntryPtr, FDI_Handle* aFlashCurrentPtr)
{
ERR_CODE status;
/* Compute the next entry address*/
*aFlashNextPtr = ((FDI_Handle)*aFlashCurrentPtr + (FDI_Handle)sizeof(RTTBL_Entry));
/* Read the next entry */
status = FLASH_ReadBuffer((UINT32)*aFlashNextPtr, (UINT8*)aEntryPtr, sizeof(RTTBL_Entry));
if(status != ERR_NONE)
{
return status;
}
return status;
}
#endif /* DIRECT_ACCESS_VOLUME */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -