xref: /titanic_52/usr/src/uts/common/sys/dktp/dadk.h (revision ba4e3c84e6b9390bbf7df80b5f1d11dec34cc525)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_DKTP_DADK_H
28 #define	_SYS_DKTP_DADK_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/dktp/tgcom.h>
37 
38 struct	dadk {
39 	struct tgdk_ext	*dad_extp;	/* back pointer to ext data	*/
40 	struct scsi_device *dad_sd;	/* back pointer to SCSI_DEVICE 	*/
41 
42 	struct  tgdk_geom dad_logg;	/* logical disk geometry 	*/
43 	struct  tgdk_geom dad_phyg;	/* physical disk geometry 	*/
44 
45 	unsigned dad_rmb : 1;		/* removable device		*/
46 	unsigned dad_rdonly : 1;	/* read only device		*/
47 	unsigned dad_cdrom : 1;		/* cdrom device			*/
48 	unsigned dad_noflush : 1;	/* flush cmd unsupported	*/
49 	unsigned dad_wce : 1;		/* disk write cache enabled	*/
50 	unsigned dad_resv : 3;
51 	unsigned char dad_type;		/* device type			*/
52 	unsigned char dad_ctype;	/* controller type 		*/
53 
54 	short	 dad_secshf;
55 	short	 dad_blkshf;
56 
57 	opaque_t dad_bbhobjp;		/* bbh object ptr		*/
58 	opaque_t dad_flcobjp;		/* flow control object ptr	*/
59 	opaque_t dad_ctlobjp;		/* controller object ptr	*/
60 	struct	tgcom_obj dad_com;	/* com object for flowctrl	*/
61 	enum dkio_state dad_iostate;	/* ejected/inserted		*/
62 	kmutex_t	dad_mutex;	/* protect dad_state		*/
63 	kcondvar_t	dad_state_cv;	/* condition variable for state */
64 	uchar_t		dad_thread_cnt;	/* reference count on removable	*/
65 					/* - disk state watcher thread	*/
66 };
67 
68 #define	DAD_SECSIZ	dad_phyg.g_secsiz
69 
70 /*
71  * Local definitions, for clarity of code
72  */
73 
74 /*
75  * Parameters
76  */
77 #define	DADK_BSY_TIMEOUT	(drv_usectohz(5 * 1000000))
78 #define	DADK_IO_TIME		35
79 #define	DADK_FLUSH_CACHE_TIME	60
80 #define	DADK_RETRY_COUNT	5
81 #define	DADK_SILENT		1
82 
83 #define	PKT2DADK(pktp)	((struct dadk *)(pktp)->cp_dev_private)
84 
85 /*
86  * packet action codes
87  */
88 #define	COMMAND_DONE		0
89 #define	COMMAND_DONE_ERROR	1
90 #define	QUE_COMMAND		2
91 #define	QUE_SENSE		3
92 #define	JUST_RETURN		4
93 
94 int dadk_init(opaque_t objp, opaque_t devp, opaque_t flcobjp,
95     opaque_t queobjp, opaque_t bbhobjp, void *lkarg);
96 int dadk_free(struct tgdk_obj *dkobjp);
97 int dadk_probe(opaque_t objp, int kmsflg);
98 int dadk_attach(opaque_t objp);
99 int dadk_open(opaque_t objp, int flag);
100 int dadk_close(opaque_t objp);
101 int dadk_ioctl(opaque_t objp, dev_t dev, int cmd, intptr_t arg,
102     int flag, cred_t *cred_p, int *rval_p);
103 int dadk_flushdone(struct buf *bp);
104 int dadk_strategy(opaque_t objp, struct buf *bp);
105 int dadk_setgeom(opaque_t objp, struct tgdk_geom *dkgeom_p);
106 int dadk_getgeom(opaque_t objp, struct tgdk_geom *dkgeom_p);
107 struct tgdk_iob *dadk_iob_alloc(opaque_t objp, daddr_t blkno,
108     ssize_t xfer, int kmsflg);
109 int dadk_iob_free(opaque_t objp, struct tgdk_iob *iobp);
110 caddr_t dadk_iob_htoc(opaque_t objp, struct tgdk_iob *iobp);
111 caddr_t dadk_iob_xfer(opaque_t objp, struct tgdk_iob *iobp, int rw);
112 int dadk_dump(opaque_t objp, struct buf *bp);
113 int dadk_getphygeom(opaque_t objp, struct tgdk_geom *dkgeom_p);
114 int dadk_set_bbhobj(opaque_t objp, opaque_t bbhobjp);
115 int dadk_check_media(opaque_t objp, int *state);
116 static void dadk_watch_thread(struct dadk *dadkp);
117 int dadk_inquiry(opaque_t objp, opaque_t *inqpp);
118 void dadk_cleanup(struct tgdk_obj *dkobjp);
119 
120 #ifdef	__cplusplus
121 }
122 #endif
123 
124 #endif	/* _SYS_DKTP_DADK_H */
125