xref: /dragonfly/sys/vfs/msdosfs/bootsect.h (revision 5667bed1)
1 /* $FreeBSD$ */
2 /*	$NetBSD: bootsect.h,v 1.9 1997/11/17 15:36:17 ws Exp $	*/
3 
4 /*-
5  * Written by Paul Popelka (paulp@uts.amdahl.com)
6  *
7  * You can do anything you want with this software, just don't say you wrote
8  * it, and don't remove this notice.
9  *
10  * This software is provided "as is".
11  *
12  * The author supplies this software to be publicly redistributed on the
13  * understanding that the author is not responsible for the correct
14  * functioning of this software in any circumstances and is not liable for
15  * any damages caused by this software.
16  *
17  * October 1992
18  */
19 #ifndef _FS_MSDOSFS_BOOTSECT_H_
20 #define	_FS_MSDOSFS_BOOTSECT_H_
21 
22 /*
23  * Format of a boot sector.  This is the first sector on a DOS floppy disk
24  * or the fist sector of a partition on a hard disk.  But, it is not the
25  * first sector of a partitioned hard disk.
26  */
27 struct bootsector33 {
28 	uint8_t		bsJump[3];		/* jump inst E9xxxx or EBxx90 */
29 	int8_t		bsOemName[8];		/* OEM name and version */
30 	int8_t		bsBPB[19];		/* BIOS parameter block */
31 	int8_t		bsDriveNumber;		/* drive number (0x80) */
32 	int8_t		bsBootCode[479];	/* pad so struct is 512b */
33 	uint8_t		bsBootSectSig0;
34 	uint8_t		bsBootSectSig1;
35 #define	BOOTSIG0	0x55
36 #define	BOOTSIG1	0xaa
37 };
38 
39 struct extboot {
40 	int8_t		exDriveNumber;		/* drive number (0x80) */
41 	int8_t		exReserved1;		/* reserved */
42 	int8_t		exBootSignature;	/* ext. boot signature (0x29) */
43 #define	EXBOOTSIG	0x29
44 #define	EXBOOTSIG2	0x28
45 	int8_t		exVolumeID[4];		/* volume ID number */
46 	int8_t		exVolumeLabel[11];	/* volume label */
47 	int8_t		exFileSysType[8];	/* fs type (FAT12 or FAT16) */
48 };
49 
50 struct bootsector50 {
51 	uint8_t		bsJump[3];		/* jump inst E9xxxx or EBxx90 */
52 	int8_t		bsOemName[8];		/* OEM name and version */
53 	int8_t		bsBPB[25];		/* BIOS parameter block */
54 	int8_t		bsExt[26];		/* Bootsector Extension */
55 	int8_t		bsBootCode[448];	/* pad so structure is 512b */
56 	uint8_t		bsBootSectSig0;
57 	uint8_t		bsBootSectSig1;
58 #define	BOOTSIG0	0x55
59 #define	BOOTSIG1	0xaa
60 };
61 
62 struct bootsector710 {
63 	uint8_t		bsJump[3];		/* jump inst E9xxxx or EBxx90 */
64 	int8_t		bsOEMName[8];		/* OEM name and version */
65 	int8_t		bsBPB[53];		/* BIOS parameter block */
66 	int8_t		bsExt[26];		/* Bootsector Extension */
67 	int8_t		bsBootCode[420];	/* pad so structure is 512b */
68 	uint8_t		bsBootSectSig0;
69 	uint8_t		bsBootSectSig1;
70 #define	BOOTSIG0	0x55
71 #define	BOOTSIG1	0xaa
72 };
73 
74 union bootsector {
75 	struct bootsector33 bs33;
76 	struct bootsector50 bs50;
77 	struct bootsector710 bs710;
78 };
79 
80 #if 0
81 /*
82  * Shorthand for fields in the bpb.
83  */
84 #define	bsBytesPerSec	bsBPB.bpbBytesPerSec
85 #define	bsSectPerClust	bsBPB.bpbSectPerClust
86 #define	bsResSectors	bsBPB.bpbResSectors
87 #define	bsFATS		bsBPB.bpbFATS
88 #define	bsRootDirEnts	bsBPB.bpbRootDirEnts
89 #define	bsSectors	bsBPB.bpbSectors
90 #define	bsMedia		bsBPB.bpbMedia
91 #define	bsFATsecs	bsBPB.bpbFATsecs
92 #define	bsSectPerTrack	bsBPB.bpbSectPerTrack
93 #define	bsHeads		bsBPB.bpbHeads
94 #define	bsHiddenSecs	bsBPB.bpbHiddenSecs
95 #define	bsHugeSectors	bsBPB.bpbHugeSectors
96 #endif
97 
98 #endif /* !_FS_MSDOSFS_BOOTSECT_H_ */
99