xref: /freebsd/sys/fs/msdosfs/bootsect.h (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
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 	int8_t		exVolumeID[4];		/* volume ID number */
45 	int8_t		exVolumeLabel[11];	/* volume label */
46 	int8_t		exFileSysType[8];	/* fs type (FAT12 or FAT16) */
47 };
48 
49 struct bootsector50 {
50 	uint8_t		bsJump[3];		/* jump inst E9xxxx or EBxx90 */
51 	int8_t		bsOemName[8];		/* OEM name and version */
52 	int8_t		bsBPB[25];		/* BIOS parameter block */
53 	int8_t		bsExt[26];		/* Bootsector Extension */
54 	int8_t		bsBootCode[448];	/* pad so structure is 512b */
55 	uint8_t		bsBootSectSig0;
56 	uint8_t		bsBootSectSig1;
57 #define	BOOTSIG0	0x55
58 #define	BOOTSIG1	0xaa
59 };
60 
61 struct bootsector710 {
62 	uint8_t		bsJump[3];		/* jump inst E9xxxx or EBxx90 */
63 	int8_t		bsOEMName[8];		/* OEM name and version */
64 	int8_t		bsBPB[53];		/* BIOS parameter block */
65 	int8_t		bsExt[26];		/* Bootsector Extension */
66 	int8_t		bsBootCode[420];	/* pad so structure is 512b */
67 	uint8_t		bsBootSectSig0;
68 	uint8_t		bsBootSectSig1;
69 #define	BOOTSIG0	0x55
70 #define	BOOTSIG1	0xaa
71 };
72 
73 union bootsector {
74 	struct bootsector33 bs33;
75 	struct bootsector50 bs50;
76 	struct bootsector710 bs710;
77 };
78 
79 #if 0
80 /*
81  * Shorthand for fields in the bpb.
82  */
83 #define	bsBytesPerSec	bsBPB.bpbBytesPerSec
84 #define	bsSectPerClust	bsBPB.bpbSectPerClust
85 #define	bsResSectors	bsBPB.bpbResSectors
86 #define	bsFATS		bsBPB.bpbFATS
87 #define	bsRootDirEnts	bsBPB.bpbRootDirEnts
88 #define	bsSectors	bsBPB.bpbSectors
89 #define	bsMedia		bsBPB.bpbMedia
90 #define	bsFATsecs	bsBPB.bpbFATsecs
91 #define	bsSectPerTrack	bsBPB.bpbSectPerTrack
92 #define	bsHeads		bsBPB.bpbHeads
93 #define	bsHiddenSecs	bsBPB.bpbHiddenSecs
94 #define	bsHugeSectors	bsBPB.bpbHugeSectors
95 #endif
96 
97 #endif /* !_FS_MSDOSFS_BOOTSECT_H_ */
98