1 /* $FreeBSD: head/sys/fs/msdosfs/bpb.h 203827 2010-02-13 12:41:07Z kib $ */
2 /* $NetBSD: bpb.h,v 1.7 1997/11/17 15:36:24 ws Exp $ */
5 * Written by Paul Popelka (paulp@uts.amdahl.com)
7 * You can do anything you want with this software, just don't say you wrote
8 * it, and don't remove this notice.
10 * This software is provided "as is".
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.
20 #ifndef _VFS_MSDOSFS_BPB_H_
21 #define _VFS_MSDOSFS_BPB_H_
24 * BIOS Parameter Block (BPB) for DOS 3.3
27 u_int16_t bpbBytesPerSec
; /* bytes per sector */
28 u_int8_t bpbSecPerClust
; /* sectors per cluster */
29 u_int16_t bpbResSectors
; /* number of reserved sectors */
30 u_int8_t bpbFATs
; /* number of FATs */
31 u_int16_t bpbRootDirEnts
; /* number of root directory entries */
32 u_int16_t bpbSectors
; /* total number of sectors */
33 u_int8_t bpbMedia
; /* media descriptor */
34 u_int16_t bpbFATsecs
; /* number of sectors per FAT */
35 u_int16_t bpbSecPerTrack
; /* sectors per track */
36 u_int16_t bpbHeads
; /* number of heads */
37 u_int16_t bpbHiddenSecs
; /* number of hidden sectors */
41 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
42 * and bpbHugeSectors is not in the 3.3 bpb.
45 u_int16_t bpbBytesPerSec
; /* bytes per sector */
46 u_int8_t bpbSecPerClust
; /* sectors per cluster */
47 u_int16_t bpbResSectors
; /* number of reserved sectors */
48 u_int8_t bpbFATs
; /* number of FATs */
49 u_int16_t bpbRootDirEnts
; /* number of root directory entries */
50 u_int16_t bpbSectors
; /* total number of sectors */
51 u_int8_t bpbMedia
; /* media descriptor */
52 u_int16_t bpbFATsecs
; /* number of sectors per FAT */
53 u_int16_t bpbSecPerTrack
; /* sectors per track */
54 u_int16_t bpbHeads
; /* number of heads */
55 u_int32_t bpbHiddenSecs
; /* # of hidden sectors */
56 u_int32_t bpbHugeSectors
; /* # of sectors if bpbSectors == 0 */
60 * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
63 u_int16_t bpbBytesPerSec
; /* bytes per sector */
64 u_int8_t bpbSecPerClust
; /* sectors per cluster */
65 u_int16_t bpbResSectors
; /* number of reserved sectors */
66 u_int8_t bpbFATs
; /* number of FATs */
67 u_int16_t bpbRootDirEnts
; /* number of root directory entries */
68 u_int16_t bpbSectors
; /* total number of sectors */
69 u_int8_t bpbMedia
; /* media descriptor */
70 u_int16_t bpbFATsecs
; /* number of sectors per FAT */
71 u_int16_t bpbSecPerTrack
; /* sectors per track */
72 u_int16_t bpbHeads
; /* number of heads */
73 u_int32_t bpbHiddenSecs
; /* # of hidden sectors */
74 u_int32_t bpbHugeSectors
; /* # of sectors if bpbSectors == 0 */
75 u_int32_t bpbBigFATsecs
; /* like bpbFATsecs for FAT32 */
76 u_int16_t bpbExtFlags
; /* extended flags: */
77 #define FATNUM 0xf /* mask for numbering active FAT */
78 #define FATMIRROR 0x80 /* FAT is mirrored (like it always was) */
79 u_int16_t bpbFSVers
; /* filesystem version */
80 #define FSVERS 0 /* currently only 0 is understood */
81 u_int32_t bpbRootClust
; /* start cluster for root directory */
82 u_int16_t bpbFSInfo
; /* filesystem info structure sector */
83 u_int16_t bpbBackup
; /* backup boot sector */
84 u_int8_t bpbReserved
[12]; /* reserved for future expansion */
89 * BPB for gemdos filesystems. Atari leaves the obsolete stuff undefined.
90 * Currently there is no need for a separate BPB structure.
94 u_int16_t bpbBytesPerSec
; /* bytes per sector */
95 u_int8_t bpbSecPerClust
; /* sectors per cluster */
96 u_int16_t bpbResSectors
; /* number of reserved sectors */
97 u_int8_t bpbFATs
; /* number of FATs */
98 u_int16_t bpbRootDirEnts
; /* number of root directory entries */
99 u_int16_t bpbSectors
; /* total number of sectors */
100 u_int8_t bpbUseless1
; /* meaningless on gemdos fs */
101 u_int16_t bpbFATsecs
; /* number of sectors per FAT */
102 u_int16_t bpbUseless2
; /* meaningless for harddisk fs */
103 u_int16_t bpbUseless3
; /* meaningless for harddisk fs */
104 u_int16_t bpbHiddenSecs
; /* the TOS-BIOS ignores this */
110 * The following structures represent how the bpb's look on disk. shorts
111 * and longs are just character arrays of the appropriate length. This is
112 * because the compiler forces shorts and longs to align on word or
113 * halfword boundaries.
116 #include <sys/endian.h>
118 #define getushort(x) le16dec(x)
119 #define getulong(x) le32dec(x)
120 #define putushort(p, v) le16enc(p, v)
121 #define putulong(p, v) le32enc(p, v)
124 * BIOS Parameter Block (BPB) for DOS 3.3
127 int8_t bpbBytesPerSec
[2]; /* bytes per sector */
128 int8_t bpbSecPerClust
; /* sectors per cluster */
129 int8_t bpbResSectors
[2]; /* number of reserved sectors */
130 int8_t bpbFATs
; /* number of FATs */
131 int8_t bpbRootDirEnts
[2]; /* number of root directory entries */
132 int8_t bpbSectors
[2]; /* total number of sectors */
133 int8_t bpbMedia
; /* media descriptor */
134 int8_t bpbFATsecs
[2]; /* number of sectors per FAT */
135 int8_t bpbSecPerTrack
[2]; /* sectors per track */
136 int8_t bpbHeads
[2]; /* number of heads */
137 int8_t bpbHiddenSecs
[2]; /* number of hidden sectors */
141 * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
142 * and bpbHugeSectors is not in the 3.3 bpb.
145 int8_t bpbBytesPerSec
[2]; /* bytes per sector */
146 int8_t bpbSecPerClust
; /* sectors per cluster */
147 int8_t bpbResSectors
[2]; /* number of reserved sectors */
148 int8_t bpbFATs
; /* number of FATs */
149 int8_t bpbRootDirEnts
[2]; /* number of root directory entries */
150 int8_t bpbSectors
[2]; /* total number of sectors */
151 int8_t bpbMedia
; /* media descriptor */
152 int8_t bpbFATsecs
[2]; /* number of sectors per FAT */
153 int8_t bpbSecPerTrack
[2]; /* sectors per track */
154 int8_t bpbHeads
[2]; /* number of heads */
155 int8_t bpbHiddenSecs
[4]; /* number of hidden sectors */
156 int8_t bpbHugeSectors
[4]; /* # of sectors if bpbSectors == 0 */
160 * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
163 u_int8_t bpbBytesPerSec
[2]; /* bytes per sector */
164 u_int8_t bpbSecPerClust
; /* sectors per cluster */
165 u_int8_t bpbResSectors
[2]; /* number of reserved sectors */
166 u_int8_t bpbFATs
; /* number of FATs */
167 u_int8_t bpbRootDirEnts
[2]; /* number of root directory entries */
168 u_int8_t bpbSectors
[2]; /* total number of sectors */
169 u_int8_t bpbMedia
; /* media descriptor */
170 u_int8_t bpbFATsecs
[2]; /* number of sectors per FAT */
171 u_int8_t bpbSecPerTrack
[2]; /* sectors per track */
172 u_int8_t bpbHeads
[2]; /* number of heads */
173 u_int8_t bpbHiddenSecs
[4]; /* # of hidden sectors */
174 u_int8_t bpbHugeSectors
[4]; /* # of sectors if bpbSectors == 0 */
175 u_int8_t bpbBigFATsecs
[4]; /* like bpbFATsecs for FAT32 */
176 u_int8_t bpbExtFlags
[2]; /* extended flags: */
177 u_int8_t bpbFSVers
[2]; /* filesystem version */
178 u_int8_t bpbRootClust
[4]; /* start cluster for root directory */
179 u_int8_t bpbFSInfo
[2]; /* filesystem info structure sector */
180 u_int8_t bpbBackup
[2]; /* backup boot sector */
181 u_int8_t bpbReserved
[12]; /* reserved for future expansion */
185 * FAT32 FSInfo block.
189 u_int8_t fsifill1
[480];
191 u_int8_t fsinfree
[4];
192 u_int8_t fsinxtfree
[4];
193 u_int8_t fsifill2
[12];
195 u_int8_t fsifill3
[508];
199 #endif /* !_VFS_MSDOSFS_BPB_H_ */