xref: /titanic_51/usr/src/uts/common/sys/fs/pc_label.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_FS_PC_LABEL_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_FS_PC_LABEL_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate /*
39*7c478bd9Sstevel@tonic-gate  * PC master boot block & partition table defines.
40*7c478bd9Sstevel@tonic-gate  */
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate #define	PCB_BPSEC	11	/* (short) bytes per sector */
43*7c478bd9Sstevel@tonic-gate #define	PCB_SPC		13	/* (byte) sectors per cluster */
44*7c478bd9Sstevel@tonic-gate #define	PCB_RESSEC	14	/* (short) reserved sectors */
45*7c478bd9Sstevel@tonic-gate #define	PCB_NFAT	16	/* (byte) number of fats */
46*7c478bd9Sstevel@tonic-gate #define	PCB_NROOTENT	17	/* (short) number of root dir entries */
47*7c478bd9Sstevel@tonic-gate #define	PCB_NSEC	19	/* (short) number of sectors on disk */
48*7c478bd9Sstevel@tonic-gate #define	PCB_MEDIA	21	/* (byte) media descriptor */
49*7c478bd9Sstevel@tonic-gate #define	PCB_SPF		22	/* (short) sectors per fat */
50*7c478bd9Sstevel@tonic-gate #define	PCB_SPT		24	/* (short) sectors per track */
51*7c478bd9Sstevel@tonic-gate #define	PCB_NHEAD	26	/* (short) number of heads */
52*7c478bd9Sstevel@tonic-gate #define	PCB_HIDSEC	28	/* (short) number of hidden sectors */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate #define	PCFS_PART	0x1be	/* partition table offs in blk 0 of unit */
55*7c478bd9Sstevel@tonic-gate #define	PCFS_NUMPART	4	/* Number of partitions in blk 0 of unit */
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate /*
58*7c478bd9Sstevel@tonic-gate  *  Offsets into the boot sector where the string 'FAT' is expected.
59*7c478bd9Sstevel@tonic-gate  *  First value is where the string is on 12 and 16 bit FATs,
60*7c478bd9Sstevel@tonic-gate  *  the second value is where it is on 32 bit FATs.
61*7c478bd9Sstevel@tonic-gate  */
62*7c478bd9Sstevel@tonic-gate #define	PCFS_TYPESTRING_OFFSET16	0x36
63*7c478bd9Sstevel@tonic-gate #define	PCFS_TYPESTRING_OFFSET32	0x52
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate #define	PCFS_BPB	0xb	/* offset of the BPB in the boot block	*/
66*7c478bd9Sstevel@tonic-gate #define	PCFS_SIGN	0x1fe   /* offset of the DOS signature		*/
67*7c478bd9Sstevel@tonic-gate #define	DOS_SYSFAT12    1	/* DOS FAT 12 system indicator		*/
68*7c478bd9Sstevel@tonic-gate #define	DOS_SYSFAT16	4	/* DOS FAT 16 system indicator		*/
69*7c478bd9Sstevel@tonic-gate #define	DOS_SYSHUGE	6	/* DOS FAT 16 system indicator > 32MB	*/
70*7c478bd9Sstevel@tonic-gate #define	DOS_FAT32	0xB	/* FAT32 system indicator */
71*7c478bd9Sstevel@tonic-gate #define	DOS_FAT32_LBA	0xC	/* FAT32 system indicator (LBA) */
72*7c478bd9Sstevel@tonic-gate #define	DOS_FAT16P_LBA	0xE	/* FAT16 system indicator (Primary/LBA ) */
73*7c478bd9Sstevel@tonic-gate #define	DOS_FAT16_LBA	0xF	/* FAT16 system indicator (Extended/LBA) */
74*7c478bd9Sstevel@tonic-gate #define	DOS_F12MAXS	20740	/* Max sector for 12 Bit FAT (DOS>=3.2)	*/
75*7c478bd9Sstevel@tonic-gate #define	DOS_F12MAXC	4086	/* Max cluster for 12 Bit FAT (DOS>=3.2) */
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate #define	DOS_ID1		0xe9	/* JMP intrasegment			*/
78*7c478bd9Sstevel@tonic-gate #define	DOS_ID2a	0xeb    /* JMP short				*/
79*7c478bd9Sstevel@tonic-gate #define	DOS_ID2b	0x90
80*7c478bd9Sstevel@tonic-gate #define	DOS_SIGN	0xaa55	/* DOS signature in boot and partition	*/
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate #define	PC_FATBLOCK	1	/* starting block number of fat */
83*7c478bd9Sstevel@tonic-gate /*
84*7c478bd9Sstevel@tonic-gate  * Media descriptor byte.
85*7c478bd9Sstevel@tonic-gate  * Found in the boot block and in the first byte of the FAT.
86*7c478bd9Sstevel@tonic-gate  * Second and third byte in the FAT must be 0xFF.
87*7c478bd9Sstevel@tonic-gate  * Note that all technical sources indicate that this means of
88*7c478bd9Sstevel@tonic-gate  * identification is extremely unreliable.
89*7c478bd9Sstevel@tonic-gate  */
90*7c478bd9Sstevel@tonic-gate #define	MD_FIXED	0xF8	/* fixed disk				*/
91*7c478bd9Sstevel@tonic-gate #define	SS8SPT		0xFE	/* single sided 8 sectors per track	*/
92*7c478bd9Sstevel@tonic-gate #define	DS8SPT		0xFF	/* double sided 8 sectors per track	*/
93*7c478bd9Sstevel@tonic-gate #define	SS9SPT		0xFC	/* single sided 9 sectors per track	*/
94*7c478bd9Sstevel@tonic-gate #define	DS9SPT		0xFD	/* double sided 9 sectors per track	*/
95*7c478bd9Sstevel@tonic-gate #define	DS18SPT		0xF0	/* double sided 18 sectors per track	*/
96*7c478bd9Sstevel@tonic-gate #define	DS9_15SPT	0xF9	/* double sided 9/15 sectors per track	*/
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate #define	PC_SECSIZE	512	/* pc filesystem sector size */
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate /*
101*7c478bd9Sstevel@tonic-gate  * conversions to/from little endian format
102*7c478bd9Sstevel@tonic-gate  */
103*7c478bd9Sstevel@tonic-gate #if defined(_LITTLE_ENDIAN)
104*7c478bd9Sstevel@tonic-gate /* e.g. i386 machines */
105*7c478bd9Sstevel@tonic-gate #define	ltohs(S)	(*((ushort_t *)(&(S))))
106*7c478bd9Sstevel@tonic-gate #define	ltohi(I)	(*((uint_t *)(&(I))))
107*7c478bd9Sstevel@tonic-gate #define	htols(S)	(*((ushort_t *)(&(S))))
108*7c478bd9Sstevel@tonic-gate #define	htoli(I)	(*((uint_t *)(&(I))))
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate #else
111*7c478bd9Sstevel@tonic-gate /* e.g. SPARC machines */
112*7c478bd9Sstevel@tonic-gate #define	getbyte(A, N)	(((unsigned char *)(&(A)))[N])
113*7c478bd9Sstevel@tonic-gate #define	ltohs(S)	((getbyte(S, 1) << 8) | getbyte(S, 0))
114*7c478bd9Sstevel@tonic-gate #define	ltohi(I)	((getbyte(I, 3) << 24) | (getbyte(I, 2) << 16) | \
115*7c478bd9Sstevel@tonic-gate 			    (getbyte(I, 1) << 8) | getbyte(I, 0))
116*7c478bd9Sstevel@tonic-gate #define	htols(S)	((getbyte(S, 1) << 8) | getbyte(S, 0))
117*7c478bd9Sstevel@tonic-gate #define	htoli(I)	((getbyte(I, 3) << 24) | (getbyte(I, 2) << 16) | \
118*7c478bd9Sstevel@tonic-gate 			    (getbyte(I, 1) << 8) | getbyte(I, 0))
119*7c478bd9Sstevel@tonic-gate #endif
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
122*7c478bd9Sstevel@tonic-gate }
123*7c478bd9Sstevel@tonic-gate #endif
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_FS_PC_LABEL_H */
126