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

📄 fdi_fmt.c

📁 FDI Intel开发的FLASH文件系统,功能很强大
💻 C
📖 第 1 页 / 共 2 页
字号:
/* ###########################################################################
###  Intel Confidential
###  Copyright (c) Intel Corporation 1995-2002
###  All Rights Reserved.
###  -------------------------------------------------------------------------
###  Project: Flash Data Integrator
###
###  Module: FDI_FMT.C - This module is a collection of all the FDI
###                      API functions.
###
###  $Archive: /FDI/SRC/FDI/fdi_fmt.c $
###  $Revision: 126 $
###  $Date: 10/21/04 11:39a $
###  $Author: Pcmcgint $
###  $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
######################## */
/* E.5.0.690 Begin */ 
/*remove include fdi_type.h and fdi_int.h */
/*add include fdi_lowl.h */

#include "fdi_ext.h"
#include "fdi_que.h"
#include "fdi_lowl.h"

/* E.5.0.690 End */ 

#ifdef CUSTOM_SEM_MTX
#include "fdi_mutx.h"
#endif

#ifdef TIMING
#include "comm.h"
#include "logLib.h"
#endif

#ifdef writeToFile

   extern FILE *rw;
#endif

#if (DIRECT_ACCESS_VOLUME == TRUE)
#include "dav.h"
#ifdef TESTING
extern VOID_PTR Buff_ptr;
#endif
#endif /* DIRECT_ACCESS_VOLUME */

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

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



/* ### Global Declarations
###################### */

extern BYTE FDI_InitComplete;
extern SEM_MTX_ID  SEM_APIMutexSemaphore;
extern SEM_MTX_ID  SEM_OpenStream;
extern SEM_ID      SEM_FDIErrorIndicator;
extern SEM_MTX_ID  SEM_FDIErrorMutex;
extern SEM_MTX_ID  SEM_FlashWrite;
extern SEM_MTX_ID  SEM_TotalSize;
#ifdef CUSTOM_SEM_MTX
extern SEM_ID      SEM_Mutex_Space;
#endif

/* E5.3.875 START */
/*#if(DIRECT_ACCESS_VOLUME == TRUE)*/
extern SEM_MTX_ID  SEM_FlashErase;
/* E5.1.811 START */
/* E 5.1.849 START */
/* 
 * Remove the declaration of SEM_DAVAPILock, SEM_DAVReclLock 
 * and SEM_DAVReclRequest since  
 * they have been declared in davlib.h 
 */
/* E 5.1.849 END */
/* E5.1.811 END */
/*#endif /DIRECT_ACCESS_VOLUME */
/* E5.3.875 END */
/* E5.1.811 START */
#if (FILE_MANAGER == TRUE)
extern SEM_MTX_ID  FileAPIMutexSemaphore;
#endif /* FILE_MANAGER */
/* E5.1.811 END */

extern DATA_LOOKUP_PTR FDI_DataLookupPtrTable[];


extern Q_ID FDI_QueueIdentifier;
#ifdef TIMING
COMM_TIMESTAMP FDI_APIfmt;
COMM_TIMESTAMP FDI_APIfmtend;
COMM_TIMESTAMP FDI_APIers;
COMM_TIMESTAMP FDI_APIersend;
extern COMM_TIMESTAMP FDI_APIend;
#endif


/*############################################################################
 *### FDI_Terminate
 *###
 *### DESCRIPTION:
 *### Terminates all semaphores and tasks associated with FDI
 *###
 *### PARAMETERS:
 *###    IN: void
 *###    OUT:
 *###
 *### RETURNS:
 *###    Returns the following errors codes:
 *###       BKGD_ERR_NONE
 *###       BKGD_ERR_SEMAPHORE
 *###*/
HW_ERROR
FDI_Terminate(void)
{
   HW_ERROR status = HW_ERR_NONE;

   FDI_InitComplete = FALSE;

   status = BKGD_Terminate();
   if(!status)
   {
      status = RECL_Terminate();
   }

   if(!status)
   {
#ifdef TESTING
      /* Make task safe during plr testing to ensure TID is updated
       * prior to preemption during power loss emulation.
       */
      taskSafe();
#endif
      if (FDI_QueueIdentifier != 0)
      {
         if (Q_Delete((Q_ID) FDI_QueueIdentifier) != Q_ERR_NONE)
         {
            status = HW_ERR_SYSTEM;
         }
      }
      FDI_QueueIdentifier = 0;
   }

   if(!status)
   {
/* E.5.5.5.987 Begin */
#if( (SEM_CREATE_DESTROY == TRUE) || defined(CUSTOM_SEM_MTX) ) 
/* E.5.5.5.987 End */
      if (SEM_APIMutexSemaphore != SEM_NULL)
      {
         SEM_MTX_DESTROY(SEM_APIMutexSemaphore);
      }
      if (SEM_OpenStream != SEM_NULL)
      {
         SEM_MTX_DESTROY(SEM_OpenStream);
      }
      if (SEM_FDIErrorMutex != SEM_NULL)
      {
         SEM_MTX_DESTROY(SEM_FDIErrorMutex);
      }
/* E.5.5.5.987 Begin */
#if(SEM_CREATE_DESTROY == TRUE)
/* E.5.5.5.987 End */
      if (SEM_FDIErrorIndicator != SEM_NULL)
      {
         SEM_DESTROY(SEM_FDIErrorIndicator);
      }
/* E.5.5.5.987 Begin */
#endif /* SEM_CREATE_DESTROY */
/* E.5.5.5.987 End */
      if (SEM_FlashWrite != SEM_NULL)
      {
         SEM_MTX_DESTROY(SEM_FlashWrite);
      }
/* E5.3.875 START */
/*#if(DIRECT_ACCESS_VOLUME == TRUE)*/
      if (SEM_FlashErase != SEM_NULL)
      {
         SEM_MTX_DESTROY(SEM_FlashErase);
      }

#if(DIRECT_ACCESS_VOLUME == TRUE)
/* E5.3.875 END */

/* E.5.5.5.987 Begin */
#if(SEM_CREATE_DESTROY == TRUE)
/* E.5.5.5.987 End */
      /*
       * E5.1.811 START
       * Destroy all Code Manager mutex semaphores here (backed out the
       * changes made by SCR806)
       */
      if (SEM_DAVReclRequest != SEM_NULL)
      {
         SEM_DESTROY(SEM_DAVReclRequest);
      }
/* E.5.5.5.987 Begin */
#endif /* SEM_CREATE_DESTROY */
/* E.5.5.5.987 End */
      if (SEM_DAVReclLock != SEM_NULL)
      {
         SEM_MTX_DESTROY(SEM_DAVReclLock);
      }
      if (SEM_DAVAPILock != SEM_NULL)
      {
         SEM_MTX_DESTROY(SEM_DAVAPILock);
      }

#endif /* DIRECT_ACCESS_VOLUME */

#if (FILE_MANAGER == TRUE)
      /* Destroy all File Manager mutex semaphores */
      if (FileAPIMutexSemaphore != SEM_NULL)
      {
         SEM_MTX_DESTROY(FileAPIMutexSemaphore);
      }
#endif /* FILE_MANAGER */
      /* E5.1.811 END */

/* E.5.5.5.987 Begin */
#if(SEM_CREATE_DESTROY == TRUE)
/* E.5.5.5.987 End */
#ifdef CUSTOM_SEM_MTX
      if(SEM_Mutex_Space != SEM_NULL)
      {
         SEM_DESTROY(SEM_Mutex_Space);
      }
#endif
/* E.5.5.5.987 Begin */
#endif /* SEM_CREATE_DESTROY */
/* E.5.5.5.987 End */
      if (SEM_TotalSize != SEM_NULL)
      {
         SEM_MTX_DESTROY(SEM_TotalSize);
      }
/* E.5.5.5.987 Begin */
#endif /* SEM_CREATE_DESTROY and CUSTOM_SEM_MTX */
/* E.5.5.5.987 End */

#if(DIRECT_ACCESS_VOLUME == TRUE)
#ifdef  TESTING
/* E.5.0.600 START */
      /* free RAM if previously allocated during object modification. */
      if(Buff_ptr != NULL)
      {
         free(Buff_ptr);
         Buff_ptr = NULL;
      }
/* E.5.0.600 END */
#endif
#endif
   }
#ifdef TESTING
   taskUnsafe();
#endif

   return status;
}                                      /* END FDI_Terminate */


#if (INCLUDE_FORMAT == TRUE)
/*
#############################################################################
### FDI_Format
###
### DESCRIPTION:
###   FDI_Format function is used during development to format the flash,
### for manufacturing, and in the field for crucial errors. The format
###   will erase all data blocks and set up the block information. It will
###   also preserve a wear leveling count if the option is enabled.
###
### PARAMETERS:
###    IN:
###
###
###    OUT:
###        error                : a descriptive error code

⌨️ 快捷键说明

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