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

📄 blockdev.c

📁 M-System DOC(Disk on a Chip) Flash芯片映像读写工具, 可以进行二片Flash芯片的内容互相拷贝, 提高烧录程序的效率.
💻 C
📖 第 1 页 / 共 5 页
字号:
/***********************************************************************************/
/*                        M-Systems Confidential                                   */
/*           Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2003            */
/*                         All Rights Reserved                                     */
/***********************************************************************************/
/*                            NOTICE OF M-SYSTEMS OEM                              */
/*                           SOFTWARE LICENSE AGREEMENT                            */
/*                                                                                 */
/*      THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE                 */
/*      AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT           */
/*      FOR THE SPECIFIC TERMS AND CONDITIONS OF USE,                              */
/*      OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE:                               */
/*      E-MAIL = info@m-sys.com                                                    */
/***********************************************************************************/

/*
 * $Log:   V:/PVCSDB/DiskOnChip/archives/general storage/TrueFFS/src/core/blockdev.c-arc  $
 * 
 *    Rev 1.25   Jan 14 2004 22:28:38   oris
 * Bug fix - Compilation error when ENVIRONMENT_VARS was not defined.
 * Bug fix - some missing FAR pointer arithmetic's
 * Added proper error message when mounting FAT-32 formatted media 
 * Added support for flFormatLogicalDrive called without the TL_FAT_FORMAT flag.
 * Added new API for closing all files and lowering the global attention flag.
 * 
 *    Rev 1.24   Dec 01 2003 16:10:02   oris
 * Removed 5.x exb support.
 * 
 *    Rev 1.23   Nov 20 2003 18:47:20   omerk
 * Added TFFS_DLL_API prefix to flBuildGeometry routine.
 * 
 *    Rev 1.22   Nov 02 2003 20:27:34   OriS
 * Bug fix - might cause memory exception, when changing environment variables for a specific socket or for all the sockets.
 * 
 *    Rev 1.21   Oct 30 2003 00:52:26   OriS
 * changed flSuspendMode to be socket specific and to accept FL_IGNORE_WRITE and FL_IGNORE_ERASE modes
 * 
 *    Rev 1.20   Oct 26 2003 19:06:28   oris
 * Added TL_DO_NOT_PERFORM_DOWNLOAD formatting flag
 * 
 *    Rev 1.19   Oct 23 2003 21:04:50   OriS
 * Prevent download operation in case of single floor programming.
 * 
 *    Rev 1.18   Oct 23 2003 13:56:26   oris
 * Added new environment variable flSkipStaticFilesWearLeveling (FL_NO_STATIC_FILES_WEAR_LEVELING)
 * Compilation error when using FL_PUTIMAGE or FL_PUTIMAGE_PARALLEL compilation flags 
 * 
 *    Rev 1.17   Oct 20 2003 08:59:22   oris
 * Added support for single floor programming - prevent mounting of the media after it was formatted in case of single floor programming.
 * 
 *    Rev 1.16   Sep 30 2003 17:56:08   oris
 * Bug fix - mount used wrong start sector when working with extended partitions.
 * Bug fix - mount might have decided on wrong FAT type (fat12/fat16) on a track boundary from the real boundary
 * Added FL prefix to SECTOR_SIZE and SECTOR_SIZE_BITS
 * Added the required prefixes to export flInit routine.
 * Added flFlushFile API
 * 
 *    Rev 1.15   Sep 01 2003 19:10:10   oris
 * - Bug fix - Bad debug print in change cache size environment variable. Used to be chains length.
 * - Bug fix - flExit routine checked flInit routine pointer instead of initDone variable causing TrueFFS to execute flExit even if nothing was done.
 * - Removed tffsRAMXXX calls.
 * - changed TLS definition to FL_TLS 
 * 
 *    Rev 1.14   Aug 03 2003 15:42:28   OriS
 * Mege with previous version.
 * 
 *    Rev 1.13   Jun 22 2003 07:21:48   OriS
 * Fixed debug print for set ting "cache size" environment variaobles.
 * 
 *    Rev 1.12   Jun 19 2003 17:20:08   OriS
 * Remove compilation errors in case of FIXED_MEDIA not defined
 * 
 *    Rev 1.11   Jun 19 2003 13:35:52   OriS
 * Removed warnings
 * 
 *    Rev 1.10   Jun 18 2003 20:47:14   OriS
 * Removed warnings
 * 
 *    Rev 1.9   Jun 16 2003 01:17:44   oris
 * Added TFFS_DLL_API prefix.
 * 
 *    Rev 1.8   May 28 2003 08:33:18   oris
 * Removed read IPL parameter check (in case size does not divide by 512)
 * 
 *    Rev 1.7   May 18 2003 15:18:54   OriS
 * Added some static prefixes.
 * Improved the affect of the FL_READ_ONLY compilation flag.
 * Changed handleConversionTable to flHandleConversionTable.
 * 
 *    Rev 1.6   May 16 2003 00:56:24   OriS
 * Removed flPhsycalRead, flPhsycalWrite , flPhsycalErase routines.
 * 
 *    Rev 1.5   May 11 2003 08:25:20   OriS
 * Forced VERIFY_WRITE to read after every write when ENVIRONMENT_VARS are undefined.
 * Removed FL_LEAVE_BINARY_AREA and FL_LEAVE_SOME_BINARY_ARE. Now using the TL_xxx version.
 * Added support for FL_WRITE_QUICK_MOUNT_INFO.
 * 
 *    Rev 1.4   May 08 2003 23:16:44   OriS
 * Bug fix - Set environment variable of cache size and do not wait for ready of all sockets or all volumes did not work.
 * Added support for FL_PUTIMAGE and FL_PUTIMAGE_PARALLEL compilation flags.
 * Added support for getting quick mount information.
 * 
 *    Rev 1.3   May 06 2003 11:52:38   OriS
 * Removed physicalRead , physicalWrite , physicalErase routines
 * Changed TFFSCPY to tffsRAMcpy
 * Changed TFFSCMP to tffsRAMcmp
 * Changed TFFSSET to tffsRAMset
 * Changed TL_CACHE to FL_TL_CACHE
 * Removed tffsxxx routine initialization under ENVIRONMENT_VARS compilation flag
 * 
 *    Rev 1.2   Apr 27 2003 14:13:50   Oris
 * Compilation ERROR when ENVIRONMENT_VARS is not defined.
 * 
 *    Rev 1.1   Apr 13 2003 20:29:06   OriS
 * Changed FL_EXTENEDED_DISK_INFO to FL_EXTENDED_DISK_INFO
 * 
 *    Rev 1.0   Apr 09 2003 12:16:04   OriS
 * Initial revision.
 * 
 */

