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