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

📄 fat32def.h

📁 这是基于博创公司ARM3000平台设计的综合实验源代码-电子菜单
💻 H
字号:
#include "..\inc\def.h"
//////////////////////////////////////
//      MBR Sector Structure        //
//////////////////////////////////////
#define BPB_Offset					0x1C6
//////////////////////////////////////
//      BPB Sector Structure        //
//////////////////////////////////////
#define	Offset_U8_BS_jmpBoot		0
#define Offset_U8_BS_OEMName		3
#define Offset_U16_BPB_BytsPerSec	11	//Count of bytes per sector. This value may take on only the  //
										//following values: 512, 1024, 2048 or 4096. If maximum       //
										//compatibility is desired, only the value 512 should be used.//
#define Offset_U8_BPB_SecPerClus	13	//Number of sectors per allocation unit. This value must be a //
										//power of 2 that is greater than 0. The legal values are 1,  //
										//2, 4, 8, 16, 32, 64,and 128.                                //
#define Offset_U16_BPB_RsvdSecCnt	14	//Number of reserved sectors in the Reserved region of the    //
										//volume starting at the first sector of the volume.For FAT32 //
										//volumes, this value is typically 32.                        //
#define Offset_U8_BPB_NumFATs		16	//The count of FAT data structures on the volume.             //
#define Offset_U16_BPB_RootEntCnt	17	//Is only useful for FAT12 and FAT16 volumes.                 //
										//For FAT32 volumes,this field must be set to 0.              //
#define Offset_U16_BPB_TotSec16		19	//For FAT12 and FAT16 volumes, this field contains the sector //
										//count, and BPB_TotSec32 is 0 if the total sector count fits //
										//(is less than 0x10000).                                     //
#define Offset_U8_BPB_Media			21	//0xF8 is the standard value for fixed(non-removable) media.  //
										//For removable media, 0xF0 is frequently used.               //
#define Offset_U16_BPB_FATSz16		22	//This field is FAT12/FAT16 16bit count of sectors occupied by//
										//1 FAT.On FAT32 volumes this field must be 0, and BPB_FATSz32//
										//contains the FAT size count.                                //
#define Offset_U16_BPB_SecPerTrk	24	//Sectors per track for interrupt 0x13. This field is only    //
										//relevant for media that have a geometry (volume is broken   //
										//down into tracks by multiple heads and cylinders) and are   //
										//visible on interrupt 0x13.This field contains the           //
										//"sectors per track" geometry value.                         //
#define Offset_U16_BPB_NumHeads		26	//Number of heads for interrupt 0x13. This field is relevant  //
										//as discussed earlier for BPB_SecPerTrk.                     //
#define Offset_U32_BPB_HiddSec		28	//Count of hidden sectors preceding the partition that        //
										//contains this FAT volume.                                   //
#define Offset_U32_BPB_TotSec32		32	//This field is the new 32-bit total count of sectors on the  //
										//volume. This count includes the count of all sectors in all //
										//four regions of the volume. This field can be 0; if it is 0,//
										//then BPB_TotSec16 must be non-zero. For FAT32 volumes, this //
										//field must be non-zero. For FAT12/FAT16 volumes, this field //
										//contains the sector count if BPB_TotSec16 is 0 (count is    //
										//greater than or equal to 0x10000).//
	//FAT32 Structure Starting at Offset 36//
#define Offset_U32_BPB_FATSz32		36	//This field is the FAT32 32-bit count of sectors occupied by //
	//根据该值得到FAT的大小//				//ONE FAT. BPB_FATSz16 must be 0.                             //
	
#define Offset_U16_BPB_ExtFlags		40	//    Bits 0-3 -- Zero-based number of active FAT.Only valid  //
										//                if mirroring is disabled.                   //
										//    Bits 4-6 -- Reserved.                                   //
										//    Bit 7    -- 0 means the FAT is mirrored at runtime into //
										//                  all FATs.                                 //
										//             -- 1 means only one FAT is active;it is the one//
										//                  referenced in bits 0-3.                   //
										//    Bits 8-15 -- Reserved.                                  //
#define Offset_U16_BPB_FSVer		42	//High byte is major revision number.                         //
										//Low byte is minor revision number.                          //
#define Offset_U32_BPB_RootClus		44	//This is set to the cluster number of the first cluster of   //
	//根据该值得到ROOT的地址//				//the root directory, usually 2 but not required to be 2.     //
	
#define Offset_U16_BPB_FSInfo		48	//Sector number of FSINFO structure in the reserved area of   //
										//the FAT32 volume.Usually 1.                                 //
#define Offset_U16_BPB_BkBootSec	50	//If non-zero, indicates the sector number in the reserved    //
										//area of the volume of a copy of the boot record.            //
										//Usually 6. No value other than 6 is recommended.            //
#define Offset_U8_BPB_Reserved		52	//Reserved for future expansion. Code that formats FAT32      //
										//volumes should always set all the bytes of this field to 0. //
#define Offset_U8_BS_DrvNum			64	//Int 0x13 drive number (e.g. 0x80).This field supports MS-DOS//
										//bootstrap and is set to the INT 0x13 drive number of the    //
										//media(0x00 for floppy disks, 0x80 for hard disks).          //
										//NOTE: This field is actually operating system specific.     //
#define Offset_U8_BS_Reserved1		65	//Reserved (used by Windows NT). Code that formats FAT volumes//
										//should always set this byte to 0.                           //
#define Offset_U8_BS_BootSig		66	//Extended boot signature(0x29). This is a signature byte that//
										//indicates that the following three fields in the boot sector//
										//are present.                                                //
#define Offset_U32_BS_VolID			67	//Volume serial number.                                       //
#define Offset_U8_BS_VolLab			71	//Volume label. This field matches the 11-byte volume label   //
										//recorded in the root directory.The setting for this field   //
										//when there is no volume label is the string "NO NAME ".     //
#define Offset_U8_BS_FilSysType		82	//Always set to the string ”FAT32 ”.
#define Offset_U8_Pading			83
#define Offset_U16_Signature		510	//0x55AA           
////////////////////////////////////
#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
//////////////////////////////////////
//        DIR Entrey define         //
//////////////////////////////////////
#define SLOT_EMPTY			0x00	//slot has never been used //
#define SLOT_E5					0x05	//the real value is 0xe5   //
#define SLOT_DELETED		0xe5	//file in this slot deleted//

#define Offset_File_ATTR 11
#define ATTR_READ_ONLY	0x01
#define ATTR_HIDDEN		0x02
#define ATTR_SYSTEM		0x04
#define ATTR_VOLUME_ID	0x08
#define ATTR_DIRECTORY	0x10
#define ATTR_FILE		0x20
#define ATTR_LONG_NAME	0x0F


#define MBR_Location	0			//MBR sector is locate at LBA0		 //
#define Sector_Size		512		//physical and logical sector size   //
#define FAT_Recode_per_Sector		Sector_Size/4		//每1个扇区所能容纳的FAT记录
#define FAT_DISK_ID					0xfffffff8	//Disk ID Type
#define FAT_Filler					0xffffffff	//
#define FAT_Bad_Cluster			0xfffffff7	//Cluster mark with bad
#define FAT_Last_Cluster		0x0ffffff8	//0xfffffff8~0xffffffff:Last Cluster in the File
#define FAT_Unused_Cluster	0x00000000	//unused Cluster
#define First_Cluster_Num		2
#define MAX_DIR_FILE_NUM		512	//1个目录缓冲中所能处理的最大文件数//


⌨️ 快捷键说明

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