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

📄 ufat_types.h

📁 凌阳SPCE3200 系统开发板随机自带源程序。共安排了32个子目录
💻 H
📖 第 1 页 / 共 2 页
字号:
#define FD32_OSHARE   0x0070    /* Bit mask for sharing type      */
#define FD32_OCOMPAT  0x0000    /* Compatibility mode             */
#define FD32_ODENYRW  0x0010    /* Deny r/w by other handles      */
#define FD32_ODENYWR  0x0020    /* Deny write by other handles    */
#define FD32_ODENYRD  0x0030    /* Deny read by other handles     */
#define FD32_ODENYNO  0x0040    /* Allow full access by others    */
#define FD32_ONOINHER (1 << 7)  /* Child processes will not       */
                                /* inherit the file               */
/* Extended LFN open flags */
#define FD32_ONOBUFF  (1 << 8)  /* Do not use buffered I/O        */
#define FD32_ONOCOMPR (1 << 9)  /* Do not compress files (N/A)    */
#define FD32_OALIAS   (1 << 10) /* Use the numeric hint for alias */
#define FD32_ONOINT24 (1 << 13) /* Do not generate INT 24 on fail */
#define FD32_OCOMMIT  (1 << 14) /* Commit file at every write     */
/* Action to take */
#define FD32_OEXIST   (1 << 16) /* Open existing file             */
#define FD32_OTRUNC   (1 << 17) /* Truncate existing file         */
#define FD32_OCREAT   (1 << 20) /* Create unexisting file         */
#define FD32_ODIR     (1 << 24) /* Open a directory as a file     */
#define FD32_OFILEID  (1 << 25) /* Interpret *FileName as a fileid */


/* * * * * * * * * * * * * * * * * * * * * * * * */
/* CHMOD system call - Flags for file attributes */
/* * * * * * * * * * * * * * * * * * * * * * * * */
#define FD32_ARDONLY 0x01 /* Read only file                          */
#define FD32_AHIDDEN 0x02 /* Hidden file                             */
#define FD32_ASYSTEM 0x04 /* System file                             */
#define FD32_AVOLID  0x08 /* Volume label                            */
#define FD32_ADIR    0x10 /* Directory                               */
#define FD32_AARCHIV 0x20 /* File modified since last backup         */
#define FD32_ALNGNAM 0x0F /* Long file name directory slot (R+H+S+V) */
#define FD32_AALL    0x3F /* Select all attributes                   */
#define FD32_ANONE   0x00 /* Select no attributes                    */


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Search flags for FINDFIRST/FINDNEXT and UNLINK system calls */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/* Allowable attributes */
#define FD32_FALLOW   0x00FF /* Allowable attributes mask */
#define FD32_FARDONLY FD32_ARDONLY
#define FD32_FAHIDDEN FD32_AHIDDEN
#define FD32_FASYSTEM FD32_ASYSTEM
#define FD32_FAVOLID  FD32_AVOLID
#define FD32_FADIR    FD32_ADIR
#define FD32_FAARCHIV FD32_AARCHIV
#define FD32_FAALL    FD32_AALL
#define FD32_FANONE   FD32_ANONE
/* Required attributes */
#define FD32_FREQUIRD 0xFF00 /* Allowable attributes mask */
#define FD32_FRRDONLY (FD32_ARDONLY << 8)
#define FD32_FRHIDDEN (FD32_AHIDDEN << 8)
#define FD32_FRSYSTEM (FD32_ASYSTEM << 8)
#define FD32_FRVOLID  (FD32_AVOLID  << 8)
#define FD32_FRDIR    (FD32_ADIR    << 8)
#define FD32_FRARCHIV (FD32_AARCHIV << 8)
#define FD32_FRALL    (FD32_AALL    << 8)
#define FD32_FRNONE   (FD32_ANONE   << 8)
/* Other search flags */
#define FD32_FDOSDATE (1 << 16) /* Use DOS date and time format */
#define FD32_FWILDCRD (1 << 17) /* Allow wildcards              */


