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