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

📄 davott.c

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

   return status;
}                               

/*########################################################################
  ### OTTTBL_WriteTable
  ###
  ### DESCRIPTION:
  ###   This function will write a ott status entry to the specified
  ###   block entry in the ott table.
  ###
  ### PARAMETERS:
  ###   table_handle     - Base address of the ott table object.
  ###   object_num       - Desired object information.
  ###   status_ptr       - Desired ott status to write.
  ###
  ### RETURNS:
  ###   ERR_NONE  - When operation completes successfully.
  ###
*/
ERR_CODE OTTTBL_WriteTable(FDI_Handle           table_handle, 
                             UINT32             object_num, 
                             OTTTBL_TableEntryPtr OTTentry_ptr,
                             BOOLEAN restart)
{
   ERR_CODE status = ERR_NONE;   
   status = 
      CalculateOTTTableEntryOffset(&table_handle, object_num, restart);
   if(status == ERR_NONE)
   {     
      status = FLASH_WriteBuffer(table_handle, 
                  (MemBufferPtr)OTTentry_ptr, OTTTBL_TableEntrySize);
   }

   return status;
}                                 

/*########################################################################
//### OTTTBL_ReadTable
//###
  ### DESCRIPTION:
  ###   This function will read a ott status entry to the specified
  ###   block entry in the ott table.
  ###
  ### PARAMETERS:
  ###   table_handle     - Base address of the ott table object.
  ###   object_num       - Desired object information.
  ###   OTTentry_ptr       - Desired ott entry to write.
  ###
  ### RETURNS:
  ###   ERR_NONE  - When operation completes successfully.
  ###
*/
ERR_CODE OTTTBL_ReadTable(FDI_Handle           table_handle, 
                            UINT32                object_num, 
                            OTTTBL_TableEntryPtr OTTentry_ptr, BOOLEAN restart)
{
   ERR_CODE status = ERR_NONE;

   status = 
      CalculateOTTTableEntryOffset(&table_handle, object_num, restart);
   if(status != ERR_NONE)
   {
      return status;
   }   

   FLASH_ReadBuffer(table_handle, (MemBufferPtr)OTTentry_ptr, 
                                                OTTTBL_TableEntrySize);
   status = UINT16_FixISF_PLR( &(OTTentry_ptr->status), table_handle + OTTTBL_OffsetToStatus, restart);
                                  
   return status;
}

