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

📄 saftl.h

📁 M-System DOC(Disk on a Chip) Flash芯片映像读写工具, 可以进行二片Flash芯片的内容互相拷贝, 提高烧录程序的效率.
💻 H
📖 第 1 页 / 共 2 页
字号:
#define SAFTL_ANAC_INFO_MASK               0x0F00 /*  9-12 LSB - ANAC bits          */
#define SAFTL_ANAC_RESERVED_MASK           0x7000 /* 12-14 LSB - ANAC reserved      */

#define SAFTL_UNIT_OFFSET_MASK             0x7800 /* 11-14 LSB - unit position in chain */
#define SAFTL_UNIT_OFFSET_SHIFT            11     /* unit position shift       */

/* CLT masks */
#define SAFTL_CHAIN_LENGTH_MASK            0x0F
#define SAFTL_ANAC_MASK                    0xF0
#define SAFTL_ANAC_SHIFT                   4

#ifndef MAX_WRITE_FAULT_TRIES
#define MAX_WRITE_FAULT_TRIES              10
#endif /* MAX_WRITE_FAULT_TRIES */
#ifndef SAFTL_HEADER_SEARCH_LIMIT
#define SAFTL_HEADER_SEARCH_LIMIT          16
#endif /* SAFTL_HEADER_SEARCH_LIMIT */

#define MAX_BAD_UNIT_IN_FORMAT             10
#define DOUBLE_CHAIN_LENGTH                (MAX_UNIT_CHAIN << 1) 
#define MAX_CACHED_UNITS                   0x0FFF /* TL limitataion, can not be changed */
#define HEADERS_SPACING                    8UL
#define NO_OF_MEDIA_HEADERS                2
#define MAX_PROTECTION_AREAS               2

#define SAFTL_PAGE_EXTRA_SIZE              8
#define DWORD_PER_PAGE_BITS                (FL_SECTOR_SIZE_BITS-2)
#define SAFTL_ALL_FLOORS                   0xff
#define ILLEGAL_DPS_NO                     0xff
#define SAFTL_FORCE_POLLING                2
#define SAFTL_ENDIAN_VALIDATION_MARK       0xaa551100L
#define SAFTL_QUICK_MOUNT_VERSION          0L


/*******************/
/* Data structures */
/*******************/

/* Unit cache entry record */
typedef struct {
   FLWord        VUN;         /* Virutal unit this entry belongs to         */
   FLWord        LUN;         /* Newest logical unit of the chain           */
   FLWord        olderUnit;   /* Cache entry less recently used             */
   FLWord        newerUnit;   /* Cache entry more recently used             */
   FLWord        oldGrade;    /* Grade of folding from the oldest unit      */
   FLWord        newGrade;    /* Grade of folding from the newest unit      */
} CNANDCache;

/* Unit controll information of the flash - first sector only */
typedef struct {
   LEushort VSO;     
   LEushort VUN;
   LEushort PUN;
   FLByte ANAC;
   FLByte unused;
}CNANDUnitHeader;

/* Sector controll information of the flash - none first sectors */
typedef struct {
  LEushort VSO;
  LEushort SSC;
  FLWord     reserved1;
  FLWord     reserved2;
}CNANDSectorHeader;

/* Wear leveling data structure */
typedef struct {
  FLWord alarm;    /* Counter to next initiated wear leveling      */
  FLWord currUnit; /* Roveing unit to perform static wear leveling */
} WLdata;

