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