/*########################################################################
  ### OTTTBL_CreateTable
  ###
  ### DESCRIPTION:
  ###   This function will create a ott table object on the
  ###   proper "power loss" recovery order.
  ###
  ### PARAMETERS:
  ###   table_info_ptr  - Used to return the table object information
  ###                     back to the caller.
  ###
  ### RETURNS:
  ###   ERR_NONE  - When operation is successful.
  ###
*/
ERR_CODE OTTTBL_CreateTable(HDR_SearchInfoPtr table_info_ptr, BOOLEAN restart)
{
UINT32          ii;
UINT8_PTR       tchar_ptr;
ERR_CODE        status;
FDI_Handle      ott_tbl_handle;
HDR_CompareInfo compare_info;

   /* All is well on the memory space front, so create the header. */
   /* Set up Power Loss Recovery Options */
 table_info_ptr->HeaderPtr->Attr16 = WORDMAX;
 table_info_ptr->HeaderPtr->Attr8 = BYTEMAX;

 table_info_ptr->HeaderPtr->Attr8 =
        HDR_SetReliableAttr((table_info_ptr->HeaderPtr->Attr8), HDR_HA_Reliable);
        
 table_info_ptr->HeaderPtr->Attr8 = 
        HDR_SetReservesAttr((table_info_ptr->HeaderPtr->Attr8), HDR_HA_NoReserves);
                
   /* NOTE: Must write status to Valid after TableInfo is written. */
   table_info_ptr->HeaderPtr->Attr16 = 
        HDR_SetStatusAttr((table_info_ptr->HeaderPtr->Attr16), HDR_HA_WriteInProgress);
   
   /* Copy the name to the header */
   ii = 0;

   tchar_ptr = (UINT8_PTR)OTTTBL_HeaderName;
   while (*(tchar_ptr + ii) != 0)
   {
      table_info_ptr->HeaderPtr->Name[ii] = *(tchar_ptr + ii);
      ii++;
   }
   table_info_ptr->HeaderPtr->NameSize = (UINT8)ii;
   
 /* Update tracking vars. */
   FDI_MemUsage.ParaOverhead.Valid += 
                      RoundUp((ii + HDR_FixedSize), FDI_ParagraphLength);
   FDI_MemUsage.ParaSpace.Valid += OTTTBL_ParaOTTTblSize;
   
   table_info_ptr->HeaderPtr->Attr16 = 
      HDR_SetAlignmentAttr((table_info_ptr->HeaderPtr->Attr16), 
                                                          HDR_HA_AlignPara);
         
   /* Calculate the size of the header and place it in the */
   /*  proper fields.                                      */
   HDR_SetObjectSize((table_info_ptr->HeaderPtr), 
                             (OTTTBL_ParaOTTTblSize / FDI_ParagraphLength));

   table_info_ptr->HeaderPtr->Attr16 = 
      HDR_SetAbsorbedAttr((table_info_ptr->HeaderPtr->Attr16), HDR_HA_Exists);
      
   table_info_ptr->HeaderPtr->Attr16 = (UINT16)
      HDR_SetPrivilegeAttr((table_info_ptr->HeaderPtr->Attr16), 0);
   
   table_info_ptr->HeaderPtr->SecurityKey = 0xfeedbeef;
   table_info_ptr->HeaderPtr->ObjectType  = FDI_HT_ObjTrkTable;

   /* Write the header to flash! */
   status = HDR_CreateHeaderEntry((FDI_HandlePtr)&ott_tbl_handle,
                                            table_info_ptr->HeaderPtr);
   if (status)
   {
      return status;
   }
   
   /* Locate the physical address of the ott table for use by  */
   /*  the WriteOTTTable function, starting from the beginning */
   /*  of the header table.                                        */
   table_info_ptr->CurrObj.HeaderAddress = 0;
   table_info_ptr->CurrObj.ConfigEntry.Status = 0;
   table_info_ptr->CurrObj.ConfigEntry.Offset = 0;

   compare_info.CompareValue = ott_tbl_handle;
   status = GetNextHeader(table_info_ptr, 
                                   HDR_ByHeaderAddress, &compare_info, restart);
   
   return status;
}

/*########################################################################
  ### OTTTBL_InfoStructFixISF_PLR
  ###
  ### DESCRIPTION:
  ###    This function will fix the PLR bit's bits in the plr fields of the
  ###    OTT info table that includes the OTT table entry from the indeterminate state of 
  ###    01 or 10 to either 00 or 11.
  ###    
  ### PARAMETERS:
  ###    OTT info struct pointer in RAM
  ###    flash address where Init' may need to fix in flash if required
  ###    size of the structure
  ###    restart to know whether to fix in flash or not.
  ###
  ### RETURNS:
  ###   Returns a status of type ERR_CODE.
  ###*/


ERR_CODE OTTTBL_InfoStructFixISF_PLR(MemBufferPtr ott_table_info_ptr, 
                                     UINT32 flash_address, 
                                     BOOLEAN restart)
{
   UINT16 count = 0;
   ERR_CODE status = ERR_NONE;

   status = UINT16_FixISF_PLR( &(((OTTTBL_TableInfo *)ott_table_info_ptr)->TableId), 
                               flash_address + OTTTBL_TableIdOffset, restart);

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

   ott_table_info_ptr += OTTTBL_TableIdSize;
   flash_address += OTTTBL_TableIdSize;

   for(count= 0; count < NUM_OTT_ENTRIES; count++)
   {
      if((((OTTTBL_TableEntryStruct *)ott_table_info_ptr)->objsize != 0xFFFFFFFF) &&
        (((OTTTBL_TableEntryStruct *)ott_table_info_ptr)->status != 0xFFFF) )
      {
         if((status = UINT16_FixISF_PLR( &(((OTTTBL_TableEntryStruct *)ott_table_info_ptr)->status), 
                               flash_address + OTTTBL_OffsetToStatus, restart)) != ERR_NONE)
         {
            break;
         }

         ott_table_info_ptr += OTTTBL_TableEntrySize;                           
         flash_address += OTTTBL_TableEntrySize;                           

      }else 
      {  
         break;
      }  
         
   }   
   return status;
}

#endif /* DIRECT_ACCESS_VOLUME */

⌨️ 快捷键说明

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