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

📄 fat1x.h

📁 嵌入式系统中文件系统源代码
💻 H
字号:
/**************************************************************
;*                                                            *
;*         INSTUTITE FOR INFORMATION INDUSTRY                 *
;*                 ATA HEADER -- FAT                          *
;*                  APRIL 30, 1998                            *
;*                                                            *
;*************************************************************/
#ifndef _FAT1X_H
#define _FAT1X_H


/*
#include <sys/constant.h>

#ifdef _PROCOMP_
  #include "/rtos/driver/FileSys/FileSys.h"
#else
  #include "../../FileSys/FileSys.h"
#endif
*/

/**************************************************************
;*                                                            *
;*              Gloabal Definitions                           *
;*                                                            *
;*************************************************************/
/*------------------[ User control options ]-----------------*/
//#define FAT_CLUSTER_CACHE_ON    // using cluster cache
#define FAT_FAT_CACHE_ON        // using FAT cache
#define FAT_ROOT_CACHE_ON     // using ROOT cache
                                //   comment the corresponding line out if cache(s)
                                //   is not necessary (smaller size but much slower)
//#define FAT_ATA_CACHE_ON      // using ATA cache
                                //   using ATA cache is not recommended

#define FAT_LFN                 // support long filename
                                //   comment this out if LFN is not needed (smaller
                                //   code size)
#define FAT_CHINESE_LFN         // support chinese long filename
                                //   the above LFN must also be defined to use chinese
                                //   LFN
#define FAT_USE_UNICODE         // use unicode to store chinese characters in dir
                                //   with this config =>
                                //      long dir entries use unicode for chinese chars
                                //      compatible with FAT32
                                //      at least 28KB bigger than without it
                                //   without this config =>
                                //      long dir entries use Big5 for chinese chars
                                //      not completely compatible with FAT32
                                //      at least 28KB smaller than using unicode
#ifdef BR2001D
#define FAT_USE_MMC
#else
#define FAT_USE_PCMCIA        // Compact Flash based on PCMCIA
#endif
//#define FAT_USE_SMC          	// SmartMedia Card
//#define FAT1X_DEBUG           // for debug and statistics functions
                                //   comment this out if debug functions are not
                                //   required (slightly smaller code size)

#ifdef FAT_CLUSTER_CACHE_ON
  #define FAT_CACHE_TAG_NO              4       /* number of tags in data cache */
  #define FAT_BLOCK_PER_TAG             4       /* number of blocks per tag */
#endif

#ifdef FAT_FAT_CACHE_ON
  #define FAT_FAT_CACHE_BLOCK           8       /* number of blocks in FAT cache */
#endif

#ifdef FAT_ROOT_CACHE_ON
  #define FAT_ROOT_CACHE_BLOCK          8       /* number of blocks in ROOT cache */
#endif

#ifdef FAT_ATA_CACHE_ON
  #define FAT1X_ATA_TAG_NO              32      /* number of tags in ATA cache */
  #define FAT1X_ATA_BLOCK_PER_TAG       5       /* number of blocks per ATA tag */
#endif

#define DRIVE_NUM               1       /* number of partitions */
//#define MAX_OPEN_FILE         100     /* max. no. of opened files at the same time */
//#define MAX_FIND_FILE         10      /* max. no. of ffblk at the same time */

/*-----------------[ File Routine Related ]------------------*/

#define FAT_FILE_NAME_LENGTH            8
#define FAT_EXT_NAME_LENGTH             3
#define FAT_PATH_NAME_LENGTH            256
#define FAT_DIR_ENTRY_SIZE              32

#ifdef FAT_LFN
// for long filename
  #define FAT_CHAR_PER_LONG_ENTRY       13      /* number of characters per long entry */
  #define FAT_MAX_ALIAS_NUM             256     /* the maximun number of alias of the same name */
                                                /*   ABCDEF~1 ==> ABCD~256 */
  #define FAT_LAST_ENTRY                0x40    /* the ending entry of a LFN */
  #define FAT_MAX_LFN_LENGTH            250     /* including the '\0' */
  #define FAT_MAX_BLOCK_SPAN            3       /* max number of blocks that a LFN may span across */
                                                /*   should be determined from FAT_MAX_LFN_LENGTH and */
                                                /*   SECTOR_SIZE */
#endif

/*---------------------[ Disk Related ]----------------------*/
#define FAT_TYPE_CHS            0       /* use CHS */
#define FAT_TYPE_LBA            1       /* use LBA */

#define FAT1X_PART_NUM          4       /* max number of partitions in a partition table */

/*-----------------[ File Format Related ]-------------------*/

#define PART_UNKNOWN    (0x00)  /* Unknown */
#define PART_DOS2_FAT   (0x01)  /* 12-bit FAT */
#define PART_DOS3_FAT   (0x04)  /* 16-bit FAT Partitions 
                                   smaller than 32MB */
#define PART_EXTENDED   (0x05)  /* Extended MS-DOS Partition */
#define PART_DOS4_FAT   (0x06)  /* 16-bit FAT. Partitions larger
                                   than or equal to 32MB. */
#define PART_DOS32      (0x0B)  /* 32-bit FAT. Partitions up to 
                                   2047GB */
#define PART_DOS32X     (0x0C)  /* Same as PART_DOS32(0Bh), 
                                   but uses Logical Block 
                                   Address Int 13h extensions. */
#define PART_DOSX13     (0x0E)  /* Same as PART_DOS4_FAT(06h), 
                                   but uses Logical Block Address
                                   Int 13h extensions. */
#define PART_DOSX13X    (0x0F)  /* Same as PART_EXTENDED(05h), but
                                   uses Logical Block Address Int 
                                   13h extensions. */

/*----------------[ Root Directory Related ]-----------------*/

/* Values of the first byte with special meaning */
#define FAT_DELETED_ENTRY       (0xe5)  /* file/directory is deleted */
#define FAT_DIRECTORY_ENTRY     (0x2e)  /* entry is a directory, the start cluster point to the parent direcory */
#define FAT_PARENT_ENTRY        (0x2e)  /* double 2e */
#define FAT_FREE_ENTRY          (0x00)  /* entry was never in use */


/*----------------[ FAT directory structure ]----------------*/
// The offset of every field in a directory entry
#define FAT_OFFSET_NAME         0
#define FAT_OFFSET_EXT          8
#define FAT_OFFSET_ATTR         11
#define FAT_OFFSET_RESERVED     12
#define FAT_OFFSET_TIME         22
#define FAT_OFFSET_DATE         24
#define FAT_OFFSET_CLUSTER      26
#define FAT_OFFSET_SIZE         28

/* Time, Date, and attribute */

/* File permission */
/*
#define O_APPEND        (0x01)  // Write from the end of the file
#define O_CREATE        (0x02)  // If file not exist, create it
#define O_CREAT         (0x02)  // If file not exist, create it
#define O_RDONLY        (0x04)  // The file is Read Only, DOS 

⌨️ 快捷键说明

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