#define FD32_E(x)     (0x80000000 | (x))
#define FD32_EINVAL   FD32_E(0x01) /* Invalid argument        */
#define FD32_ENOENT   FD32_E(0x02) /* (FIXME: file not found) No such file or directory */
#define FD32_ENOTDIR  FD32_E(0x03) /* (FIXME: path not found) Not a directory */
#define FD32_EMFILE   FD32_E(0x04) /* Too many open files     */
#define FD32_EACCES   FD32_E(0x05) /* Access denied           */
#define FD32_EBADF    FD32_E(0x06) /* Invalid file handle     */
#define FD32_ENOMEM   FD32_E(0x08) /* Insufficient memory     */
#define FD32_EFORMAT  FD32_E(0x0B) /* Format invalid          */
#define FD32_EACODE   FD32_E(0x0C) /* Access code invalid     */
#define FD32_EIDATA   FD32_E(0x0D) /* Data invalid            */
#define FD32_ENODRV   FD32_E(0x0F) /* Invalid drive           */
#define FD32_EBUSY    FD32_E(0x10) /* Attempt to remove the current directory */
#define FD32_EXDEV    FD32_E(0x11) /* Not same device         */
#define FD32_ENMFILE  FD32_E(0x12) /* No more files           */
#define FD32_EROFS    FD32_E(0x13) /* Read-only file system   */
#define FD32_ENODEV   FD32_E(0x14) /* No such device          */
#define FD32_ENOTRDY  FD32_E(0x15) /* Drive not ready         */
#define FD32_ECRC     FD32_E(0x17) /* CRC error               */
#define FD32_EISEEK   FD32_E(0x19) /* Invalid seek            */
#define FD32_EMEDIA   FD32_E(0x1A) /* Unknown media (not DOS) */
#define FD32_ENOSEC   FD32_E(0x1B) /* Sector not found        */
#define FD32_EWRITE   FD32_E(0x1D) /* Write fault             */
#define FD32_EREAD    FD32_E(0x1E) /* Read fault              */
#define FD32_EGENERAL FD32_E(0x1F) /* General failure         */
#define FD32_EVSHAR   FD32_E(0x20) /* Sharing violation       */
#define FD32_EVLOCK   FD32_E(0x21) /* Lock violation          */
#define FD32_ECHANGE  FD32_E(0x22) /* Invalid media change (ES:DI -> media ID structure)(see #1546) */
#define FD32_EOINPUT  FD32_E(0x26) /* Out of input            */
#define FD32_ENOSPC   FD32_E(0x27) /* No space left on drive  */
#define FD32_EEXIST   FD32_E(0x50) /* File exists             */
#define FD32_EMKDIR   FD32_E(0x52) /* Cannot make directory   */
#define FD32_EINT24   FD32_E(0x53) /* Fail on INT 24          */
#define FD32_ENOTLCK  FD32_E(0xB0) /* Not locked              */
#define FD32_ELOCKED  FD32_E(0xB1) /* Locked in drive         */
#define FD32_ENOTREM  FD32_E(0xB2) /* Media not removable     */
#define FD32_ENOLCK   FD32_E(0xB4) /* No more locks available */
#define FD32_EEJECT   FD32_E(0xB5) /* Eject request failed    */
/* FD32 defined error codes */
#define FD32_ENMOUNT  FD32_E(0x100) /* File system not mounted */
#define FD32_EUTF8    FD32_E(0x101) /* Invalid UTF-8 sequence  */
#define FD32_EUTF16   FD32_E(0x102) /* Invalid UTF-32 sequence */
#define FD32_EUTF32   FD32_E(0x103) /* Invalid Unicode char    */
#define FD32_ENMDEV   FD32_E(0x104) /* No more devices         */


#define FAT12_BAD 0x0FF7
#define FAT16_BAD 0xFFF7
#define FAT32_BAD 0x0FFFFFF7

/* Special codes for the first byte of a directory entry */
#define FREEENT  0xE5 /* The directory entry is free             */
#define ENDOFDIR 0x00 /* This and the following entries are free */

#define FD32_GENSFN_FORMAT_MASK   (0xFF << 8)
#define FD32_GENSFN_FORMAT_FCB    (0x00 << 8)
#define FD32_GENSFN_FORMAT_NORMAL (0x01 << 8)

#define FD32_GENSFN_CASE_CHANGED  (1 << 0)
#define FD32_GENSFN_WAS_INVALID   (1 << 1)

/* Use the following defines to add features to the FAT driver */
/* TODO: The FAT driver currently doesn't work with buffers disabled! */
/* TODO: The name cache is totally broken! */
#define FATBUFFERS   /* Uncomment this to use the buffered I/O        */
#define FATLFN       /* Define this to use Long File Names            */
#define FATWRITE     /* Define this to enable writing facilities      */
#define FATSHARE     /* Define this to enable sharing support         */
//#define FATNAMECACHE /* Define this to enable the opening name cache  */
#define FATREMOVABLE /* Define this to enable removable media support */
#define FAT_FD32DEV  /* Define this to enable FD32 devices support    */

/* 4-characters signatures to identify correct FAT driver structures */
#define FAT_VOLSIG 0x46415456 /* "FATV": FAT volume signature */
#define FAT_FILSIG 0x46415446 /* "FATF": FAT file signature   */

/* FIX ME: These should be read from CONFIG.SYS (or similar) */
#define FAT_MAX_FILES   20
#define FAT_MAX_BUFFERS 30

