FreeBSD/Linux Kernel Cross Reference
sys/fs/msdosfs/bpb.h
1 /* $NetBSD: bpb.h,v 1.5 2006/11/30 15:59:23 christos Exp $ */
2
3 /*
4 * Written by Paul Popelka (paulp@uts.amdahl.com)
5 *
6 * You can do anything you want with this software, just don't say you wrote
7 * it, and don't remove this notice.
8 *
9 * This software is provided "as is".
10 *
11 * The author supplies this software to be publicly redistributed on the
12 * understanding that the author is not responsible for the correct
13 * functioning of this software in any circumstances and is not liable for
14 * any damages caused by this software.
15 *
16 * October 1992
17 */
18
19 #ifndef _MSDOSFS_BPB_H_
20 #define _MSDOSFS_BPB_H_
21
22 /*
23 * BIOS Parameter Block (BPB) for DOS 3.3
24 */
25 struct bpb33 {
26 u_int16_t bpbBytesPerSec; /* bytes per sector */
27 u_int8_t bpbSecPerClust; /* sectors per cluster */
28 u_int16_t bpbResSectors; /* number of reserved sectors */
29 u_int8_t bpbFATs; /* number of FATs */
30 u_int16_t bpbRootDirEnts; /* number of root directory entries */
31 u_int16_t bpbSectors; /* total number of sectors */
32 u_int8_t bpbMedia; /* media descriptor */
33 u_int16_t bpbFATsecs; /* number of sectors per FAT */
34 u_int16_t bpbSecPerTrack; /* sectors per track */
35 u_int16_t bpbHeads; /* number of heads */
36 u_int16_t bpbHiddenSecs; /* number of hidden sectors */
37 };
38
39 /*
40 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
41 * and bpbHugeSectors is not in the 3.3 bpb.
42 */
43 struct bpb50 {
44 u_int16_t bpbBytesPerSec; /* bytes per sector */
45 u_int8_t bpbSecPerClust; /* sectors per cluster */
46 u_int16_t bpbResSectors; /* number of reserved sectors */
47 u_int8_t bpbFATs; /* number of FATs */
48 u_int16_t bpbRootDirEnts; /* number of root directory entries */
49 u_int16_t bpbSectors; /* total number of sectors */
50 u_int8_t bpbMedia; /* media descriptor */
51 u_int16_t bpbFATsecs; /* number of sectors per FAT */
52 u_int16_t bpbSecPerTrack; /* sectors per track */
53 u_int16_t bpbHeads; /* number of heads */
54 u_int32_t bpbHiddenSecs; /* # of hidden sectors */
55 u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
56 };
57
58 /*
59 * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
60 */
61 struct bpb710 {
62 u_int16_t bpbBytesPerSec; /* bytes per sector */
63 u_int8_t bpbSecPerClust; /* sectors per cluster */
64 u_int16_t bpbResSectors; /* number of reserved sectors */
65 u_int8_t bpbFATs; /* number of FATs */
66 u_int16_t bpbRootDirEnts; /* number of root directory entries */
67 u_int16_t bpbSectors; /* total number of sectors */
68 u_int8_t bpbMedia; /* media descriptor */
69 u_int16_t bpbFATsecs; /* number of sectors per FAT */
70 u_int16_t bpbSecPerTrack; /* sectors per track */
71 u_int16_t bpbHeads; /* number of heads */
72 u_int32_t bpbHiddenSecs; /* # of hidden sectors */
73 u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
74 u_int32_t bpbBigFATsecs; /* like bpbFATsecs for FAT32 */
75 u_int16_t bpbExtFlags; /* extended flags: */
76 #define FATNUM 0xf /* mask for numbering active FAT */
77 #define FATMIRROR 0x80 /* FAT is mirrored (like it always was) */
78 u_int16_t bpbFSVers; /* filesystem version */
79 #define FSVERS 0 /* currently only 0 is understood */
80 u_int32_t bpbRootClust; /* start cluster for root directory */
81 u_int16_t bpbFSInfo; /* filesystem info structure sector */
82 u_int16_t bpbBackup; /* backup boot sector */
83 u_int8_t bpbReserved[12]; /* Reserved for future expansion */
84 };
85
86 #ifdef atari
87 /*
88 * BPB for gemdos filesystems. Atari leaves the obsolete stuff undefined.
89 * Currently there is no need for a separate BPB structure.
90 */
91 #if 0
92 struct bpb_a {
93 u_int16_t bpbBytesPerSec; /* bytes per sector */
94 u_int8_t bpbSecPerClust; /* sectors per cluster */
95 u_int16_t bpbResSectors; /* number of reserved sectors */
96 u_int8_t bpbFATs; /* number of FATs */
97 u_int16_t bpbRootDirEnts; /* number of root directory entries */
98 u_int16_t bpbSectors; /* total number of sectors */
99 u_int8_t bpbUseless1; /* meaningless on gemdos fs */
100 u_int16_t bpbFATsecs; /* number of sectors per FAT */
101 u_int16_t bpbUseless2; /* meaningless for harddisk fs */
102 u_int16_t bpbUseless3; /* meaningless for harddisk fs */
103 u_int16_t bpbHiddenSecs; /* the TOS-BIOS ignores this */
104 };
105 #endif
106 #endif /* atari */
107
108 /*
109 * The following structures represent how the bpb's look on disk. shorts
110 * and longs are just character arrays of the appropriate length. This is
111 * because the compiler forces shorts and longs to align on word or
112 * halfword boundaries.
113 *
114 * XXX The little-endian code here assumes that the processor can access
115 * 16-bit and 32-bit quantities on byte boundaries. If this is not true,
116 * use the macros for the big-endian case.
117 */
118 #include <machine/endian.h>
119 #ifdef __STDC__
120 #define __ICAST(q,a,x) ((q u_int ## a ## _t *)(q void *)(x))
121 #else
122 #define __ICAST(q,a,x) ((q u_int/**/a/**/_t *)(q void *)(x))
123 #endif
124 #if (BYTE_ORDER == LITTLE_ENDIAN) && defined(UNALIGNED_ACCESS)
125 #define getushort(x) *__ICAST(const,16,x)
126 #define getulong(x) *__ICAST(const,32,x)
127 #define putushort(p, v) (void)(*__ICAST(,16,p) = (v))
128 #define putulong(p, v) (void)(*__ICAST(,32,p) = (v))
129 #else
130 #define getushort(x) ((u_int16_t)(__ICAST(const,8,x)[0] \
131 | (__ICAST(const,8,x)[1] << 8)))
132 #define getulong(x) ((u_int32_t)(__ICAST(const,8,x)[0] \
133 | (__ICAST(const,8,x)[1] << 8) \
134 | (__ICAST(const,8,x)[2] << 16) \
135 | (__ICAST(const,8,x)[3] << 24)))
136 #define putushort(p, v) (void)(__ICAST(,8,p)[0] = (v), \
137 __ICAST(,8,p)[1] = (v) >> 8)
138 #define putulong(p, v) (void)(__ICAST(,8,p)[0] = (v), \
139 __ICAST(,8,p)[1] = (v) >> 8, \
140 __ICAST(,8,p)[2] = (v) >> 16,\
141 __ICAST(,8,p)[3] = (v) >> 24)
142 #endif
143
144 /*
145 * BIOS Parameter Block (BPB) for DOS 3.3
146 */
147 struct byte_bpb33 {
148 int8_t bpbBytesPerSec[2]; /* bytes per sector */
149 int8_t bpbSecPerClust; /* sectors per cluster */
150 int8_t bpbResSectors[2]; /* number of reserved sectors */
151 int8_t bpbFATs; /* number of FATs */
152 int8_t bpbRootDirEnts[2]; /* number of root directory entries */
153 int8_t bpbSectors[2]; /* total number of sectors */
154 int8_t bpbMedia; /* media descriptor */
155 int8_t bpbFATsecs[2]; /* number of sectors per FAT */
156 int8_t bpbSecPerTrack[2]; /* sectors per track */
157 int8_t bpbHeads[2]; /* number of heads */
158 int8_t bpbHiddenSecs[2]; /* number of hidden sectors */
159 };
160
161 /*
162 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
163 * and bpbHugeSectors is not in the 3.3 bpb.
164 */
165 struct byte_bpb50 {
166 int8_t bpbBytesPerSec[2]; /* bytes per sector */
167 int8_t bpbSecPerClust; /* sectors per cluster */
168 int8_t bpbResSectors[2]; /* number of reserved sectors */
169 int8_t bpbFATs; /* number of FATs */
170 int8_t bpbRootDirEnts[2]; /* number of root directory entries */
171 int8_t bpbSectors[2]; /* total number of sectors */
172 int8_t bpbMedia; /* media descriptor */
173 int8_t bpbFATsecs[2]; /* number of sectors per FAT */
174 int8_t bpbSecPerTrack[2]; /* sectors per track */
175 int8_t bpbHeads[2]; /* number of heads */
176 int8_t bpbHiddenSecs[4]; /* number of hidden sectors */
177 int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
178 };
179
180 /*
181 * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
182 */
183 struct byte_bpb710 {
184 u_int8_t bpbBytesPerSec[2]; /* bytes per sector */
185 u_int8_t bpbSecPerClust; /* sectors per cluster */
186 u_int8_t bpbResSectors[2]; /* number of reserved sectors */
187 u_int8_t bpbFATs; /* number of FATs */
188 u_int8_t bpbRootDirEnts[2]; /* number of root directory entries */
189 u_int8_t bpbSectors[2]; /* total number of sectors */
190 u_int8_t bpbMedia; /* media descriptor */
191 u_int8_t bpbFATsecs[2]; /* number of sectors per FAT */
192 u_int8_t bpbSecPerTrack[2]; /* sectors per track */
193 u_int8_t bpbHeads[2]; /* number of heads */
194 u_int8_t bpbHiddenSecs[4]; /* # of hidden sectors */
195 u_int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
196 u_int8_t bpbBigFATsecs[4]; /* like bpbFATsecs for FAT32 */
197 u_int8_t bpbExtFlags[2]; /* extended flags: */
198 u_int8_t bpbFSVers[2]; /* filesystem version */
199 u_int8_t bpbRootClust[4]; /* start cluster for root directory */
200 u_int8_t bpbFSInfo[2]; /* filesystem info structure sector */
201 u_int8_t bpbBackup[2]; /* backup boot sector */
202 u_int8_t bpbReserved[12]; /* Reserved for future expansion */
203 };
204
205 /*
206 * FAT32 FSInfo block.
207 */
208 struct fsinfo {
209 u_int8_t fsisig1[4];
210 u_int8_t fsifill1[480];
211 u_int8_t fsisig2[4];
212 u_int8_t fsinfree[4];
213 u_int8_t fsinxtfree[4];
214 u_int8_t fsifill2[12];
215 u_int8_t fsisig3[4];
216 u_int8_t fsifill3[508];
217 u_int8_t fsisig4[4];
218 };
219 #endif /* _MSDOSFS_BPB_H_ */
Cache object: 62b353bc77cd4a0500863ae0fb0d5b70
|