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

📄 davcfgtbl.c

📁 FDI Intel开发的FLASH文件系统,功能很强大
💻 C
📖 第 1 页 / 共 5 页
字号:
  ###   returned otherwise, it returns a status of type ERR_CODE.
  ###*/
BOOLEAN CFGTBL_IsValidPgEntry(CFGTBL_PgReclaimEntryPtr aEntry)
{
   BOOLEAN result = FALSE;

   if(CFGTBL_GetPgUniqueId1(aEntry) == CFGTBL_UniqueId1 &&
      CFGTBL_GetPgUniqueId2(aEntry) == CFGTBL_UniqueId2)
   {
      result = TRUE;
   }

   return result;
}

/*########################################################################
  ### CFGTBL_IsValidPaEntry
  ###
  ### DESCRIPTION:
  ###    This function validates a cfgtable paragraph entry by searching 
  ###    for the unique identifiers that are in a predescribed location.
  ###    
  ### PARAMETERS:
  ###    aPtr - A pointer to the cfgtbl paragraph entry to validate
  ###
  ### RETURNS:
  ###   When this function passes with no errors a value of 0 is
  ###   returned otherwise, it returns a status of type ERR_CODE.
  ###*/
BOOLEAN CFGTBL_IsValidPaEntry(CFGTBL_PaReclaimEntryPtr aEntry)
{
   BOOLEAN result = FALSE;

   if(CFGTBL_GetPaUniqueId1(aEntry) == CFGTBL_UniqueId1 &&
      CFGTBL_GetPaUniqueId2(aEntry) == CFGTBL_UniqueId2 )
   {
      result = TRUE;
   }

   return result;
}

/*########################################################################
  ### CFGTBL_IsValidTable
  ###
  ### DESCRIPTION:
  ###    This function validates a cfgtable by searching for the
  ###    unique identifiers that are in a predescribed location.
  ###    
  ### PARAMETERS:
  ###    aPtr - A pointer to the cfgtbl to validate
  ###
  ### RETURNS:
  ###   When this function passes with no errors a value of 0 is
  ###   returned otherwise, it returns a status of type ERR_CODE.
  ###*/
BOOLEAN CFGTBL_IsValidTable(CFGTBL_ObjectTablePtr aPtr)
{
   BOOLEAN result = FALSE;

   if(CFGTBL_IsValidPgEntry(&aPtr->PgReclaimStatus) == TRUE)
   {
      if(CFGTBL_IsValidPaEntry(&aPtr->PaReclaimStatus) == TRUE)
      {
         result = TRUE;
      }
   }

   return result;
}
/*============================ TABLE ===============================*/
/*########################################################################
  ### CFGTBL_Allocate_PAGE_RECLAIM
  ###
  ### DESCRIPTION:
  ###    This function create a CT entry for the page reclaim. It creates
  ###    and validates the ct entry.
  ###    
  ### 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 CFGTBL_Allocate_PAGE_RECLAIM()
{
   ERR_CODE status = ERR_NONE;

   FDI_Handle    handleEntry;
   CFGTBL_Entry  entry;
   UINT8         numEntries;
   UINT8         ctIndex;

   /* Validate that no page reclaim tables exists */
   /* Get the first entry */
   status = CFGTBL_GetFirstCtEntry(&handleEntry, &entry, &numEntries);
   if(status != ERR_NONE)
   {
      return status;
   }

   /* Walk through all of the rest of the entries */
   for(ctIndex=2; ctIndex<=numEntries; ctIndex++)
   {
      if(CFGTBL_GetCtEntryType(&entry) == CFGTBL_CtEntryStatus_EntryValid)
      {
         switch(CFGTBL_GetCtEntryType(&entry))
         {
         /* These should not exits */
         case CFGTBL_CtEntryType_PAGE_RECLAIM:
         case CFGTBL_CtEntryType_OTT:
         case CFGTBL_CtEntryType_RAT:
         case CFGTBL_CtEntryType_RT:
            status = ERR_STATE;
            break;
         default:
            status = ERR_NONE;
         }
      }

      if(status != ERR_NONE)
      {
         return status;
      }

      /* Get the next entry */
      status = CFGTBL_GetNextCtEntry(&handleEntry, &entry, &handleEntry);
      if(status != ERR_NONE)
      {
         return status;
      }
   } /* for */

   /* Get a ctIndex */
   status = CFGTBL_GetUnusedCtEntry(&ctIndex, &entry);
   if(status != ERR_NONE)
   {
      return status;
   }

      /* Create the entry */
      UTIL_ClearVariable((UINT8*)&entry, sizeof(entry), 0xFF);
      CFGTBL_SetCtEntryType(&entry, CFGTBL_CtEntryType_PAGE_RECLAIM);
      status = CFGTBL_CreateCtEntryInFlash(ctIndex, &entry);
      if(status != ERR_NONE)
      {
         return status;
      }

   /* Validate the entry */
   status = CFGTBL_ValidateCtEntryInFlash(ctIndex);
   if(status != ERR_NONE)
   {
      return status;
   }

   return status;
}