/* Media Header Global Record */
typedef struct {
  LEulong    bootRecordId[2];      /* "CNAND" */
  LEulong    noOfBootImageBlocks;  /* no of good blocks in the boot image area */
  LEulong    noOfBinaryPartitions; /* no of binary partitions                  */
  LEulong    noOfBDTLPartitions;   /* no of BDTL partitions                    */
  LEulong    blockMultiplierBits;  /* no of bits used to represent the         */
                                   /* times a flash erasable block fits inside */
                                   /* an INFTL erasable unit.                  */
  LEulong    formatFlags;          /* Currently only QUICK_MOUNT               */
  LEulong    osakVersion;          /* version of osak used to format the media */
  LEulong    percentUsed;          /* Percent of the media to be exported      */
  LEulong    headerUnits;          /* Number of units reserved in the begining */
                                   /* of each floor for the media header       */
  LEulong    floorNo;              /* Number of current floor                  */
  LEulong    minOsakVersion;       /* Smallest TrueFFS version supported       */
  LEulong    programmerName;       /* Programmer name                          */
  LEulong    programmerVersion;    /* Programmer version                       */
  LEulong    unused1;
} CNANDBootRecord;

/* Media Header Volume record */
typedef struct {
  LEulong  totalGoodUnits;  /* Total good unit (sum of the next 4 fields)     */
  LEulong  virtualUnits;    /* Virtual unit size exported by the TL           */
  LEulong  transferUnits;   /* Number of good units found in BB percentage    */
  LEulong  spareUnits;      /* Number of spare units requeuested by the user    */
  LEulong  quickMountUnits; /* Number of good units used by the quick mount   */  
  LEulong  firstUnit;       /* First unit of the partition                    */
  LEulong  lastUnit;        /* Last unit of the partition                     */
  LEulong  firstQuickMountUnit; /* First unit used for the quick mount data   */
  LEulong  flags;           /* See list above "Partition flags"               */
  LEulong  protectionArea;      /* Number of the partitions protection area */
  LEulong  unused1;
  LEulong  unused2;
  LEulong  unused3;
  LEulong  unused4;
} CNANDVolumeHeaderRecord;

/* Quick mount flash structure */
typedef struct {
   FLDword       quickMountVersion;   /* Version of the quick mount data      */
   FLDword       endianValidation;    /* This string is read differently      */
                                      /* pending the endian architecture      */ 
   FLDword       noOfCachedUnits;     /* The number of cached units           */
   FLDword       neededFreeUnits;     /* Minimal number of free units that    */
                                      /* require folding                      */
   FLDword       freeUnits;           /* Free units on media                  */
   FLDword       roverUnit;           /* Starting point for allocation search */
   FLDword       bootUnits;           /* No of boot units before partition 0  */
   FLDword       multiUnitListHead;   /* Head of multi unit chains cache      */
   FLDword       multiUnitListTail;   /* Tail of multi unit chains cache      */
   FLDword       singleUnitListHead;  /* Head of single unit chains cache     */
   FLDword       singleUnitListTail;  /* Tail of single unit chains cache     */
   FLDword       freeCacheUnitList;   /* free cache entries queue               */
                          /* Accumulated statistics. */
   FLDword       sectorsRead,         /* Virutal sectors read                 */
                 sectorsWritten,      /* Virutal sectors written              */
                 sectorsDeleted,      /* Virutal sectors deleted              */
                 parasiteWritesFromOldest, /* Sectors written while folding   */
                 parasiteWritesFromNewest, /* Sectors written while folding   */ 
                 unitsFoldedFromOldest,    /* Units folded from oldest        */
                 unitsFoldedFromNewest;    /* Units folded from newest        */ 
   FLDword       alarm;       /* Counter to next initiated wear leveling      */
   FLDword       currUnit;    /* Roveing unit to perform static wear leveling */
   FLDword       eraseSum;    /* Accumulator of the erase operations          */
   FLDword       noOfUsedUnits; /* No of used virtual units                   */
} CNANDQuickMountInfo;

/* Format private record */
typedef enum {
   binaryPartition, 
   BDTLPartition,
   leaveBinary
} PartitionType;