/* FAT Types */
typedef enum { FAT12, FAT16, FAT32 } tFatType;

/* EOC (End Of Clusterchain) check macros.                               */
/* These expressions are true (nonzero) if the value of a FAT entry is   */
/* an EOC for the FAT type. An EOC indicates the last cluster of a file. */
#define  FAT12_EOC(EntryValue)  (EntryValue >= 0x0FF8)
#define  FAT16_EOC(EntryValue)  (EntryValue >= 0xFFF8)
#define  FAT32_EOC(EntryValue)  (EntryValue >= 0x0FFFFFF8)
/* -------------end --------------------*/

#define LFN_FETCH_SLOTS 21
typedef struct {
  UINT8 dm_drive;
#if LFN
  INT8 dm_name_pat[FD32_LFNPMAX];	
#else
  INT8 dm_name_pat[FNAME_SIZE + FEXT_SIZE];
#endif
  INT8 dm_attr_srch;
  UINT16 dm_entry;
#if WITHFAT32
  UINT32 dm_dircluster;
#else
  UINT16 dm_dircluster;
  UINT16 reserved;
#endif

  struct {
	  int attr_active:1;
	  int match_reserved:1;
  }dm_flag;

} dmatch;

/* FAT file system attribute bits                                   */
#define D_NORMAL        0       /* normal                       */
#define D_RDONLY        0x01    /* read-only file               */
#define D_HIDDEN        0x02    /* hidden                       */
#define D_SYSTEM        0x04    /* system                       */
#define D_VOLID         0x08    /* volume id                    */
#define D_DIR           0x10    /* subdir                       */
#define D_ARCHIVE       0x20    /* archive bit                  */

#define D_LFN (D_RDONLY | D_HIDDEN | D_SYSTEM | D_VOLID)
#define D_ALL (D_RDONLY | D_HIDDEN | D_SYSTEM | D_DIR | D_ARCHIVE)

struct ufat3_stat
{	
    unsigned short st_mode;
    long st_size;
    unsigned long st_mtime;
};

#ifndef INCLUDE_PLATFORM_ECOS
#define	ENOENT   2 	  /* No such file or directory */
#define	EIO      5	  /* I/O error */
#define	EBADF 	 9	  /* Bad file number */
#define	ENOMEM 	 12   /* Not enough memory */
#define	EACCES	 13   /* Permission denied */
#define	EBUSY    16	  /* Device or resource busy */
#define	EEXIST   17   /* File exists */
#define	EISDIR   21
#define	EINVAL 	 22   /* Invalid argument */
#define	EMFILE 	 24   /* Too many open files */
#define	ENOSPC 	 28   /* No space left on device */
#define ENOTEMPTY 93  /* directory is not empty; or directory is either current working directory or root directory.*/
#define	ERANGE       34	/* Math result not representable */
#define	EROFS        30	/* Read-only file system */
#define ENAMETOOLONG 78
//#define ENAMEINVALID 38   //add by yongliang,delete by wanghuidi
#define ENOTDIR 20
#else
#include "codes.h"
#endif

/***************************************************************/
/*                                                              */
/* Convienence defines                                          */
/*                                                              */
#define FOREVER         while(TRUE)
#ifndef max
#define max(a,b)       (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b)       (((a) < (b)) ? (a) : (b))
#endif

/* dskxfer mode */
#define DSKWRITE	(2)
#define DSKREAD		(1)

/* FAT version checkers */
#define ISFAT32(dpbp) (((dpbp) ->dpb_fatsize) == 0)
#if WITHFAT32
#define ISFAT16(dpbp) ((((dpbp) ->dpb_fatsize) != 0) && (((dpbp) ->dpb_size) > FAT_MAGIC && ((dpbp) ->dpb_size) <= FAT_MAGIC16))
#else
#define ISFAT16(dpbp) (((dpbp) ->dpb_size) > FAT_MAGIC && ((dpbp) ->dpb_size) <= FAT_MAGIC16)
#endif
#define ISFAT12(dpbp)   (((dpbp) ->dpb_size) != 0 && ((dpbp) ->dpb_size) <= FAT_MAGIC)  

#ifndef NULL
#define NULL ((void *)0)
#endif

#if 0
/* Commented By Ahan on: 2005/09/15, move to ufat_fcntl.h */
/* open flags */
#define O_RDONLY	(0x00u)
#define O_WRONLY	(0x01u)
#define O_RDWR		(0x02u)
#define O_TRUNC		(0x04u)
#define O_CREAT		(0x08u)
#define O_EXCL		(0x10u)
#define O_OPEN		(0x20u)
#define O_FCB		(0x80u)
#define O_ACCMODE	(0x03u)
#endif


