xref: /freebsd/sys/fs/msdosfs/bootsect.h (revision 8a88248d57af1e19fa2b8340b0eb18f86909e7fa)
1c3aac50fSPeter Wemm /* $FreeBSD$ */
2952a6212SJordan K. Hubbard /*	$NetBSD: bootsect.h,v 1.9 1997/11/17 15:36:17 ws Exp $	*/
327a0bc89SDoug Rabson 
427a0bc89SDoug Rabson /*
527a0bc89SDoug Rabson  * Written by Paul Popelka (paulp@uts.amdahl.com)
627a0bc89SDoug Rabson  *
727a0bc89SDoug Rabson  * You can do anything you want with this software, just don't say you wrote
827a0bc89SDoug Rabson  * it, and don't remove this notice.
927a0bc89SDoug Rabson  *
1027a0bc89SDoug Rabson  * This software is provided "as is".
1127a0bc89SDoug Rabson  *
1227a0bc89SDoug Rabson  * The author supplies this software to be publicly redistributed on the
1327a0bc89SDoug Rabson  * understanding that the author is not responsible for the correct
1427a0bc89SDoug Rabson  * functioning of this software in any circumstances and is not liable for
1527a0bc89SDoug Rabson  * any damages caused by this software.
1627a0bc89SDoug Rabson  *
1727a0bc89SDoug Rabson  * October 1992
1827a0bc89SDoug Rabson  */
1927a0bc89SDoug Rabson 
2027a0bc89SDoug Rabson /*
2127a0bc89SDoug Rabson  * Format of a boot sector.  This is the first sector on a DOS floppy disk
2227a0bc89SDoug Rabson  * or the fist sector of a partition on a hard disk.  But, it is not the
2327a0bc89SDoug Rabson  * first sector of a partitioned hard disk.
2427a0bc89SDoug Rabson  */
2527a0bc89SDoug Rabson struct bootsector33 {
26952a6212SJordan K. Hubbard 	u_int8_t	bsJump[3];		/* jump inst E9xxxx or EBxx90 */
27952a6212SJordan K. Hubbard 	int8_t		bsOemName[8];		/* OEM name and version */
28952a6212SJordan K. Hubbard 	int8_t		bsBPB[19];		/* BIOS parameter block */
29952a6212SJordan K. Hubbard 	int8_t		bsDriveNumber;		/* drive number (0x80) */
30952a6212SJordan K. Hubbard 	int8_t		bsBootCode[479];	/* pad so struct is 512b */
31952a6212SJordan K. Hubbard 	u_int8_t	bsBootSectSig0;
32952a6212SJordan K. Hubbard 	u_int8_t	bsBootSectSig1;
33952a6212SJordan K. Hubbard #define	BOOTSIG0	0x55
34952a6212SJordan K. Hubbard #define	BOOTSIG1	0xaa
35952a6212SJordan K. Hubbard };
36952a6212SJordan K. Hubbard 
37952a6212SJordan K. Hubbard struct extboot {
38952a6212SJordan K. Hubbard 	int8_t		exDriveNumber;		/* drive number (0x80) */
39952a6212SJordan K. Hubbard 	int8_t		exReserved1;		/* reserved */
40952a6212SJordan K. Hubbard 	int8_t		exBootSignature;	/* ext. boot signature (0x29) */
41952a6212SJordan K. Hubbard #define	EXBOOTSIG	0x29
42952a6212SJordan K. Hubbard 	int8_t		exVolumeID[4];		/* volume ID number */
43952a6212SJordan K. Hubbard 	int8_t		exVolumeLabel[11];	/* volume label */
44952a6212SJordan K. Hubbard 	int8_t		exFileSysType[8];	/* fs type (FAT12 or FAT16) */
4527a0bc89SDoug Rabson };
4627a0bc89SDoug Rabson 
4727a0bc89SDoug Rabson struct bootsector50 {
48952a6212SJordan K. Hubbard 	u_int8_t	bsJump[3];		/* jump inst E9xxxx or EBxx90 */
49952a6212SJordan K. Hubbard 	int8_t		bsOemName[8];		/* OEM name and version */
50952a6212SJordan K. Hubbard 	int8_t		bsBPB[25];		/* BIOS parameter block */
51952a6212SJordan K. Hubbard 	int8_t		bsExt[26];		/* Bootsector Extension */
52952a6212SJordan K. Hubbard 	int8_t		bsBootCode[448];	/* pad so structure is 512b */
53952a6212SJordan K. Hubbard 	u_int8_t	bsBootSectSig0;
54952a6212SJordan K. Hubbard 	u_int8_t	bsBootSectSig1;
55952a6212SJordan K. Hubbard #define	BOOTSIG0	0x55
56952a6212SJordan K. Hubbard #define	BOOTSIG1	0xaa
5727a0bc89SDoug Rabson };
5827a0bc89SDoug Rabson 
59952a6212SJordan K. Hubbard struct bootsector710 {
60952a6212SJordan K. Hubbard 	u_int8_t	bsJump[3];		/* jump inst E9xxxx or EBxx90 */
61952a6212SJordan K. Hubbard 	int8_t		bsOEMName[8];		/* OEM name and version */
628a88248dSJohn Baldwin 	int8_t		bsBPB[53];		/* BIOS parameter block */
63952a6212SJordan K. Hubbard 	int8_t		bsExt[26];		/* Bootsector Extension */
64952a6212SJordan K. Hubbard 	int8_t		bsBootCode[418];	/* pad so structure is 512b */
65952a6212SJordan K. Hubbard 	u_int8_t	bsBootSectSig2;		/* 2 & 3 are only defined for FAT32? */
66952a6212SJordan K. Hubbard 	u_int8_t	bsBootSectSig3;
67952a6212SJordan K. Hubbard 	u_int8_t	bsBootSectSig0;
68952a6212SJordan K. Hubbard 	u_int8_t	bsBootSectSig1;
69952a6212SJordan K. Hubbard #define	BOOTSIG0	0x55
70952a6212SJordan K. Hubbard #define	BOOTSIG1	0xaa
71952a6212SJordan K. Hubbard #define	BOOTSIG2	0
72952a6212SJordan K. Hubbard #define	BOOTSIG3	0
73952a6212SJordan K. Hubbard };
74952a6212SJordan K. Hubbard 
7527a0bc89SDoug Rabson union bootsector {
7627a0bc89SDoug Rabson 	struct bootsector33 bs33;
7727a0bc89SDoug Rabson 	struct bootsector50 bs50;
78952a6212SJordan K. Hubbard 	struct bootsector710 bs710;
7927a0bc89SDoug Rabson };
8027a0bc89SDoug Rabson 
81952a6212SJordan K. Hubbard #if 0
8227a0bc89SDoug Rabson /*
8327a0bc89SDoug Rabson  * Shorthand for fields in the bpb.
8427a0bc89SDoug Rabson  */
8527a0bc89SDoug Rabson #define	bsBytesPerSec	bsBPB.bpbBytesPerSec
8627a0bc89SDoug Rabson #define	bsSectPerClust	bsBPB.bpbSectPerClust
8727a0bc89SDoug Rabson #define	bsResSectors	bsBPB.bpbResSectors
8827a0bc89SDoug Rabson #define	bsFATS		bsBPB.bpbFATS
8927a0bc89SDoug Rabson #define	bsRootDirEnts	bsBPB.bpbRootDirEnts
9027a0bc89SDoug Rabson #define	bsSectors	bsBPB.bpbSectors
9127a0bc89SDoug Rabson #define	bsMedia		bsBPB.bpbMedia
9227a0bc89SDoug Rabson #define	bsFATsecs	bsBPB.bpbFATsecs
9327a0bc89SDoug Rabson #define	bsSectPerTrack	bsBPB.bpbSectPerTrack
9427a0bc89SDoug Rabson #define	bsHeads		bsBPB.bpbHeads
9527a0bc89SDoug Rabson #define	bsHiddenSecs	bsBPB.bpbHiddenSecs
9627a0bc89SDoug Rabson #define	bsHugeSectors	bsBPB.bpbHugeSectors
97952a6212SJordan K. Hubbard #endif
98