1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/* $FreeBSD: src/sys/msdosfs/bpb.h,v 1.7 1999/08/28 00:48:07 peter Exp $ */
26/*	$NetBSD: bpb.h,v 1.7 1997/11/17 15:36:24 ws Exp $	*/
27
28/*
29 * Written by Paul Popelka (paulp@uts.amdahl.com)
30 *
31 * You can do anything you want with this software, just don't say you wrote
32 * it, and don't remove this notice.
33 *
34 * This software is provided "as is".
35 *
36 * The author supplies this software to be publicly redistributed on the
37 * understanding that the author is not responsible for the correct
38 * functioning of this software in any circumstances and is not liable for
39 * any damages caused by this software.
40 *
41 * October 1992
42 */
43
44
45/*
46 * The following structures represent how the bpb's look on disk.  shorts
47 * and longs are just character arrays of the appropriate length.  This is
48 * because the compiler forces shorts and longs to align on word or
49 * halfword boundaries.
50 *
51 * XXX The little-endian code here assumes that the processor can access
52 * 16-bit and 32-bit quantities on byte boundaries.  If this is not true,
53 * use the macros for the big-endian case.
54 */
55#include <machine/endian.h>
56#if (BYTE_ORDER == LITTLE_ENDIAN) 			/* && defined(UNALIGNED_ACCESS) */
57#define	getushort(x)	*((u_int16_t *)(x))
58#define	getulong(x)	*((u_int32_t *)(x))
59#else
60#define getushort(x)	(((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8))
61#define getulong(x)	(((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8) \
62			 + (((u_int8_t *)(x))[2] << 16)	\
63			 + (((u_int8_t *)(x))[3] << 24))
64#endif
65
66/*
67 * BPB for DOS 7.10 (FAT32).  This one has a few extensions to bpb50.
68 */
69struct byte_bpb710 {
70	u_int8_t bpbBytesPerSec[2];	/* bytes per sector */
71	u_int8_t bpbSecPerClust;	/* sectors per cluster */
72	u_int8_t bpbResSectors[2];	/* number of reserved sectors */
73	u_int8_t bpbFATs;		/* number of FATs */
74	u_int8_t bpbRootDirEnts[2];	/* number of root directory entries */
75	u_int8_t bpbSectors[2];		/* total number of sectors */
76	u_int8_t bpbMedia;		/* media descriptor */
77	u_int8_t bpbFATsecs[2];		/* number of sectors per FAT */
78	u_int8_t bpbSecPerTrack[2];	/* sectors per track */
79	u_int8_t bpbHeads[2];		/* number of heads */
80	u_int8_t bpbHiddenSecs[4];	/* # of hidden sectors */
81	u_int8_t bpbHugeSectors[4];	/* # of sectors if bpbSectors == 0 */
82	u_int8_t bpbBigFATsecs[4];	/* like bpbFATsecs for FAT32 */
83	u_int8_t bpbExtFlags[2];	/* extended flags: */
84	u_int8_t bpbFSVers[2];		/* filesystem version */
85	u_int8_t bpbRootClust[4];	/* start cluster for root directory */
86	u_int8_t bpbFSInfo[2];		/* filesystem info structure sector */
87	u_int8_t bpbBackup[2];		/* backup boot sector */
88	/* There is a 12 byte filler here, but we ignore it */
89};
90
91