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

📄 davrcvr.c

📁 FDI Intel开发的FLASH文件系统,功能很强大
💻 C
📖 第 1 页 / 共 5 页
字号:
  ###   aRefPtr - Parameter used throughout the recovery.
  ###
  ### 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 RECOVER_PAGE_ResetInitializeRat(PAGE_RECLAIM_Address* aRefPtr)
{
   ERR_CODE status;

   BOOLEAN       plrRestart = TRUE;
   FDI_Handle    unusedEntryHandle;

   RATTBL_Entry  ratEntry;
   RATTBL_Leader ratLeader;


#ifdef ENABLE_RECOVER_TESTS
   /*TBD EVT_TestEvent(EVT_RECOVER_RestartInitializePageReclaim_Start);*/
#endif

   /* PLR - RECLAIM-IN-PLACE */
   /* PLR - DEFRAG           */
   /* PLR - REALLOCATE       */
   /*         It would seem that we can just delete the tables and back out, however, */
   /*         under double plr conditions, we encounter half deleted tables. This     */
   /*         causes us to recover into a point where the tables have been deleted.   */
   /*         The best recovery for realloc double plr is just to finish realloc and  */
   /*         and let reclaim-in-place cleanup. */

   /* Assume that we can recover */
   aRefPtr->startOperation = enInitializeRatTable;

   /* Get a RAT entry which gives us a indication of the table state */
   status = RATTBL_GetFirstRatEntry(&unusedEntryHandle, &ratEntry, &ratLeader);
   if(status != ERR_NONE)
   {
      /* Does a entry/table (in valid state) exist? */
      if(status == ERR_NOTEXISTS)
      {
         /* No. Insure to delete any lingering table (in allocating state ). */
         status = CFGTBL_InvalidateCtEntryByStatus(CFGTBL_CtEntryType_RAT, CFGTBL_CtEntryStatus_EntryAllocating, plrRestart);
         switch(status)
         {
         case ERR_NONE:      /* Entry exists and was invalidated */
            break;
         case ERR_NOTEXISTS: /* Entry did not exists */
            break;
         default:
            return status;
            break;
         } /* switch */
         status = ERR_NONE;
      }
   }

#ifdef ENABLE_RECOVER_TESTS
   /*TBD EVT_TestEvent(EVT_RECOVER_RestartInitializePageReclaim_End);*/
#endif

	return status;
}

/*#################################################################
  ### RECOVER_PAGE_ResetRelocateHeaders
  ###
  ### DESCRIPTION:
  ###   This will reset the relocateHeaders.
  ###
  ### PARAMETERS 
  ###   aRefPtr            - Parameter used throughout the recovery.
  ###   aParaRecoveryState - Indicates what the state of the
  ###      paragraph reclaim was.
  ###
  ### 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 RECOVER_PAGE_ResetRelocateHeaders(PAGE_RECLAIM_Address* aRefPtr, EnReclaimRecovery aParaRecoveryState)
{
   ERR_CODE     status;

#ifdef ENABLE_RECOVER_TESTS
   /*TBD EVT_TestEvent(EVT_RECOVER_RestartMoveObject_Start);*/
