xref: /titanic_52/usr/src/uts/common/sys/dktp/fdisk.h (revision aa1b14e7d68925d80eebf0ce8ed0b9cc55246546)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5df5e8b1fSmg147109  * Common Development and Distribution License (the "License").
6df5e8b1fSmg147109  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21342440ecSPrasad Singamsetty 
227c478bd9Sstevel@tonic-gate /*
23*aa1b14e7SSheshadri Vasudevan  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988 AT&T	*/
277c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef _SYS_DKTP_FDISK_H
317c478bd9Sstevel@tonic-gate #define	_SYS_DKTP_FDISK_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * fdisk.h
397c478bd9Sstevel@tonic-gate  * This file defines the structure of physical disk sector 0 for use on
407c478bd9Sstevel@tonic-gate  * AT386 systems.  The format of this sector is constrained by the ROM
417c478bd9Sstevel@tonic-gate  * BIOS and MS-DOS conventions.
427c478bd9Sstevel@tonic-gate  * Note that this block does not define the partitions used by the unix
437c478bd9Sstevel@tonic-gate  * driver.  The unix partitions are obtained from the VTOC.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate 
46df5e8b1fSmg147109 /*
47*aa1b14e7SSheshadri Vasudevan  * the MAX values are the maximum usable values for BIOS chs values
48*aa1b14e7SSheshadri Vasudevan  * The MAX_CYL value of 1022 is the maximum usable value
49*aa1b14e7SSheshadri Vasudevan  *   the value of 1023 is a fence value,
50*aa1b14e7SSheshadri Vasudevan  *   indicating no CHS geometry exists for the corresponding LBA value.
51*aa1b14e7SSheshadri Vasudevan  * HEAD range [ 0 .. MAX_HEAD ], so number of heads is (MAX_HEAD + 1)
52*aa1b14e7SSheshadri Vasudevan  * SECT range [ 1 .. MAX_SECT ], so number of sectors is (MAX_SECT)
53*aa1b14e7SSheshadri Vasudevan  */
54*aa1b14e7SSheshadri Vasudevan #define	MAX_SECT	(63)
55*aa1b14e7SSheshadri Vasudevan #define	MAX_CYL		(1022)
56*aa1b14e7SSheshadri Vasudevan #define	MAX_HEAD	(254)
57*aa1b14e7SSheshadri Vasudevan 
58*aa1b14e7SSheshadri Vasudevan /*
59df5e8b1fSmg147109  * BOOTSZ was reduced from 446 to 440 bytes to NOT overwrite the Windows
60df5e8b1fSmg147109  * Vista DISKID. Otherwise Vista won't boot from Solaris GRUB in a dual-boot
61df5e8b1fSmg147109  * setup.
62df5e8b1fSmg147109  * The actual size of mboot code is 425 bytes while that of GRUB stage1 is
63df5e8b1fSmg147109  * 423 bytes. So this changes does not harm them.
64df5e8b1fSmg147109  */
65df5e8b1fSmg147109 #define	BOOTSZ		440	/* size of boot code in master boot block */
667c478bd9Sstevel@tonic-gate #define	FD_NUMPART	4	/* number of 'partitions' in fdisk table */
677c478bd9Sstevel@tonic-gate #define	MBB_MAGIC	0xAA55	/* magic number for mboot.signature */
687c478bd9Sstevel@tonic-gate #define	DEFAULT_INTLV	4	/* default interleave for testing tracks */
697c478bd9Sstevel@tonic-gate #define	MINPSIZE	4	/* minimum number of cylinders in a partition */
707c478bd9Sstevel@tonic-gate #define	TSTPAT		0xE5	/* test pattern for verifying disk */
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * structure to hold the fdisk partition table
747c478bd9Sstevel@tonic-gate  */
757c478bd9Sstevel@tonic-gate struct ipart {
767c478bd9Sstevel@tonic-gate 	unsigned char bootid;	/* bootable or not */
777c478bd9Sstevel@tonic-gate 	unsigned char beghead;	/* beginning head, sector, cylinder */
787c478bd9Sstevel@tonic-gate 	unsigned char begsect;	/* begcyl is a 10-bit number. High 2 bits */
797c478bd9Sstevel@tonic-gate 	unsigned char begcyl;	/*	are in begsect. */
807c478bd9Sstevel@tonic-gate 	unsigned char systid;	/* OS type */
817c478bd9Sstevel@tonic-gate 	unsigned char endhead;	/* ending head, sector, cylinder */
827c478bd9Sstevel@tonic-gate 	unsigned char endsect;	/* endcyl is a 10-bit number.  High 2 bits */
837c478bd9Sstevel@tonic-gate 	unsigned char endcyl;	/*	are in endsect. */
84342440ecSPrasad Singamsetty 	uint32_t relsect;	/* first sector relative to start of disk */
85342440ecSPrasad Singamsetty 	uint32_t numsect;	/* number of sectors in partition */
867c478bd9Sstevel@tonic-gate };
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  * Values for bootid.
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate #define	NOTACTIVE	0
917c478bd9Sstevel@tonic-gate #define	ACTIVE		128
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  * Values for systid.
947c478bd9Sstevel@tonic-gate  */
95*aa1b14e7SSheshadri Vasudevan #define	UNUSED		0	/* Empty Partition */
967c478bd9Sstevel@tonic-gate #define	DOSOS12		1	/* DOS partition, 12-bit FAT */
977c478bd9Sstevel@tonic-gate #define	PCIXOS		2	/* PC/IX partition */
987c478bd9Sstevel@tonic-gate #define	DOSOS16		4	/* DOS partition, 16-bit FAT */
997c478bd9Sstevel@tonic-gate #define	EXTDOS		5	/* EXT-DOS partition */
1007c478bd9Sstevel@tonic-gate #define	DOSHUGE		6	/* Huge DOS partition  > 32MB */
1017c478bd9Sstevel@tonic-gate #define	FDISK_IFS	7	/* Installable File System (IFS): HPFS & NTFS */
1027c478bd9Sstevel@tonic-gate #define	FDISK_AIXBOOT	8	/* AIX Boot */
1037c478bd9Sstevel@tonic-gate #define	FDISK_AIXDATA	9	/* AIX Data */
1047c478bd9Sstevel@tonic-gate #define	FDISK_OS2BOOT	10	/* OS/2 Boot Manager */
1057c478bd9Sstevel@tonic-gate #define	FDISK_WINDOWS	11	/* Windows 95 FAT32 (up to 2047GB) */
1067c478bd9Sstevel@tonic-gate #define	FDISK_EXT_WIN	12	/* Windows 95 FAT32 (extended-INT13) */
1077c478bd9Sstevel@tonic-gate #define	FDISK_FAT95	14	/* DOS 16-bit FAT, LBA-mapped */
1087c478bd9Sstevel@tonic-gate #define	FDISK_EXTLBA	15	/* Extended partition, LBA-mapped */
1097c478bd9Sstevel@tonic-gate #define	DIAGPART	18	/* Diagnostic boot partition (OS independent) */
1107c478bd9Sstevel@tonic-gate #define	FDISK_LINUX	65	/* Linux */
1117c478bd9Sstevel@tonic-gate #define	FDISK_LINUXDSWAP	66	/* Linux swap (sharing disk w/ DRDOS) */
1127c478bd9Sstevel@tonic-gate #define	FDISK_LINUXDNAT	67	/* Linux native (sharing disk with DRDOS) */
1137c478bd9Sstevel@tonic-gate #define	FDISK_CPM	82	/* CP/M */
1147c478bd9Sstevel@tonic-gate #define	DOSDATA		86	/* DOS data partition */
1157c478bd9Sstevel@tonic-gate #define	OTHEROS		98	/* part. type for appl. (DB?) needs */
1167c478bd9Sstevel@tonic-gate 				/* raw partition.  ID was 0 but conflicted */
1177c478bd9Sstevel@tonic-gate 				/* with DOS 3.3 fdisk    */
1187c478bd9Sstevel@tonic-gate #define	UNIXOS		99	/* UNIX V.x partition */
119*aa1b14e7SSheshadri Vasudevan #define	FDISK_NOVELL2	100	/* Novell Netware 286 */
1207c478bd9Sstevel@tonic-gate #define	FDISK_NOVELL3	101	/* Novell Netware 3.x and later */
1217c478bd9Sstevel@tonic-gate #define	FDISK_QNX4	119	/* QNX 4.x */
1227c478bd9Sstevel@tonic-gate #define	FDISK_QNX42	120	/* QNX 4.x 2nd part */
1237c478bd9Sstevel@tonic-gate #define	FDISK_QNX43	121	/* QNX 4.x 3rd part */
1247c478bd9Sstevel@tonic-gate #define	SUNIXOS		130	/* Solaris UNIX partition */
1257c478bd9Sstevel@tonic-gate #define	FDISK_LINUXNAT	131	/* Linux native */
1267c478bd9Sstevel@tonic-gate #define	FDISK_NTFSVOL1	134	/* NTFS volume set 1 */
1277c478bd9Sstevel@tonic-gate #define	FDISK_NTFSVOL2	135	/* NTFS volume set 2 */
1287c478bd9Sstevel@tonic-gate #define	FDISK_BSD	165	/* BSD/386, 386BSD, NetBSD, FreeBSD, OpenBSD */
1297c478bd9Sstevel@tonic-gate #define	FDISK_NEXTSTEP	167	/* NeXTSTEP */
1307c478bd9Sstevel@tonic-gate #define	FDISK_BSDIFS	183	/* BSDI file system */
1317c478bd9Sstevel@tonic-gate #define	FDISK_BSDISWAP	184	/* BSDI swap */
1327c478bd9Sstevel@tonic-gate #define	X86BOOT		190	/* x86 Solaris boot partition */
1337c478bd9Sstevel@tonic-gate #define	SUNIXOS2	191	/* Solaris UNIX partition */
1347c478bd9Sstevel@tonic-gate #define	EFI_PMBR	238	/* EFI PMBR */
1357c478bd9Sstevel@tonic-gate #define	EFI_FS		239	/* EFI File System (System Partition) */
1367c478bd9Sstevel@tonic-gate #define	MAXDOS		65535L	/* max size (sectors) for DOS partition */
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate /*
1397c478bd9Sstevel@tonic-gate  * structure to hold master boot block in physical sector 0 of the disk.
1407c478bd9Sstevel@tonic-gate  * Note that partitions stuff can't be directly included in the structure
1417c478bd9Sstevel@tonic-gate  * because of lameo '386 compiler alignment design.
142b5134f31Smg147109  * Alignment issues also force us to have 2 16bit entities for a single
143b5134f31Smg147109  * 32bit win_volserno. It is not used anywhere anyway.
1447c478bd9Sstevel@tonic-gate  */
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate struct mboot {	/* master boot block */
1477c478bd9Sstevel@tonic-gate 	char	bootinst[BOOTSZ];
148b5134f31Smg147109 	uint16_t win_volserno_lo;
149b5134f31Smg147109 	uint16_t win_volserno_hi;
150df5e8b1fSmg147109 	uint16_t reserved;
1517c478bd9Sstevel@tonic-gate 	char	parts[FD_NUMPART * sizeof (struct ipart)];
1527c478bd9Sstevel@tonic-gate 	ushort_t signature;
1537c478bd9Sstevel@tonic-gate };
1547c478bd9Sstevel@tonic-gate 
155*aa1b14e7SSheshadri Vasudevan #if defined(__i386) || defined(__amd64)
156*aa1b14e7SSheshadri Vasudevan 
157*aa1b14e7SSheshadri Vasudevan /* Byte offset of the start of the partition table within the sector */
158*aa1b14e7SSheshadri Vasudevan #define	FDISK_PART_TABLE_START	446
159*aa1b14e7SSheshadri Vasudevan 
160*aa1b14e7SSheshadri Vasudevan /* Maximum number of valid partitions assumed as 32 */
161*aa1b14e7SSheshadri Vasudevan #define	MAX_EXT_PARTS	32
162*aa1b14e7SSheshadri Vasudevan 
163*aa1b14e7SSheshadri Vasudevan #else
164*aa1b14e7SSheshadri Vasudevan 
165*aa1b14e7SSheshadri Vasudevan #define	MAX_EXT_PARTS	0
166*aa1b14e7SSheshadri Vasudevan 
167*aa1b14e7SSheshadri Vasudevan #endif	/* if defined(__i386) || defined(__amd64) */
168*aa1b14e7SSheshadri Vasudevan 
1697c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1707c478bd9Sstevel@tonic-gate }
1717c478bd9Sstevel@tonic-gate #endif
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate #endif	/* _SYS_DKTP_FDISK_H */
174