xref: /dragonfly/sys/vfs/msdosfs/bootsect.h (revision 678e8cc6)
1 /* $FreeBSD: src/sys/msdosfs/bootsect.h,v 1.7 1999/08/28 00:48:06 peter Exp $ */
2 /* $DragonFly: src/sys/vfs/msdosfs/bootsect.h,v 1.3 2004/01/08 18:39:18 asmodai Exp $ */
3 /*	$NetBSD: bootsect.h,v 1.9 1997/11/17 15:36:17 ws Exp $	*/
4 
5 /*
6  * Written by Paul Popelka (paulp@uts.amdahl.com)
7  *
8  * You can do anything you want with this software, just don't say you wrote
9  * it, and don't remove this notice.
10  *
11  * This software is provided "as is".
12  *
13  * The author supplies this software to be publicly redistributed on the
14  * understanding that the author is not responsible for the correct
15  * functioning of this software in any circumstances and is not liable for
16  * any damages caused by this software.
17  *
18  * October 1992
19  */
20 
21 /*
22  * Format of a boot sector.  This is the first sector on a DOS floppy disk
23  * or the fist sector of a partition on a hard disk.  But, it is not the
24  * first sector of a partitioned hard disk.
25  */
26 struct bootsector33 {
27 	u_int8_t	bsJump[3];		/* jump inst E9xxxx or EBxx90 */
28 	int8_t		bsOemName[8];		/* OEM name and version */
29 	int8_t		bsBPB[19];		/* BIOS parameter block */
30 	int8_t		bsDriveNumber;		/* drive number (0x80) */
31 	int8_t		bsBootCode[479];	/* pad so struct is 512b */
32 	u_int8_t	bsBootSectSig0;
33 	u_int8_t	bsBootSectSig1;
34 #define	BOOTSIG0	0x55
35 #define	BOOTSIG1	0xaa
36 };
37 
38 struct extboot {
39 	int8_t		exDriveNumber;		/* drive number (0x80) */
40 	int8_t		exReserved1;		/* reserved */
41 	int8_t		exBootSignature;	/* ext. boot signature (0x29) */
42 #define	EXBOOTSIG	0x29
43 #define	EXBOOTSIG2	0x28
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 	u_int8_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 	u_int8_t	bsBootSectSig0;
56 	u_int8_t	bsBootSectSig1;
57 #define	BOOTSIG0	0x55
58 #define	BOOTSIG1	0xaa
59 };
60 
61 struct bootsector710 {
62 	u_int8_t	bsJump[3];		/* jump inst E9xxxx or EBxx90 */
63 	int8_t		bsOEMName[8];		/* OEM name and version */
64 	int8_t		bsPBP[53];		/* BIOS parameter block */
65 	int8_t		bsExt[26];		/* Bootsector Extension */
66 	int8_t		bsBootCode[418];	/* pad so structure is 512b */
67 	u_int8_t	bsBootSectSig2;		/* 2 & 3 are only defined for FAT32? */
68 	u_int8_t	bsBootSectSig3;
69 	u_int8_t	bsBootSectSig0;
70 	u_int8_t	bsBootSectSig1;
71 #define	BOOTSIG0	0x55
72 #define	BOOTSIG1	0xaa
73 #define	BOOTSIG2	0
74 #define	BOOTSIG3	0
75 };
76 #ifdef	atari
77 /*
78  * The boot sector on a gemdos fs is a little bit different from the msdos fs
79  * format. Currently there is no need to declare a separate structure, the
80  * bootsector33 struct will do.
81  */
82 #if 0
83 struct bootsec_atari {
84 	u_int8_t	bsBranch[2];		/* branch inst if auto-boot	*/
85 	int8_t		bsFiller[6];		/* anything or nothing		*/
86 	int8_t		bsSerial[3];		/* serial no. for mediachange	*/
87 	int8_t		bsBPB[19];		/* BIOS parameter block		*/
88 	int8_t		bsBootCode[482];	/* pad so struct is 512b	*/
89 };
90 #endif
91 #endif /* atari */
92 
93 union bootsector {
94 	struct bootsector33 bs33;
95 	struct bootsector50 bs50;
96 	struct bootsector710 bs710;
97 };
98 
99 #if 0
100 /*
101  * Shorthand for fields in the bpb.
102  */
103 #define	bsBytesPerSec	bsBPB.bpbBytesPerSec
104 #define	bsSectPerClust	bsBPB.bpbSectPerClust
105 #define	bsResSectors	bsBPB.bpbResSectors
106 #define	bsFATS		bsBPB.bpbFATS
107 #define	bsRootDirEnts	bsBPB.bpbRootDirEnts
108 #define	bsSectors	bsBPB.bpbSectors
109 #define	bsMedia		bsBPB.bpbMedia
110 #define	bsFATsecs	bsBPB.bpbFATsecs
111 #define	bsSectPerTrack	bsBPB.bpbSectPerTrack
112 #define	bsHeads		bsBPB.bpbHeads
113 #define	bsHiddenSecs	bsBPB.bpbHiddenSecs
114 #define	bsHugeSectors	bsBPB.bpbHugeSectors
115 #endif
116