/*########################################################################
  ### CFGTBL_Allocate_OTTTBL
  ###
  ### DESCRIPTION:
  ###    This function creates a ct entry with an associated ott table.
  ###    The table is filled at the same time it is allocated.
  ###    
  ### PARAMETERS:
  ###    aSramListPtr - A pointer to a ott array in sram
  ###    aArraySize   - The size of the passed array
  ###    aReclaimType - The type of page reclaim being performed
  ###    aEndBlock    - A ending working block
  ###    aStartBlock  - A starting working block
  ###
  ### 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 CFGTBL_Allocate_OTTTBL(OTTTBL_EntryPtr aSramListPtr, UINT16 aArraySize, UINT8 aReclaimType, UINT16 aEndBlock, UINT16 aStartBlock)
{
   ERR_CODE status = ERR_NONE;

   CFGTBL_Entry entry;
   FDI_Handle   objHandle;
   UINT32       psSize;
   UINT8        ctIndex;

   /* Insure we do no exceed our maximum table size */
   if(aArraySize > OTTTBL_MaxEntries)
   {
      return ERR_STATE;
   }

   status = MEM_CalcSizeAndHandleOfFreePoolInParaSpace(&psSize, &objHandle);
   if(status != ERR_NONE)
   {
      return status;
   }

   /* Insure we have enough paragraph space */
   if(psSize < OTTTBL_CalcTableSize(aArraySize))
   {
      return ERR_STATE;
   }

   /* Get Unused Ct Entry */
   status = CFGTBL_GetUnusedCtEntry(&ctIndex, &entry);
   if(status != ERR_NONE)
   {
      return status;
   }

   /* Allocate the Ct Entry */
   CFGTBL_SetCtEntryType(&entry, CFGTBL_CtEntryType_OTT);
   status = CFGTBL_CreateCtEntryInFlash(ctIndex, &entry);
   if(status != ERR_NONE)
   {
      return status;
   }
      /* Write the OTT Table */
      status = OTTTBL_AllocateFlash(objHandle, aSramListPtr, aArraySize, aReclaimType, aEndBlock, aStartBlock);
      if(status != ERR_NONE)
      {
         return status;
      }

   /* Validate the Ct Entry */
   status = CFGTBL_ValidateCtEntryInFlash(ctIndex);
   if(status != ERR_NONE)
   {
      return status;
   }

   return status;
}

/*########################################################################
  ### CFGTBL_Allocate_RTTBL
  ###
  ### DESCRIPTION:
  ###    This function creates a ct entry with an associated rt table.
  ###    The table is filled at the same time it is allocated.
  ###    
  ### PARAMETERS:
  ###    aLastBlock - The last block requiring work
  ###    aNumBlocks - The number of block work is being performed on
  ###    aStatePtr  - An array of precalculated block states. This prevents
  ###                 all of the logic being done in one area.
  ###
  ### RETURNS:
  ###   When this function passes with no errors a value of 0 is
  ###   returned otherwise, it returns a status of type ERR_CODE.
  ###*/
