1786Slclee /* 2786Slclee * CDDL HEADER START 3786Slclee * 4786Slclee * The contents of this file are subject to the terms of the 53525Sshidokht * Common Development and Distribution License (the "License"). 63525Sshidokht * You may not use this file except in compliance with the License. 7786Slclee * 8786Slclee * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9786Slclee * or http://www.opensolaris.org/os/licensing. 10786Slclee * See the License for the specific language governing permissions 11786Slclee * and limitations under the License. 12786Slclee * 13786Slclee * When distributing Covered Code, include this CDDL HEADER in each 14786Slclee * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15786Slclee * If applicable, add the following below this CDDL HEADER, with the 16786Slclee * fields enclosed by brackets "[]" replaced with your own identifying 17786Slclee * information: Portions Copyright [yyyy] [name of copyright owner] 18786Slclee * 19786Slclee * CDDL HEADER END 20786Slclee */ 217563SPrasad.Singamsetty@Sun.COM 22786Slclee /* 237563SPrasad.Singamsetty@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24786Slclee * Use is subject to license terms. 25786Slclee */ 26786Slclee 27786Slclee #ifndef _SYS_CMLB_IMPL_H 28786Slclee #define _SYS_CMLB_IMPL_H 29786Slclee 30786Slclee #ifdef __cplusplus 31786Slclee extern "C" { 32786Slclee #endif 33786Slclee 34786Slclee #include <sys/cmlb.h> 35786Slclee #include <sys/ddi.h> 36786Slclee #include <sys/sunddi.h> 37786Slclee 38786Slclee #if defined(_SUNOS_VTOC_8) 39786Slclee #define NSDMAP NDKMAP 40786Slclee #elif defined(_SUNOS_VTOC_16) 41*8333SSuhasini.Peddada@Sun.COM #define NSDMAP (NDKMAP + FD_NUMPART + 1) 42786Slclee #else 43786Slclee #error "No VTOC format defined." 44786Slclee #endif 45786Slclee 46786Slclee #define MAXPART (NSDMAP + 1) 47786Slclee #define WD_NODE 7 48786Slclee 49786Slclee 50786Slclee #if defined(__i386) || defined(__amd64) 51786Slclee 52786Slclee #define P0_RAW_DISK (NDKMAP) 53786Slclee #define FDISK_P1 (NDKMAP+1) 54786Slclee #define FDISK_P2 (NDKMAP+2) 55786Slclee #define FDISK_P3 (NDKMAP+3) 56786Slclee #define FDISK_P4 (NDKMAP+4) 57786Slclee 58786Slclee #endif /* __i386 || __amd64 */ 59786Slclee 60786Slclee /* Driver Logging Levels */ 61786Slclee #define CMLB_LOGMASK_ERROR 0x00000001 62786Slclee #define CMLB_LOGMASK_INFO 0x00000002 63786Slclee #define CMLB_LOGMASK_TRACE 0x00000004 64786Slclee 65786Slclee #define CMLB_TRACE 0x00000001 66786Slclee #define CMLB_INFO 0x00000002 67786Slclee #define CMLB_ERROR 0x00000004 68786Slclee 69786Slclee 703525Sshidokht #define CMLB_MUTEX(cl) (&((cl)->cl_mutex)) 713525Sshidokht #define CMLB_DEVINFO(cl) ((cl)->cl_devi) 723525Sshidokht #define CMLB_LABEL(cl) (DEVI(((cl)->cl_devi))->devi_binding_name) 73786Slclee 74786Slclee 753525Sshidokht #define ISREMOVABLE(cl) (cl->cl_is_removable == 1) 763525Sshidokht #define ISCD(cl) (cl->cl_device_type == DTYPE_RODIRECT) 773525Sshidokht #define ISHOTPLUGGABLE(cl) (cl->cl_is_hotpluggable == 1) 78786Slclee 79786Slclee #if defined(_SUNOS_VTOC_8) 80786Slclee 81786Slclee #define CMLBUNIT_SHIFT 3 82786Slclee #define CMLBPART_MASK 7 83786Slclee 84786Slclee #elif defined(_SUNOS_VTOC_16) 85786Slclee 86786Slclee #define CMLBUNIT_SHIFT 6 87786Slclee #define CMLBPART_MASK 63 88786Slclee 89786Slclee #else 90786Slclee #error "No VTOC format defined." 91786Slclee #endif 92786Slclee 93786Slclee #define CMLBUNIT(dev) (getminor((dev)) >> CMLBUNIT_SHIFT) 94786Slclee #define CMLBPART(dev) (getminor((dev)) & CMLBPART_MASK) 95786Slclee 96786Slclee 97786Slclee #define TRUE 1 98786Slclee #define FALSE 0 99786Slclee 100786Slclee /* 101786Slclee * Return codes of cmlb_uselabel(). 102786Slclee */ 103786Slclee #define CMLB_LABEL_IS_VALID 0 104786Slclee #define CMLB_LABEL_IS_INVALID 1 105786Slclee 1067563SPrasad.Singamsetty@Sun.COM #define CMLB_2TB_BLOCKS 0xffffffff 1077563SPrasad.Singamsetty@Sun.COM #define CMLB_1TB_BLOCKS 0x7fffffff 1087563SPrasad.Singamsetty@Sun.COM 1097563SPrasad.Singamsetty@Sun.COM #define CMLB_EXTVTOC_LIMIT CMLB_2TB_BLOCKS 1107563SPrasad.Singamsetty@Sun.COM #define CMLB_OLDVTOC_LIMIT CMLB_1TB_BLOCKS 1117563SPrasad.Singamsetty@Sun.COM 112786Slclee /* 113786Slclee * fdisk partition mapping structure 114786Slclee */ 115786Slclee struct fmap { 1167563SPrasad.Singamsetty@Sun.COM ulong_t fmap_start; /* starting block number */ 1177563SPrasad.Singamsetty@Sun.COM ulong_t fmap_nblk; /* number of blocks */ 118786Slclee }; 119786Slclee 120786Slclee /* for cm_state */ 121786Slclee typedef enum { 122786Slclee CMLB_INITED = 0, 123786Slclee CMLB_ATTACHED 124786Slclee } cmlb_state_t; 125786Slclee 126786Slclee typedef enum 127786Slclee { 128786Slclee CMLB_LABEL_UNDEF = 0, 129786Slclee CMLB_LABEL_VTOC, 130786Slclee CMLB_LABEL_EFI 131786Slclee } cmlb_label_t; 132786Slclee 1337563SPrasad.Singamsetty@Sun.COM #define CMLB_ALLOW_2TB_WARN 0x1 1347563SPrasad.Singamsetty@Sun.COM 135786Slclee 136786Slclee typedef struct cmlb_lun { 1373525Sshidokht dev_info_t *cl_devi; /* pointer to devinfo */ 1383525Sshidokht struct dk_vtoc cl_vtoc; /* disk VTOC */ 1393525Sshidokht struct dk_geom cl_g; /* disk geometry */ 140786Slclee 1413525Sshidokht diskaddr_t cl_blockcount; /* capacity */ 1423525Sshidokht uint32_t cl_tgt_blocksize; /* blocksize */ 143786Slclee 1443525Sshidokht diskaddr_t cl_solaris_size; /* size of Solaris partition */ 1453525Sshidokht uint_t cl_solaris_offset; /* offset to Solaris part. */ 146786Slclee 1473525Sshidokht struct dk_map cl_map[MAXPART]; /* logical partitions */ 1487563SPrasad.Singamsetty@Sun.COM /* cylno is overloaded. used */ 1497563SPrasad.Singamsetty@Sun.COM /* for starting block for EFI */ 1507563SPrasad.Singamsetty@Sun.COM 1513525Sshidokht diskaddr_t cl_offset[MAXPART]; /* partition start blocks */ 152786Slclee 153*8333SSuhasini.Peddada@Sun.COM struct fmap cl_fmap[FD_NUMPART]; /* fdisk partitions */ 154786Slclee 1553525Sshidokht uchar_t cl_asciilabel[LEN_DKL_ASCII]; /* Disk ASCII label */ 156786Slclee 157786Slclee /* 158786Slclee * This is the HBAs current notion of the geometry of the drive, 159786Slclee * for HBAs that support the "geometry" property. 160786Slclee */ 1613525Sshidokht struct cmlb_geom cl_lgeom; 162786Slclee 163786Slclee /* 164786Slclee * This is the geometry of the device as reported by the MODE SENSE, 165786Slclee * command, Page 3 (Format Device Page) and Page 4 (Rigid Disk Drive 166786Slclee * Geometry Page), assuming MODE SENSE is supported by the target. 167786Slclee */ 1683525Sshidokht struct cmlb_geom cl_pgeom; 169786Slclee 1703525Sshidokht ushort_t cl_dkg_skew; /* skew */ 171786Slclee 1723525Sshidokht cmlb_label_t cl_def_labeltype; /* default label type */ 173786Slclee 174786Slclee /* label type based on which minor nodes were created last */ 1753525Sshidokht cmlb_label_t cl_last_labeltype; 176786Slclee 1773525Sshidokht cmlb_label_t cl_cur_labeltype; /* current label type */ 178786Slclee 179786Slclee /* indicates whether vtoc label is read from media */ 1807563SPrasad.Singamsetty@Sun.COM cmlb_label_t cl_label_from_media; 181786Slclee 1823525Sshidokht cmlb_state_t cl_state; /* state of handle */ 183786Slclee 1843525Sshidokht int cl_f_geometry_is_valid; 1853525Sshidokht int cl_sys_blocksize; 186786Slclee 1873525Sshidokht kmutex_t cl_mutex; 188786Slclee 189786Slclee /* the following are passed in at attach time */ 1903525Sshidokht int cl_is_removable; /* 1 is removable */ 1913525Sshidokht int cl_is_hotpluggable; /* 1 is hotpluggable */ 1923525Sshidokht int cl_alter_behavior; 1933525Sshidokht char *cl_node_type; /* DDI_NT_... */ 1943525Sshidokht int cl_device_type; /* DTYPE_DIRECT,.. */ 1953525Sshidokht int cl_reserved; /* reserved efi partition # */ 196786Slclee cmlb_tg_ops_t *cmlb_tg_ops; 1977563SPrasad.Singamsetty@Sun.COM uint8_t cl_msglog_flag; /* used to enable/suppress */ 1987563SPrasad.Singamsetty@Sun.COM /* certain log messages */ 199786Slclee } cmlb_lun_t; 200786Slclee 201786Slclee _NOTE(SCHEME_PROTECTS_DATA("stable data", cmlb_lun::cmlb_tg_ops)) 2023525Sshidokht _NOTE(SCHEME_PROTECTS_DATA("stable data", cmlb_lun::cl_devi)) 2033525Sshidokht _NOTE(SCHEME_PROTECTS_DATA("stable data", cmlb_lun::cl_is_removable)) 2043525Sshidokht _NOTE(SCHEME_PROTECTS_DATA("stable data", cmlb_lun::cl_is_hotpluggable)) 2053525Sshidokht _NOTE(SCHEME_PROTECTS_DATA("stable data", cmlb_lun::cl_node_type)) 2063525Sshidokht _NOTE(SCHEME_PROTECTS_DATA("stable data", cmlb_lun::cl_sys_blocksize)) 2073525Sshidokht _NOTE(SCHEME_PROTECTS_DATA("stable data", cmlb_lun::cl_alter_behavior)) 208786Slclee _NOTE(SCHEME_PROTECTS_DATA("private data", cmlb_geom)) 2093525Sshidokht _NOTE(SCHEME_PROTECTS_DATA("safe sharing", cmlb_lun::cl_f_geometry_is_valid)) 2103525Sshidokht 2117909SXiao.L@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(cmlb_lun::cl_mutex, cmlb_lun::cl_vtoc)) 212786Slclee 213786Slclee 2143525Sshidokht #define DK_TG_READ(ihdlp, bufaddr, start_block, reqlength, tg_cookie)\ 2153525Sshidokht (ihdlp->cmlb_tg_ops->tg_rdwr)(CMLB_DEVINFO(ihdlp), TG_READ, \ 2163525Sshidokht bufaddr, start_block, reqlength, tg_cookie) 217786Slclee 2183525Sshidokht #define DK_TG_WRITE(ihdlp, bufaddr, start_block, reqlength, tg_cookie)\ 2193525Sshidokht (ihdlp->cmlb_tg_ops->tg_rdwr)(CMLB_DEVINFO(ihdlp), TG_WRITE,\ 2203525Sshidokht bufaddr, start_block, reqlength, tg_cookie) 2213525Sshidokht 2223525Sshidokht #define DK_TG_GETPHYGEOM(ihdlp, phygeomp, tg_cookie) \ 2233525Sshidokht (ihdlp->cmlb_tg_ops->tg_getinfo)(CMLB_DEVINFO(ihdlp), TG_GETPHYGEOM,\ 2243525Sshidokht (void *)phygeomp, tg_cookie) 225786Slclee 2263525Sshidokht #define DK_TG_GETVIRTGEOM(ihdlp, virtgeomp, tg_cookie) \ 2273525Sshidokht (ihdlp->cmlb_tg_ops->tg_getinfo)(CMLB_DEVINFO(ihdlp), TG_GETVIRTGEOM,\ 2283525Sshidokht (void *)virtgeomp, tg_cookie) 2293525Sshidokht 2303525Sshidokht #define DK_TG_GETCAP(ihdlp, capp, tg_cookie) \ 2313525Sshidokht (ihdlp->cmlb_tg_ops->tg_getinfo)(CMLB_DEVINFO(ihdlp), TG_GETCAPACITY,\ 2323525Sshidokht capp, tg_cookie) 233786Slclee 2343525Sshidokht #define DK_TG_GETBLOCKSIZE(ihdlp, lbap, tg_cookie) \ 2353525Sshidokht (ihdlp->cmlb_tg_ops->tg_getinfo)(CMLB_DEVINFO(ihdlp),\ 2363525Sshidokht TG_GETBLOCKSIZE, lbap, tg_cookie) 237786Slclee 2383525Sshidokht #define DK_TG_GETATTRIBUTE(ihdlp, attributep, tg_cookie) \ 2393525Sshidokht (ihdlp->cmlb_tg_ops->tg_getinfo)(CMLB_DEVINFO(ihdlp), TG_GETATTR,\ 2403525Sshidokht attributep, tg_cookie) 241786Slclee 242786Slclee #ifdef __cplusplus 243786Slclee } 244786Slclee #endif 245786Slclee 246786Slclee #endif /* _SYS_CMLB_IMPL_H */ 247