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 5342440ecSPrasad Singamsetty * Common Development and Distribution License (the "License"). 6342440ecSPrasad Singamsetty * 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*65908c77Syu, larry liu - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_DKLABEL_H 287c478bd9Sstevel@tonic-gate #define _SYS_DKLABEL_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 317c478bd9Sstevel@tonic-gate #include <sys/types32.h> 327c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 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 * Miscellaneous defines 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate #define DKL_MAGIC 0xDABE /* magic number */ 427c478bd9Sstevel@tonic-gate #define FKL_MAGIC 0xff /* magic number for DOS floppies */ 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #if defined(_SUNOS_VTOC_16) 457c478bd9Sstevel@tonic-gate #define NDKMAP 16 /* # of logical partitions */ 467c478bd9Sstevel@tonic-gate #define DK_LABEL_LOC 1 /* location of disk label */ 477c478bd9Sstevel@tonic-gate #elif defined(_SUNOS_VTOC_8) 487c478bd9Sstevel@tonic-gate #define NDKMAP 8 /* # of logical partitions */ 497c478bd9Sstevel@tonic-gate #define DK_LABEL_LOC 0 /* location of disk label */ 507c478bd9Sstevel@tonic-gate #else 517c478bd9Sstevel@tonic-gate #error "No VTOC format defined." 527c478bd9Sstevel@tonic-gate #endif 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate #define LEN_DKL_ASCII 128 /* length of dkl_asciilabel */ 557c478bd9Sstevel@tonic-gate #define LEN_DKL_VVOL 8 /* length of v_volume */ 567c478bd9Sstevel@tonic-gate #define DK_LABEL_SIZE 512 /* size of disk label */ 577c478bd9Sstevel@tonic-gate #define DK_MAX_BLOCKS 0x7fffffff /* max # of blocks handled */ 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate /* 607c478bd9Sstevel@tonic-gate * Reserve two cylinders on SCSI disks. 617c478bd9Sstevel@tonic-gate * One is for the backup disk label and the other is for the deviceid. 627c478bd9Sstevel@tonic-gate * 637c478bd9Sstevel@tonic-gate * IPI disks only reserve one cylinder, but they will go away soon. 647c478bd9Sstevel@tonic-gate * CDROMs do not reserve any cylinders. 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate #define DK_ACYL 2 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * Format of a Sun disk label. 707c478bd9Sstevel@tonic-gate * Resides in cylinder 0, head 0, sector 0. 717c478bd9Sstevel@tonic-gate * 727c478bd9Sstevel@tonic-gate * sizeof (struct dk_label) should be 512 (the current sector size), 737c478bd9Sstevel@tonic-gate * but should the sector size increase, this structure should remain 747c478bd9Sstevel@tonic-gate * at the beginning of the sector. 757c478bd9Sstevel@tonic-gate */ 767c478bd9Sstevel@tonic-gate 77342440ecSPrasad Singamsetty #if !defined(BLKADDR_TYPE) 78342440ecSPrasad Singamsetty #define BLKADDR_TYPE 79342440ecSPrasad Singamsetty #if defined(_EXTVTOC) 80342440ecSPrasad Singamsetty typedef unsigned long blkaddr_t; 81342440ecSPrasad Singamsetty typedef unsigned int blkaddr32_t; 82342440ecSPrasad Singamsetty #else 83342440ecSPrasad Singamsetty typedef daddr_t blkaddr_t; 84342440ecSPrasad Singamsetty typedef daddr32_t blkaddr32_t; 85342440ecSPrasad Singamsetty #endif 86342440ecSPrasad Singamsetty #endif 87342440ecSPrasad Singamsetty 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * partition headers: section 1 907c478bd9Sstevel@tonic-gate * Returned in struct dk_allmap by ioctl DKIOC[SG]APART (dkio(7I)) 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate struct dk_map { 93342440ecSPrasad Singamsetty blkaddr_t dkl_cylno; /* starting cylinder */ 94342440ecSPrasad Singamsetty blkaddr_t dkl_nblk; /* number of blocks; if == 0, */ 957c478bd9Sstevel@tonic-gate /* partition is undefined */ 967c478bd9Sstevel@tonic-gate }; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * partition headers: section 1 1007c478bd9Sstevel@tonic-gate * Fixed size for on-disk dk_label 1017c478bd9Sstevel@tonic-gate */ 1027c478bd9Sstevel@tonic-gate struct dk_map32 { 103342440ecSPrasad Singamsetty blkaddr32_t dkl_cylno; /* starting cylinder */ 104342440ecSPrasad Singamsetty blkaddr32_t dkl_nblk; /* number of blocks; if == 0, */ 1057c478bd9Sstevel@tonic-gate /* partition is undefined */ 1067c478bd9Sstevel@tonic-gate }; 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* 1097c478bd9Sstevel@tonic-gate * partition headers: section 2, 1107c478bd9Sstevel@tonic-gate * brought over from AT&T SVr4 vtoc structure. 1117c478bd9Sstevel@tonic-gate */ 1127c478bd9Sstevel@tonic-gate struct dk_map2 { 1137c478bd9Sstevel@tonic-gate uint16_t p_tag; /* ID tag of partition */ 1147c478bd9Sstevel@tonic-gate uint16_t p_flag; /* permission flag */ 1157c478bd9Sstevel@tonic-gate }; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate struct dkl_partition { 1187c478bd9Sstevel@tonic-gate uint16_t p_tag; /* ID tag of partition */ 1197c478bd9Sstevel@tonic-gate uint16_t p_flag; /* permision flags */ 120342440ecSPrasad Singamsetty blkaddr32_t p_start; /* start sector no of partition */ 121342440ecSPrasad Singamsetty blkaddr32_t p_size; /* # of blocks in partition */ 1227c478bd9Sstevel@tonic-gate }; 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate /* 1267c478bd9Sstevel@tonic-gate * VTOC inclusions from AT&T SVr4 1277c478bd9Sstevel@tonic-gate * Fixed sized types for on-disk VTOC 1287c478bd9Sstevel@tonic-gate */ 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate struct dk_vtoc { 1317c478bd9Sstevel@tonic-gate #if defined(_SUNOS_VTOC_16) 1327c478bd9Sstevel@tonic-gate uint32_t v_bootinfo[3]; /* info for mboot (unsupported) */ 1337c478bd9Sstevel@tonic-gate uint32_t v_sanity; /* to verify vtoc sanity */ 1347c478bd9Sstevel@tonic-gate uint32_t v_version; /* layout version */ 1357c478bd9Sstevel@tonic-gate char v_volume[LEN_DKL_VVOL]; /* volume name */ 1367c478bd9Sstevel@tonic-gate uint16_t v_sectorsz; /* sector size in bytes */ 1377c478bd9Sstevel@tonic-gate uint16_t v_nparts; /* number of partitions */ 1387c478bd9Sstevel@tonic-gate uint32_t v_reserved[10]; /* free space */ 1397c478bd9Sstevel@tonic-gate struct dkl_partition v_part[NDKMAP]; /* partition headers */ 1407c478bd9Sstevel@tonic-gate time32_t timestamp[NDKMAP]; /* partition timestamp (unsupported) */ 1417c478bd9Sstevel@tonic-gate char v_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ 1427c478bd9Sstevel@tonic-gate #elif defined(_SUNOS_VTOC_8) 1437c478bd9Sstevel@tonic-gate uint32_t v_version; /* layout version */ 1447c478bd9Sstevel@tonic-gate char v_volume[LEN_DKL_VVOL]; /* volume name */ 1457c478bd9Sstevel@tonic-gate uint16_t v_nparts; /* number of partitions */ 1467c478bd9Sstevel@tonic-gate struct dk_map2 v_part[NDKMAP]; /* partition hdrs, sec 2 */ 1477c478bd9Sstevel@tonic-gate uint32_t v_bootinfo[3]; /* info needed by mboot */ 1487c478bd9Sstevel@tonic-gate uint32_t v_sanity; /* to verify vtoc sanity */ 1497c478bd9Sstevel@tonic-gate uint32_t v_reserved[10]; /* free space */ 1507c478bd9Sstevel@tonic-gate time32_t v_timestamp[NDKMAP]; /* partition timestamp */ 1517c478bd9Sstevel@tonic-gate #else 1527c478bd9Sstevel@tonic-gate #error "No VTOC format defined." 1537c478bd9Sstevel@tonic-gate #endif 1547c478bd9Sstevel@tonic-gate }; 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate /* 1577c478bd9Sstevel@tonic-gate * define the amount of disk label padding needed to make 1587c478bd9Sstevel@tonic-gate * the entire structure occupy 512 bytes. 1597c478bd9Sstevel@tonic-gate */ 1607c478bd9Sstevel@tonic-gate #if defined(_SUNOS_VTOC_16) 1617c478bd9Sstevel@tonic-gate #define LEN_DKL_PAD (DK_LABEL_SIZE - \ 1627c478bd9Sstevel@tonic-gate ((sizeof (struct dk_vtoc) + \ 1637c478bd9Sstevel@tonic-gate (4 * sizeof (uint32_t)) + \ 1647c478bd9Sstevel@tonic-gate (12 * sizeof (uint16_t)) + \ 1657c478bd9Sstevel@tonic-gate (2 * (sizeof (uint16_t)))))) 1667c478bd9Sstevel@tonic-gate #elif defined(_SUNOS_VTOC_8) 1677c478bd9Sstevel@tonic-gate #define LEN_DKL_PAD (DK_LABEL_SIZE \ 1687c478bd9Sstevel@tonic-gate - ((LEN_DKL_ASCII) + \ 1697c478bd9Sstevel@tonic-gate (sizeof (struct dk_vtoc)) + \ 1707c478bd9Sstevel@tonic-gate (sizeof (struct dk_map32) * NDKMAP) + \ 1717c478bd9Sstevel@tonic-gate (14 * (sizeof (uint16_t))) + \ 1727c478bd9Sstevel@tonic-gate (2 * (sizeof (uint16_t))))) 1737c478bd9Sstevel@tonic-gate #else 1747c478bd9Sstevel@tonic-gate #error "No VTOC format defined." 1757c478bd9Sstevel@tonic-gate #endif 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate struct dk_label { 1797c478bd9Sstevel@tonic-gate #if defined(_SUNOS_VTOC_16) 1807c478bd9Sstevel@tonic-gate struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */ 1817c478bd9Sstevel@tonic-gate uint32_t dkl_pcyl; /* # of physical cylinders */ 1827c478bd9Sstevel@tonic-gate uint32_t dkl_ncyl; /* # of data cylinders */ 1837c478bd9Sstevel@tonic-gate uint16_t dkl_acyl; /* # of alternate cylinders */ 1847c478bd9Sstevel@tonic-gate uint16_t dkl_bcyl; /* cyl offset (for fixed head area) */ 1857c478bd9Sstevel@tonic-gate uint32_t dkl_nhead; /* # of heads */ 1867c478bd9Sstevel@tonic-gate uint32_t dkl_nsect; /* # of data sectors per track */ 1877c478bd9Sstevel@tonic-gate uint16_t dkl_intrlv; /* interleave factor */ 1887c478bd9Sstevel@tonic-gate uint16_t dkl_skew; /* skew factor */ 1897c478bd9Sstevel@tonic-gate uint16_t dkl_apc; /* alternates per cyl (SCSI only) */ 1907c478bd9Sstevel@tonic-gate uint16_t dkl_rpm; /* revolutions per minute */ 1917c478bd9Sstevel@tonic-gate uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */ 1927c478bd9Sstevel@tonic-gate uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */ 1937c478bd9Sstevel@tonic-gate uint16_t dkl_extra[4]; /* for compatible expansion */ 1947c478bd9Sstevel@tonic-gate char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */ 1957c478bd9Sstevel@tonic-gate #elif defined(_SUNOS_VTOC_8) 1967c478bd9Sstevel@tonic-gate char dkl_asciilabel[LEN_DKL_ASCII]; /* for compatibility */ 1977c478bd9Sstevel@tonic-gate struct dk_vtoc dkl_vtoc; /* vtoc inclusions from AT&T SVr4 */ 1987c478bd9Sstevel@tonic-gate uint16_t dkl_write_reinstruct; /* # sectors to skip, writes */ 1997c478bd9Sstevel@tonic-gate uint16_t dkl_read_reinstruct; /* # sectors to skip, reads */ 2007c478bd9Sstevel@tonic-gate char dkl_pad[LEN_DKL_PAD]; /* unused part of 512 bytes */ 2017c478bd9Sstevel@tonic-gate uint16_t dkl_rpm; /* rotations per minute */ 2027c478bd9Sstevel@tonic-gate uint16_t dkl_pcyl; /* # physical cylinders */ 2037c478bd9Sstevel@tonic-gate uint16_t dkl_apc; /* alternates per cylinder */ 2047c478bd9Sstevel@tonic-gate uint16_t dkl_obs1; /* obsolete */ 2057c478bd9Sstevel@tonic-gate uint16_t dkl_obs2; /* obsolete */ 2067c478bd9Sstevel@tonic-gate uint16_t dkl_intrlv; /* interleave factor */ 2077c478bd9Sstevel@tonic-gate uint16_t dkl_ncyl; /* # of data cylinders */ 2087c478bd9Sstevel@tonic-gate uint16_t dkl_acyl; /* # of alternate cylinders */ 2097c478bd9Sstevel@tonic-gate uint16_t dkl_nhead; /* # of heads in this partition */ 210*65908c77Syu, larry liu - Sun Microsystems - Beijing China uint16_t dkl_nsect; /* # of sectors per track */ 2117c478bd9Sstevel@tonic-gate uint16_t dkl_obs3; /* obsolete */ 2127c478bd9Sstevel@tonic-gate uint16_t dkl_obs4; /* obsolete */ 2137c478bd9Sstevel@tonic-gate struct dk_map32 dkl_map[NDKMAP]; /* logical partition headers */ 2147c478bd9Sstevel@tonic-gate #else 2157c478bd9Sstevel@tonic-gate #error "No VTOC format defined." 2167c478bd9Sstevel@tonic-gate #endif 2177c478bd9Sstevel@tonic-gate uint16_t dkl_magic; /* identifies this label format */ 2187c478bd9Sstevel@tonic-gate uint16_t dkl_cksum; /* xor checksum of sector */ 2197c478bd9Sstevel@tonic-gate }; 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate #if defined(_SUNOS_VTOC_16) 2227c478bd9Sstevel@tonic-gate #define dkl_asciilabel dkl_vtoc.v_asciilabel 2237c478bd9Sstevel@tonic-gate #define v_timestamp timestamp 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate #elif defined(_SUNOS_VTOC_8) 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate /* 2287c478bd9Sstevel@tonic-gate * These defines are for historic compatibility with old drivers. 2297c478bd9Sstevel@tonic-gate */ 2307c478bd9Sstevel@tonic-gate #define dkl_gap1 dkl_obs1 /* used to be gap1 */ 2317c478bd9Sstevel@tonic-gate #define dkl_gap2 dkl_obs2 /* used to be gap2 */ 2327c478bd9Sstevel@tonic-gate #define dkl_bhead dkl_obs3 /* used to be label head offset */ 2337c478bd9Sstevel@tonic-gate #define dkl_ppart dkl_obs4 /* used to by physical partition */ 2347c478bd9Sstevel@tonic-gate #else 2357c478bd9Sstevel@tonic-gate #error "No VTOC format defined." 2367c478bd9Sstevel@tonic-gate #endif 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate struct fk_label { /* DOS floppy label */ 2397c478bd9Sstevel@tonic-gate uchar_t fkl_type; 2407c478bd9Sstevel@tonic-gate uchar_t fkl_magich; 2417c478bd9Sstevel@tonic-gate uchar_t fkl_magicl; 2427c478bd9Sstevel@tonic-gate uchar_t filler; 2437c478bd9Sstevel@tonic-gate }; 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate /* 2467c478bd9Sstevel@tonic-gate * Layout of stored fabricated device id (on-disk) 2477c478bd9Sstevel@tonic-gate */ 2487c478bd9Sstevel@tonic-gate #define DK_DEVID_BLKSIZE (512) 2497c478bd9Sstevel@tonic-gate #define DK_DEVID_SIZE (DK_DEVID_BLKSIZE - ((sizeof (uchar_t) * 7))) 2507c478bd9Sstevel@tonic-gate #define DK_DEVID_REV_MSB (0) 2517c478bd9Sstevel@tonic-gate #define DK_DEVID_REV_LSB (1) 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate struct dk_devid { 2547c478bd9Sstevel@tonic-gate uchar_t dkd_rev_hi; /* revision (MSB) */ 2557c478bd9Sstevel@tonic-gate uchar_t dkd_rev_lo; /* revision (LSB) */ 2567c478bd9Sstevel@tonic-gate uchar_t dkd_flags; /* flags (not used yet) */ 2577c478bd9Sstevel@tonic-gate uchar_t dkd_devid[DK_DEVID_SIZE]; /* devid stored here */ 2587c478bd9Sstevel@tonic-gate uchar_t dkd_checksum3; /* checksum (MSB) */ 2597c478bd9Sstevel@tonic-gate uchar_t dkd_checksum2; 2607c478bd9Sstevel@tonic-gate uchar_t dkd_checksum1; 2617c478bd9Sstevel@tonic-gate uchar_t dkd_checksum0; /* checksum (LSB) */ 2627c478bd9Sstevel@tonic-gate }; 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate #define DKD_GETCHKSUM(dkd) ((dkd)->dkd_checksum3 << 24) + \ 2657c478bd9Sstevel@tonic-gate ((dkd)->dkd_checksum2 << 16) + \ 2667c478bd9Sstevel@tonic-gate ((dkd)->dkd_checksum1 << 8) + \ 2677c478bd9Sstevel@tonic-gate ((dkd)->dkd_checksum0) 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate #define DKD_FORMCHKSUM(c, dkd) (dkd)->dkd_checksum3 = hibyte(hiword((c))); \ 2707c478bd9Sstevel@tonic-gate (dkd)->dkd_checksum2 = lobyte(hiword((c))); \ 2717c478bd9Sstevel@tonic-gate (dkd)->dkd_checksum1 = hibyte(loword((c))); \ 2727c478bd9Sstevel@tonic-gate (dkd)->dkd_checksum0 = lobyte(loword((c))); 2737c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2747c478bd9Sstevel@tonic-gate } 2757c478bd9Sstevel@tonic-gate #endif 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate #endif /* _SYS_DKLABEL_H */ 278