#endif

   if(aRefPtr->reclaimType == enPageReallocate)
   {
      aRefPtr->startOperation = enRelocateHeaders;

      /* PLR - REALLOCATE       */
      /*         It would seem that we can just delete the tables and back out, however, */
      /*         under double plr conditions, we encounter half deleted tables. This     */
      /*         causes us to recover into a point where the tables have been deleted.   */
      /*         The best recovery for realloc double plr is just to finish realloc and  */
      /*         and let reclaim-in-place cleanup. */

      return ERR_NONE; /* Normal exit */
   }

   if(aRefPtr->reclaimType == enPageReclaimInPlace)
   {
      /* PLR - RECLAIM-IN-PLACE */

      /* We can recover */
      aRefPtr->startOperation = enRelocateHeaders;
      status = ERR_NONE;
      return status; /* Normal exit */
   }


   /* Set the restart point based on the paragraph recovery point */
   switch(aParaRecoveryState)
   {
   case enReclaimRecoveryRequired:
      /* Required and completed, restart at the next state */
      aRefPtr->startOperation = enRelocateHeaders; /* TBD Should be relocate. ReTest */
      break;
   case enReclaimRecoveryNotNeeded:
      /* Switch into the relocate state, however, never started it              */
      /* Completed the relocate state, however, no indication that it was done */
      /*   Do it over again, will not hurt */
      aRefPtr->startOperation = enRelocateHeaders;
      break;
   case enReclaimRecoveryNotPossible:
      aRefPtr->startOperation = enRelocateHeaders;
      break;
   case enReclaimRecoveryBackedOut:
      aRefPtr->startOperation = enRelocateHeaders;
      break;
   case enReclaimRecoveryNotDetermined:
      return ERR_STATE;
      break;
   } /* switch */


#ifdef ENABLE_RECOVER_TESTS
   /*TBD EVT_TestEvent(EVT_RECOVER_RestartMoveObject_End);*/
#endif

   return ERR_NONE;
}


/*#################################################################
  ### RECOVER_PAGE_ResetMoveObject
  ###
  ### DESCRIPTION:
  ###   This will reset the page reclaim from the move object step.
  ###
  ### PARAMETERS 
  ###   aRefPtr - Parameter used throughout the recovery.
  ###
  ### 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 RECOVER_PAGE_ResetMoveObject(PAGE_RECLAIM_Address* aRefPtr)
{
   ERR_CODE     status;

   FDI_Handle   rtEntryHandle;
   RTTBL_Entry  rtEntry;
   RTTBL_Leader rtLeader;
   /*Fix Start:SCR964 */
   UINT16        rtIndex;
   UINT16        rtStartBlock;
   UINT16        rtEndBlock;
   /*Fix End:SCR964 */
   BOOLEAN      rtContinue = FALSE;
   UINT32       offset;
/* E5.5.969 Start */ 
   UINT16       progress_state;
/* E5.5.969 End */ 

#ifdef ENABLE_RECOVER_TESTS
   /*TBD EVT_TestEvent(EVT_RECOVER_RestartMoveObject_Start);*/
#endif

   /* PLR - RECLAIM-IN-PLACE */
   if(aRefPtr->reclaimType == enPageReclaimInPlace)
   {
      /* We can recover */
      aRefPtr->startOperation = enMoveUserObjects;
      status = ERR_NONE;
      return status; /* Normal exit */
   }

   /* PLR - REALLOCATE */

   /* Assume that we can recover */
   aRefPtr->startOperation = enMoveUserObjects;

   status = RTTBL_GetFirstRtEntry(&rtEntryHandle, &rtEntry, &rtLeader);
   if(status != ERR_NONE)
   {
      return ERR_STATE;
   }

   /* Compute the range of blocks to process */
   rtEndBlock   = RTTBL_GetLastBlock(&rtLeader);
   rtStartBlock = RTTBL_GetLastBlock(&rtLeader) - RTTBL_GetNumRows(&rtLeader)+1;

   /* loop until we find a partially completed block */
   for(rtIndex=rtStartBlock; rtIndex<=rtEndBlock; rtIndex++)
   {
      /* We know the handle to the entry, compute the offset to the ProgressState */
      offset = (UINT32)&rtEntry.ProgressState - (UINT32)&rtEntry;
/* E5.5.969 Start */ 
      progress_state = RTTBL_GetRecoveredRtEntryProgressState( &rtEntry,
                                                               rtEntryHandle + offset,
                                                               &status );
      if( status != ERR_NONE )
      {
         return status;
      }
      switch( progress_state )
/* E5.5.969 End */ 
      {
      case RTTBL_RtEntryProgressState_NoOperationInProgress:
      case RTTBL_RtEntryProgressState_OperationComplete:
      case RTTBL_RtEntryProgressState_NoOperationRequired:
         /* Block has no work to do */
         rtContinue = TRUE;
         break;

      case RTTBL_RtEntryProgressState_CopyOutInProgress:
         /* We were copying the current page block to the reclaim block */
         rtContinue = FALSE;

         /* Erase the reclaim block so the copy can restart properly */
         status = FLASH_EraseBlock(FDI_ReclaimBlockAddressBottom, TRUE);
         if(status != ERR_NONE)
         {
            return status;
         }
         break;

      case RTTBL_RtEntryProgressState_ErasePageBlockInProgress:
         /* We are erasing the current page block */
         rtContinue = FALSE;

         /* We can proceed with out resetting anything */
         break;

      case RTTBL_RtEntryProgressState_CopyBackInProgress:
         /* We were copying the reclaim block back to the page block */
         rtContinue = FALSE;

         status = FLASH_EraseBlock(UTIL_CalcHandleOfBlockBottomBoundary(rtIndex), TRUE);
         if(status != ERR_NONE)
         {
            return status;
         }

         break;

      case RTTBL_RtEntryProgressState_EraseReclaimBlockInProgress:
         rtContinue = FALSE;
         break;

      } /* switch */

      if(rtContinue == TRUE)
      {
         status = RTTBL_GetNextRtEntry(&rtEntryHandle, &rtEntry, &rtEntryHandle);
         if(status != ERR_NONE)
         {
            return ERR_STATE;
         }
      }
      else
      {
         break; /* out of the for loop */
      }
   } /* for */

#ifdef ENABLE_RECOVER_TESTS
   /*TBD EVT_TestEvent(EVT_RECOVER_RestartMoveObject_End);*/
#endif

   return status;
}


/*#################################################################
  ### RECOVER_PAGE_ResetInitializePageReclaim
  ###
  ### DESCRIPTION:
  ###   This will reset the page reclaim from the initialization
  ###   step.
  ###
  ### PARAMETERS 
  ###   aRefPtr - Parameter used throughout the recovery.
  ###
  ### 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 RECOVER_PAGE_ResetInitializePageReclaim(PAGE_RECLAIM_Address* aRefPtr)
{
   ERR_CODE status;

   BOOLEAN       plrRestart = TRUE;
   FDI_Handle    unusedEntryHandle;

   RTTBL_Entry   rtEntry;
   RTTBL_Leader  rtLeader;

   OTTTBL_Entry  ottEntry;
   OTTTBL_Leader ottLeader;

#ifdef ENABLE_RECOVER_TESTS
   /*TBD EVT_TestEvent(EVT_RECOVER_RestartInitializePageReclaim_Start);*/
#endif

   /* We cannot recover only if the OTT was written               */
   /* PLR - RECLAIM-IN-PLACE                                      */
   /*         If no otttable, will restart via the api recovery   */
   /* PLR - REALLOCATE       */
   /*         It would seem that we can just delete the tables and back out, however, */
   /*         under double plr conditions, we encounter half deleted tables. This     */
   /*         causes us to recover into a point where the tables have been deleted.   */
   /*         The best recovery for realloc double plr is just to finish realloc and  */
   /*         and let reclaim-in-place cleanup. */
   /* PLR - DEFRAG (FULL/PARTIAL)                                 */
   /*         It is safe to backout at this point                 */

   /* Assume that we can recover */
   aRefPtr->startOperation = enInitializeOttRtTables;

   /* Can we get a complete RTTBL */
   status = RTTBL_GetFirstRtEntry(&unusedEntryHandle, &rtEntry, &rtLeader);
   if(status != ERR_NONE)
   {
      if(status == ERR_NOTEXISTS)
      {
         /* No. Cleanup partial table state */
         status = CFGTBL_InvalidateCtEntryByStatus(CFGTBL_CtEntryType_RT, 
            CFGTBL_CtEntryStatus_EntryAllocating, plrRestart);
         switch(status)
         {
         case ERR_NONE:      /* Entry exists and was invalidated */
            break;
         case ERR_NOTEXISTS: /* Entry did not exists */
            break;
         default:
            return status;

⌨️ 快捷键说明

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