xdf_shell.h revision 8863:94039d51dda4
11573Srgrimes/*
21573Srgrimes * CDDL HEADER START
31573Srgrimes *
41573Srgrimes * The contents of this file are subject to the terms of the
51573Srgrimes * Common Development and Distribution License (the "License").
61573Srgrimes * You may not use this file except in compliance with the License.
71573Srgrimes *
81573Srgrimes * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91573Srgrimes * or http://www.opensolaris.org/os/licensing.
101573Srgrimes * See the License for the specific language governing permissions
111573Srgrimes * and limitations under the License.
121573Srgrimes *
131573Srgrimes * When distributing Covered Code, include this CDDL HEADER in each
141573Srgrimes * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151573Srgrimes * If applicable, add the following below this CDDL HEADER, with the
161573Srgrimes * fields enclosed by brackets "[]" replaced with your own identifying
171573Srgrimes * information: Portions Copyright [yyyy] [name of copyright owner]
181573Srgrimes *
191573Srgrimes * CDDL HEADER END
201573Srgrimes */
211573Srgrimes/*
221573Srgrimes * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
231573Srgrimes * Use is subject to license terms.
241573Srgrimes */
251573Srgrimes
261573Srgrimes#ifndef	_XDF_SHELL_H
271573Srgrimes#define	_XDF_SHELL_H
281573Srgrimes
2950476Speter#ifdef	__cplusplus
301573Srgrimesextern "C" {
31178245Skib#endif
321573Srgrimes
3379531Sru/* These interfaces are all dependant upon xdf */
341573Srgrimes#include <io/xdf.h>
35178245Skib
36178245Skib/* Include files required for this header file. */
371573Srgrimes#include <sys/vtoc.h>
3859460Sphantom
3959460Sphantom/*
401573Srgrimes * These include files are not strictly required to include this header
4184306Sru * file, but pretty much every xdf_shell client will need to include these
42176215Sru * header files, so just include them here.
43176607Sru */
44178245Skib#include <sys/cdio.h>
45178245Skib#include <sys/dklabel.h>
46178245Skib#include <sys/dktp/altsctr.h>
47178245Skib#include <sys/dktp/bbh.h>
481573Srgrimes#include <sys/dktp/cmdk.h>
49108028Sru#include <sys/dktp/dadev.h>
50108028Sru#include <sys/dktp/dadkio.h>
51108028Sru#include <sys/fdio.h>
521573Srgrimes
531573Srgrimes/*
541573Srgrimes * XDF Shell driver state structures
551573Srgrimes */
561573Srgrimestypedef struct xdfs_state {
571573Srgrimes	dev_info_t	*xdfss_dip;
5817782Smpp	const char	*xdfss_pv;
5917782Smpp	const char	*xdfss_hvm;
60108028Sru
611573Srgrimes	/* Members below are protected by xdfss_mutex */
621573Srgrimes	kmutex_t	xdfss_mutex;
631573Srgrimes	kcondvar_t	xdfss_cv;
64178245Skib	cmlb_handle_t	xdfss_cmlbhandle;
65178245Skib	int		xdfss_otyp_count[OTYPCNT][XDF_PEXT];
66178245Skib
67178245Skib	/* Members below are only valid when xdfss_tgt_attached is true */
68178245Skib	dev_info_t	*xdfss_tgt_dip;
69178245Skib	boolean_t	xdfss_tgt_attached;
70178245Skib	int		xdfss_tgt_holds;
71178245Skib	dev_t		xdfss_tgt_dev;
72178245Skib	ddi_devid_t	xdfss_tgt_devid;
73178245Skib	boolean_t	xdfss_tgt_locked;
74178245Skib	boolean_t	xdfss_tgt_is_cd;
75178245Skib	ldi_handle_t	xdfss_tgt_lh[XDF_PEXT];
76178245Skib} xdfs_state_t;
77178245Skib
78178245Skibtypedef struct xdfs_h2p_map {
79178245Skib	const char	*xdfs_h2p_hvm;
80178245Skib	const char	*xdfs_h2p_pv;
81178245Skib} xdfs_h2p_map_t;
82178245Skib
83178245Skib/*
84178245Skib * Globals defined by xdf_shell.c
851573Srgrimes */
861573Srgrimesextern major_t xdfs_major;
87176215Sru
881573Srgrimes/*
891573Srgrimes * Functions defined by xdf_shell.c
901573Srgrimes */
91108028Sruextern int xdfs_lb_rdwr(dev_info_t *, uchar_t, void *, diskaddr_t, size_t,
92108028Sru    void *);
93108028Sruextern int xdfs_strategy(struct buf *);
941573Srgrimesextern void xdfs_minphys(struct buf *);
9559954Sphantom
961573Srgrimes/*
971573Srgrimes * Globals that must be defined by xdf_shell.c clients
981573Srgrimes */
991573Srgrimesextern const char		*xdfs_c_name;
1001573Srgrimesextern const char		*xdfs_c_linkinfo;
1011573Srgrimesextern void			**xdfs_c_hvm_ss;
1021573Srgrimesextern const size_t		xdfs_c_hvm_ss_size;
1031573Srgrimesextern const struct dev_ops	*xdfs_c_hvm_dev_ops;
1041573Srgrimesextern const xdfs_h2p_map_t	xdfs_c_h2p_map[];
1051573Srgrimes
1061573Srgrimes/*
1071573Srgrimes * Functions that must be implemented by xdf_shell.c clients
1081573Srgrimes */
1091573Srgrimes
1101573Srgrimes/*
1111573Srgrimes * xdfs_c_devid_setup() is invoked during device probe.  If possible, it
112108087Sru * should create a devid for the associated disk device.  This routine will
113108087Sru * not be invoked for cdrom devices.
114108087Sru */
1151573Srgrimesextern void xdfs_c_devid_setup(xdfs_state_t *);
1161573Srgrimes
117178245Skib/*
118178245Skib * xdfs_c_bb_check() is invoked during device probe.  It should check for
119178245Skib * the existance of bad blocks mappings in an alternate partition/slice and
120178245Skib * return B_FALSE if there are no bad block mappings found and return B_TRUE
121178245Skib * is there are bad block mappings found.  The presence of bad block
122178245Skib * mappings will cause the device attach to fail.  This routine will not be
123178245Skib * invoked for cdrom devices.
124178245Skib */
125178245Skibextern boolean_t xdfs_c_bb_check(xdfs_state_t *);
126178245Skib
127178245Skib/*
128178245Skib * xdfs_c_getpgeom() is invoked during device probe.  It should return the
129178245Skib * physical geometery of a disk device that is being attached.  The failure
130178245Skib * of this routine will cause the device attach to fail.  This routine will
131178245Skib * not be invoked for cdrom devices.
132178245Skib */
133178245Skibextern int xdfs_c_getpgeom(dev_info_t *, cmlb_geom_t *);
134178245Skib
135178245Skib/*
136178245Skib * xdfs_c_cmlb_node_type() and xdfs_c_cmlb_alter_behavior() are invoked
137178245Skib * during device probe while initializing the cmlb module for the device
138178245Skib * node being probed.  They should return a cmlb node type and cmlb alter
139178245Skib * behavior flag value that can be passed to cmlb_attach().
140178245Skib */
1411573Srgrimesextern char *xdfs_c_cmlb_node_type(xdfs_state_t *);
14220888Swoschextern int xdfs_c_cmlb_alter_behavior(xdfs_state_t *);
1431573Srgrimes
14420888Swosch/*
14520888Swosch * xdfs_c_attach() is invoked during device attach.  It provides an
146178245Skib * opportunity for the client to create properties or do anything else
147178245Skib * necessary for attach.
148178245Skib */
149178245Skibextern void xdfs_c_attach(xdfs_state_t *);
1501573Srgrimes
1511573Srgrimes/*
15217782Smpp * xdfs_c_getpgeom() is invoked to handle ioctl operations.
153108028Sru */
1541573Srgrimesextern int xdfs_c_ioctl(xdfs_state_t *, dev_t, int,
155178245Skib    int, intptr_t, int, cred_t *, int *, boolean_t *);
156178245Skib
157178245Skib#ifdef	__cplusplus
158178245Skib}
159#endif
160
161#endif	/* _XDF_SHELL_H */
162