kernel - kqueue - major refactoring
[dragonfly.git] / sys / vfs / msdosfs / bpb.h
blob12f438cec6c7c5fbe863d4efadd7f872b5bb97b5
1 /* $FreeBSD: src/sys/msdosfs/bpb.h,v 1.7.2.1 2000/10/27 09:45:07 bde Exp $ */
2 /* $DragonFly: src/sys/vfs/msdosfs/bpb.h,v 1.2 2003/06/17 04:28:47 dillon Exp $ */
3 /* $NetBSD: bpb.h,v 1.7 1997/11/17 15:36:24 ws Exp $ */
5 /*
6 * Written by Paul Popelka (paulp@uts.amdahl.com)
8 * You can do anything you want with this software, just don't say you wrote
9 * it, and don't remove this notice.
11 * This software is provided "as is".
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.
18 * October 1992
22 * BIOS Parameter Block (BPB) for DOS 3.3
24 struct bpb33 {
25 u_int16_t bpbBytesPerSec; /* bytes per sector */
26 u_int8_t bpbSecPerClust; /* sectors per cluster */
27 u_int16_t bpbResSectors; /* number of reserved sectors */
28 u_int8_t bpbFATs; /* number of FATs */
29 u_int16_t bpbRootDirEnts; /* number of root directory entries */
30 u_int16_t bpbSectors; /* total number of sectors */
31 u_int8_t bpbMedia; /* media descriptor */
32 u_int16_t bpbFATsecs; /* number of sectors per FAT */
33 u_int16_t bpbSecPerTrack; /* sectors per track */
34 u_int16_t bpbHeads; /* number of heads */
35 u_int16_t bpbHiddenSecs; /* number of hidden sectors */
39 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
40 * and bpbHugeSectors is not in the 3.3 bpb.
42 struct bpb50 {
43 u_int16_t bpbBytesPerSec; /* bytes per sector */
44 u_int8_t bpbSecPerClust; /* sectors per cluster */
45 u_int16_t bpbResSectors; /* number of reserved sectors */
46 u_int8_t bpbFATs; /* number of FATs */
47 u_int16_t bpbRootDirEnts; /* number of root directory entries */
48 u_int16_t bpbSectors; /* total number of sectors */
49 u_int8_t bpbMedia; /* media descriptor */
50 u_int16_t bpbFATsecs; /* number of sectors per FAT */
51 u_int16_t bpbSecPerTrack; /* sectors per track */
52 u_int16_t bpbHeads; /* number of heads */
53 u_int32_t bpbHiddenSecs; /* # of hidden sectors */
54 u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
58 * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
60 struct bpb710 {
61 u_int16_t bpbBytesPerSec; /* bytes per sector */
62 u_int8_t bpbSecPerClust; /* sectors per cluster */
63 u_int16_t bpbResSectors; /* number of reserved sectors */
64 u_int8_t bpbFATs; /* number of FATs */
65 u_int16_t bpbRootDirEnts; /* number of root directory entries */
66 u_int16_t bpbSectors; /* total number of sectors */
67 u_int8_t bpbMedia; /* media descriptor */
68 u_int16_t bpbFATsecs; /* number of sectors per FAT */
69 u_int16_t bpbSecPerTrack; /* sectors per track */
70 u_int16_t bpbHeads; /* number of heads */
71 u_int32_t bpbHiddenSecs; /* # of hidden sectors */
72 u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
73 u_int32_t bpbBigFATsecs; /* like bpbFATsecs for FAT32 */
74 u_int16_t bpbExtFlags; /* extended flags: */
75 #define FATNUM 0xf /* mask for numbering active FAT */
76 #define FATMIRROR 0x80 /* FAT is mirrored (like it always was) */
77 u_int16_t bpbFSVers; /* filesystem version */
78 #define FSVERS 0 /* currently only 0 is understood */
79 u_int32_t bpbRootClust; /* start cluster for root directory */
80 u_int16_t bpbFSInfo; /* filesystem info structure sector */
81 u_int16_t bpbBackup; /* backup boot sector */
82 /* There is a 12 byte filler here, but we ignore it */
85 #ifdef atari
87 * BPB for gemdos filesystems. Atari leaves the obsolete stuff undefined.
88 * Currently there is no need for a separate BPB structure.
90 #if 0
91 struct bpb_a {
92 u_int16_t bpbBytesPerSec; /* bytes per sector */
93 u_int8_t bpbSecPerClust; /* sectors per cluster */
94 u_int16_t bpbResSectors; /* number of reserved sectors */
95 u_int8_t bpbFATs; /* number of FATs */
96 u_int16_t bpbRootDirEnts; /* number of root directory entries */
97 u_int16_t bpbSectors; /* total number of sectors */
98 u_int8_t bpbUseless1; /* meaningless on gemdos fs */
99 u_int16_t bpbFATsecs; /* number of sectors per FAT */
100 u_int16_t bpbUseless2; /* meaningless for harddisk fs */
101 u_int16_t bpbUseless3; /* meaningless for harddisk fs */
102 u_int16_t bpbHiddenSecs; /* the TOS-BIOS ignores this */
104 #endif
105 #endif /* atari */
108 * The following structures represent how the bpb's look on disk. shorts
109 * and longs are just character arrays of the appropriate length. This is
110 * because the compiler forces shorts and longs to align on word or
111 * halfword boundaries.
113 * XXX The little-endian code here assumes that the processor can access
114 * 16-bit and 32-bit quantities on byte boundaries. If this is not true,
115 * use the macros for the big-endian case.
118 #include <machine/endian.h>
120 #ifdef __i386__
121 #define UNLALIGNED_ACCESS
122 #endif
124 #if (BYTE_ORDER == LITTLE_ENDIAN) && defined(UNALIGNED_ACCESS)
125 #define getushort(x) *((u_int16_t *)(x))
126 #define getulong(x) *((u_int32_t *)(x))
127 #define putushort(p, v) (*((u_int16_t *)(p)) = (v))
128 #define putulong(p, v) (*((u_int32_t *)(p)) = (v))
129 #else
130 #define getushort(x) (((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8))
131 #define getulong(x) (((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8) \
132 + (((u_int8_t *)(x))[2] << 16) \
133 + (((u_int8_t *)(x))[3] << 24))
134 #define putushort(p, v) (((u_int8_t *)(p))[0] = (v), \
135 ((u_int8_t *)(p))[1] = (v) >> 8)
136 #define putulong(p, v) (((u_int8_t *)(p))[0] = (v), \
137 ((u_int8_t *)(p))[1] = (v) >> 8, \
138 ((u_int8_t *)(p))[2] = (v) >> 16,\
139 ((u_int8_t *)(p))[3] = (v) >> 24)
140 #endif
143 * BIOS Parameter Block (BPB) for DOS 3.3
145 struct byte_bpb33 {
146 int8_t bpbBytesPerSec[2]; /* bytes per sector */
147 int8_t bpbSecPerClust; /* sectors per cluster */
148 int8_t bpbResSectors[2]; /* number of reserved sectors */
149 int8_t bpbFATs; /* number of FATs */
150 int8_t bpbRootDirEnts[2]; /* number of root directory entries */
151 int8_t bpbSectors[2]; /* total number of sectors */
152 int8_t bpbMedia; /* media descriptor */
153 int8_t bpbFATsecs[2]; /* number of sectors per FAT */
154 int8_t bpbSecPerTrack[2]; /* sectors per track */
155 int8_t bpbHeads[2]; /* number of heads */
156 int8_t bpbHiddenSecs[2]; /* number of hidden sectors */
160 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
161 * and bpbHugeSectors is not in the 3.3 bpb.
163 struct byte_bpb50 {
164 int8_t bpbBytesPerSec[2]; /* bytes per sector */
165 int8_t bpbSecPerClust; /* sectors per cluster */
166 int8_t bpbResSectors[2]; /* number of reserved sectors */
167 int8_t bpbFATs; /* number of FATs */
168 int8_t bpbRootDirEnts[2]; /* number of root directory entries */
169 int8_t bpbSectors[2]; /* total number of sectors */
170 int8_t bpbMedia; /* media descriptor */
171 int8_t bpbFATsecs[2]; /* number of sectors per FAT */
172 int8_t bpbSecPerTrack[2]; /* sectors per track */
173 int8_t bpbHeads[2]; /* number of heads */
174 int8_t bpbHiddenSecs[4]; /* number of hidden sectors */
175 int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
179 * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
181 struct byte_bpb710 {
182 u_int8_t bpbBytesPerSec[2]; /* bytes per sector */
183 u_int8_t bpbSecPerClust; /* sectors per cluster */
184 u_int8_t bpbResSectors[2]; /* number of reserved sectors */
185 u_int8_t bpbFATs; /* number of FATs */
186 u_int8_t bpbRootDirEnts[2]; /* number of root directory entries */
187 u_int8_t bpbSectors[2]; /* total number of sectors */
188 u_int8_t bpbMedia; /* media descriptor */
189 u_int8_t bpbFATsecs[2]; /* number of sectors per FAT */
190 u_int8_t bpbSecPerTrack[2]; /* sectors per track */
191 u_int8_t bpbHeads[2]; /* number of heads */
192 u_int8_t bpbHiddenSecs[4]; /* # of hidden sectors */
193 u_int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
194 u_int8_t bpbBigFATsecs[4]; /* like bpbFATsecs for FAT32 */
195 u_int8_t bpbExtFlags[2]; /* extended flags: */
196 u_int8_t bpbFSVers[2]; /* filesystem version */
197 u_int8_t bpbRootClust[4]; /* start cluster for root directory */
198 u_int8_t bpbFSInfo[2]; /* filesystem info structure sector */
199 u_int8_t bpbBackup[2]; /* backup boot sector */
200 /* There is a 12 byte filler here, but we ignore it */
204 * FAT32 FSInfo block.
206 struct fsinfo {
207 u_int8_t fsisig1[4];
208 u_int8_t fsifill1[480];
209 u_int8_t fsisig2[4];
210 u_int8_t fsinfree[4];
211 u_int8_t fsinxtfree[4];
212 u_int8_t fsifill2[12];
213 u_int8_t fsisig3[4];
214 u_int8_t fsifill3[508];
215 u_int8_t fsisig4[4];