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

📄 davinit.c

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

/* ###########################################################################
###  DAV - Direct Access Volume Enhancement to FDI 
###
###  Module: dav_init.c - Main DAV Initialization Module
###
###  $Workfile: davinit.c $
###  $Revision: 70 $
###  $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 "DavLib.h"

#if (DIRECT_ACCESS_VOLUME == TRUE)

#include "Dav.h"
#include "DavInit.h"
#include "DavMem.h"
#include "DavMath.h"
#include "davcfgtbl.h"
#include "DavRcvr.h"
#include "fdi_lowl.h"

/*### Local Declarations
#########################*/

/* temp mpg: Moved to FlshAddr.h 
## #define FDI_DefaultStartAddress 0xFFE00000
## #define FDI_DefaultDatabaseSize (16 * 0x10000)
*/


/*### DAV Global Declarations
############################*/
FDI_Handle FDI_NextFreeHeaderEntry;  /* Points to the first available   */
                                     /* paragraph in the header table.  */

FDI_Handle FDI_LastHeaderEntry;      /* Points to the last header       */
                                     /* entry in the header             */

UINT16     FDI_PageObjectCounter;   /* Counter for number of page objects in flash */

/* Performance improvement could come from changing
   FDI_BlockSize to a const.
*/                                     
/* Parameters returned from the flash module. */
UINT32   FDI_BlockSize;               
UINT32   FDI_StartAddress;            
UINT32   FDI_TotalBlocks;  

UINT32   FDI_TopOfMemory;             /* Address of the very top of       */
                                      /* managed flash                    */

UINT32   FDI_ReclaimBlockAddressTop;
UINT32   FDI_ReclaimBlockAddressBottom;
UINT32   FDI_ParaSpaceAddressTop;
UINT32   FDI_ParaSpaceAddressBottom;
UINT32   FDI_PageSpaceAddressTop;
UINT32   FDI_PageSpaceAddressBottom;

UINT32   FDI_LastObjectAddress;
UINT32   FDI_FirstObjectAddress;

UINT32   FDI_TotalFlashSpace;
UINT32   FDI_TotalObjectSpace;


UINT32   DAV_MEM_FirstHeaderAddr;

BOOLEAN  FDI_LockoutObjectAllocation; /* Prevents allocation of a WIP     */
                                      /* object until the current WIP     */
                                      /* object is complete.              */
                                     
BOOLEAN  FDI_ReAllocateOverrideFlag;  /* Prevents allocate from searching */
                                      /* for a duplicate object           */
                                      /* (provided for re-allocate)       */
UINT16   FDI_SystemState;             /* Bit field for system state       */
UINT32   FDI_ReclaimLevel;            /* Global Reclaim Level             */

/* E5.1.797 START */
BOOLEAN  DAV_InitializationComplete = FALSE;
/* E5.1.797 END */

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


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

/*#################################################################
  ### FDI_DAVInit
  ###
  ### DESCRIPTION:
  ###   This function should be the first call before accessing any
  ###   functionality of the DAV.  It is responsible for invoking the 
  ###   initialization of the flash memory, recovering from system 
  ###   failures and setting up global variables.
  ###
  ### PARAMETERS:
  ###   IN:
  ###   OUT:
  ###
  ### 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 FDI_DAVInit(void)
{

   ERR_CODE        status = ERR_NONE;
   FLASH_Info      flash_info;
   /* Since we are initialize, do not want to ignore the recovery */
   BOOLEAN         performPlrRecovery = TRUE;

#if ((BLOCK_LOCK_SUPPORT == TRUE) && (ENABLE_FDI_BLOCKLOCKING == FALSE))
   UINT16 block;
   HW_ERROR hw_status = HW_ERR_NONE;
#endif /* BLOCK_LOCK_SUPPORT */


   /* Initialize the counter for number of page objects in flash */ 
   FDI_PageObjectCounter = 0;

   DAV_Terminate();

/*
 * The SEM_FlashErase semaphore is shared between Code Manager 
 * and Data Manager and should be created before erasing data in flash.
 * Therefore, the creation of SEM_FlashErase semaphore is moved to 
 * FDI_Init function 
 */

#if ((BLOCK_LOCK_SUPPORT == TRUE) && (ENABLE_FDI_BLOCKLOCKING == FALSE))
   /* Block locking/unlocking is disable in lowlvl.  Unlock the DAV
         managed blocks at initialization (i.e. now). */
   for (block = 0 ; block < DAV_BLOCKCOUNT; block++)
   {
      hw_status = FlashDevLock(0, ((DWORD)block * (DWORD)DAV_BLOCK_SIZE) +
                                  DAV_START_ADDRESS, HW_CMD_UNLOCK);
      if (hw_status != HW_ERR_NONE)
      {
         /* If the flash is ready and program suspended */
         if (hw_status == HW_ERR_SUSPEND)
         {
            return ERR_SUSPEND;
         }
         /* If the flash is busy */
         else if (hw_status == HW_ERR_NOTRDY)
         {
            return ERR_NOTRDY;
         }
         /* If the arguments were wrong */
         else if (hw_status == HW_ERR_PARAM)
         {
            return ERR_PARAM;
         }
         /* Can happen only when stack is corrupted */
         return ERR_SYSTEM;
      }
   }                                   /* ENDIF each block */
#endif /* BLOCK_LOCK_SUPPORT */

   /* All mutex semaphores are created by FDI_Init */
   status = DAV_SoftInit(&flash_info, performPlrRecovery);
   if (status)
   {
      mDEBUG_CHECK_ERRCODE(status) /* E.5.1.513 */
      return status;
   }
   
   /* Performs redundant recovery scan but, since no recovery will
      be necessary it won't take that much time. */
   GlbPinObjectListEntries = 0;
   UTIL_ClearVariable((UINT8*)&GlbPinObjectList[0], sizeof(GlbPinObjectList), 0x00);
   UTIL_ClearVariable((UINT8*)&GlbPinBlockTable[0], sizeof(GlbPinBlockTable), 0x00);
   status = RECOVER_ValidateSystem(); /* FDI_DAVInit */
   if(status != ERR_NONE)
   {
      if(status != ERR_NOTEXISTS)
      {
         return status;
      }
      else
      {
         status = status;
      }
   }

   status = MEM_CalcMemoryStatistics(FALSE); /* FDI_DAVInit */
   if(status != ERR_NONE)
   {
      return status;
   }

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



/*#################################################################
  ### DAV_SoftInit
  ###
  ### DESCRIPTION:
  ###   This function is responsible for performing an initialization
  ###   of data structures and will recover from power loss but
  ###   will not perform any WIP object removal.
  ###
  ### PARAMETERS:
  ###   flash_info_ptr  - pointer to a valid flash info structure
  ###     that tells the DAV what to manage.
  ###   perform_plr_recovery - Indicates if a recovery needs to
  ###     be performed. 
  ###   IN:  none
  ###     
  ###   OUT:
  ###     BlockSize   - number of bytes in the erase block.
  ###     TotalBytes  - total bytes being managed.
  ###     FlashBase   - Base address of region to manage.
  ###                   May or may not be virtual.

⌨️ 快捷键说明

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