/*Fix Start:SCR964 */
ERR_CODE CFGTBL_Allocate_RTTBL(UINT16 aLastBlock,  UINT16 aNumBlocks, EnBlockOperation* aStatePtr)
/*Fix End:SCR964 */
{
   ERR_CODE status = ERR_NONE;

   CFGTBL_Entry entry;
   FDI_Handle   objHandle;
   UINT32       psSize;
   UINT8        ctIndex;

   /* Insure we do no exceed our maximum table size */
   if(aNumBlocks > RTTBL_MaxEntries)
   {
      return ERR_STATE;
   }

   /* Obtain a starting address of a chunk of free paragraph space for the table */
   status = MEM_CalcSizeAndHandleOfFreePoolInParaSpace(&psSize, &objHandle);
   if(status != ERR_NONE)
   {
      return status;
   }

   /* Insure we have enough paragraph space */
   if(psSize < RTTBL_CalcTableSize(aNumBlocks))
   {
      return ERR_STATE;
   }

   /* Get Unused Ct Entry */
   status = CFGTBL_GetUnusedCtEntry(&ctIndex, &entry);
   if(status != ERR_NONE)
   {
      return status;
   }

   /* Allocate the Ct Entry */
   CFGTBL_SetCtEntryType(&entry, CFGTBL_CtEntryType_RT);
   status = CFGTBL_CreateCtEntryInFlash(ctIndex, &entry);
   if(status != ERR_NONE)
   {
      return status;
   }

      status = RTTBL_AllocateFlash(objHandle, aLastBlock, aNumBlocks, aStatePtr);
      if(status != ERR_NONE)
      {
         return status;
      }

   /* Validate the Ct Entry */
   status = CFGTBL_ValidateCtEntryInFlash(ctIndex);
   if(status != ERR_NONE)
   {
      return status;
   }

   return status;
}


/*########################################################################
  ### CFGTBL_Allocate_RATTBL
  ###
  ### DESCRIPTION:
  ###    This function creates a ct entry with an associated rat table.
  ###    The table is allocated and left in a work-in-process state so
  ###    that the caller can fill in the rows as the process is being
  ###    computed.
  ###    
  ### PARAMETERS:
  ###    aNumRows      - The number of groups in the rat table
  ###    aBackupOffset - The offset to the backup
  ###    aValidateFlag - A flag to validate the table (the user has
  ###      completed their modifications).
  ###
  ### 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 CFGTBL_Allocate_RATTBL(UINT16 aNumRows, UINT32 aBackupOffset, UINT32 aBackupSize, BOOLEAN aValidateFlag)
{
   ERR_CODE status = ERR_NONE;

   CFGTBL_Entry entry;
   FDI_Handle   objHandle;
   FDI_Handle   unusedHandle;
   UINT32       psSize;
   UINT8        ctIndex;

   CFGTBL_PgReclaimEntry  cfgPageReclaim;
   FDI_Handle             cfgPageHandle;

   /* Are we validating that all entries are good? */
   if(aValidateFlag == TRUE)
   {
      /* Yes. Find a ctEntry that is in the allocation mode*/
      if(CFGTBL_GetCtEntryByStatus(FDI_ParaSpaceAddressBottom, CFGTBL_CtEntryType_RAT, CFGTBL_CtEntryStatus_EntryAllocating,
         &cfgPageReclaim, &cfgPageHandle, &ctIndex, &unusedHandle) == FALSE)
      {
         return ERR_STATE;
      }

      /* Set the ctEntry to a valid state */
      status = CFGTBL_ValidateCtEntryInFlash(ctIndex);
      if(status != ERR_NONE)
      {
         return status;
      }

   }
   else
   {
      /* Insure we do no exceed our maximum table size */
      if(aNumRows > RATTBL_MaxEntries)
      {
         return ERR_STATE;
      }

      status = MEM_CalcSizeAndHandleOfFreePoolInParaSpace(&psSize, &objHandle);
      if(status != ERR_NONE)
      {
         return status;
      }

      /* Insure we have enough paragraph space */
      if(psSize < RATTBL_CalcTableSize(aNumRows))
      {
         return ERR_STATE;
      }

      /* Get Unused Ct Entry */
      status = CFGTBL_GetUnusedCtEntry(&ctIndex, &entry);
      if(status != ERR_NONE)
      {
         return status;
      }

      /* Allocate the Ct Entry */
      CFGTBL_SetCtEntryType(&entry, CFGTBL_CtEntryType_RAT);
      status = CFGTBL_CreateCtEntryInFlash(ctIndex, &entry);
      if(status != ERR_NONE)
      {
         return status;
      }

         status = RATTBL_AllocateFlash(objHandle, aNumRows, aBackupOffset, aBackupSize);
         if(status != ERR_NONE)
         {
            return status;
         }

      /* Validation of the Ct Entry is done after the table is filled by the caller */
   }

   return status;
}

/*########################################################################
  ### CFGTBL_DeAllocatePageTables
  ###
  ### DESCRIPTION:
  ###    This function deallocates all of the tables associated with a
  ###    page reclaim.
  ###    
  ### PARAMETERS:
  ###    aCleanupType - Indicates if the clean up is being done due to
  ###       normally or abnormally.
  ###    aStatus      - The last status before the normal or abnormal
  ###       termination.
  ###    aPlrRestart  - A flag t

⌨️ 快捷键说明

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