xref: /titanic_44/usr/src/uts/common/sys/dktp/cmdk.h (revision 1a7c1b724419d3cb5fa6eea75123c6b2060ba31b)
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_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 #define	CMDK_UNITSHF	6
37 #define	CMDK_MAXPART	(1 << CMDK_UNITSHF)
38 
39 struct	dk_openinfo {
40 	uint64_t	dk_reg[OTYPCNT];	/* bit per partition: 2^6 */
41 	ulong_t		dk_lyr[CMDK_MAXPART];	/* OTYP_LYR cnt per partition */
42 	uint64_t	dk_exl;			/* bit per partition: 2^6 */
43 };
44 
45 struct	cmdk_label {
46 	opaque_t	dkl_objp;
47 	char		dkl_name[OBJNAMELEN];
48 };
49 
50 #define	CMDK_LABEL_MAX	3
51 struct	cmdk {
52 	long		dk_flag;
53 	dev_info_t	*dk_dip;
54 	dev_t		dk_dev;
55 
56 	ksema_t		dk_semoclose;	/* lock for opens/closes 	*/
57 	struct		dk_openinfo dk_open;
58 
59 	opaque_t 	dk_tgobjp;	/* target disk object pointer	*/
60 	opaque_t 	dk_lbobjp;
61 	struct cmdk_label dk_lb[CMDK_LABEL_MAX];
62 
63 	kmutex_t	dk_pinfo_lock;
64 	kcondvar_t	dk_pinfo_cv;
65 	int		dk_pinfo_state;
66 };
67 
68 /*	common disk flags definitions					*/
69 #define	CMDK_OPEN		0x1
70 #define	CMDK_VALID_LABEL	0x2
71 #define	CMDK_TGDK_OPEN		0x4
72 
73 #define	CMDKUNIT(dev) (getminor((dev)) >> CMDK_UNITSHF)
74 #define	CMDKPART(dev) (getminor((dev)) & (CMDK_MAXPART - 1))
75 
76 #define	CMDK_TGOBJP(dkp)	(dkp)->dk_tgobjp
77 
78 /*	dk_pinfo_states for cmdk_part_info() */
79 #define	CMDK_PARTINFO_INVALID	0
80 #define	CMDK_PARTINFO_BUSY	1
81 #define	CMDK_PARTINFO_BUSY2	2
82 #define	CMDK_PARTINFO_VALID	3
83 
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif	/* _SYS_DKTP_CMDK_H */
90