typedef struct {
   FLWord     wLength;                 /* Number of units in the partition          */
   FLWord     wLengthSoFar;            /* Number of units used up to this partition */
   FLWord     wPreviousLengthSoFar;    /* Number of units used up to this floor     */
   FLWord     wLengthInFloor;          /* Number of units used in this floor        */
   FLWord     wSpare;                  /* Number of spare units for this partition  */ 
   FLSWord    swTransferUnits;         /* Number of transfer units for so far       */
   FLSWord    swPreviousTransferUnits; /* Number of transfer units in the previos units  */
   FLWord     wQuickMountUnits;        /* Number of quick mount units               */
   FLWord     wDynamicBadBlocks;       /* Number of dynamic bad blocks              */
   FLByte     bSignPtr[BINARY_SIGNATURE_LEN]; /* Binary signature for binary partition */
   FLByte     bMatchingType;           /* Type of matching SM/AM                    */  
   FLDword    dwMTDFlags;              /* MTD flags of the parititon                */
   FLDword    dwMediaFlags;            /* Volume header flags for the partition     */
   PartitionType   type;               /* Type - binary / leave binary / bdtl       */
   FLByte bProtectionType;             /* Protection attributes                     */
#ifdef HW_PROTECTION
   FLByte protectionKey[8];            /* Partition protection key                  */
#endif /*HW_PROTECTION*/
   FLByte bProtectionArea;             /* DPS number used for the partition         */
}SaftlFormatPartition;

