xref: /illumos-gate/usr/src/uts/common/sys/dktp/fdisk.h (revision b5134f31)
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
5df5e8b1fSmg  * Common Development and Distribution License (the "License").
6df5e8b1fSmg  * 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  */
217c478bd9Sstevel@tonic-gate /*
22df5e8b1fSmg  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988 AT&T	*/
267c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifndef _SYS_DKTP_FDISK_H
307c478bd9Sstevel@tonic-gate #define	_SYS_DKTP_FDISK_H
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /*
397c478bd9Sstevel@tonic-gate  * fdisk.h
407c478bd9Sstevel@tonic-gate  * This file defines the structure of physical disk sector 0 for use on
417c478bd9Sstevel@tonic-gate  * AT386 systems.  The format of this sector is constrained by the ROM
427c478bd9Sstevel@tonic-gate  * BIOS and MS-DOS conventions.
437c478bd9Sstevel@tonic-gate  * Note that this block does not define the partitions used by the unix
447c478bd9Sstevel@tonic-gate  * driver.  The unix partitions are obtained from the VTOC.
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate 
47df5e8b1fSmg /*
48df5e8b1fSmg  * BOOTSZ was reduced from 446 to 440 bytes to NOT overwrite the Windows
49df5e8b1fSmg  * Vista DISKID. Otherwise Vista won't boot from Solaris GRUB in a dual-boot
50df5e8b1fSmg  * setup.
51df5e8b1fSmg  * The actual size of mboot code is 425 bytes while that of GRUB stage1 is
52df5e8b1fSmg  * 423 bytes. So this changes does not harm them.
53df5e8b1fSmg  */
54df5e8b1fSmg #define	BOOTSZ		440	/* size of boot code in master boot block */
557c478bd9Sstevel@tonic-gate #define	FD_NUMPART	4	/* number of 'partitions' in fdisk table */
567c478bd9Sstevel@tonic-gate #define	MBB_MAGIC	0xAA55	/* magic number for mboot.signature */
577c478bd9Sstevel@tonic-gate #define	DEFAULT_INTLV	4	/* default interleave for testing tracks */
587c478bd9Sstevel@tonic-gate #define	MINPSIZE	4	/* minimum number of cylinders in a partition */
597c478bd9Sstevel@tonic-gate #define	TSTPAT		0xE5	/* test pattern for verifying disk */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * structure to hold the fdisk partition table
637c478bd9Sstevel@tonic-gate  */
647c478bd9Sstevel@tonic-gate struct ipart {
657c478bd9Sstevel@tonic-gate 	unsigned char bootid;	/* bootable or not */
667c478bd9Sstevel@tonic-gate 	unsigned char beghead;	/* beginning head, sector, cylinder */
677c478bd9Sstevel@tonic-gate 	unsigned char begsect;	/* begcyl is a 10-bit number. High 2 bits */
687c478bd9Sstevel@tonic-gate 	unsigned char begcyl;	/*	are in begsect. */
697c478bd9Sstevel@tonic-gate 	unsigned char systid;	/* OS type */
707c478bd9Sstevel@tonic-gate 	unsigned char endhead;	/* ending head, sector, cylinder */
717c478bd9Sstevel@tonic-gate 	unsigned char endsect;	/* endcyl is a 10-bit number.  High 2 bits */
727c478bd9Sstevel@tonic-gate 	unsigned char endcyl;	/*	are in endsect. */
737c478bd9Sstevel@tonic-gate 	int	relsect;	/* first sector relative to start of disk */
747c478bd9Sstevel@tonic-gate 	int	numsect;	/* number of sectors in partition */
757c478bd9Sstevel@tonic-gate };
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate  * Values for bootid.
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate #define	NOTACTIVE	0
807c478bd9Sstevel@tonic-gate #define	ACTIVE		128
817c478bd9Sstevel@tonic-gate /*
827c478bd9Sstevel@tonic-gate  * Values for systid.
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate #define	DOSOS12		1	/* DOS partition, 12-bit FAT */
857c478bd9Sstevel@tonic-gate #define	PCIXOS		2	/* PC/IX partition */
867c478bd9Sstevel@tonic-gate #define	DOSOS16		4	/* DOS partition, 16-bit FAT */
877c478bd9Sstevel@tonic-gate #define	EXTDOS		5	/* EXT-DOS partition */
887c478bd9Sstevel@tonic-gate #define	DOSHUGE		6	/* Huge DOS partition  > 32MB */
897c478bd9Sstevel@tonic-gate #define	FDISK_IFS	7	/* Installable File System (IFS): HPFS & NTFS */
907c478bd9Sstevel@tonic-gate #define	FDISK_AIXBOOT	8	/* AIX Boot */
917c478bd9Sstevel@tonic-gate #define	FDISK_AIXDATA	9	/* AIX Data */
927c478bd9Sstevel@tonic-gate #define	FDISK_OS2BOOT	10	/* OS/2 Boot Manager */
937c478bd9Sstevel@tonic-gate #define	FDISK_WINDOWS	11	/* Windows 95 FAT32 (up to 2047GB) */
947c478bd9Sstevel@tonic-gate #define	FDISK_EXT_WIN	12	/* Windows 95 FAT32 (extended-INT13) */
957c478bd9Sstevel@tonic-gate #define	FDISK_FAT95	14	/* DOS 16-bit FAT, LBA-mapped */
967c478bd9Sstevel@tonic-gate #define	FDISK_EXTLBA	15	/* Extended partition, LBA-mapped */
977c478bd9Sstevel@tonic-gate #define	DIAGPART	18	/* Diagnostic boot partition (OS independent) */
987c478bd9Sstevel@tonic-gate #define	FDISK_LINUX	65	/* Linux */
997c478bd9Sstevel@tonic-gate #define	FDISK_LINUXDSWAP	66	/* Linux swap (sharing disk w/ DRDOS) */
1007c478bd9Sstevel@tonic-gate #define	FDISK_LINUXDNAT	67	/* Linux native (sharing disk with DRDOS) */
1017c478bd9Sstevel@tonic-gate #define	FDISK_CPM	82	/* CP/M */
1027c478bd9Sstevel@tonic-gate #define	DOSDATA		86	/* DOS data partition */
1037c478bd9Sstevel@tonic-gate #define	OTHEROS		98	/* part. type for appl. (DB?) needs */
1047c478bd9Sstevel@tonic-gate 				/* raw partition.  ID was 0 but conflicted */
1057c478bd9Sstevel@tonic-gate 				/* with DOS 3.3 fdisk    */
1067c478bd9Sstevel@tonic-gate #define	UNIXOS		99	/* UNIX V.x partition */
1077c478bd9Sstevel@tonic-gate #define	UNUSED		100	/* unassigned partition */
1087c478bd9Sstevel@tonic-gate #define	FDISK_NOVELL3	101	/* Novell Netware 3.x and later */
1097c478bd9Sstevel@tonic-gate #define	FDISK_QNX4	119	/* QNX 4.x */
1107c478bd9Sstevel@tonic-gate #define	FDISK_QNX42	120	/* QNX 4.x 2nd part */
1117c478bd9Sstevel@tonic-gate #define	FDISK_QNX43	121	/* QNX 4.x 3rd part */
1127c478bd9Sstevel@tonic-gate #define	SUNIXOS		130	/* Solaris UNIX partition */
1137c478bd9Sstevel@tonic-gate #define	FDISK_LINUXNAT	131	/* Linux native */
1147c478bd9Sstevel@tonic-gate #define	FDISK_NTFSVOL1	134	/* NTFS volume set 1 */
1157c478bd9Sstevel@tonic-gate #define	FDISK_NTFSVOL2	135	/* NTFS volume set 2 */
1167c478bd9Sstevel@tonic-gate #define	FDISK_BSD	165	/* BSD/386, 386BSD, NetBSD, FreeBSD, OpenBSD */
1177c478bd9Sstevel@tonic-gate #define	FDISK_NEXTSTEP	167	/* NeXTSTEP */
1187c478bd9Sstevel@tonic-gate #define	FDISK_BSDIFS	183	/* BSDI file system */
1197c478bd9Sstevel@tonic-gate #define	FDISK_BSDISWAP	184	/* BSDI swap */
1207c478bd9Sstevel@tonic-gate #define	X86BOOT		190	/* x86 Solaris boot partition */
1217c478bd9Sstevel@tonic-gate #define	SUNIXOS2	191	/* Solaris UNIX partition */
1227c478bd9Sstevel@tonic-gate #define	EFI_PMBR	238	/* EFI PMBR */
1237c478bd9Sstevel@tonic-gate #define	EFI_FS		239	/* EFI File System (System Partition) */
1247c478bd9Sstevel@tonic-gate #define	MAXDOS		65535L	/* max size (sectors) for DOS partition */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate /*
1277c478bd9Sstevel@tonic-gate  * structure to hold master boot block in physical sector 0 of the disk.
1287c478bd9Sstevel@tonic-gate  * Note that partitions stuff can't be directly included in the structure
1297c478bd9Sstevel@tonic-gate  * because of lameo '386 compiler alignment design.
130*b5134f31Smg  * Alignment issues also force us to have 2 16bit entities for a single
131*b5134f31Smg  * 32bit win_volserno. It is not used anywhere anyway.
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate struct mboot {	/* master boot block */
135*b5134f31Smg 	char	bootinst[BOOTSZ];
136*b5134f31Smg 	uint16_t win_volserno_lo;
137*b5134f31Smg 	uint16_t win_volserno_hi;
138df5e8b1fSmg 	uint16_t reserved;
139*b5134f31Smg 	char	parts[FD_NUMPART * sizeof (struct ipart)];
1407c478bd9Sstevel@tonic-gate 	ushort_t signature;
1417c478bd9Sstevel@tonic-gate };
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1447c478bd9Sstevel@tonic-gate }
1457c478bd9Sstevel@tonic-gate #endif
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate #endif	/* _SYS_DKTP_FDISK_H */
148