/* FAT file system attribute bits*/
#define D_NORMAL			0		/* normal */
#define D_RDONLY			0x01	/* read-only file */
#define D_HIDDEN			0x02	/* hidden */
#define D_SYSTEM			0x04	/* system */
#define D_VOLID				0x08	/* volume id */
#define D_DIR				0x10	/* subdir */
#define D_ARCHIVE			0x20	/* archive bit */
#define D_OPEN_DIR_FOR_STAT	0x80	/* open directory anyway */

/* status for extended open */
enum	{S_OPENED = 1, S_CREATED = 2, S_REPLACED = 3};

/* CHMOD system call - Flags for file attributes */
#define FD32_ARDONLY 0x01 /* Read only file */
#define FD32_AHIDDEN 0x02 /* Hidden file */
#define FD32_ASYSTEM 0x04 /* System file */
#define FD32_AVOLID  0x08 /* Volume label */
#define FD32_ADIR    0x10 /* Directory */
#define FD32_AARCHIV 0x20 /* File modified since last backup */
#define FD32_ALNGNAM 0x0F /* Long file name directory slot (R+H+S+V) */
#define FD32_AALL    0x3F /* Select all attributes */
#define FD32_ANONE   0x00 /* Select no attributes */
#define FD32_AALL    0x3F /* Select all attributes */

/* Required attributes */
#define FD32_FREQUIRD 0xFF00 /* Allowable attributes mask */
#define FD32_FRRDONLY (FD32_ARDONLY << 8)
#define FD32_FRHIDDEN (FD32_AHIDDEN << 8)
#define FD32_FRSYSTEM (FD32_ASYSTEM << 8)
#define FD32_FRVOLID  (FD32_AVOLID  << 8)
#define FD32_FRDIR    (FD32_ADIR    << 8)
#define FD32_FRARCHIV (FD32_AARCHIV << 8)
#define FD32_FRALL    (FD32_AALL    << 8)
#define FD32_FRNONE   (FD32_ANONE   << 8)
#define FD32_FAALL    FD32_AALL
#define FREE	0x000

#ifdef HANDLE_BY_ID
struct file_id
{
	UINT32 f_dirstartsec; /* the starting cluster of dir  */
    UINT16   f_dent_off;    /* offset/32 of the dir entry   */
};
#endif

struct f_info         
{
#if LFN
	INT8	f_name[FD32_LFNMAX];
#else
	INT8	f_name[FD32_SFNMAX];
#endif
	UINT8	f_attrib;
	UINT16  f_time;
	UINT16  f_date;
	UINT32	f_size;
#if HANDLE_BY_ID
	struct file_id f_id;
#endif
};

typedef struct f_info st_f_info;

#ifdef _555_FS_
	#define CHAR_BYTES 3
#else
	#define CHAR_BYTES 2
#endif

/* bios parameter block for read dbr used only */
#define FAT_NO_MIRRORING 0x80

#define BPB_SIZEOF 31           /* size of the standard BPB */

typedef struct {
  UINT16 bpb_nbyte;              /* Bytes per Sector             */
  UINT8 bpb_nsector;            /* Sectors per Allocation Unit  */
  UINT16 bpb_nreserved;          /* # Reserved Sectors           */
  UINT8 bpb_nfat;               /* # FAT's                      */
  UINT16 bpb_ndirent;            /* # Root Directory entries     */
  UINT16 bpb_nsize;              /* Size in sectors              */
  UINT16 bpb_nfsect;             /* FAT size in sectors          */
  UINT16 bpb_nsecs;              /* Sectors per track            */
  UINT16 bpb_nheads;             /* Number of heads              */
  UINT32 bpb_hidden;             /* Hidden sectors               */
  UINT32 bpb_huge;               /* Size in sectors if           */
  /* bpb_nsize == 0               */
#if WITHFAT32
  UINT32 bpb_xnfsect;            /* FAT size in sectors if       */
  /* bpb_nfsect == 0              */
  UINT16 bpb_xflags;             /* extended flags               */
  /* bit 7: disable mirroring     */
  /* bits 6-4: reserved (0)       */
  /* bits 3-0: active FAT number  */
  UINT32 bpb_xrootclst;          /* starting cluster of root dir */
  UINT16 bpb_xfsinfosec;         /* FS info sector number,       */
  /* 0xFFFF if unknown            */
  UINT16 bpb_xbackupsec;         /* backup boot sector number    */
  /* 0xFFFF if unknown            */
#endif
} bpb;

/* rwblock dma mode flag */
#define D_DMA_MODE	8

#endif /* _UFAT3_HEADER_UFAT_TYPES_H_ */

/* end of file */

⌨️ 快捷键说明

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