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