#include "bddefs.h"
#include "blockdev.h"

#ifdef FL_BACKGROUND
#include "backgrnd.h"
#endif


/********************* Extern Function Prototype Start *******************/
#ifdef WRITE_EXB_IMAGE
extern FLStatus getExbInfo(Volume vol, void FAR1 * buf, FLDword bufLen, FLWord exbFlags);
extern FLStatus placeExbByBuffer(Volume vol, FLByte  FAR1 * buf, FLDword bufLen,
                 FLWord windowBase,FLWord exbFlags);
#endif /* WRITE_EXB_IMAGE */

#ifdef FORMAT_VOLUME
extern FLStatus flDosFormat(TL *, BDTLPartitionFormatParams FAR1 *formatParams);
#ifdef COMPRESSION
extern FLStatus flFormatZIP(unsigned volNo, TL *baseTL , FLFlash * flash);
#endif /* COMPRESSION */
#endif /* FORMAT_VOLUME */

#if (defined(FL_FILES) && FL_FILES > 0)
extern File     fileTable[FL_FILES];       /* the file table */
#ifndef FL_NO_SURE_FS_SUPPORT
extern FLStatus autoRepair(Volume vol);
extern FLStatus flushFile(File *file);
#endif /* FL_NO_SURE_FS_SUPPORT */
extern FLStatus flushBuffer(Volume vol);
extern FLStatus openFile(Volume vol, IOreq FAR2 *ioreq);
extern FLStatus closeFile(File *file);
extern FLStatus joinFile (File *file, IOreq FAR2 *ioreq);
extern FLStatus splitFile (File *file, IOreq FAR2 *ioreq);
extern FLStatus readFile(File *file,IOreq FAR2 *ioreq);
extern FLStatus writeFile(File *file, IOreq FAR2 *ioreq);
extern FLStatus seekFile(File *file, IOreq FAR2 *ioreq);
extern FLStatus findFile(Volume vol, File *file, IOreq FAR2 *ioreq);
extern FLStatus findFirstFile(Volume vol, IOreq FAR2 *ioreq);
extern FLStatus findNextFile(File *file, IOreq FAR2 *ioreq);
extern FLStatus getDiskInfo(Volume vol, IOreq FAR2 *ioreq);
extern FLStatus deleteFile(Volume vol, IOreq FAR2 *ioreq, 
                           FLBoolean isDirectory);
extern FLStatus renameFile(Volume vol, IOreq FAR2 *ioreq);
extern FLStatus makeDir(Volume vol, IOreq FAR2 *ioreq);
#endif /* FL_FILES > 0 */

/********************* Extern Function Prototype End *******************/

/********************* Internal Function Prototype Start ***************/
static FLStatus volumeInfo(Volume vol, IOreq FAR2 *ioreq);
/********************* Internal Function Prototype End *****************/

/********************* Global variables Start **************************/

Volume    vols[VOLUMES];
static    FLMutex   flMutex[SOCKETS];
FLByte    flHandleConversionTable[SOCKETS][FL_MAX_TL_PARTITIONS];
static    FLBoolean initDone = FALSE;           /* Initialization not done yet   */
static    FLBoolean initGlobalVarsDone = FALSE; /* Initialization of environment */
                                                /* and access type variables not */
                                                /* done yet.                     */
unsigned  noOfDrives;

FLDword flMsecCounter = 0;

/* bus configuration
 *
 * DiskOnChip minimal bus width
 */
#ifndef FL_NO_USE_FUNC
FLDword   flBusConfig[SOCKETS];
#endif /* FL_NO_USE_FUNC */

/* Verify write state
 *
 * BDTL   partitions : 0-(FL_MAX_TL_PARTITIONS-1)
 * Binary partitions : FL_MAX_TL_PARTITIONS - (2*FL_MAX_TL_PARTITIONS-2)
 * Last              : 2*FL_MAX_TL_PARTITIONS-1
 */
#ifdef VERIFY_WRITE
FLByte    flVerifyWrite[SOCKETS][FL_MAX_TL_PARTITIONS<<1];
#endif /* VERIFY_WRITE */

/********************************************/
/* default values for environment variables */
/********************************************/

#ifdef ENVIRONMENT_VARS

#ifdef VERIFY_WRITE
/* Max sectors verified per write operation (must be even number) */
FLDword  flSectorsVerifiedPerFolding = 64;
#endif /* VERIFY_WRITE */
#ifdef MULTI_DOC
/* No multi-doc (MTL)                        */
FLByte    flUseMultiDoc;
/* MTL defragmentaion mode (0 - standard)    */
FLByte    flMTLdefragMode;
#endif /* MULTI_DOC */
/* Set the TL operation policy               */
FLByte    flPolicy[SOCKETS][FL_MAX_TL_PARTITIONS];
/* Maximum chain length                      */
FLByte    flMaxUnitChain;
/* Mark the delete sector on the flash       */
FLByte    flMarkDeleteOnFlash;
/* Read Only mode                            */
FLByte    flSuspendMode[SOCKETS];
/* Cache Size                                */
#ifdef FL_FAR_MALLOC
FLWord    flCacheSize[SOCKETS][FL_MAX_TL_PARTITIONS];
#endif /* FL_FAR_MALLOC */
FLByte    flDoNotWaitForReady[SOCKETS][FL_MAX_TL_PARTITIONS];
FLByte    flSkipStaticFilesWearLeveling[SOCKETS][FL_MAX_TL_PARTITIONS];

#endif /* ENVIRONMENT_VARS */

/********************* Global variables End *****************************/

/*----------------------------------------------------------------------*/
/*                     f l I n i t G l o b a l V a r s                  */
/*                                                                      */
/* Initializes the FLite system, environment and access type variables. */
/*                                                                      */
/* Parameters:                                                          */
/*      None                                                            */
/*                                                                      */
/* Returns:                                                             */
/*      None                                                            */
/*----------------------------------------------------------------------*/

void flInitGlobalVars(void)
{
   FLFlash * flash;
   int i,j;

   if(initGlobalVarsDone == TRUE)
     return;

   /* Do not initialize variables on next call */
   initGlobalVarsDone     = TRUE;

   /*
    * Set default values to per socket/volume variables
    */

   for(i=0;i<SOCKETS;i++)
   {
      flash = flFlashOf((FLByte)i);
      /* tffsset is not yet initialized */
      for(j=0;j<(int)sizeof(FLFlash);j++)
      {
         ((FLByte  *)flash)[j] = 0;
      }
#ifndef FL_NO_USE_FUNC
      flBusConfig[i] = FL_NO_ADDR_SHIFT        |
                       FL_BUS_HAS_8BIT_ACCESS  |
                       FL_BUS_HAS_16BIT_ACCESS |
                       FL_BUS_HAS_32BIT_ACCESS;
#endif /* FL_NO_USE_FUNC */
#ifdef ENVIRONMENT_VARS
      flSuspendMode[i] = FL_OFF;
      for (j=0;j<FL_MAX_TL_PARTITIONS;j++)
      {
         flPolicy[i][j]      = FL_DEFAULT_POLICY; /* FL_COMPLETE_ASAP */
#ifdef FL_FAR_MALLOC
#ifdef FL_TL_CACHE
         flCacheSize[i][j]   = 0xFFF;
#else
         flCacheSize[i][j]   = FL_DEFAULT_CACHE_SIZE_FOR_MINIMAL_CACHE;
#endif /* FL_TL_CACHE */
#endif /* FL_FAR_MALLOC */
         flDoNotWaitForReady[i][j] = FL_OFF;
		 flSkipStaticFilesWearLeveling[i][j] = FL_OFF;
      }
#ifdef VERIFY_WRITE
      for (j=0;j<FL_MAX_TL_PARTITIONS<<1;j++)
      {
         flVerifyWrite[i][j] = FL_OFF; /* FL_ON , FL_UPS */
      }
#endif /* VERIFY_WRITE */
#endif /* ENVIRONMENT_VARS */
   }

⌨️ 快捷键说明

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