📄 davott.c
字号:
/* Copyright (c) 1995-2002 Intel Corporation */
/* Intel Confidential */
/* ###########################################################################
### OTTTBL
###
### Module: objtrktbl.c - Object Tracking Table Module
###
### $Workfile: davott.c $
### $Revision: 55 $
### $NoKeywords: $
########################################################################### */
/*
*****************************************************************
* NOTICE OF LICENSE AGREEMENT
*
* This code is provided by Intel Corp., and the use is governed
* under the terms of a license agreement. See license agreement
* for complete terms of license.
*
* YOU MAY ONLY USE THE SOFTWARE WITH INTEL FLASH PRODUCTS. YOUR
* USE OF THE SOFTWARE WITH ANY OTHER FLASH PRODUCTS IS EXPRESSLY
* PROHIBITED UNLESS AND UNTIL YOU APPLY FOR, AND ARE GRANTED IN
* INTEL'S SOLE DISCRETION, A SEPARATE WRITTEN SOFTWARE LICENSE
* FROM INTEL LICENSING ANY SUCH USE.
*****************************************************************
*/
/*### Include Files
//#########################*/
#include "dav.h"
#if (DIRECT_ACCESS_VOLUME == TRUE)
/* This should only be enabled for debug to */
/* check the block number range. */
/*
#define ENABLE_BLOCK_RANGE_CHECK
*/
/*### Local Declarations
//#########################*/
static ERR_CODE CalculateOTTTableEntryOffset(FDI_Handle *table_handle_ptr,
UINT32 object_num, BOOLEAN restart);
/*### Global Declarations
//#########################*/
/* E5.0.607 Begin */
OTTTBL_TableInfo OTTTableInfo;
/* E5.0.607 End */
/*### Local Functions
//#########################*/
/*########################################################################
### CalculateOTTTableEntryOffset
###
### DESCRIPTION:
### This function does the necessary calculations to locate the
### source address, destination address and size into the ott
### table for a particular object.
###
### PARAMETERS:
### table_handle - A pointer to the base address of the
### ott table.
### object_num - Desired object information.
###
### RETURNS:
### Handle to address of OTT entry of the ott table.
###
*/
static ERR_CODE CalculateOTTTableEntryOffset(FDI_Handle *table_handle_ptr,
UINT32 object_num, BOOLEAN restart)
{
ERR_CODE status = ERR_NONE;
/* E5.0.607 Begin */
OTTTBL_TableInfoPtr table_info_ptr = &OTTTableInfo;
/* Read the OTT table. */
FLASH_ReadBuffer(*table_handle_ptr, (MemBufferPtr)table_info_ptr,
OTTTBL_TableInfoSize);
status = OTTTBL_InfoStructFixISF_PLR((MemBufferPtr)table_info_ptr,
*table_handle_ptr,
restart);
/* E5.0.607 End */
if(status)
{
return status;
}
/* Calculate the relative offset of the object entry based */
/* on the object number. */
(*table_handle_ptr) += OTTTBL_TableIdSize +
(object_num * OTTTBL_TableEntrySize);
return status;
}
/*### Global Functions
//#########################*/
/*########################################################################
### OTTTBL_MarkTableComplete
###
### DESCRIPTION:
### This function will indicate to the system recover code that
### the ott table has been initialized and the data in it
### can be relied upon.
###
### PARAMETERS:
### tbl_hdr_addr - Address of the ott table object header.
### tbl_base_addr - Base address of the ott table object.
### header_ptr - A header strucutre
###
### RETURNS:
###
###
*/
ERR_CODE OTTTBL_MarkTableComplete( FDI_Handle tbl_hdr_addr,
FDI_Handle tbl_base_addr,
BOOLEAN mark_hdr2valid,
BOOLEAN restart)
{
UINT16 hdr_attr16;
ERR_CODE status;
/* E5.0.607 Begin */
OTTTBL_TableInfoPtr table_info_ptr = &OTTTableInfo;
/* 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -