📄 davrecip.c
字号:
/* Copyright (c) 1995-2002 Intel Corporation */
/* Intel Confidential */
/* ###########################################################################
### RECINPLC
###
### Module: recinplc.c - Reclaim In Place
###
### $Workfile: davrecip.c $
### $Revision: 51 $
### $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)
/*### Local Declarations
#########################*/
typedef enum
{
RECINPLC_STEP_NoRestart,
RECINPLC_STEP_BottomSection_RecoveryState1,
RECINPLC_STEP_BottomSection_RecoveryState2,
RECINPLC_STEP_BottomSection_RecoveryState3,
RECINPLC_STEP_BottomSection_RecoveryState4,
RECINPLC_STEP_MiddleSection,
RECINPLC_STEP_TopSection_RecoveryState1,
RECINPLC_STEP_TopSection_RecoveryState2,
RECINPLC_STEP_TopSection_RecoveryState3,
RECINPLC_STEP_TopSection_RecoveryState4,
RECINPLC_STEP_DeallocateRAT,
RECINPLC_STEP_MarkCfgEntryDone
} RECINPLC_RestartStates;
typedef enum
{
RECINPLC_RAT_NoStatus_NoStatus =
((RECINPLC_ST_NoStatus << 8) | RECINPLC_ST_NoStatus),
RECINPLC_RAT_EIP_NoStatus =
((RECINPLC_ST_EraseInProgress << 8) | RECINPLC_ST_NoStatus),
RECINPLC_RAT_EC_NoStatus =
((RECINPLC_ST_EraseComplete << 8) | RECINPLC_ST_NoStatus),
RECINPLC_RAT_CC_NoStatus =
((RECINPLC_ST_CopyComplete << 8) | RECINPLC_ST_NoStatus),
RECINPLC_RAT_Done_NoStatus =
((RECINPLC_ST_BlockDone << 8) | RECINPLC_ST_NoStatus),
RECINPLC_RAT_Done_EIP =
((RECINPLC_ST_BlockDone << 8) | RECINPLC_ST_EraseInProgress),
RECINPLC_RAT_Done_EC =
((RECINPLC_ST_BlockDone << 8) | RECINPLC_ST_EraseComplete),
RECINPLC_RAT_Done_CC =
((RECINPLC_ST_BlockDone << 8) | RECINPLC_ST_CopyComplete),
RECINPLC_RAT_Done_Done =
((RECINPLC_ST_BlockDone << 8) | RECINPLC_ST_BlockDone)
} RECINPLC_RestartStatus;
UINT32 RECINPLC_BottomSectionAddr;
UINT32 RECINPLC_TopSectionAddr;
UINT8 RECINPLC_BottomStatus;
UINT8 RECINPLC_TopStatus;
/*### Global Declarations
#########################*/
/*### Local Functions
#########################*/
ERR_CODE RECINPLC_AllocateRAT(HDR_SearchInfoPtr obj_info_ptr,
BOOLEAN restart);
/* E.5.0.652 Begin */
ERR_CODE RECINPLC_InitRAT(HDR_SearchInfo *table_info_ptr,
HDR_SearchInfo *obj_info_ptr );
/* E.5.0.652 End */
ERR_CODE RECINPLC_ProcessBlock(FDI_Handle table_base_addr,
FDI_Handle start_addr_in_block,
FDI_Handle end_addr_in_block,
RECINPLC_RestartStates rip_restart_state);
ERR_CODE RECINPLC_AuthenticateRAT(FDI_Handle table_address,
UINT32_PTR top_address_ptr,
UINT32_PTR bottom_address_ptr,
UINT8_PTR top_status,
UINT8_PTR bottom_status,
BOOLEAN restart);
ERR_CODE RECINPLC_EntryFixISF_PLR(RECINPLC_ReAllocateTable *rat_table_ptr,
UINT32 flash_address,
BOOLEAN restart);
/*### Global Functions
#########################*/
/*#################################################################
### RECLAIM_ReclaimObjectInPlace
###
### DESCRIPTION:
### This function will use the object info specified by the
### obj_info_ptr parameter and will erase all of the
### data associated with that object. Any valid data
### around that object will be preserved in the manor
### prescribed by the power loss recover and normal
### reclaim process.
###
### PARAMETERS:
### obj_info_ptr - IN: CurrObj.ObjectAddress must be valid.
### CurrObj.ObjectSize must be valid.
### - OUT: No change.
### restart - BOOLEAN to determine if this is a restart.
### On restart
### CurrObj.HeaderAddress = cfg_entry
### CurrObj.ObjectAddress = cfg_entry_index
###
### RETURNS:
### When this function passes with no errors a value of 0 is
### returned otherwise, it returns a status of type ERR_CODE.
###*/
/* E.5.0.652 Begin */
ERR_CODE RECINPLC_ReclaimObjectInPlace(HDR_SearchInfo *obj_info_ptr,
BOOLEAN restart)
/* E.5.0.652 End */
{
ERR_CODE status = ERR_NONE; /* DAV init */
RECINPLC_RestartStates rip_restart_state;
CFGHDR_ConfigurationEntry cfg_entry;
UINT8 cfg_entry_index = 0;
UINT32 block;
UINT32 bottom_block = 0xffffffff; /* DAV init to illegal value */
UINT32 top_block;
UINT32 start_addr_in_block;
UINT32 end_addr_in_block;
HDR_CompareInfo compare_info;
RECINPLC_RestartStatus bottom_status_top_status;
#ifdef ENABLE_REALLOCATE_TESTS
EVT_TestEvent(EVT_RECINPLC_ReclaimInPlace_Start);
#endif
HDR_InitSearchInfo(&FDI_GlobalInfo, &FDI_GlobalHeader);
if (restart)
{
cfg_entry_index = (UINT8)obj_info_ptr->CurrObj.ObjectAddress;
if (CFGHDR_GetOffsetStatus(obj_info_ptr->CurrObj.ConfigEntry) ==
CFGHDR_STATUS_ValidOffset)
{
/* Load table_info with data for RAT */
FDI_GlobalInfo.CurrObj.ObjectSize = RECINPLC_ReAllocateTableSize;
FDI_GlobalInfo.CurrObj.HeaderAddress =
CFGHDR_GetOffset(obj_info_ptr->CurrObj.ConfigEntry);
FDI_GlobalInfo.CurrObj.ObjectAddress =
FDI_GlobalInfo.CurrObj.HeaderAddress -
FDI_GlobalInfo.CurrObj.ObjectSize;
/* Find an authentic RAT */
if ((status =
RECINPLC_AuthenticateRAT(FDI_GlobalInfo.CurrObj.ObjectAddress,
&RECINPLC_TopSectionAddr,
&RECINPLC_BottomSectionAddr,
&RECINPLC_TopStatus,
&RECINPLC_BottomStatus, restart))
!= ERR_NONE)
{
/* RAT was not found */
if(status != (ERR_CODE)1)
{
return status;
}
status = CFGHDR_WriteReclaimComplete(cfg_entry_index);
return status;
}
/* Combine Bottom and Top section statuses */
bottom_status_top_status =
RECINPLC_CombineStatus(RECINPLC_BottomStatus,
RECINPLC_TopStatus);
RECINPLC_BottomStatus = 0x0;
RECINPLC_TopStatus = 0x0;
/* Find restart state */
switch(bottom_status_top_status)
{
case RECINPLC_RAT_NoStatus_NoStatus:
rip_restart_state = RECINPLC_STEP_BottomSection_RecoveryState1;
/* Starting point in block processing */
bottom_block = RECINPLC_BottomSectionAddr;
break;
case RECINPLC_RAT_EIP_NoStatus:
rip_restart_state = RECINPLC_STEP_BottomSection_RecoveryState2;
/* Starting point in block processing */
bottom_block = RECINPLC_BottomSectionAddr;
break;
case RECINPLC_RAT_EC_NoStatus:
rip_restart_state = RECINPLC_STEP_BottomSection_RecoveryState3;
/* Starting point in block processing */
bottom_block = RECINPLC_BottomSectionAddr;
break;
case RECINPLC_RAT_CC_NoStatus:
rip_restart_state = RECINPLC_STEP_BottomSection_RecoveryState4;
/* Starting point in block processing */
bottom_block = RECINPLC_BottomSectionAddr;
break;
case RECINPLC_RAT_Done_NoStatus:
rip_restart_state = RECINPLC_STEP_MiddleSection;
/* Starting point in block processing */
bottom_block = RECINPLC_BottomSectionAddr + FDI_BlockSize;
break;
case RECINPLC_RAT_Done_EIP:
rip_restart_state = RECINPLC_STEP_TopSection_RecoveryState2;
/* Starting point in block processing */
bottom_block = RECINPLC_TopSectionAddr;
break;
case RECINPLC_RAT_Done_EC:
rip_restart_state = RECINPLC_STEP_TopSection_RecoveryState3;
/* Starting point in block processing */
bottom_block = RECINPLC_TopSectionAddr;
break;
case RECINPLC_RAT_Done_CC:
rip_restart_state = RECINPLC_STEP_TopSection_RecoveryState4;
/* Starting point in block processing */
bottom_block = RECINPLC_TopSectionAddr;
break;
case RECINPLC_RAT_Done_Done:
rip_restart_state = RECINPLC_STEP_DeallocateRAT;
/* Starting point in block processing */
bottom_block = RECINPLC_TopSectionAddr + FDI_BlockSize;
break;
default:
/* Unknown State produce fatal error */
return(ERR_SYSTEM);
}
/* DAV - check for valid value */
if (bottom_block != 0xffffffff)
{
bottom_block = Handle2Block(bottom_block);
}
}
else
{
/* SEARCH FOR RAT */
compare_info.CompareValue = FDI_HT_ReAllocateTable;
status = GetNextHeader(&FDI_GlobalInfo, HDR_ByValidType,
&compare_info, restart);
if ((status != ERR_NONE) && (status != ERR_NO_MORE_ENTRIES) &&
(status != ERR_PARAM))
{
return(status);
}
if (status == ERR_NONE)
{
rip_restart_state = RECINPLC_STEP_DeallocateRAT;
}
else
{
rip_restart_state = RECINPLC_STEP_MarkCfgEntryDone;
}
}
}
else
{
rip_restart_state = RECINPLC_STEP_NoRestart;
}
switch (rip_restart_state)
{
case RECINPLC_STEP_NoRestart:
#ifdef ENABLE_REALLOCATE_TESTS
EVT_TestEvent(EVT_RECINPLC_NoRestart);
#endif
/* Allocate Cfg Entry */
status = CFGHDR_AllocateConfigurationEntry(&cfg_entry_index,
&cfg_entry,
CFGHDR_TYPE_ReAllocateTable, restart);
if (status)
{
return(status);
}
/* Allocate a RAT */
status = RECINPLC_AllocateRAT(&FDI_GlobalInfo, restart);
if (status)
{
return(status);
}
/* Initialize RAT */
status = RECINPLC_InitRAT(&FDI_GlobalInfo, obj_info_ptr);
if (status)
{
return(status);
}
/* Mark Offset */
status = CFGHDR_WriteTableOffset(cfg_entry_index,
FDI_GlobalInfo.CurrObj.HeaderAddress);
if (status)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -