📄 davcfgtbl.c
字号:
offset = (UINT32)(&aEntryPtr->TypeAllocStatus) - (UINT32)(aEntryPtr);
status = FLASH_WriteBuffer(entryHandle+offset, (UINT8*)((UINT32)aEntryPtr+offset), sizeof(aEntryPtr->TypeAllocStatus));
if(status != ERR_NONE)
{
return status;
}
/* Write the offset/progress */
offset = (UINT32)(&aEntryPtr->ProgressState) - (UINT32)(aEntryPtr);
status = FLASH_WriteBuffer(entryHandle+offset, (UINT8*)((UINT32)aEntryPtr+offset), sizeof(aEntryPtr->ProgressState));
if(status != ERR_NONE)
{
return status;
}
/* Write the status */
CFGTBL_SetCtAllocationStatus(aEntryPtr, CFGTBL_CtAllocationStatus_WriteInProgress);
offset = (UINT32)(&aEntryPtr->TypeAllocStatus) - (UINT32)(aEntryPtr);
status = FLASH_WriteBuffer(entryHandle+offset, (UINT8*)((UINT32)aEntryPtr+offset), sizeof(aEntryPtr->TypeAllocStatus));
if(status != ERR_NONE)
{
return status;
}
return status;
}
/*########################################################################
### CFGTBL_ValidateCtEntryInFlash
###
### DESCRIPTION:
### This function validates a ct entry in flash. The caller has
### finished writing its information in the entry.
###
### PARAMETERS:
### aIndex - The ct entry to validate
###
### 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 CFGTBL_ValidateCtEntryInFlash(UINT8 aIndex)
{
ERR_CODE status = ERR_NONE;
HDR_FixedHeader fixHeader;
FDI_Handle tableHandle;
FDI_Handle entryHandle;
CFGTBL_Entry entry;
UINT32 offset;
/* Search and read the fixed header */
status = FHDR_ReadFixedHeader(CFGHDR_HeaderAddress, &fixHeader, FALSE);
if(status != ERR_NONE)
{
return status;
}
/* Get the handle to the table */
tableHandle = FHDR_CalcObjectHandle(&fixHeader);
/* Get the handle to the specified entry */
entryHandle = CFGTBL_CalcEntryHandle(&tableHandle, aIndex);
/* READ THE CURRENT STATUS */
status = FLASH_ReadBuffer(entryHandle, (UINT8*)&entry, sizeof(CFGTBL_Entry));
if(status != ERR_NONE)
{
return status;
}
/* Write the allocation status */
CFGTBL_SetCtAllocationStatus(&entry, CFGTBL_CtAllocationStatus_Valid);
offset = (UINT32)(&entry.TypeAllocStatus) - (UINT32)(&entry);
status = FLASH_WriteBuffer(entryHandle+offset, (UINT8*)((UINT32)&entry+offset), sizeof(entry.TypeAllocStatus));
if(status != ERR_NONE)
{
return status;
}
/* Write the entry status */
CFGTBL_SetCtEntryStatus(&entry, CFGTBL_CtEntryStatus_EntryValid);
offset = (UINT32)(&entry.TypeAllocStatus) - (UINT32)(&entry);
status = FLASH_WriteBuffer(entryHandle+offset, (UINT8*)((UINT32)&entry+offset), sizeof(entry.TypeAllocStatus));
if(status != ERR_NONE)
{
return status;
}
return status;
}
/*########################################################################
### CFGTBL_WriteTableEntryPage
###
### DESCRIPTION:
### This function writes the page entry portion of the
### cfgtbl into flash.
###
### PARAMETERS:
### aHandle - Handle to the page 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 CFGTBL_WriteTableEntryPage(FDI_Handle aHandle)
{
ERR_CODE status;
CFGTBL_PgReclaimEntry entryPg;
UINT32 offset;
/* Set the first unique Id*/
UTIL_ClearVariable((UINT8*)&entryPg, sizeof(CFGTBL_PgReclaimEntry), 0xFF);
CFGTBL_SetPgUniqueId1(&entryPg, CFGTBL_UniqueId1);
offset = (UINT32)(&entryPg.UniqueId1) - (UINT32)(&entryPg);
status = FLASH_WriteBuffer(aHandle+offset, (UINT8*)((UINT32)&entryPg+offset), sizeof(entryPg.UniqueId1));
if(status != ERR_NONE)
{
return status;
}
/* Set the second unique Id*/
CFGTBL_SetPgUniqueId2(&entryPg, CFGTBL_UniqueId2);
offset = (UINT32)(&entryPg.UniqueId2) - (UINT32)(&entryPg);
status = FLASH_WriteBuffer(aHandle+offset, (UINT8*)((UINT32)&entryPg+offset), sizeof(entryPg.UniqueId2));
if(status != ERR_NONE)
{
return status;
}
/* Let all Ct Entrys at 1's */
return status;
}
/*#################################################################
### CFGTBL_GetPgUniqueId1
###
### DESCRIPTION:
### This function will set the first unique id from the
### cfgtbl page entry.
###
### PARAMETERS:
### aPtr - Pointer to the cfgtbl page entry
### aWord - The value of the unique id
###
### RETURNS:
### None.
###*/
UINT16 CFGTBL_GetPgUniqueId1(CFGTBL_PgReclaimEntryPtr aPtr)
{
return aPtr->UniqueId1;
}
/*#################################################################
### CFGTBL_SetPgUniqueId2
###
### DESCRIPTION:
### This function will set the first unique id from the
### cfgtbl page entry.
###
### PARAMETERS:
### aPtr - Pointer to the cfgtbl page entry
### aWord - The value of the unique id
###
### RETURNS:
### None.
###*/
void CFGTBL_SetPgUniqueId1(CFGTBL_PgReclaimEntryPtr aPtr, UINT16 aWord)
{
aPtr->UniqueId1 = aWord;
}
/*#################################################################
### CFGTBL_GetPgUniqueId2
###
### DESCRIPTION:
### This function will set the second unique id from the
### cfgtbl page entry.
###
### PARAMETERS:
### aPtr - Pointer to the cfgtbl page entry
### aWord - The value of the unique id
###
### RETURNS:
### None.
###*/
UINT16 CFGTBL_GetPgUniqueId2(CFGTBL_PgReclaimEntryPtr aPtr)
{
return aPtr->UniqueId2;
}
/*#################################################################
### CFGTBL_SetPgUniqueId2
###
### DESCRIPTION:
### This function will set the second unique id from the
### cfgtbl page entry.
###
### PARAMETERS:
### aPtr - Pointer to the cfgtbl page entry
### aWord - The value of the unique id
###
### RETURNS:
### None.
###*/
void CFGTBL_SetPgUniqueId2(CFGTBL_PgReclaimEntryPtr aPtr, UINT16 aWord)
{
aPtr->UniqueId2 = aWord;
}
/*#################################################################
### CFGTBL_GetCtAllocationStatus
###
### DESCRIPTION:
### This function will retreive the current allocation
### status from the ct entry.
###
### PARAMETERS:
### aPtr - Pointer to the ct entry
###
### RETURNS:
### Allocation Status Field
###*/
UINT8 CFGTBL_GetCtAllocationStatus(CFGTBL_EntryPtr aPtr)
{
return ((aPtr->TypeAllocStatus & CFGTBL_MASK_CtAllocationStatus) >> 6);
}
/*#################################################################
### CFGTBL_SetCtAllocationStatus
###
### DESCRIPTION:
### This function will set the current allocation status from
### the ct entry.
###
### PARAMETERS:
### aPtr - Pointer to the ct entry
###
### RETURNS:
### Allocation Status Field
###*/
void CFGTBL_SetCtAllocationStatus(CFGTBL_EntryPtr aPtr, UINT8 aByte)
{
aPtr->TypeAllocStatus = ((aPtr->TypeAllocStatus & ~CFGTBL_MASK_CtAllocationStatus) | (aByte << 6));
}
/*#################################################################
### CFGTBL_GetCtEntryStatus
###
### DESCRIPTION:
### This function will get the status of the specified ct entry.
###
### PARAMETERS:
### aPtr - Pointer to the ct entry
###
### RETURNS:
### The entry status
###*/
UINT8 CFGTBL_GetCtEntryStatus(CFGTBL_EntryPtr aPtr)
{
return (aPtr->TypeAllocStatus & CFGTBL_MASK_CtEntryStatus);
}
/*#################################################################
### CFGTBL_GetRecoveredEntryStatusAndRepairAllocation
###
### DESCRIPTION:
### This function will extract the Allocation and Entry status
### right after the recovery is performed on the progress
### state field.
###
### PARAMETERS:
### aPtr - Pointer to the cfg entry
### aPtr - Handle to the cfg entry
###
### RETURNS:
### The recovered entry status
###*/
/* E5.5.969 Start */
UINT8 CFGTBL_GetRecoveredEntryStatusAndRepairAllocation( CFGTBL_EntryPtr aEntryPtr,
FDI_Handle aHandle,
ERR_CODE * statusPtr)
{
CFGTBL_EntryPtr dummyEntryPtr = 0; /* Zero, is used to compute offset */
UINT32 offset = (UINT32)&dummyEntryPtr->TypeAllocStatus;
/* fix up the type-allocation field of the entry */
/* E5.5.970 Start */
*statusPtr = CFGTBL_CtEntry_FixISF_PLR( (UINT16*)&aEntryPtr->TypeAllocStatus,
aHandle + offset,
TRUE);
/* E5.5.970 End */
if(*statusPtr != ERR_NONE)
{
return (UINT8)0;
}
offset = (UINT32)&dummyEntryPtr->ProgressState;
/* fix up the progress state field of the entry */
*statusPtr = UTIL_UINT16_FixISF_PLR( (UINT16*)&aEntryPtr->ProgressState,
aHandle + offset,
TRUE);
if(*statusPtr != ERR_NONE)
{
return (UINT8)0;
}
/* Read the status bit */
return CFGTBL_GetCtEntryStatus(aEntryPtr);
}
/* E5.5.969 End */
/*#################################################################
### CFGTBL_SetCtEntryStatus
###
### DESCRIPTION:
### This function will set the ct entry status from the
### input parameters.
###
### PARAMETERS:
### aPtr - Pointer to the ct entry
### aByte = New value to set
###
### RETURNS:
### The entry status
###*/
void CFGTBL_SetCtEntryStatus(CFGTBL_EntryPtr aPtr, UINT8 aByte)
{
aPtr->TypeAllocStatus = ((aPtr->TypeAllocStatus & ~CFGTBL_MASK_CtEntryStatus) | aByte);
}
/*#################################################################
### CFGTBL_GetCtEntryType
###
### DESCRIPTION:
### This function will get the entry type for the specified
### ct entry.
###
### PARAMETERS:
### aPtr - Pointer to the ct entry
###
### RETURNS:
### The entry type
###*/
UINT8 CFGTBL_GetCtEntryType(CFGTBL_EntryPtr aPtr)
{
return ((aPtr->TypeAllocStatus & CFGTBL_MASK_CtEntryType) >> 12);
}
/*#################################################################
### CFGTBL_SetCtEntryType
###
### DESCRIPTION:
### This function will get the entry type for the specified
### ct entry.
###
### PARAMETERS:
### aPtr - Pointer to the ct entry
### aByte - New value of the entry
###
### RETURNS:
### None
###*/
void CFGTBL_SetCtEntryType(CFGTBL_EntryPtr aPtr, UINT8 aByte)
{
aPtr->TypeAllocStatus = ((aPtr->TypeAllocStatus & ~CFGTBL_MASK_CtEntryType) | (aByte << 12));
}
/*#################################################################
### CFGTBL_GetCtProgressState
###
### DESCRIPTION:
### This function will retreive the ct progress state from
### the passed ct entry.
###
### PARAMETERS:
### aPtr - Pointer to the ct entry
###
### RETURNS:
### The progress state
###*/
UINT16 CFGTBL_GetCtProgressState(CFGTBL_EntryPtr aPtr)
{
return aPtr->ProgressState;
}
/*#################################################################
### CFGTBL_SetCtProgressState
###
### DESCRIPTION:
### This function will set the ct progress state to the
### passed value.
###
### PARAMETERS:
### aPtr - Pointer to the ct entry
### aWord = New value to set
###
### RETURNS:
### None
###*/
void CFGTBL_SetCtProgressState(CFGTBL_EntryPtr aPtr, UINT16 aWord)
{
aPtr->ProgressState = aWord;
}
/*#################################################################
### CFGTBL_GetRecoveredPaProgressState
###
### DESCRIPTION:
### This function will extract the ct progress state
### right after the recovery is performed on the progress
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -