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

📄 davrcvr.c

📁 FDI Intel开发的FLASH文件系统,功能很强大
💻 C
📖 第 1 页 / 共 5 页
字号:
            break;
         } /* switch */
      }
   }

   /* Get a OTT entry which gives us a indication of the table state */
   status = OTTTBL_GetFirstOttEntry(&unusedEntryHandle, &ottEntry, &ottLeader);
   if(status != ERR_NONE)
   {
      /* Does a entry/table (in valid state) exist? */
      if(status == ERR_NOTEXISTS)
      {
         /* This means we cannot recover */
         aRefPtr->startOperation = enAbortPageReclaim;

         /* No. Insure to delete any lingering table (in allocating state ). */
         status = CFGTBL_InvalidateCtEntryByStatus(CFGTBL_CtEntryType_OTT, 
            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 */

         /* If the ott table did not exist, then remove the ctEntry for the page reclaim */
         status = RECOVER_PAGE_ResetPageReclaimCtEntry(); /* ResetInitializePageReclaim */
         if(status != ERR_NONE)
         {
            return status;
         }
      }
   }


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

	return status;
}

/*#################################################################
  ### RECOVER_PAGE_ResetNoOperationInProgress
  ###
  ### DESCRIPTION:
  ###   This will reset the page reclaim from the no operation
  ###   in progress 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_ResetNoOperationInProgress(PAGE_RECLAIM_Address* aRefPtr)
{
   ERR_CODE status;
 
   /* We cannot recover because the OTT was not written to recover from this point*/
   /* PLR - RECLAIM-IN-PLACE                                      */
   /*         This will be restart automatically via api recovery */
   /* PLR - REALLOCATE                                            */
   /*         It is safe to backout at this point                 */
   /* PLR - DEFRAG (FULL/PARTIAL)                                 */
   /*         It is safe to backout at this point                 */
   aRefPtr->startOperation = enAbortPageReclaim;

   /* Clean up tables */
   /*Fix Start :SCR990*/
   status = RECOVER_PAGE_ResetPageReclaimCtEntry(); /* RestartReclaim */
   /*Fix End :SCR990*/
   if(status != ERR_NONE)
   {
      return status;
   }

	return ERR_NONE;
}


/*#################################################################
  ### RECOVER_PARAGRAPH_ResetFormatOrAllocateCfgTbl
  ###
  ### DESCRIPTION:
  ###   This will reset the power-loss during a format or the
  ###   initial creation of the configuration tab.e
  ###
  ### PARAMETERS 
  ###   None
  ###
  ### 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_PARAGRAPH_ResetFormatOrAllocateCfgTbl()
{
   ERR_CODE status;

   /* The reclaim block should already be erased */
   /* The page space should already be erased */
   /* Erase the paragraph block so the copy can restart properly */
   status = FLASH_EraseBlock(FDI_ParaSpaceAddressBottom, TRUE);
   if(status != ERR_NONE)
   {
      return status;
   }

   /* This is a legal call when everything is wiped */
   status = MEM_CalcMemoryStatistics(FALSE);
   if(status != ERR_NONE)
   {
      return status;
   }

   /* We were creating a cfgtable */
   status = CFGTBL_AllocateFlash();
   if(status != ERR_NONE)
   {
      return status;
   }

   return status;
}

/*#################################################################
  ### RECOVER_API_RestartApi
  ###
  ### DESCRIPTION:
  ###   This will restart the reallocate that had a powerloss 
  ###   before the user had a changes to replace the object.
  ###
  ### PARAMETERS 
  ###   aPlrInfoPtr -  A series of parameters that all plr
  ###     functions may need.
  ###
  ### 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_API_RestartApi(RECOVER_Info* aPlrInfoPtr)
{
   ERR_CODE   status        = ERR_NONE;
   UINT16     cntBackups    = 0;
   FDI_Handle unusedHandle;

   PAGE_RECLAIM_Address* ptrReclaimRef = &GlbReclaimRef;
   UTIL_ClearVariable((UINT8*)ptrReclaimRef, sizeof(PAGE_RECLAIM_Address), 0x00);

   /* See if we have any backups lying around */
   aPlrInfoPtr->plrApiRecoveryState = enReclaimRecoveryNotNeeded;
   ptrReclaimRef->relocObjHandle    = 0;
   ptrReclaimRef->bkupObjHandle     = 0;
   status = BKUP_CalcValidBackupsInSystem(&cntBackups, &unusedHandle, &ptrReclaimRef->bkupObjHandle);
   if(status != ERR_NONE)
   {
      return status;
   }

   /* At this point the page reclaim has been completed */
   /* If we find a single backup object, then we were doing a reallocate operation */
   if(cntBackups == 1)
   {
      /* We not complete the reallocate, only restore to its original state*/
      aPlrInfoPtr->plrApiRecoveryState = enReclaimRecoveryBackedOut;

      /* Search for a page object that matches the backup */
      status = BKUP_FindOrigObjForBackupObj(ptrReclaimRef->bkupObjHandle, &ptrReclaimRef->relocObjHandle);
      if(status != ERR_NONE)
      {
         return status;
      }

      /* Set Global flag for System State */
      /* We can be more specific on the type of page reclaim recovery */
      SetSystemState(FDI_SystemState, FDI_ST_ReallocateRecover);

      /* Set the defrag type */
      ptrReclaimRef->reclaimType           = enPageReclaimInPlace; /* Reallocate Defrag Opr */
      ptrReclaimRef->desiredPageSize       = 0;                    /* Reallocate Defrag Opr */

      /* Pass the pin list */
      ptrReclaimRef->sramPinEntriesListPtr = &GlbPinObjectList[0];
      ptrReclaimRef->sramPinEntries        = 0;

      /* Other Initialization */
      ptrReclaimRef->sramOttEntries        = 0;                    /* Forces a OTT re-read */
      ptrReclaimRef->plrRestart            = FALSE;                /* Used for PLR         */
      ptrReclaimRef->startOperation        = enStartOfPageReclaim;

      /* Start the reclaim (Non-Powerloss)*/
      status = RECLAIM_PAGE_StartReclaim(ptrReclaimRef); /* Api - ReclaimInPlace */
      if(status != ERR_NONE)
      {
         return status;
      }

   }
   else if(cntBackups > 0)
   {
      /* If more than one backup, it should of been cleaned up within the page reclaim */
      status = ERR_STATE;
      return status;
   }

   return status;
}

/*#################################################################
  ### RECOVER_PAGE_RestartReclaim
  ###
  ### DESCRIPTION:
  ###   This will restart the paragraph reclaim from the reclaim
  ###   block.
  ###
  ### PARAMETERS 
  ###   aPlrInfoPtr        -  A series of parameters that all plr
  ###     functions may need.
  ###
  ### 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_RestartReclaim(RECOVER_Info* aPlrInfoPtr)
{
   ERR_CODE status = ERR_NONE;

   BOOLEAN                plrRestart = TRUE;
   BOOLEAN                manualRecovery = FALSE;
   UINT32                 offset;

   FDI_Handle             ottEntryHandle;
   OTTTBL_Entry           ottEntry;
   OTTTBL_Leader          ottLeader;

   CFGTBL_PgReclaimEntry  cfgPageReclaim;
   FDI_Handle             cfgPageHandle;
   UINT8                  ctIndex;
   FDI_Handle             ctEntryHandle;
   UINT16                 cntBackups;
   FDI_Handle             unusedHandle;
   PAGE_RECLAIM_Address*  ptrReclaimRef = &GlbReclaimRef;
/* E5.5.969 Start */  
   UINT16                 progress_state;
