⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 davrcvpg.c

📁 FDI Intel开发的FLASH文件系统,功能很强大
💻 C
字号:
/* Copyright (c) 1995-2002 Intel Corporation */
/* Intel Confidential                        */

/* ###########################################################################
###  Object: RCVRPAGE
###
###  Module: rcvrpage.c - Page Reclaim Recovery Module
###
###  $Workfile: davrcvpg.c $
###  $Revision: 53 $
###  $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
//#########################*/

/*### Local Functions
//#########################*/

/*### Global Declarations
//#########################*/

/*### Global Functions
//#########################*/

/*########################################################################
  ### RCVRPAGE_SetupForPageReclaimRestart
  ###
  ### DESCRIPTION:
  ###   This function will setup the page reclaim state machine
  ###   to re-enter the state machine at the ReadNextObject state.
  ###
  ### PARAMETERS:
  ###   none.
  ###
  ### RETURNS:
  ###   ERR_NONE  - When operation is successful.
  ###
*/
ERR_CODE RCVRPAGE_SetupForPageReclaimRestart(BOOLEAN restart)
{
   int        in_block;
   UINT32      obj_lo_addr, obj_hi_addr;
   ERR_CODE status = ERR_NONE;
   BOOLEAN invalid_page_exist = FALSE;    
   MemMap.FreeBlk.BaseAddr = Block2Handle(0);
   
   /* Search through the header table until an object is    */
   /*  found that lies within the FROM block. (FROM object) */
   HDR_InitSearchInfo(&SearchInfo, &SearchHeader);
   do
   {
      status = GetNextHeader(&SearchInfo, HDR_ByNextObject, 0, restart);
      if ((status != ERR_NONE) && (status != ERR_NO_MORE_ENTRIES) && 
          (status != ERR_PARAM))
      {
         return(status);
      }

      if (!status)
      {
         if ((HDR_GetAlignmentAttr((SearchInfo.HeaderPtr->Attr16)) ==
                                                     HDR_HA_AlignPage) &&
                   (HDR_GetAbsorbedAttr(SearchInfo.HeaderPtr->Attr16) == 
                                                           HDR_HA_Exists))
         {

            /* If there is an invalid page object, */
            /* restore the invalid page object size for PLR. */
            if (!(HDR_GetHdrState(SearchInfo.HeaderPtr->Attr16) == 
                                                     HDR_HA_STATE_Valid))
            {
               ReclaimState.InvalidObjectSize =
                  PAGE_TO_BYTES(SearchInfo.HeaderPtr->LoSize);

               /* Initialize number of objects that will be modified so that */
               /* it begins to count right after the invalid page object. */
               ReclaimState.CurrentObject2Modify = 0;

               invalid_page_exist = TRUE; 
            }
            else
            {
               if (invalid_page_exist == FALSE)
               {
                 ReclaimState.CurrentObject2Modify = 0;
 
               }
               else
               {
                 /* Increase number of objects that will be modified */ 
                 ReclaimState.CurrentObject2Modify++;
               }
            }  
            obj_hi_addr = SearchInfo.CurrObj.ObjectAddress + 
                                        SearchInfo.CurrObj.ObjectSize - 1;
            in_block = IsInBlock(SearchInfo.CurrObj.ObjectAddress, 
                                     obj_hi_addr, RecoverState.FROMBlock);
            
            if (in_block == -1)
            {
               if (HDR_GetHdrState((SearchInfo.HeaderPtr->Attr16)) ==
                                                           HDR_HA_STATE_Valid)
               {
                  MemMap.FreeBlk.BaseAddr += SearchInfo.CurrObj.ObjectSize;
               }
            }
            else
            {
               if (in_block == 0)
               {
                  if (HDR_GetHdrState((SearchInfo.HeaderPtr->Attr16)) ==
                                                              HDR_HA_STATE_Valid)
                  {
                     obj_lo_addr = SearchInfo.CurrObj.ObjectAddress;
                     GetInBlockHiLoAddress(&obj_lo_addr, &obj_hi_addr, 
                                                RecoverState.FROMBlock);
                  
                     /* Add in the amount of the object that is before the  */
                     /*  FROM Block.                                        */
                     MemMap.FreeBlk.BaseAddr += obj_lo_addr - 
                                          SearchInfo.CurrObj.ObjectAddress;

/* E.5.0.600 Begin */
                     if((SearchInfo.HeaderPtr->ObjectType) != FDI_HT_ReclaimTable)
                     {
/* E.5.0.595 Begin */
                        if((SearchInfo.CurrObj.ObjectAddress == 
                               Block2Handle(RecoverState.FROMBlock)) &&
                           (ReclaimState.CurrentObject2Modify != 0))
                        {
                           ReclaimState.CurrentObject2Modify--;
                           /* Read the current object entry. */
                           status = OTTTBL_ReadTable(ReclaimState.OTTTblBaseAddr, 
                                              ReclaimState.CurrentObject2Modify, 
                                              &ReclaimState.OTTTblEntry, restart);
                           if(status != ERR_NONE)
                           {
                              return status;
                           }    

                           if ((ReclaimState.OTTTblEntry.objsize == DWORDMAX) &&
                               (ReclaimState.OTTTblEntry.status == WORDMAX))
                           {
                              ReclaimState.OTTTblEntry.objsize = 
                                        SearchInfo.CurrObj.ObjectSize;
      
                              /* Write the current object entry. */
                              status = OTTTBL_WriteTable(ReclaimState.OTTTblBaseAddr, 
                                                ReclaimState.CurrentObject2Modify, 
                                                  &ReclaimState.OTTTblEntry, restart);
                              if(status != ERR_NONE)
                              {
                                 return status;
                              }   

                              /* Mark the current object status 
                                 to OTTTBL_MASK_OTTEntryValid. */    
                              OTTTBL_MarkOTTEntryValid(ReclaimState.OTTTblEntry.status);
                              status = OTTTBL_WriteTable(ReclaimState.OTTTblBaseAddr, 
                                                ReclaimState.CurrentObject2Modify, 
                                                &ReclaimState.OTTTblEntry, restart);
                              if(status != ERR_NONE)
                              {
                                 return status;
                              }
                              ReclaimState.CurrentObject2Modify++;
                           }
                        }
/* E.5.0.595 End */    
                     }
/* E.5.0.600 End */		 
                  }
               }
               break;
            }
         }
      }
      
   } while (!status);

   
   
   /* We will always read the header of the FROM object, so */
   /*  do everything that would be done if we had just read */
   /*  the object.                                          */
   ReclaimState.NextState = (UINT16)RECLAIM_ST_ReadNextObj;
   ReclaimState.SingleSkipRead = TRUE;
   
   /* Base address of the reclaim block never moves, only   */
   /*  the BytesUsed field does.                            */
   MemMap.RecBlk.BaseAddr = FDI_ReclaimBlockAddress;
   
   if ((RecoverState.TOBlock == RecoverState.FROMBlock) &&
                    (Handle2Block(MemMap.FreeBlk.BaseAddr) == 
                                            RecoverState.TOBlock))
   {
      MemMap.RecBlk.BytesUsed = MemMap.FreeBlk.BaseAddr - 
                                Block2Handle(RecoverState.TOBlock);
      MemMap.FreeBlk.BaseAddr = Block2Handle(RecoverState.TOBlock);
   }
   else
   {
      MemMap.RecBlk.BytesUsed = 0;                                           
   }

   MemMap.FreeBlk.BytesFree = 
              Block2Handle(RecoverState.FROMBlock) - 
                                           MemMap.FreeBlk.BaseAddr;

   return ERR_NONE;
}

#endif /* DIRECT_ACCESS_VOLUME */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -