📄 davott.c
字号:
/* Marking the TableId to 0xF0F0 indicates that the table info */
/* is valid. */
table_info_ptr->TableId = OTTTBL_TableDataValid;
status = FLASH_WriteBuffer((tbl_base_addr + OTTTBL_TableIdOffset),
(MemBufferPtr)(&(table_info_ptr->TableId)),
sizeof(table_info_ptr->TableId));
/* E5.0.607 End */
if (status)
{
return status;
}
if (mark_hdr2valid)
{
#ifdef ENABLE_CRASH_TEST
if (CT_TestSelection(CT_RECLAIM_StateE_SP2))
{
return ERR_CRASH_N_BURN;
}
#endif
/* Read the reclaim table header attributes */
FLASH_ReadBuffer((tbl_hdr_addr + HDR_Attrib16Offset),
(MemBufferPtr)&hdr_attr16, sizeof(hdr_attr16));
status = UINT16_HeaderFixISF_PLR( &hdr_attr16, (tbl_hdr_addr + HDR_Attrib16Offset),
restart);
if(status)
{
return status;
}
/* Marking the Reclaim Table Header status to Valid indicates */
/* that the table has been initialized (mainly for page */
/* reclaim). */
hdr_attr16 = HDR_SetStatusAttr(hdr_attr16, HDR_HA_Valid);
status = FLASH_WriteBuffer((tbl_hdr_addr + HDR_Attrib16Offset),
(MemBufferPtr)&hdr_attr16, sizeof(hdr_attr16));
}
return status;
}
/*########################################################################
### OTTTBL_WriteTableInfo
###
### DESCRIPTION:
### This function writes the TableInfo structure to the first
### location in the ott table.
###
### PARAMETERS:
### table_address - Base address of the ott table object.
### table_info_ptr - Table information struct.
###
### RETURNS:
### ERR_NONE - When operation is successful.
###
*/
ERR_CODE OTTTBL_WriteTableInfo(FDI_Handle table_address,
OTTTBL_TableInfoPtr table_info_ptr)
{
ERR_CODE status;
table_info_ptr->TableId = OTTTBL_TableDataInit;
/* Write the actual table info following the TableId. */
status = FLASH_WriteBuffer(table_address,
(MemBufferPtr)table_info_ptr, OTTTBL_TableInfoSize);
return status;
}
/*########################################################################
### OTTTBL_GetTableInfo
###
### DESCRIPTION:
### This function returns the table info
### structure for the specified type of reclaim table.
###
### PARAMETERS:
### table_address - Base address of the ott table object.
### table_info_ptr - Table info structure for returning table info.
###
### RETURNS:
### ERR_NONE - When operation completes successfully.
###
*/
ERR_CODE OTTTBL_GetTableInfo(FDI_Handle table_address,
OTTTBL_TableInfoPtr table_info_ptr, BOOLEAN restart)
{
ERR_CODE status = ERR_NONE;
/* The TableInfo structure is the first item in the ott table. */
FLASH_ReadBuffer(table_address,
(MemBufferPtr)table_info_ptr, OTTTBL_TableInfoSize);
status = OTTTBL_InfoStructFixISF_PLR((MemBufferPtr)table_info_ptr,
table_address,
restart);
return status;
}
/*########################################################################
### OTTTBL_WriteTable
###
### DESCRIPTION:
### This function will write a ott status entry to the specified
### block entry in the ott table.
###
### PARAMETERS:
### table_handle - Base address of the ott table object.
### object_num - Desired object information.
### status_ptr - Desired ott status to write.
###
### RETURNS:
### ERR_NONE - When operation completes successfully.
###
*/
ERR_CODE OTTTBL_WriteTable(FDI_Handle table_handle,
UINT32 object_num,
OTTTBL_TableEntryPtr OTTentry_ptr,
BOOLEAN restart)
{
ERR_CODE status = ERR_NONE;
status =
CalculateOTTTableEntryOffset(&table_handle, object_num, restart);
if(status == ERR_NONE)
{
status = FLASH_WriteBuffer(table_handle,
(MemBufferPtr)OTTentry_ptr, OTTTBL_TableEntrySize);
}
return status;
}
/*########################################################################
//### OTTTBL_ReadTable
//###
### DESCRIPTION:
### This function will read a ott status entry to the specified
### block entry in the ott table.
###
### PARAMETERS:
### table_handle - Base address of the ott table object.
### object_num - Desired object information.
### OTTentry_ptr - Desired ott entry to write.
###
### RETURNS:
### ERR_NONE - When operation completes successfully.
###
*/
ERR_CODE OTTTBL_ReadTable(FDI_Handle table_handle,
UINT32 object_num,
OTTTBL_TableEntryPtr OTTentry_ptr, BOOLEAN restart)
{
ERR_CODE status = ERR_NONE;
status =
CalculateOTTTableEntryOffset(&table_handle, object_num, restart);
if(status != ERR_NONE)
{
return status;
}
FLASH_ReadBuffer(table_handle, (MemBufferPtr)OTTentry_ptr,
OTTTBL_TableEntrySize);
status = UINT16_FixISF_PLR( &(OTTentry_ptr->status), table_handle + OTTTBL_OffsetToStatus, restart);
return status;
}
/*########################################################################
### OTTTBL_CreateTable
###
### DESCRIPTION:
### This function will create a ott table object on the
### proper "power loss" recovery order.
###
### PARAMETERS:
### table_info_ptr - Used to return the table object information
### back to the caller.
###
### RETURNS:
### ERR_NONE - When operation is successful.
###
*/
ERR_CODE OTTTBL_CreateTable(HDR_SearchInfoPtr table_info_ptr, BOOLEAN restart)
{
UINT32 ii;
UINT8_PTR tchar_ptr;
ERR_CODE status;
FDI_Handle ott_tbl_handle;
HDR_CompareInfo compare_info;
/* All is well on the memory space front, so create the header. */
/* Set up Power Loss Recovery Options */
table_info_ptr->HeaderPtr->Attr16 = WORDMAX;
table_info_ptr->HeaderPtr->Attr8 = BYTEMAX;
table_info_ptr->HeaderPtr->Attr8 =
HDR_SetReliableAttr((table_info_ptr->HeaderPtr->Attr8), HDR_HA_Reliable);
table_info_ptr->HeaderPtr->Attr8 =
HDR_SetReservesAttr((table_info_ptr->HeaderPtr->Attr8), HDR_HA_NoReserves);
/* NOTE: Must write status to Valid after TableInfo is written. */
table_info_ptr->HeaderPtr->Attr16 =
HDR_SetStatusAttr((table_info_ptr->HeaderPtr->Attr16), HDR_HA_WriteInProgress);
/* Copy the name to the header */
ii = 0;
tchar_ptr = (UINT8_PTR)OTTTBL_HeaderName;
while (*(tchar_ptr + ii) != 0)
{
table_info_ptr->HeaderPtr->Name[ii] = *(tchar_ptr + ii);
ii++;
}
table_info_ptr->HeaderPtr->NameSize = (UINT8)ii;
/* Update tracking vars. */
FDI_MemUsage.ParaOverhead.Valid +=
RoundUp((ii + HDR_FixedSize), FDI_ParagraphLength);
FDI_MemUsage.ParaSpace.Valid += OTTTBL_ParaOTTTblSize;
table_info_ptr->HeaderPtr->Attr16 =
HDR_SetAlignmentAttr((table_info_ptr->HeaderPtr->Attr16),
HDR_HA_AlignPara);
/* Calculate the size of the header and place it in the */
/* proper fields. */
HDR_SetObjectSize((table_info_ptr->HeaderPtr),
(OTTTBL_ParaOTTTblSize / FDI_ParagraphLength));
table_info_ptr->HeaderPtr->Attr16 =
HDR_SetAbsorbedAttr((table_info_ptr->HeaderPtr->Attr16), HDR_HA_Exists);
table_info_ptr->HeaderPtr->Attr16 = (UINT16)
HDR_SetPrivilegeAttr((table_info_ptr->HeaderPtr->Attr16), 0);
table_info_ptr->HeaderPtr->SecurityKey = 0xfeedbeef;
table_info_ptr->HeaderPtr->ObjectType = FDI_HT_ObjTrkTable;
/* Write the header to flash! */
status = HDR_CreateHeaderEntry((FDI_HandlePtr)&ott_tbl_handle,
table_info_ptr->HeaderPtr);
if (status)
{
return status;
}
/* Locate the physical address of the ott table for use by */
/* the WriteOTTTable function, starting from the beginning */
/* of the header table. */
table_info_ptr->CurrObj.HeaderAddress = 0;
table_info_ptr->CurrObj.ConfigEntry.Status = 0;
table_info_ptr->CurrObj.ConfigEntry.Offset = 0;
compare_info.CompareValue = ott_tbl_handle;
status = GetNextHeader(table_info_ptr,
HDR_ByHeaderAddress, &compare_info, restart);
return status;
}
/*########################################################################
### OTTTBL_InfoStructFixISF_PLR
###
### DESCRIPTION:
### This function will fix the PLR bit's bits in the plr fields of the
### OTT info table that includes the OTT table entry from the indeterminate state of
### 01 or 10 to either 00 or 11.
###
### PARAMETERS:
### OTT info struct pointer in RAM
### flash address where Init' may need to fix in flash if required
### size of the structure
### restart to know whether to fix in flash or not.
###
### RETURNS:
### Returns a status of type ERR_CODE.
###*/
ERR_CODE OTTTBL_InfoStructFixISF_PLR(MemBufferPtr ott_table_info_ptr,
UINT32 flash_address,
BOOLEAN restart)
{
UINT16 count = 0;
ERR_CODE status = ERR_NONE;
status = UINT16_FixISF_PLR( &(((OTTTBL_TableInfo *)ott_table_info_ptr)->TableId),
flash_address + OTTTBL_TableIdOffset, restart);
if(status != ERR_NONE)
{
return status;
}
ott_table_info_ptr += OTTTBL_TableIdSize;
flash_address += OTTTBL_TableIdSize;
for(count= 0; count < NUM_OTT_ENTRIES; count++)
{
if((((OTTTBL_TableEntryStruct *)ott_table_info_ptr)->objsize != 0xFFFFFFFF) &&
(((OTTTBL_TableEntryStruct *)ott_table_info_ptr)->status != 0xFFFF) )
{
if((status = UINT16_FixISF_PLR( &(((OTTTBL_TableEntryStruct *)ott_table_info_ptr)->status),
flash_address + OTTTBL_OffsetToStatus, restart)) != ERR_NONE)
{
break;
}
ott_table_info_ptr += OTTTBL_TableEntrySize;
flash_address += OTTTBL_TableEntrySize;
}else
{
break;
}
}
return status;
}
#endif /* DIRECT_ACCESS_VOLUME */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -