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

📄 flbase.h

📁 M-System DOC(Disk on a Chip) Flash芯片的诊断工具, 可以从Flash芯片中获取特定的数据信息, 用于判断芯片当前的状态.
💻 H
字号:
/***********************************************************************************/
/*                        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/include/flbase.h-arc  $
 * 
 *    Rev 1.12   Jan 14 2004 22:30:32   oris
 * Removed warnings
 * Replaced FL_SLEEP with FL_TFFS_SLEEP (FL_SLEEP was used by Linux)
 * Added pointer arithmetic's macros in order to remove warnings.
 * 
 *    Rev 1.11   Dec 01 2003 16:07:50   oris
 * Added FLZONE_UTIL for hidden printing in the utilities.
 * 
 *    Rev 1.10   Oct 30 2003 00:52:32   OriS
 * changed flSuspendMode to be socket specific and to accept FL_IGNORE_WRITE and FL_IGNORE_ERASE modes
 * 
 *    Rev 1.9   Oct 23 2003 17:20:02   OriS
 * Bug fix - compilation errors for BDK package
 * 
 *    Rev 1.8   Oct 23 2003 13:56:54   oris
 * Added extern declaration of new environment variable flSkipStaticFilesWearLeveling (FL_NO_STATIC_FILES_WEAR_LEVELING)
 * Added customization check for flsleep and FL_SLEEP macro
 * 
 *    Rev 1.7   Sep 30 2003 17:57:46   oris
 * Added FL prefix to SECTOR_SIZE and SECTOR_SIZE_BITS
 * 
 *    Rev 1.6   Sep 01 2003 19:08:22   oris
 * - Added new print zone FLZONE_STATISTICS (0x200)
 * - Added new typedef - FLWchar
 * 
 *    Rev 1.5   May 11 2003 14:06:14   OriS
 * Changed MAX_VOLUME_MBYTES to FL_ASSUMED_MAX_VOLUME_MBYTES
 * Changed ASSUMED_NFTL_UNIT_SIZE to FL_ASSUMED_MIN_UNIT_SIZE
 * 
 *    Rev 1.4   May 11 2003 08:25:58   OriS
 * Moved FAR definition to prevent old compiler errors.
 * 
 *    Rev 1.3   May 08 2003 23:24:24   OriS
 * Restored declaration of flmemxxx routines
 * 
 *    Rev 1.2   May 06 2003 11:54:04   OriS
 * Moved backward competability check of memory manipulation routines to flchkdef.h
 * 
 *    Rev 1.1   Apr 13 2003 20:29:26   OriS
 * Fixed compilation error for BDK
 * 
 *    Rev 1.0   Apr 09 2003 12:15:58   OriS
 * Initial revision.
 * 
 */

#ifndef FLBASE_H
#define FLBASE_H

/***************************************************************************/
/*                                                                         */
/* Include customization files                                             */
/* Note the following files are used for :                                 */
/*   mtdsa.h    - Complete customization - standalone applications         */
/*                                         like Binary SDK                 */
/*   flsystem.h - System customization - TrueFFS applications like drivers */
/*   flchkdef.h - Customized defintion check of TrueFFS applications.      */
/*                                                                         */
/***************************************************************************/

#include "flchkdef.h"
#include "flstatus.h"

 /* Number of translation layer partitions
 *
 * Defines Maximum Number of Traslation layer partitons on a physical device
 *
 * The actual number of partitions depends on the format placed on each device.
 */

#define FL_MAX_TL_PARTITIONS 4

 /* Number of floors supported by the S/W
 *
 * Define Maximum Number of floors in a physical device
 *
 * The actual number of floors depends on the physical device placed 
 * on the socket.
 */

#define FL_MAX_NO_OF_FLOORS  4

/* Sector size
 *
 * Define the log2 of sector size for the FAT & translation layers. Note
 * that the default 512 bytes is the de-facto standard and practically
 * the only one that provides real PC interoperability.
 */

#define FL_SECTOR_SIZE_BITS   9

/* Zones for debug printing */

#define FLZONE_NONE       0
#define FLZONE_MTD        0x0001
#define FLZONE_BDK        0x0002
#define FLZONE_TL         0x0004
#define FLZONE_BLKDEV     0x0008
#define FLZONE_FORMAT     0x0010
#define FLZONE_FS         0x0020
#define FLZONE_SOCKET     0x0040
#define FLZONE_IOCTL      0x0080
#define FLZONE_PROD       0x0100
#define FLZONE_STATISTICS 0x0200
#define FLZONE_UTIL       0x0400
#define FLZONE_FULL       0xffff

/* standard type definitions */
typedef int         FLBoolean;

/* Boolean constants */

#ifndef FALSE
#define FALSE    0
#endif
#ifndef TRUE
#define TRUE    1
#endif

#ifndef FL_ON
#define FL_ON    1
#endif
#ifndef FL_OFF
#define FL_OFF    0
#endif

/* General types definitions */

#ifndef FLByte
typedef unsigned char  FLByte;           /* 8  bit unsigned variable */
#endif
#ifndef FLWord 
typedef unsigned short FLWord;           /* 16 bit unsigned variable */
#endif
#ifndef FLDword
typedef unsigned long  FLDword;          /* 32 bit unsigned variable */
#endif
#ifndef FLNative
typedef unsigned int   FLNative;         /* Native variable at least 16 bits */
#endif 
#ifndef FLSByte
typedef signed char    FLSByte;          /* 8  bit signed variable */
#endif
#ifndef FLSWord
typedef signed short   FLSWord;          /* 16 bit signed variable */
#endif
#ifndef FLSDword
typedef signed long    FLSDword;         /* 32 bit signed variable */
#endif
#ifndef FLSNative
typedef int            FLSNative;        /* Signed native variable at least 16 bits */
#endif

#ifndef FLWchar
#define FLWchar FLSWord                  /* Unicode type variable */
#endif /* FLWchar */


/* x86 pointer far level dictated several of the TrueFFS pointers types. */
#ifndef FAR0
#if FAR_LEVEL > 0
#define FAR0    far
#else
#define FAR0
#endif
#endif /* FAR0 */

#ifndef FAR1
#if FAR_LEVEL > 1
#define FAR1    far
#else
#define FAR1
#endif
#endif /* FAR1 */

#ifndef FAR2
#if FAR_LEVEL > 2
#define FAR2    far
#else
#define FAR2
#endif
#endif /* FAR2 */

/* Patch for using flsleep (FL_SLEEP)
 *
 * This is a workaround for using the flash media descriptor in the flsleep 
 * implementation, while retaining backward compatbility.
 *
 */

#ifndef MTD_STANDALONE
#ifndef FL_TFFS_SLEEP
extern void flsleep(FLDword msec);
#define FL_TFFS_SLEEP(time,flash) flsleep(time)
#endif /* FL_TFFS_SLEEP */
#endif /* MTD_STANDALONE */


/* Geral purpose macroes */

#define BYTE_ADD_FAR(x,y) ((FLByte FAR1 *)addToFarPointer((FLByte FAR1 *)x,y))
#define WORD_ADD_FAR(x,y) ((FLWord FAR1 *)addToFarPointer((FLByte FAR1 *)x,y))
#define DWORD_ADD_FAR(x,y) ((FLDword FAR1 *)addToFarPointer((FLByte FAR1 *)x,y))
#define SBYTE_ADD_FAR(x,y) ((FLSByte FAR1 *)addToFarPointer((FLByte FAR1 *)x,y))
#define SWORD_ADD_FAR(x,y) ((FLSWord FAR1 *)addToFarPointer((FLByte FAR1 *)x,y))
#define SDWORD_ADD_FAR(x,y) ((FLSDword FAR1 *)addToFarPointer((FLByte FAR1 *)x,y))

/* Drive handle masks */

#define FL_GET_SOCKET_FROM_HANDLE(ioreq)    (FLByte)(ioreq->irHandle & 0x0f)
#define FL_GET_PARTITION_FROM_HANDLE(ioreq) (FLByte)((ioreq->irHandle & 0xf0) >> 4)
#define INVALID_VOLUME_NUMBER 0xff
#define TL_SIGNATURE          6

#define FL_SECTOR_SIZE        (1 << FL_SECTOR_SIZE_BITS)
#define FL_SECTOR_MASK     (FL_SECTOR_SIZE - 1)
#define BITS_PER_BITE      8

/* General purpose Macroes adjusted according to the above customization files. */

/* define SectorNo range according to media maximum size */
#if (FL_ASSUMED_MAX_VOLUME_MBYTES * (0x100000L / FL_SECTOR_SIZE)) > 0x10000L
typedef FLDword SectorNo;
#define    UNASSIGNED_SECTOR 0xffffffffl
#else
typedef FLWord SectorNo;
#define UNASSIGNED_SECTOR 0xffff
#endif

/* Call a procedure returning status and fail if it fails. This works only in */
/* routines that return Status: */
#define checkStatus(exp)      {    FLStatus fl__status = (exp);if (fl__status != flOK) return fl__status; }

#define vol (*pVol)
#define TFFSMIN(a,b) (((a)>(b)) ? (b):(a))
#define TFFSMAX(a,b) (((a)<(b)) ? (b):(a))

/***************************************************************************/
/* Big \ Little endien architecture conversion macroes.                    */
/***************************************************************************/

#ifndef FL_BIG_ENDIAN

typedef FLWord   LEushort;
typedef FLDword  LEulong;

#define LE2(arg)         arg
#define toLE2(to,arg)    (to) = (arg)
#define LE4(arg)         arg
#define toLE4(to,arg)    (to) = (arg)
#define COPY2(to,arg)    (to) = (arg)
#define COPY4(to,arg)    (to) = (arg)

typedef FLByte        Unaligned[2];
typedef Unaligned     Unaligned4[2];

#define UNAL2(arg)       fromUNAL(arg)
#define toUNAL2(to,arg)  toUNAL(to,arg)

#define UNAL4(arg)       fromUNALLONG((Unaligned const FAR0 *)(arg))
#define toUNAL4(to,arg)  toUNALLONG(to,arg)

extern void toUNAL(FLByte FAR0 *unal, FLWord n);

extern FLWord fromUNAL(FLByte const FAR0 *unal);

extern void toUNALLONG(Unaligned FAR0 *unal, FLDword n);

extern FLDword fromUNALLONG(Unaligned const FAR0 *unal);

#else

typedef FLByte LEushort[2];
typedef FLByte LEulong[4];

#define LE2(arg)      fromLEushort(arg)
#define toLE2(to,arg) toLEushort(to,arg)
#define LE4(arg)      fromLEulong(arg)
#define toLE4(to,arg) toLEulong(to,arg)
#define COPY2(to,arg) copyShort(to,arg)
#define COPY4(to,arg) copyLong(to,arg)

#define Unaligned     LEushort
#define Unaligned4    LEulong

extern void toLEushort(FLByte FAR0 *le, FLWord n);

extern FLWord fromLEushort(FLByte const FAR0 *le);

extern void toLEulong(FLByte FAR0 *le, FLDword n);

extern FLDword fromLEulong(FLByte const FAR0 *le);

extern void copyShort(FLByte FAR0 *to,
              FLByte const FAR0 *from);

extern void copyLong(FLByte FAR0 *to,
             FLByte const FAR0 *from);

#define UNAL2        LE2
#define toUNAL2      toLE2

#define UNAL4        LE4
#define toUNAL4      toLE4

#endif /* FL_BIG_ENDIAN */

typedef LEulong LEmin;

#ifndef MTD_STANDALONE
#include "flsysfun.h"
#endif /* MTD_STANDALONE */

/*************************************************/
/* Use routines instead of 'c' standard librarys */
/*************************************************/

#ifdef VERIFY_WRITE
extern FLByte  flVerifyWrite[SOCKETS][FL_MAX_TL_PARTITIONS<<1];
/* Vefrify write */
#define FL_UPS 2
/* 
 * See also FL_ON and FL_OFF
 */
#endif /* VERIFY_WRITE */

/**********************************************/
/* Declare the TrueFFS environment variables  */
/**********************************************/

#ifdef ENVIRONMENT_VARS

extern void FAR0* NAMING_CONVENTION FAR0 flmemcpy(void FAR0* dest,const void FAR0 *src,size_t count);
extern void FAR0* NAMING_CONVENTION FAR0 flmemset(void FAR0* dest,int cval,size_t count);
extern int  NAMING_CONVENTION FAR0 flmemcmp(const void FAR0* dest,const void FAR0 *src,size_t count);

/**********************************************/
/* Declare the TrueFFS environment variables  */
/**********************************************/

extern FLByte   flUse8Bit;
#ifndef MTD_STANDALONE
extern FLByte   flUseNFTLCache;

extern FLByte   flUseMultiDoc;
extern FLByte   flMTLdefragMode;
extern FLByte   flMaxUnitChain;
extern FLByte   flMarkDeleteOnFlash;
extern FLByte   flPolicy[SOCKETS][FL_MAX_TL_PARTITIONS];
extern FLByte   flSuspendMode[SOCKETS];
#ifdef FL_FAR_MALLOC
extern FLWord   flCacheSize[SOCKETS][FL_MAX_TL_PARTITIONS];
#endif /* FL_FAR_MALLOC */
extern FLByte   flDoNotWaitForReady[SOCKETS][FL_MAX_TL_PARTITIONS];
extern FLByte   flSkipStaticFilesWearLeveling[SOCKETS][FL_MAX_TL_PARTITIONS];

#ifdef VERIFY_WRITE
extern FLDword  flSectorsVerifiedPerFolding;
#endif /* VERIFY_WRITE */

/* Policies definitions (FL_SET_POLICY) */
#define FL_DEFAULT_POLICY             0
#define FL_COMPLETE_ASAP              1
/* Mtl policies defintions (FL_MTL_POLICY) */
#define FL_MTL_DEFRAGMENT_ALL_DEVICES 0
#define FL_MTL_DEFRAGMENT_SEQUANTIAL  1
/* Suspend mode other then FL_OFF */
#define FL_SUSPEND_WRITE 1
#define FL_SUSPEND_IO    3
#define FL_IGNORE_WRITE  4
#define FL_IGNORE_ERASE  8

typedef enum {        /* Variable type code for flSetEnv routin */
      FL_ENV_VARS_PER_SYSTEM           = 0,
      FL_IS_RAM_CHECK_ENABLED          = 1, /* No longer supported from 6.1 */
      FL_TL_CACHE_ENABLED              = 2,
      FL_DOC_8BIT_ACCESS               = 3,
      FL_MULTI_DOC_ENABLED             = 4,      
      FL_SET_MAX_CHAIN                 = 5,
      FL_MARK_DELETE_ON_FLASH          = 6,
      FL_MTL_POLICY                    = 7,
      FL_SECTORS_VERIFIED_PER_FOLDING  = 8,      

      FL_ENV_VARS_PER_SOCKET           = 100,
      FL_VERIFY_WRITE_OTHER            = 101,
      FL_MTD_BUS_ACCESS_TYPE           = 102,
	  FL_SUSPEND_MODE                  = 103,

      FL_ENV_VARS_PER_VOLUME           = 200,
      FL_SET_POLICY                    = 201,
      FL_VERIFY_WRITE_BDTL             = 202,
      FL_VERIFY_WRITE_BINARY           = 203,
      FL_MAX_CACHE_SIZE                = 204,
      FL_DO_NOT_WAIT_FOR_READY         = 205,
	  FL_NO_STATIC_FILES_WEAR_LEVELING = 206

} FLEnvVars;

extern void flSetEnvVar(void);
#endif /* MTD_STANDALONE */
#endif /* ENVIRONMENT_VARS */

#ifndef FL_NO_USE_FUNC
extern FLDword  flBusConfig[SOCKETS];
#endif /* FL_NO_USE_FUNC */

#endif


⌨️ 快捷键说明

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