1*7f0b8309SEdward Pilatowicz /* 2*7f0b8309SEdward Pilatowicz * CDDL HEADER START 3*7f0b8309SEdward Pilatowicz * 4*7f0b8309SEdward Pilatowicz * The contents of this file are subject to the terms of the 5*7f0b8309SEdward Pilatowicz * Common Development and Distribution License (the "License"). 6*7f0b8309SEdward Pilatowicz * You may not use this file except in compliance with the License. 7*7f0b8309SEdward Pilatowicz * 8*7f0b8309SEdward Pilatowicz * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*7f0b8309SEdward Pilatowicz * or http://www.opensolaris.org/os/licensing. 10*7f0b8309SEdward Pilatowicz * See the License for the specific language governing permissions 11*7f0b8309SEdward Pilatowicz * and limitations under the License. 12*7f0b8309SEdward Pilatowicz * 13*7f0b8309SEdward Pilatowicz * When distributing Covered Code, include this CDDL HEADER in each 14*7f0b8309SEdward Pilatowicz * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*7f0b8309SEdward Pilatowicz * If applicable, add the following below this CDDL HEADER, with the 16*7f0b8309SEdward Pilatowicz * fields enclosed by brackets "[]" replaced with your own identifying 17*7f0b8309SEdward Pilatowicz * information: Portions Copyright [yyyy] [name of copyright owner] 18*7f0b8309SEdward Pilatowicz * 19*7f0b8309SEdward Pilatowicz * CDDL HEADER END 20*7f0b8309SEdward Pilatowicz */ 21*7f0b8309SEdward Pilatowicz /* 22*7f0b8309SEdward Pilatowicz * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23*7f0b8309SEdward Pilatowicz * Use is subject to license terms. 24*7f0b8309SEdward Pilatowicz */ 25*7f0b8309SEdward Pilatowicz 26*7f0b8309SEdward Pilatowicz #ifndef _XDF_SHELL_H 27*7f0b8309SEdward Pilatowicz #define _XDF_SHELL_H 28*7f0b8309SEdward Pilatowicz 29*7f0b8309SEdward Pilatowicz #ifdef __cplusplus 30*7f0b8309SEdward Pilatowicz extern "C" { 31*7f0b8309SEdward Pilatowicz #endif 32*7f0b8309SEdward Pilatowicz 33*7f0b8309SEdward Pilatowicz /* These interfaces are all dependant upon xdf */ 34*7f0b8309SEdward Pilatowicz #include <io/xdf.h> 35*7f0b8309SEdward Pilatowicz 36*7f0b8309SEdward Pilatowicz /* Include files required for this header file. */ 37*7f0b8309SEdward Pilatowicz #include <sys/vtoc.h> 38*7f0b8309SEdward Pilatowicz 39*7f0b8309SEdward Pilatowicz /* 40*7f0b8309SEdward Pilatowicz * These include files are not strictly required to include this header 41*7f0b8309SEdward Pilatowicz * file, but pretty much every xdf_shell client will need to include these 42*7f0b8309SEdward Pilatowicz * header files, so just include them here. 43*7f0b8309SEdward Pilatowicz */ 44*7f0b8309SEdward Pilatowicz #include <sys/cdio.h> 45*7f0b8309SEdward Pilatowicz #include <sys/dklabel.h> 46*7f0b8309SEdward Pilatowicz #include <sys/dktp/altsctr.h> 47*7f0b8309SEdward Pilatowicz #include <sys/dktp/bbh.h> 48*7f0b8309SEdward Pilatowicz #include <sys/dktp/cmdk.h> 49*7f0b8309SEdward Pilatowicz #include <sys/dktp/dadev.h> 50*7f0b8309SEdward Pilatowicz #include <sys/dktp/dadkio.h> 51*7f0b8309SEdward Pilatowicz #include <sys/fdio.h> 52*7f0b8309SEdward Pilatowicz 53*7f0b8309SEdward Pilatowicz /* 54*7f0b8309SEdward Pilatowicz * XDF Shell driver state structures 55*7f0b8309SEdward Pilatowicz */ 56*7f0b8309SEdward Pilatowicz typedef struct xdfs_state { 57*7f0b8309SEdward Pilatowicz dev_info_t *xdfss_dip; 58*7f0b8309SEdward Pilatowicz const char *xdfss_pv; 59*7f0b8309SEdward Pilatowicz const char *xdfss_hvm; 60*7f0b8309SEdward Pilatowicz 61*7f0b8309SEdward Pilatowicz /* Members below are protected by xdfss_mutex */ 62*7f0b8309SEdward Pilatowicz kmutex_t xdfss_mutex; 63*7f0b8309SEdward Pilatowicz kcondvar_t xdfss_cv; 64*7f0b8309SEdward Pilatowicz cmlb_handle_t xdfss_cmlbhandle; 65*7f0b8309SEdward Pilatowicz int xdfss_otyp_count[OTYPCNT][XDF_PEXT]; 66*7f0b8309SEdward Pilatowicz 67*7f0b8309SEdward Pilatowicz /* Members below are only valid when xdfss_tgt_attached is true */ 68*7f0b8309SEdward Pilatowicz dev_info_t *xdfss_tgt_dip; 69*7f0b8309SEdward Pilatowicz boolean_t xdfss_tgt_attached; 70*7f0b8309SEdward Pilatowicz int xdfss_tgt_holds; 71*7f0b8309SEdward Pilatowicz dev_t xdfss_tgt_dev; 72*7f0b8309SEdward Pilatowicz ddi_devid_t xdfss_tgt_devid; 73*7f0b8309SEdward Pilatowicz boolean_t xdfss_tgt_locked; 74*7f0b8309SEdward Pilatowicz boolean_t xdfss_tgt_is_cd; 75*7f0b8309SEdward Pilatowicz ldi_handle_t xdfss_tgt_lh[XDF_PEXT]; 76*7f0b8309SEdward Pilatowicz } xdfs_state_t; 77*7f0b8309SEdward Pilatowicz 78*7f0b8309SEdward Pilatowicz typedef struct xdfs_h2p_map { 79*7f0b8309SEdward Pilatowicz const char *xdfs_h2p_hvm; 80*7f0b8309SEdward Pilatowicz const char *xdfs_h2p_pv; 81*7f0b8309SEdward Pilatowicz } xdfs_h2p_map_t; 82*7f0b8309SEdward Pilatowicz 83*7f0b8309SEdward Pilatowicz /* 84*7f0b8309SEdward Pilatowicz * Globals defined by xdf_shell.c 85*7f0b8309SEdward Pilatowicz */ 86*7f0b8309SEdward Pilatowicz extern major_t xdfs_major; 87*7f0b8309SEdward Pilatowicz 88*7f0b8309SEdward Pilatowicz /* 89*7f0b8309SEdward Pilatowicz * Functions defined by xdf_shell.c 90*7f0b8309SEdward Pilatowicz */ 91*7f0b8309SEdward Pilatowicz extern int xdfs_lb_rdwr(dev_info_t *, uchar_t, void *, diskaddr_t, size_t, 92*7f0b8309SEdward Pilatowicz void *); 93*7f0b8309SEdward Pilatowicz extern int xdfs_strategy(struct buf *); 94*7f0b8309SEdward Pilatowicz extern void xdfs_minphys(struct buf *); 95*7f0b8309SEdward Pilatowicz 96*7f0b8309SEdward Pilatowicz /* 97*7f0b8309SEdward Pilatowicz * Globals that must be defined by xdf_shell.c clients 98*7f0b8309SEdward Pilatowicz */ 99*7f0b8309SEdward Pilatowicz extern const char *xdfs_c_name; 100*7f0b8309SEdward Pilatowicz extern const char *xdfs_c_linkinfo; 101*7f0b8309SEdward Pilatowicz extern void **xdfs_c_hvm_ss; 102*7f0b8309SEdward Pilatowicz extern const size_t xdfs_c_hvm_ss_size; 103*7f0b8309SEdward Pilatowicz extern const struct dev_ops *xdfs_c_hvm_dev_ops; 104*7f0b8309SEdward Pilatowicz extern const xdfs_h2p_map_t xdfs_c_h2p_map[]; 105*7f0b8309SEdward Pilatowicz 106*7f0b8309SEdward Pilatowicz /* 107*7f0b8309SEdward Pilatowicz * Functions that must be implemented by xdf_shell.c clients 108*7f0b8309SEdward Pilatowicz */ 109*7f0b8309SEdward Pilatowicz 110*7f0b8309SEdward Pilatowicz /* 111*7f0b8309SEdward Pilatowicz * xdfs_c_devid_setup() is invoked during device probe. If possible, it 112*7f0b8309SEdward Pilatowicz * should create a devid for the associated disk device. This routine will 113*7f0b8309SEdward Pilatowicz * not be invoked for cdrom devices. 114*7f0b8309SEdward Pilatowicz */ 115*7f0b8309SEdward Pilatowicz extern void xdfs_c_devid_setup(xdfs_state_t *); 116*7f0b8309SEdward Pilatowicz 117*7f0b8309SEdward Pilatowicz /* 118*7f0b8309SEdward Pilatowicz * xdfs_c_bb_check() is invoked during device probe. It should check for 119*7f0b8309SEdward Pilatowicz * the existance of bad blocks mappings in an alternate partition/slice and 120*7f0b8309SEdward Pilatowicz * return B_FALSE if there are no bad block mappings found and return B_TRUE 121*7f0b8309SEdward Pilatowicz * is there are bad block mappings found. The presence of bad block 122*7f0b8309SEdward Pilatowicz * mappings will cause the device attach to fail. This routine will not be 123*7f0b8309SEdward Pilatowicz * invoked for cdrom devices. 124*7f0b8309SEdward Pilatowicz */ 125*7f0b8309SEdward Pilatowicz extern boolean_t xdfs_c_bb_check(xdfs_state_t *); 126*7f0b8309SEdward Pilatowicz 127*7f0b8309SEdward Pilatowicz /* 128*7f0b8309SEdward Pilatowicz * xdfs_c_getpgeom() is invoked during device probe. It should return the 129*7f0b8309SEdward Pilatowicz * physical geometery of a disk device that is being attached. The failure 130*7f0b8309SEdward Pilatowicz * of this routine will cause the device attach to fail. This routine will 131*7f0b8309SEdward Pilatowicz * not be invoked for cdrom devices. 132*7f0b8309SEdward Pilatowicz */ 133*7f0b8309SEdward Pilatowicz extern int xdfs_c_getpgeom(dev_info_t *, cmlb_geom_t *); 134*7f0b8309SEdward Pilatowicz 135*7f0b8309SEdward Pilatowicz /* 136*7f0b8309SEdward Pilatowicz * xdfs_c_cmlb_node_type() and xdfs_c_cmlb_alter_behavior() are invoked 137*7f0b8309SEdward Pilatowicz * during device probe while initializing the cmlb module for the device 138*7f0b8309SEdward Pilatowicz * node being probed. They should return a cmlb node type and cmlb alter 139*7f0b8309SEdward Pilatowicz * behavior flag value that can be passed to cmlb_attach(). 140*7f0b8309SEdward Pilatowicz */ 141*7f0b8309SEdward Pilatowicz extern char *xdfs_c_cmlb_node_type(xdfs_state_t *); 142*7f0b8309SEdward Pilatowicz extern int xdfs_c_cmlb_alter_behavior(xdfs_state_t *); 143*7f0b8309SEdward Pilatowicz 144*7f0b8309SEdward Pilatowicz /* 145*7f0b8309SEdward Pilatowicz * xdfs_c_attach() is invoked during device attach. It provides an 146*7f0b8309SEdward Pilatowicz * opportunity for the client to create properties or do anything else 147*7f0b8309SEdward Pilatowicz * necessary for attach. 148*7f0b8309SEdward Pilatowicz */ 149*7f0b8309SEdward Pilatowicz extern void xdfs_c_attach(xdfs_state_t *); 150*7f0b8309SEdward Pilatowicz 151*7f0b8309SEdward Pilatowicz /* 152*7f0b8309SEdward Pilatowicz * xdfs_c_getpgeom() is invoked to handle ioctl operations. 153*7f0b8309SEdward Pilatowicz */ 154*7f0b8309SEdward Pilatowicz extern int xdfs_c_ioctl(xdfs_state_t *, dev_t, int, 155*7f0b8309SEdward Pilatowicz int, intptr_t, int, cred_t *, int *, boolean_t *); 156*7f0b8309SEdward Pilatowicz 157*7f0b8309SEdward Pilatowicz #ifdef __cplusplus 158*7f0b8309SEdward Pilatowicz } 159*7f0b8309SEdward Pilatowicz #endif 160*7f0b8309SEdward Pilatowicz 161*7f0b8309SEdward Pilatowicz #endif /* _XDF_SHELL_H */ 162