xref: /illumos-gate/usr/src/uts/common/sys/dktp/cmdk.h (revision ddb365bfc9e868ad24ccdcb0dc91af18b10df082)
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 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_DKTP_CMDK_H
28 #define	_SYS_DKTP_CMDK_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/cmlb.h>
35 #include <sys/dktp/tgdk.h>
36 
37 #define	CMDK_UNITSHF	6
38 #define	CMDK_MAXPART	(1 << CMDK_UNITSHF)
39 
40 /*
41  * Model number is 40 ASCII characters
42  * Serial number is 20 ASCII characters
43  */
44 #define	CMDK_HWIDLEN	(64)
45 
46 struct	cmdk {
47 	/* set during probe */
48 	dev_info_t	*dk_dip;
49 	dev_t		dk_dev;
50 	struct tgdk_obj *dk_tgobjp;		/* target disk object pointer */
51 
52 	/* set during attach */
53 	cmlb_handle_t	dk_cmlbhandle;
54 	ddi_devid_t	dk_devid;
55 
56 	kmutex_t	dk_mutex;		/* mutex for cmdk struct */
57 
58 	long		dk_flag;
59 	uint64_t	dk_open_reg[OTYPCNT];	/* bit per partition: 2^6 */
60 	ulong_t		dk_open_lyr[CMDK_MAXPART]; /* OTYP_LYR cnt/partition */
61 	uint64_t	dk_open_exl;		/* bit per partition: 2^6 */
62 
63 	struct bbh_obj	dk_bbh_obj;
64 
65 	/*
66 	 * BBH variables
67 	 * protected by dk_bbh_mutex
68 	 */
69 	krwlock_t	dk_bbh_mutex;		/* bbh mutex */
70 	tgdk_iob_handle	dk_alts_hdl;		/* iob for V_ALTSCTR */
71 	uint32_t	dk_altused;		/* num entries in V_ALTSCTR */
72 	uint32_t	*dk_slc_cnt;		/* entries per slice */
73 	struct alts_ent	**dk_slc_ent;		/* link to remap data */
74 
75 	/*
76 	 * for power management
77 	 */
78 	kmutex_t	dk_pm_mutex;
79 	kcondvar_t	dk_suspend_cv;
80 	uint32_t	dk_pm_level;
81 	uint32_t	dk_pm_is_enabled;
82 };
83 
84 /*
85  * Power Management definitions
86  */
87 #define	CMDK_SPINDLE_UNINIT	((uint_t)(-1))
88 #define	CMDK_SPINDLE_OFF	0x0
89 #define	CMDK_SPINDLE_ON		0x1
90 
91 /*	common disk flags definitions					*/
92 #define	CMDK_OPEN		0x1
93 #define	CMDK_SUSPEND		0x2
94 #define	CMDK_TGDK_OPEN		0x4
95 
96 #define	CMDKUNIT(dev) (getminor((dev)) >> CMDK_UNITSHF)
97 #define	CMDKPART(dev) (getminor((dev)) & (CMDK_MAXPART - 1))
98 
99 #ifdef	__cplusplus
100 }
101 #endif
102 
103 #endif	/* _SYS_DKTP_CMDK_H */
104