; STRUCT _sBOOT_SEC ; 62 bytes .JMP: BLOCK 3,0 ; +#00 "JMP" .ID_NAME: TEXT 8, {"DSS_1.7","0"} ; +#03 DOS NAME - DB "DSS_1.70" ; Block Parameters BIOS .B_P_S: WORD #200 ; +#0B BYTE PER SECTOR .S_P_C: BYTE 2 ; +#0D SECTORS PER CLUSTER .RESERVE: WORD 1 ; +#0E RESERVE SECTORS .FAT_NUM: BYTE 2 ; +#10 AMOUNT FATS .F_P_DIR: WORD 112 ; +#11 FILES IN DIRECTORY .S_P_D: WORD 1440 ; +#13 ALL SECTORS ON DISK .ID_FORM: BYTE #F0 ; +#15 ID FORMAT .S_P_F: WORD 2 ; +#16 SIZE FAT IN SECTORS .S_P_T: WORD 9 ; +#18 SECTOR PER TRACK .HEADS: WORD 2 ; +#1A AMOUNT SIDES .HIDDEN: DWORD 0 ; +#1C HIDDEN SECTORS .BPB_BIG_TOTAL_SECTORS: DWORD 0 ; +#20 BIG TOTAL SECTOR .BPB_PHISICAL_DRIVE_NUMBER: WORD #80 ; +#24 PHISICAL DRIVE NUMBER .BPB_EXT_BOOT_RECORD_SIGNATURE: BYTE #29 ; +#26 EXTENDED BOOT RECORD SIGNATURE .BPB_SERIAL_NUMBER: DWORD 0 ; +#27 VOLUME SERIAL NUMBER .BPB_LABEL: TEXT 11, {"NO NAME"," "} ; +#2B DISK LABEL .ID_FAT: TEXT 8, {"FAT16"," "} ; +#36 FILE SYSTEM ID (BPB_FS_ID) ;.BOOT_CODE BLOCK 448,0 ; +#3E boot loader's code ;.SIGNATURE WORD #AA55 ; +#1FE Signature ENDS ; STRUCT _sMBR_Table ENDS //--------------------------------------------------------------------------- ; * DOS partition types ; * ; * Taken from fdisk/i386_sys_types.c and fdisk/common.h of ; * util-linux 2.11n (as packaged by Debian), Feb 08, 2003. ; * ; * Part of the info is also taken from PartInfo tool from PartitionMagic 8 ; const system_identifier_t system_identifiers[] = ; { ; {0x00, "Empty"}, ; {0x01, "FAT12"}, ; {0x02, "XENIX root"}, ; {0x03, "XENIX usr"}, ; {0x04, "FAT16 <32MB"}, ; {0x05, "Extended"}, ; {0x06, "FAT16B (>= 32 MB)"}, ; {0x07, "Installable File System (NTFS, HPFS)"}, ; {0x08, "AIX"}, ; {0x09, "AIX bootable"}, ; {0x0A, "OS/2 Boot Manager"}, ; {0x0B, "Win95 FAT32"}, ; {0x0C, "Win95 FAT32 (LBA)"}, ; {0x0E, "Win95 FAT16 (LBA)"}, ; {0x0F, "Win95 Extended (LBA)"}, ; {0x10, "OPUS"}, ; {0x11, "Hidden FAT12"}, ; {0x12, "Compaq diagnostics"}, ; {0x14, "Hidden FAT16 <32MB"}, ; {0x16, "Hidden FAT16"}, ; {0x17, "Hidden IFS (HPFS/NTFS)"}, ; {0x18, "AST SmartSleep"}, ; {0x1B, "Hidden Win95 FAT32"}, ; {0x1C, "Hidden Win95 FAT32 (LBA)"}, ; {0x1E, "Hidden Win95 FAT16 (LBA)"}, ; {0x24, "NEC DOS"}, ; {0x2C, "WildFile/Adaptec GOBack"}, ; {0x39, "Plan 9"}, ; {0x3C, "PowerQuest Recoverable Partition"}, ; {0x40, "Venix 80286"}, ; {0x41, "PPC PReP Boot"}, ; {0x42, "Veritas Logical Disk Manager"}, ; {0x4d, "QNX4.x"}, ; {0x4e, "QNX4.x 2nd part"}, ; {0x4f, "QNX4.x 3rd part"}, ; {0x50, "OnTrack DM"}, ; {0x51, "OnTrack DM6 Aux1"}, ; {0x52, "CP/M"}, ; {0x53, "OnTrack DM6 Aux3"}, ; {0x54, "OnTrackDM6"}, ; {0x55, "EZ-Drive"}, ; {0x56, "Golden Bow"}, ; {0x5c, "Priam Edisk"}, ; {0x61, "SpeedStor"}, ; {0x63, "GNU HURD or SysV"}, ; {0x64, "Novell Netware 286"}, ; {0x65, "Novell Netware (3.11 and 4.1)"}, ; {0x66, "Novell Netware 386"}, ; {0x70, "DiskSecure Multi-Boot"}, ; {0x75, "PC/IX"}, ; {0x78, "XOSL"}, ; {0x80, "Old Minix"}, ; {0x81, "Linux/Minix v1.4b+"}, ; {0x82, "Linux swap / Solaris"}, ; {0x83, "Linux native file system (Ext2/3)"}, ; {0x84, "OS/2 hiding type 04h partition"}, ; {0x85, "Linux extended"}, ; {0x86, "NT FAT volume set"}, ; {0x87, "NT IFS volume set"}, ; {0x8e, "Linux LVM"}, ; {0x93, "Amoeba/Hidden Linux native file system (Ext2/3)"}, ; {0x94, "Amoeba BBT"}, ; {0x9f, "BSD/OS"}, ; {0xA0, "IBM Thinkpad hibernation"}, ; {0xA5, "FreeBSD"}, ; {0xA6, "OpenBSD"}, ; {0xA7, "NeXTSTEP"}, ; {0xA9, "NetBSD"}, ; {0xB7, "BSDI fs"}, ; {0xb8, "BSDI swap"}, ; {0xbb, "Boot Wizard hidden"}, ; {0xc1, "DRDOS / sec (FAT-12)"}, ; {0xc4, "DRDOS / sec (FAT-16 < 32M)"}, ; {0xc6, "Disabled NT FAT (FAT-16) volume set/DRDOS"}, ; {0xc7, "Syrinx / Disabled NT IFS volume set"}, ; {0xda, "Non-FS data"}, ; {0xdb, "CP/M / CTOS / ..."}, ; {0xde, "Dell Corporation diagnostic partition"}, ; {0xdf, "BootIt"}, ; {0xe1, "DOS access"}, ; {0xe3, "DOS R/O"}, ; {0xe4, "SpeedStor"}, ; {0xeb, "BeOS fs"}, ; {0xee, "EFI GPT"}, ; {0xef, "EFI (FAT-12/16/32)"}, ; {0xf0, "Linux/PA-RISC boot"}, ; {0xf1, "SpeedStor"}, ; {0xf4, "SpeedStor"}, ; {0xf2, "DOS secondary"}, ; {0xfd, "Linux raid autodetect"}, ; {0xfe, "LANstep"}, ; {0xff, "Bad Track Table"}, ; {0, 0} // End-Of-Table ; }; ; Limits and boundaries ; MAX_DIR 0x200000 ; Max size of FAT directory ; MAX_DIR_EX 0x10000000 ; Max size of exFAT directory ; MAX_FAT12 0xFF5 ; Max FAT12 clusters (differs from specs, but right for real DOS/Windows behavior) ; MAX_FAT16 0xFFF5 ; Max FAT16 clusters (differs from specs, but right for real DOS/Windows behavior) ; MAX_FAT32 0x0FFFFFF5 ; Max FAT32 clusters (not specified, practical limit) ; MAX_EXFAT 0x7FFFFFFD ; Max exFAT clusters (differs from specs, implementation limit) ; Character code support macros ; IsUpper(c) ((c) >= 'A' && (c) <= 'Z') ; IsLower(c) ((c) >= 'a' && (c) <= 'z') ; IsDigit(c) ((c) >= '0' && (c) <= '9') ; IsSeparator(c) ((c) == '/' || (c) == '\\') ; IsTerminator(c) ((UINT)(c) < (FF_USE_LFN ? ' ' : '!')) ; IsSurrogate(c) ((c) >= 0xD800 && (c) <= 0xDFFF) ; IsSurrogateH(c) ((c) >= 0xD800 && (c) <= 0xDBFF) ; IsSurrogateL(c) ((c) >= 0xDC00 && (c) <= 0xDFFF) ; Additional file access control and file status flags for internal use ; FA_SEEKEND 0x20 ; Seek to end of the file on file open ; FA_MODIFIED 0x40 ; File has been modified ; FA_DIRTY 0x80 ; FIL.buf[] needs to be written-back ; Additional file attribute bits for internal use ; AM_VOL 0x08 ; Volume label ; AM_LFN 0x0F ; LFN entry ; AM_MASK 0x3F ; Mask of defined bits in FAT ; AM_MASKX 0x37 ; Mask of defined bits in exFAT ; Name status flags in fn[11] ; NSFLAG 11 ; Index of the name status byte ; NS_LOSS 0x01 ; Out of 8.3 format ; NS_LFN 0x02 ; Force to create LFN entry ; NS_LAST 0x04 ; Last segment ; NS_BODY 0x08 ; Lower case flag (body) ; NS_EXT 0x10 ; Lower case flag (ext) ; NS_DOT 0x20 ; Dot entry ; NS_NOLFN 0x40 ; Do not find LFN ; NS_NONAME 0x80 ; Not followed ; exFAT directory entry types ; ET_BITMAP 0x81 ; Allocation bitmap ; ET_UPCASE 0x82 ; Up-case table ; ET_VLABEL 0x83 ; Volume label ; ET_FILEDIR 0x85 ; File and directory ; ET_STREAM 0xC0 ; Stream extension ; ET_FILENAME 0xC1 ; Name extension ; FatFs refers the FAT structure as simple byte array instead of structure member ; because the C structure is not binary compatible between different platforms ; BS_JmpBoot 0 ; x86 jump instruction (3-byte) ; BS_OEMName 3 ; OEM name (8-byte) ; BPB_BytsPerSec 11 ; Sector size [byte] (WORD) ; BPB_SecPerClus 13 ; Cluster size [sector] (BYTE) ; BPB_RsvdSecCnt 14 ; Size of reserved area [sector] (WORD) ; BPB_NumFATs 16 ; Number of FATs (BYTE) ; BPB_RootEntCnt 17 ; Size of root directory area for FAT [entry] (WORD) ; BPB_TotSec16 19 ; Volume size (16-bit) [sector] (WORD) ; BPB_Media 21 ; Media descriptor byte (BYTE) ; BPB_FATSz16 22 ; FAT size (16-bit) [sector] (WORD) ; BPB_SecPerTrk 24 ; Number of sectors per track for int13h [sector] (WORD) ; BPB_NumHeads 26 ; Number of heads for int13h (WORD) ; BPB_HiddSec 28 ; Volume offset from top of the drive (DWORD) ; BPB_TotSec32 32 ; Volume size (32-bit) [sector] (DWORD) ; BS_DrvNum 36 ; Physical drive number for int13h (BYTE) ; BS_NTres 37 ; WindowsNT error flag (BYTE) ; BS_BootSig 38 ; Extended boot signature (BYTE) ; BS_VolID 39 ; Volume serial number (DWORD) ; BS_VolLab 43 ; Volume label string (8-byte) ; BS_FilSysType 54 ; Filesystem type string (8-byte) ; BS_BootCode 62 ; Boot code (448-byte) ; BS_55AA 510 ; Signature word (WORD) ; BPB_FATSz32 36 ; FAT32: FAT size [sector] (DWORD) ; BPB_ExtFlags32 40 ; FAT32: Extended flags (WORD) ; BPB_FSVer32 42 ; FAT32: Filesystem version (WORD) ; BPB_RootClus32 44 ; FAT32: Root directory cluster (DWORD) ; BPB_FSInfo32 48 ; FAT32: Offset of FSINFO sector (WORD) ; BPB_BkBootSec32 50 ; FAT32: Offset of backup boot sector (WORD) ; BS_DrvNum32 64 ; FAT32: Physical drive number for int13h (BYTE) ; BS_NTres32 65 ; FAT32: Error flag (BYTE) ; BS_BootSig32 66 ; FAT32: Extended boot signature (BYTE) ; BS_VolID32 67 ; FAT32: Volume serial number (DWORD) ; BS_VolLab32 71 ; FAT32: Volume label string (8-byte) ; BS_FilSysType32 82 ; FAT32: Filesystem type string (8-byte) ; BS_BootCode32 90 ; FAT32: Boot code (420-byte) ; BPB_ZeroedEx 11 ; exFAT: MBZ field (53-byte) ; BPB_VolOfsEx 64 ; exFAT: Volume offset from top of the drive [sector] (QWORD) ; BPB_TotSecEx 72 ; exFAT: Volume size [sector] (QWORD) ; BPB_FatOfsEx 80 ; exFAT: FAT offset from top of the volume [sector] (DWORD) ; BPB_FatSzEx 84 ; exFAT: FAT size [sector] (DWORD) ; BPB_DataOfsEx 88 ; exFAT: Data offset from top of the volume [sector] (DWORD) ; BPB_NumClusEx 92 ; exFAT: Number of clusters (DWORD) ; BPB_RootClusEx 96 ; exFAT: Root directory start cluster (DWORD) ; BPB_VolIDEx 100 ; exFAT: Volume serial number (DWORD) ; BPB_FSVerEx 104 ; exFAT: Filesystem version (WORD) ; BPB_VolFlagEx 106 ; exFAT: Volume flags (WORD) ; BPB_BytsPerSecEx 108 ; exFAT: Log2 of sector size in unit of byte (BYTE) ; BPB_SecPerClusEx 109 ; exFAT: Log2 of cluster size in unit of sector (BYTE) ; BPB_NumFATsEx 110 ; exFAT: Number of FATs (BYTE) ; BPB_DrvNumEx 111 ; exFAT: Physical drive number for int13h (BYTE) ; BPB_PercInUseEx 112 ; exFAT: Percent in use (BYTE) ; BPB_RsvdEx 113 ; exFAT: Reserved (7-byte) ; BS_BootCodeEx 120 ; exFAT: Boot code (390-byte) ; DIR_Name 0 ; Short file name (11-byte) ; DIR_Attr 11 ; Attribute (BYTE) ; DIR_NTres 12 ; Lower case flag (BYTE) ; DIR_CrtTime10 13 ; Created time sub-second (BYTE) ; DIR_CrtTime 14 ; Created time (DWORD) ; DIR_LstAccDate 18 ; Last accessed date (WORD) ; DIR_FstClusHI 20 ; Higher 16-bit of first cluster (WORD) ; DIR_ModTime 22 ; Modified time (DWORD) ; DIR_FstClusLO 26 ; Lower 16-bit of first cluster (WORD) ; DIR_FileSize 28 ; File size (DWORD) ; LDIR_Ord 0 ; LFN: LFN order and LLE flag (BYTE) ; LDIR_Attr 11 ; LFN: LFN attribute (BYTE) ; LDIR_Type 12 ; LFN: Entry type (BYTE) ; LDIR_Chksum 13 ; LFN: Checksum of the SFN (BYTE) ; LDIR_FstClusLO 26 ; LFN: MBZ field (WORD) ; XDIR_Type 0 ; exFAT: Type of exFAT directory entry (BYTE) ; XDIR_NumLabel 1 ; exFAT: Number of volume label characters (BYTE) ; XDIR_Label 2 ; exFAT: Volume label (11-WORD) ; XDIR_CaseSum 4 ; exFAT: Sum of case conversion table (DWORD) ; XDIR_NumSec 1 ; exFAT: Number of secondary entries (BYTE) ; XDIR_SetSum 2 ; exFAT: Sum of the set of directory entries (WORD) ; XDIR_Attr 4 ; exFAT: File attribute (WORD) ; XDIR_CrtTime 8 ; exFAT: Created time (DWORD) ; XDIR_ModTime 12 ; exFAT: Modified time (DWORD) ; XDIR_AccTime 16 ; exFAT: Last accessed time (DWORD) ; XDIR_CrtTime10 20 ; exFAT: Created time subsecond (BYTE) ; XDIR_ModTime10 21 ; exFAT: Modified time subsecond (BYTE) ; XDIR_CrtTZ 22 ; exFAT: Created timezone (BYTE) ; XDIR_ModTZ 23 ; exFAT: Modified timezone (BYTE) ; XDIR_AccTZ 24 ; exFAT: Last accessed timezone (BYTE) ; XDIR_GenFlags 33 ; exFAT: General secondary flags (BYTE) ; XDIR_NumName 35 ; exFAT: Number of file name characters (BYTE) ; XDIR_NameHash 36 ; exFAT: Hash of file name (WORD) ; XDIR_ValidFileSize 40 ; exFAT: Valid file size (QWORD) ; XDIR_FstClus 52 ; exFAT: First cluster of the file data (DWORD) ; XDIR_FileSize 56 ; exFAT: File/Directory size (QWORD) ; SZDIRE 32 ; Size of a directory entry ; DDEM 0xE5 ; Deleted directory entry mark set to DIR_Name[0] ; RDDEM 0x05 ; Replacement of the character collides with DDEM ; LLEF 0x40 ; Last long entry flag in LDIR_Ord ; FSI_LeadSig 0 ; FAT32 FSI: Leading signature (DWORD) ; FSI_StrucSig 484 ; FAT32 FSI: Structure signature (DWORD) ; FSI_Free_Count 488 ; FAT32 FSI: Number of free clusters (DWORD) ; FSI_Nxt_Free 492 ; FAT32 FSI: Last allocated cluster (DWORD) ; MBR_Table 446 ; MBR: Offset of partition table in the MBR ; SZ_PTE 16 ; MBR: Size of a partition table entry ; PTE_Boot 0 ; MBR PTE: Boot indicator ; PTE_StHead 1 ; MBR PTE: Start head ; PTE_StSec 2 ; MBR PTE: Start sector ; PTE_StCyl 3 ; MBR PTE: Start cylinder ; PTE_System 4 ; MBR PTE: System ID ; PTE_EdHead 5 ; MBR PTE: End head ; PTE_EdSec 6 ; MBR PTE: End sector ; PTE_EdCyl 7 ; MBR PTE: End cylinder ; PTE_StLba 8 ; MBR PTE: Start in LBA ; PTE_SizLba 12 ; MBR PTE: Size in LBA ; GPTH_Sign 0 ; GPT: Header signature (8-byte) ; GPTH_Rev 8 ; GPT: Revision (DWORD) ; GPTH_Size 12 ; GPT: Header size (DWORD) ; GPTH_Bcc 16 ; GPT: Header BCC (DWORD) ; GPTH_CurLba 24 ; GPT: Main header LBA (QWORD) ; GPTH_BakLba 32 ; GPT: Backup header LBA (QWORD) ; GPTH_FstLba 40 ; GPT: First LBA for partitions (QWORD) ; GPTH_LstLba 48 ; GPT: Last LBA for partitions (QWORD) ; GPTH_DskGuid 56 ; GPT: Disk GUID (16-byte) ; GPTH_PtOfs 72 ; GPT: Partation table LBA (QWORD) ; GPTH_PtNum 80 ; GPT: Number of table entries (DWORD) ; GPTH_PteSize 84 ; GPT: Size of table entry (DWORD) ; GPTH_PtBcc 88 ; GPT: Partation table BCC (DWORD) ; SZ_GPTE 128 ; GPT: Size of partition table entry ; GPTE_PtGuid 0 ; GPT PTE: Partition type GUID (16-byte) ; GPTE_UpGuid 16 ; GPT PTE: Partition unique GUID (16-byte) ; GPTE_FstLba 32 ; GPT PTE: First LBA (QWORD) ; GPTE_LstLba 40 ; GPT PTE: Last LBA inclusive (QWORD) ; GPTE_Flags 48 ; GPT PTE: Flags (QWORD) ; GPTE_Name 56 ; GPT PTE: Name