?? fat16.h
字號:
#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 + -