/* Translation Layer context record */
struct tTLrec{
  CNANDSectorHeader FAR1 * myHeaders;  /* Pointer to array of sector headers  */
  FLWord FAR1 * VUT;                   /* Pointer to Virtual Unit Table.      */
                                       /* Indexed by virtual unit no'.        */
                                       /* Stores the logical unit no' of the  */
                                       /* newest logical unit of the virtual  */
                                       /* chain. In case unit is cached, it   */
                                       /* will indicate the cache entry no'   */
                                       /* used for this virtual unit data.    */
  FLWord FAR1 * LUT;                   /* Pointer to the Logical Unit Table.  */
                                       /* Indexed by logical unit no'.        */
                                       /* Stores the no' of the older logical */
                                       /* unit in the virtual chain.          */
                                       /* A value of 0xFXXX indicates the     */
                                       /* does not have an older unit. Such a */
                                       /* unit is either the oldest unit      */
                                       /* marked with 0x1111,0XXX,XXXX,XXXX.  */
                                       /* where the 11 LSB represent a        */
                                       /* zero-based index of the last used   */
                                       /* sector in the newest unit of the    */
                                       /* chain, or any of the following:     */
                                       /* F800H - Unit is in use, but its     */
                                       /*         entry is not valid.         */
                                       /* F801H - Unit is free.               */ 
                                       /* F802H - Unit is bad.                */
                                       /* F803H - Unit is unavailable.        */
   FLByte FAR1 * CLT;                  /* Chains Length Table.                */
                                       /* Indexed by both logical unit and    */
                                       /* virtual unit.                       */
                                       /* Stores the length of virtual chain  */
                                       /* Stores the ANAC of the logical unit */
   FLByte FAR1 * foldingBuffer;        /* Internal buffer for folding.        */
   CNANDCache FAR1 * CT;               /* Pointer to the SAFTL cache table.   */                 
   FLWord FAR1 * sectors;              /* Pointer to sector cache table.      */
   CNANDUnitHeader   unitHeader;       /* Unit header - used for mount        */
   FLByte      FAR1 *buffer;           /* Pointer to TL buffer                */
#ifndef _FL_ALWAYS_WAIT_FOR_READY 
   FLByte      FAR1 *savedData;        /* Pointer to delayed wait buffer      */
   FLDword      dwLastVirSector;       /* Virtusl Sector of last delayed write */
   FLDword      dwLastNoOfVirSectors;  /* Number of last delayed write        */ 
   FLByte       bCompleteLastOperation; /* Is there a delayed write       */
   LastOperationResults lastOpPtr;   /* delayed write return structure        */
#endif /* _FL_ALWAYS_WAIT_FOR_READY */
   FLBoolean    remapped;            /* Status of TL internal buffer         */   
   FLFlash      *flash;              /* Poniter to MTD record                */
   FLDword      mediaFlags;          /* Meida specific flags                 */
   FLDword      volumeFlags;         /* Volume specific flags                */
   FLDword      MTDFlags;            /* MTD modes - common dwOpFlags fields  */
   FLByte       socketNo;            /* Socket number of the volume          */
   FLByte       partitionNo;         /* Partition number of the volume       */
   FLBoolean    fIsQuickMountValid;  /* Indicator for writing the quick      */
                                     /* mount                                */
   FLByte       neededFreeUnits;     /* Minimal number of free units that    */
                                     /* require folding                      */
   FLWord       foldingBufferSize;   /* Actual size of the folding buffer    */   
   FLByte       minSectorsForFolding;   /* Minimum sectors that can be written together */
   FLByte       minSectorsForNextWrite; /* Minumum number of sectors allignment for write operation */
   FLByte       maxRelatedSectors;   /* Max number of sectors that might be written together */
   FLWord       noOfCachedUnits;     /* No' of cached units                  */
   FLWord       noOfUnits;           /* No' of units in the partition        */
   FLWord       firstQuickMountUnit; /* The quick mount first unit           */
   FLWord       firstUnit;           /* First unit number of the volume      */
   FLWord       freeUnits;           /* Free units on media                  */
   FLWord       noOfVirtualUnits;    /* No of units exported by the TL       */
   FLWord       noOfTransferUnits;   /* No of spare units for chaining       */
   FLWord       noOfQuickMountUnits; /* No of quick mount units              */
   FLWord       roverUnit;           /* Starting point for allocation search */
   FLWord       bootUnits;           /* No of boot units before partition 0  */
   FLWord       doubleHeadChain[4];  /* The 2 heads of the same virtual unit */
   FLWord       multiUnitListHead;   /* Head of multi unit chains cache      */
   FLWord       multiUnitListTail;   /* Tail of multi unit chains cache      */
   FLWord       singleUnitListHead;  /* Head of single unit chains cache     */
   FLWord       singleUnitListTail;  /* Tail of single unit chains cache     */
   FLWord       freeCacheUnitList;   /* Free cache entries queue             */
   FLWord       noOfUsedUnits;       /* No of used virtual units             */
   FLDword      pageMask;            /* First sector of a flash page mask    */
   FLByte       sectorsInUnitBits;   /* No' of bits used to represent the    */
                                     /* no' of sectors in a logical unit     */
   FLDword      sectorsInUnitMask;   /* Mask of number of sectors in a unit  */
   FLWord       sectorsInUnit;       /* No of sectors in a logical unit      */
   FLByte       unitSizeBits;        /* No' of bits used to represent a unit */
   const void FAR0 *mappedSector;
   CardAddress      mappedSectorAddress;
   SectorNo         mappedSectorNo; /* Currently mapped sector            */
#ifndef TL_NO_STATISTICS
   /* Accumulated statistics. */
   FLDword          sectorsRead,    /* Virutal sectors read               */
                    sectorsWritten, /* Virutal sectors written            */
                    sectorsDeleted, /* Virutal sectors deleted            */
                    parasiteWritesFromNewest, /* Logical sectors written in folding */
                    parasiteWritesFromOldest, /* Logical sectors written in folding */
                    unitsFoldedFromNewest,    /* Units erase as part of folding     */
                    unitsFoldedFromOldest;    /* Units erase as part of folding     */
#endif /* TL_NO_STATISTICS */
   WLdata           wearLevel;           /* Wear leveling data                   */
   FLDword          eraseSum;            /* Accumulator of the erase operations  */
   SectorNo         virtualSectors;      /* No of sectors exported by the TL     */
};

typedef TLrec Cnand;

#endif /* SAFTL_H */

⌨️ 快捷键说明

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