/* E5.5.969 End */ 
   UTIL_ClearVariable((UINT8*)ptrReclaimRef, sizeof(PAGE_RECLAIM_Address), 0x00);

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

   /* Do we have a page reclaim in progress (status is valid)? */
   if(CFGTBL_GetCtEntryByStatus(FDI_ParaSpaceAddressBottom, CFGTBL_CtEntryType_PAGE_RECLAIM, CFGTBL_CtEntryStatus_EntryValid,
      &cfgPageReclaim, &cfgPageHandle, &ctIndex, &ctEntryHandle) == TRUE)
   {
      /* Yes. We want to investigate the recovery further */
      aPlrInfoPtr->plrPageRecoveryState = enReclaimRecoveryRequired;
   }
   else if(CFGTBL_GetCtEntryByStatus(FDI_ParaSpaceAddressBottom, CFGTBL_CtEntryType_PAGE_RECLAIM, CFGTBL_CtEntryStatus_EntryAllocating,
      &cfgPageReclaim, &cfgPageHandle, &ctIndex, &ctEntryHandle) == TRUE)
   {
      /* Not really. We did not get a complete start */
      aPlrInfoPtr->plrPageRecoveryState = enReclaimRecoveryBackedOut;

      /* We were trying to allocate a ctEntry to start the reclaim, however, */
      /*   could not complete the allocation due to powerloss                */
      status = RECOVER_PAGE_ResetPageReclaimCtEntry();
      if(status != ERR_NONE)
      {
         return status;
      }
   }
   else
   {
      /* No CtEntry was found for a page reclaim */
      aPlrInfoPtr->plrPageRecoveryState = enReclaimRecoveryNotNeeded;

   }

   /* This will account for either type of recovery modes */
   if(aPlrInfoPtr->plrPageRecoveryState != enReclaimRecoveryNotNeeded)
   {
      /* Set Global flag for System State */
      SetSystemState(FDI_SystemState, FDI_ST_ReclaimRecover);

   }

   /* Investigate a recovery further? */
   if(aPlrInfoPtr->plrPageRecoveryState == enReclaimRecoveryRequired)
   {
#ifdef ENABLE_RECOVER_TESTS
      /*TBD EVT_TestEvent(EVT_RECOVER_RestartParagraphReclaim_Start);*/
#endif
      /* At this point, the paragraph reclaim is in a completed state.  */
      /* It is save to resync the header data and do a repair  at the   */
      /* same time */
      status = MEM_CalcMemoryStatistics(plrRestart);
      if(status != ERR_NONE)
      {
         return status;
      }

      /*## Clean up after WIP and absorbing page objects */
      status = RECOVER_HandleWIPandAbsorbingPageObjectsDuringReclaim(plrRestart);
      if(status != ERR_NONE)
      {
         if (status == ERR_NO_MORE_ENTRIES)
         {
            status = ERR_NONE;
         }
         else
         {
            return (status);
         }
      }

      /* Compute and recover each status fields for the paragraph reclaim */
      offset = (UINT32)&cfgPageReclaim.CtEntry[ctIndex] - 
         (UINT32)&aPlrInfoPtr->plrCfgTable;

      /* Try and get the defrag type */
/* E5.5.969 Start */ 
      progress_state = CFGTBL_GetRecoveredCtProgressState( &cfgPageReclaim.CtEntry[ctIndex],
                                                           aPlrInfoPtr->plrCfgTableHandle +offset,
                                                           &status );
      if( status != ERR_NONE )
      {
         return status;
      }
      switch( progress_state )
/* E5.5.969 End */ 
      {
      case CFGTBL_CtProgressState_NoOperationInProgress:
      case CFGTBL_CtProgressState_InitializeInProgress:
      case CFTTBL_CtProgressState_DefragComplete:
         /* Try and get a first ott entry to determine type of defrag  */
         status = OTTTBL_GetFirstOttEntry(&ottEntryHandle, &ottEntry, &ottLeader);
         /* Did we see a ott table? */
         if(status == ERR_NONE)
         {
            /* Yes. Get the reclaim type */
            switch(OTT

⌨️ 快捷键说明

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