12923869a4b0c5eca32d7c8c97f060edefa14860
[dragonfly.git] / sys / vfs / msdosfs / bootsect.h
1 /* $FreeBSD: src/sys/msdosfs/bootsect.h,v 1.7 1999/08/28 00:48:06 peter Exp $ */
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
20 #ifndef _VFS_MSDOSFS_BOOTSECT_H_
21 #define _VFS_MSDOSFS_BOOTSECT_H_
22
23 /*
24  * Format of a boot sector.  This is the first sector on a DOS floppy disk
25  * or the fist sector of a partition on a hard disk.  But, it is not the
26  * first sector of a partitioned hard disk.
27  */
28 struct bootsector33 {
29         u_int8_t        bsJump[3];              /* jump inst E9xxxx or EBxx90 */
30         int8_t          bsOemName[8];           /* OEM name and version */
31         int8_t          bsBPB[19];              /* BIOS parameter block */
32         int8_t          bsDriveNumber;          /* drive number (0x80) */
33         int8_t          bsBootCode[479];        /* pad so struct is 512b */
34         u_int8_t        bsBootSectSig0;
35         u_int8_t        bsBootSectSig1;
36 #define BOOTSIG0        0x55
37 #define BOOTSIG1        0xaa
38 };
39
40 struct extboot {
41         int8_t          exDriveNumber;          /* drive number (0x80) */
42         int8_t          exReserved1;            /* reserved */
43         int8_t          exBootSignature;        /* ext. boot signature (0x29) */
44 #define EXBOOTSIG       0x29
45 #define EXBOOTSIG2      0x28
46         int8_t          exVolumeID[4];          /* volume ID number */
47         int8_t          exVolumeLabel[11];      /* volume label */
48         int8_t          exFileSysType[8];       /* fs type (FAT12 or FAT16) */
49 };
50
51 struct bootsector50 {
52         u_int8_t        bsJump[3];              /* jump inst E9xxxx or EBxx90 */
53         int8_t          bsOemName[8];           /* OEM name and version */
54         int8_t          bsBPB[25];              /* BIOS parameter block */
55         int8_t          bsExt[26];              /* Bootsector Extension */
56         int8_t          bsBootCode[448];        /* pad so structure is 512b */
57         u_int8_t        bsBootSectSig0;
58         u_int8_t        bsBootSectSig1;
59 #define BOOTSIG0        0x55
60 #define BOOTSIG1        0xaa
61 };
62
63 struct bootsector710 {
64         u_int8_t        bsJump[3];              /* jump inst E9xxxx or EBxx90 */
65         int8_t          bsOEMName[8];           /* OEM name and version */
66         int8_t          bsPBP[53];              /* BIOS parameter block */
67         int8_t          bsExt[26];              /* Bootsector Extension */
68         int8_t          bsBootCode[418];        /* pad so structure is 512b */
69         u_int8_t        bsBootSectSig2;         /* 2 & 3 are only defined for FAT32? */
70         u_int8_t        bsBootSectSig3;
71         u_int8_t        bsBootSectSig0;
72         u_int8_t        bsBootSectSig1;
73 #define BOOTSIG0        0x55
74 #define BOOTSIG1        0xaa
75 #define BOOTSIG2        0
76 #define BOOTSIG3        0
77 };
78
79 #ifdef atari
80 /*
81  * The boot sector on a gemdos fs is a little bit different from the msdos fs
82  * format. Currently there is no need to declare a separate structure, the
83  * bootsector33 struct will do.
84  */
85 #if 0
86 struct bootsec_atari {
87         u_int8_t        bsBranch[2];            /* branch inst if auto-boot     */
88         int8_t          bsFiller[6];            /* anything or nothing          */
89         int8_t          bsSerial[3];            /* serial no. for mediachange   */
90         int8_t          bsBPB[19];              /* BIOS parameter block         */
91         int8_t          bsBootCode[482];        /* pad so struct is 512b        */
92 };
93 #endif
94 #endif /* atari */
95
96 union bootsector {
97         struct bootsector33 bs33;
98         struct bootsector50 bs50;
99         struct bootsector710 bs710;
100 };
101
102 #if 0
103 /*
104  * Shorthand for fields in the bpb.
105  */
106 #define bsBytesPerSec   bsBPB.bpbBytesPerSec
107 #define bsSectPerClust  bsBPB.bpbSectPerClust
108 #define bsResSectors    bsBPB.bpbResSectors
109 #define bsFATS          bsBPB.bpbFATS
110 #define bsRootDirEnts   bsBPB.bpbRootDirEnts
111 #define bsSectors       bsBPB.bpbSectors
112 #define bsMedia         bsBPB.bpbMedia
113 #define bsFATsecs       bsBPB.bpbFATsecs
114 #define bsSectPerTrack  bsBPB.bpbSectPerTrack
115 #define bsHeads         bsBPB.bpbHeads
116 #define bsHiddenSecs    bsBPB.bpbHiddenSecs
117 #define bsHugeSectors   bsBPB.bpbHugeSectors
118 #endif
119
120 #endif /* !_VFS_MSDOSFS_BOOTSECT_H_ */