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

📄 fat16.h

📁 在s3c44b0下利用SD卡进行WAV文件(FAT16格式)播放的源程序
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef FAT_H
#define FAT_H

#ifndef BYTE
typedef unsigned char BYTE;
#endif

#ifndef CHAR
typedef char CHAR;
#endif

#ifndef WORD
typedef unsigned short WORD;
#endif

#ifndef DWORD
typedef unsigned long DWORD;
#endif

#define CLUST_FIRST     0      // 第一个数据簇  // first legal cluster number(for PART_TYPE_FAT16xxx)

 // Format of a boot sector.  This is the first sector on a DOS floppy disk
 // or the first sector of a partition on a hard disk.  But, it is not the
 // first sector of a partitioned hard disk.
#define NAND_FLASH_Drv   1
#define DRIVE0           NAND_FLASH_Drv

#define FAT12_MASK      0x00000fff      // FAT12掩码 // mask for 12 bit cluster numbers
#define FAT16_MASK      0x0000ffff      // FAT16掩码 // mask for 16 bit cluster numbers
#define FAT32_MASK      0x0fffffff      // FAT32掩码 // mask for FAT32 cluster numbers

// 分区类型  // Partition Type used in the partition record
#define PART_TYPE_UNKNOWN       0x00
#define PART_TYPE_FAT12         0x01
#define PART_TYPE_XENIX         0x02
#define PART_TYPE_DOSFAT16      0x04
#define PART_TYPE_EXTDOS        0x05
#define PART_TYPE_FAT16         0x06
#define PART_TYPE_NTFS          0x07
#define PART_TYPE_FAT32         0x0B
#define PART_TYPE_FAT32LBA      0x0C
#define PART_TYPE_FAT16LBA      0x0E
#define PART_TYPE_EXTDOSLBA     0x0F
#define PART_TYPE_ONTRACK       0x33
#define PART_TYPE_NOVELL        0x40
#define PART_TYPE_PCIX          0x4B
#define PART_TYPE_PHOENIXSAVE   0xA0
#define PART_TYPE_CPM           0xDB
#define PART_TYPE_DBFS          0xE0
#define PART_TYPE_BBT           0xFF
//MBR struct
typedef __packed struct //没用到
{
     CHAR    psPartCode[512-64-2];       // 启动代码 (446 bytes)  // pad so struct is 512b
     BYTE    psPart[64];                 // 四个分区表(64 bytes)  // four partition records (64 bytes)
     BYTE    psBootSectSig0;             // 两个签名(2 bytes)     // two signature bytes (2 bytes)
     BYTE    psBootSectSig1;
 #define BOOTSIG0        0x55
 #define BOOTSIG1        0xaa
}PARTSECTOR;


//partition record information
typedef __packed struct  //没用到  // length 16 bytes
 {           
     BYTE    prIsActive;                 // 0x80代表该分区为缺省分区  // 0x80 indicates active partition
     BYTE    prStartHead;                // 该分区入口的磁头地址      // starting head for partition
     WORD    prStartCylSect;             // 该分区入口的扇区地址和柱面地址// starting cylinder and sector
     BYTE    prPartType;                 // 该分区类型  // partition type (see above PART_TYPE_XXX)
     BYTE    prEndHead;                  // 该分区结束的扇区地址  // ending head for this partition
     WORD    prEndCylSect;               // 该分区结束的柱面地址  // ending cylinder and sector
     DWORD   prStartLBA;                 // 该分区内第一个扇区地址  // first LBA sector for this partition
     DWORD   prSize;                     // 该分区所包含的扇区总数  // size of this partition (bytes or sectors ?sector)
 }PARTRECORD;
//boot sector for dos3.3 
typedef __packed struct {	//没用到
     BYTE    bsJump[3];                  // jump inst E9xxxx or EBxx90
     CHAR    bsOemName[8];               // OEM name and version
     CHAR    bsBPB[19];                  // BIOS parameter block
     CHAR    bsDriveNumber;              // drive number (0x80)
     CHAR    bsBootCode[479];            // pad so struct is 512b
     BYTE    bsBootSectSig0;             // boot sector signature byte 0x55
     BYTE    bsBootSectSig1;             // boot sector signature byte 0xAA
 #define BOOTSIG0        0x55
 #define BOOTSIG1        0xaa
 }BOOTSECTOR33 ;
 
 
 
typedef __packed struct {
     CHAR    exDriveNumber;              // drive number (0x80)
     CHAR    exReserved1;                // reserved
     CHAR    exBootSignature;            // ext. boot signature (0x29)
 #define EXBOOTSIG       0x29
     DWORD   exVolumeID;              // volume ID number
     CHAR    exVolumeLabel[11];          // volume label
     CHAR    exFileSysType[8];           // fs type (FAT12 or FAT16)
 }EXTBOOT;
 
//boot sector for dos5.0 
//系统引导扇区(DOS BOOT RECORD)DBR结构
typedef __packed struct {
     BYTE    bsJump[3];                  // 跳转指令  // jump inst E9xxxx or EBxx90
     CHAR    bsOemName[8];               // 厂商标志和OS版本号  // OEM name and version
     CHAR    bsBPB[25];                  // BIOS 参数块  // BIOS parameter block
     CHAR    bsExt[26];                  // 扩展BPB  // Bootsector Extension
     CHAR    bsBootCode[448];            // 引导扇区代码  // pad so structure is 512b
     BYTE    bsBootSectSig0;             // 引导扇区签名0x55  // boot sector signature byte 0x55 
     BYTE    bsBootSectSig1;             // 引导扇区签名0xAA  // boot sector signature byte 0xAA
 #define BOOTSIG0        0x55
 #define BOOTSIG1        0xaa
 }BOOTSECTOR50;
 
 
 
//系统引导扇区(DOS BOOT RECORD)DBR结构 
//boot sector for dos7.1  //没用到
typedef __packed struct {
     BYTE    bsJump[3];                  // 跳转指令  // jump inst E9xxxx or EBxx90
     CHAR    bsOEMName[8];               // 厂商标志和OS版本号  // OEM name and version
     CHAR    bsBPB[53];                  // BIOS 参数块  // BIOS parameter block
     CHAR    bsExt[26];                  // 扩展BPB  // Bootsector Extension
     CHAR    bsBootCode[418];            // 引导扇区代码  // pad so structure is 512b
     BYTE    bsBootSectSig2;             // 2 & 3 are only defined for FAT32?
     BYTE    bsBootSectSig3;
     BYTE    bsBootSectSig0;             // 引导扇区签名0x55  // boot sector signature byte 0x55
     BYTE    bsBootSectSig1;             // 引导扇区签名0xAA  // boot sector signature byte 0xAA
 #define BOOTSIG0        0x55
 #define BOOTSIG1        0xaa
 #define BOOTSIG2        0
 #define BOOTSIG3        0
 }BOOTSECTOR710;
 
 /***************************************************************/
 /***************************************************************/
 
 // BIOS Parameter Block (BPB) for DOS 3.3
typedef __packed struct {		 //没用到
         WORD    bpbBytesPerSec; // bytes per sector
         BYTE    bpbSecPerClust; // sectors per cluster
         WORD    bpbResSectors;  // number of reserved sectors
         BYTE    bpbFATs;        // number of FATs
         WORD    bpbRootDirEnts; // number of root directory entries
         WORD    bpbSectors;     // total number of sectors
         BYTE    bpbMedia;       // media descriptor
         WORD    bpbFATsecs;     // number of sectors per FAT
         WORD    bpbSecPerTrack; // sectors per track
         WORD    bpbHeads;       // number of heads
         WORD    bpbHiddenSecs;  // number of hidden sectors
 }BPB33;
 
 
 
 // BPB for DOS 5.0
 // The difference is bpbHiddenSecs is a short for DOS 3.3,
 // and bpbHugeSectors is not present in the DOS 3.3 bpb.
 typedef __packed struct {
         WORD    bpbBytesPerSec; //每扇区字节数  bytes per sector
         BYTE    bpbSecPerClust; //每族扇区数    sectors per cluster
         WORD    bpbResSectors;  //保留扇区数    number of reserved sectors
         BYTE    bpbFATs;        //FAT表的份数:2  number of FATs
         WORD    bpbRootDirEnts; //根目录项数  // number of root directory entries
         WORD    bpbSectors;     //此域为存储卷上的扇区总数  // total number of sectors
         BYTE    bpbMedia;       //固定存储介质描述  // media descriptor
         WORD    bpbFATsecs;     //每个FAT的扇区数  number of sectors per FAT
         WORD    bpbSecPerTrack; //每道扇区数  // sectors per track
         WORD    bpbHeads;       //磁头数  // number of heads
         DWORD   bpbHiddenSecs;  //隐藏扇区数  # of hidden sectors
 // 3.3 compat ends here
         DWORD   bpbHugeSectors; //最大扇区数 # of sectors if bpbSectors == 0
 }BPB50;
 
 
 
 // BPB for DOS 7.10 (FAT32)
 // This one has a few extensions to bpb50.
 typedef __packed struct {		 //没用到
         WORD    bpbBytesPerSec; // 每扇区字节数  // bytes per sector
         BYTE    bpbSecPerClust; // 每簇扇区数    // sectors per cluster

⌨️ 快捷键说明

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