xref: /titanic_50/usr/src/uts/common/sys/cmlb.h (revision 7f0b8309074a5d8e9f9d8ffe7aad7bb0b1ee6b1f)
13ccda647Slclee /*
23ccda647Slclee  * CDDL HEADER START
33ccda647Slclee  *
43ccda647Slclee  * The contents of this file are subject to the terms of the
5e8fb11a1Sshidokht  * Common Development and Distribution License (the "License").
6e8fb11a1Sshidokht  * You may not use this file except in compliance with the License.
73ccda647Slclee  *
83ccda647Slclee  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93ccda647Slclee  * or http://www.opensolaris.org/os/licensing.
103ccda647Slclee  * See the License for the specific language governing permissions
113ccda647Slclee  * and limitations under the License.
123ccda647Slclee  *
133ccda647Slclee  * When distributing Covered Code, include this CDDL HEADER in each
143ccda647Slclee  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153ccda647Slclee  * If applicable, add the following below this CDDL HEADER, with the
163ccda647Slclee  * fields enclosed by brackets "[]" replaced with your own identifying
173ccda647Slclee  * information: Portions Copyright [yyyy] [name of copyright owner]
183ccda647Slclee  *
193ccda647Slclee  * CDDL HEADER END
203ccda647Slclee  */
213ccda647Slclee /*
22*7f0b8309SEdward Pilatowicz  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
233ccda647Slclee  * Use is subject to license terms.
243ccda647Slclee  */
253ccda647Slclee 
263ccda647Slclee #ifndef _SYS_CMLB_H
273ccda647Slclee #define	_SYS_CMLB_H
283ccda647Slclee 
293ccda647Slclee #ifdef	__cplusplus
303ccda647Slclee extern "C" {
313ccda647Slclee #endif
323ccda647Slclee 
333ccda647Slclee #include <sys/dktp/fdisk.h>
343ccda647Slclee 
353ccda647Slclee /*
363ccda647Slclee  * structure used for getting phygeom and virtgeom from target driver
373ccda647Slclee  */
383ccda647Slclee typedef struct cmlb_geom {
393ccda647Slclee 	unsigned int    g_ncyl;
403ccda647Slclee 	unsigned short  g_acyl;
413ccda647Slclee 	unsigned short  g_nhead;
423ccda647Slclee 	unsigned short  g_nsect;
433ccda647Slclee 	unsigned short  g_secsize;
443ccda647Slclee 	diskaddr_t	g_capacity;
453ccda647Slclee 	unsigned short  g_intrlv;
463ccda647Slclee 	unsigned short  g_rpm;
473ccda647Slclee } cmlb_geom_t;
483ccda647Slclee 
493ccda647Slclee 
503ccda647Slclee typedef struct tg_attribute {
513ccda647Slclee 	int media_is_writable;
523ccda647Slclee } tg_attribute_t;
533ccda647Slclee 
543ccda647Slclee 
553ccda647Slclee 
56e8fb11a1Sshidokht /* bit definitions for alter_behavior passed to cmlb_attach */
573ccda647Slclee 
583ccda647Slclee #define	CMLB_CREATE_ALTSLICE_VTOC_16_DTYPE_DIRECT	0x00000001
593ccda647Slclee #define	CMLB_FAKE_GEOM_LABEL_IOCTLS_VTOC8		0x00000002
60e8fb11a1Sshidokht #define	CMLB_OFF_BY_ONE					0x00000004
61843e1988Sjohnlev #define	CMLB_FAKE_LABEL_ONE_PARTITION			0x00000008
6206bbe1e0Sedp #define	CMLB_INTERNAL_MINOR_NODES			0x00000010
63e8fb11a1Sshidokht 
64e8fb11a1Sshidokht /* bit definitions of flag passed to cmlb_validate */
65e8fb11a1Sshidokht #define	CMLB_SILENT					0x00000001
66e8fb11a1Sshidokht 
67e8fb11a1Sshidokht /* version for tg_ops */
68e8fb11a1Sshidokht #define	TG_DK_OPS_VERSION_0	0
69e8fb11a1Sshidokht #define	TG_DK_OPS_VERSION_1	1
70e8fb11a1Sshidokht 
71e8fb11a1Sshidokht /* definitions for cmd passed to tg_rdwr */
72e8fb11a1Sshidokht #define	TG_READ			0
73e8fb11a1Sshidokht #define	TG_WRITE		1
74e8fb11a1Sshidokht 
75e8fb11a1Sshidokht /* definitions for cmd passed to tg_getinfo */
76e8fb11a1Sshidokht #define	TG_GETPHYGEOM		1
77e8fb11a1Sshidokht #define	TG_GETVIRTGEOM		2
78e8fb11a1Sshidokht #define	TG_GETCAPACITY		3
79e8fb11a1Sshidokht #define	TG_GETBLOCKSIZE		4
80e8fb11a1Sshidokht #define	TG_GETATTR		5
81e8fb11a1Sshidokht 
823ccda647Slclee 
833ccda647Slclee /*
843ccda647Slclee  * Ops vector including utility functions into target driver that cmlb uses.
853ccda647Slclee  */
863ccda647Slclee typedef struct cmlb_tg_ops {
87e8fb11a1Sshidokht 	int	tg_version;
88e8fb11a1Sshidokht 
893ccda647Slclee 	/*
903ccda647Slclee 	 * tg_rdwr:
913ccda647Slclee 	 *	perform read/write on target device associated with devi.
92e8fb11a1Sshidokht 	 *
933ccda647Slclee 	 * Arguments:
94e8fb11a1Sshidokht 	 *
953ccda647Slclee 	 *	devi:		pointer to device's dev_info structure.
96e8fb11a1Sshidokht 	 *
973ccda647Slclee 	 *	cmd:		operation to perform.
983ccda647Slclee 	 *			Possible values: TG_READ, TG_WRITE
99e8fb11a1Sshidokht 	 *
1003ccda647Slclee 	 *	bufp:		pointer to allocated buffer for transfer
101e8fb11a1Sshidokht 	 *
1023ccda647Slclee 	 *	start_block:	starting block number to read/write (based on
1033ccda647Slclee 	 *			system blocksize, DEV_BSIZE)
1043ccda647Slclee 	 *
1053ccda647Slclee 	 *	reqlength:	requested transfer length (in bytes)
1063ccda647Slclee 	 *
107e8fb11a1Sshidokht 	 *	tg_cookie 	cookie from target driver to be passed back to
108e8fb11a1Sshidokht 	 *			target driver when we call back to it through
109e8fb11a1Sshidokht 	 *			tg_ops.
110e8fb11a1Sshidokht 	 *
1113ccda647Slclee 	 * Note: It is the responsibility of caller to make sure
1123ccda647Slclee 	 *	length of buffer pointed to by bufp is at least equal to
1133ccda647Slclee 	 *	requested transfer length
1143ccda647Slclee 	 *
1153ccda647Slclee 	 * Return values:
1163ccda647Slclee 	 *	0		success
1173ccda647Slclee 	 *	ENOMEM		can not allocate memory
1183ccda647Slclee 	 *	EACCESS  	reservation conflict
1193ccda647Slclee 	 *	EIO		I/O error
1203ccda647Slclee 	 *	EFAULT		copyin/copyout error
1213ccda647Slclee 	 *	ENXIO		internal error/ invalid devi
1223ccda647Slclee 	 *	EINVAL		invalid command value.
1233ccda647Slclee 	 */
1243ccda647Slclee 	int (*tg_rdwr)(dev_info_t *devi, uchar_t cmd, void *bufp,
125e8fb11a1Sshidokht 	    diskaddr_t start_block, size_t reqlength, void *tg_cookie);
1263ccda647Slclee 
1273ccda647Slclee 	/*
128e8fb11a1Sshidokht 	 * tg_getinfo:
1293ccda647Slclee 	 * 	Report the information requested on device/media and
130e8fb11a1Sshidokht 	 *	store the requested info in area pointed to by arg.
1313ccda647Slclee 	 *
1323ccda647Slclee 	 * Arguments:
1333ccda647Slclee 	 *	devi:		pointer to device's dev_info structure.
134e8fb11a1Sshidokht 	 *
135e8fb11a1Sshidokht 	 *	cmd:		operation to perform
136e8fb11a1Sshidokht 	 *
137e8fb11a1Sshidokht 	 *	arg:		arg for the operation for result.
138e8fb11a1Sshidokht 	 *
139e8fb11a1Sshidokht 	 *	tg_cookie 	cookie from target driver to be passed back to
140e8fb11a1Sshidokht 	 *			target driver when we call back to it through
141e8fb11a1Sshidokht 	 *			tg_ops.
142e8fb11a1Sshidokht 	 *
143e8fb11a1Sshidokht 	 * 	Possible commands and the interpretation of arg:
144e8fb11a1Sshidokht 	 *
145e8fb11a1Sshidokht 	 *	cmd:
146e8fb11a1Sshidokht 	 *		TG_GETPHYGEOM
147e8fb11a1Sshidokht 	 *			Obtain raw physical geometry from target,
148e8fb11a1Sshidokht 	 *			and store in structure pointed to by arg,
149e8fb11a1Sshidokht 	 *			a cmlb_geom_t structure.
150e8fb11a1Sshidokht 	 *
151e8fb11a1Sshidokht 	 * 		TG_GETVIRTGEOM:
152e8fb11a1Sshidokht 	 *			Obtain HBA geometry for the target and
153e8fb11a1Sshidokht 	 *			store in struct pointed to by arg,
154e8fb11a1Sshidokht 	 *			a cmlb_geom_t structure.
155e8fb11a1Sshidokht 	 *
156e8fb11a1Sshidokht 	 *		TG_GETCAPACITY:
157e8fb11a1Sshidokht 	 *			Report the capacity of the target (in system
158e8fb11a1Sshidokht 	 *			blocksize (DEV_BSIZE) and store in the
159e8fb11a1Sshidokht 	 *			space pointed to by arg, a diskaddr_t.
160e8fb11a1Sshidokht 	 *
161e8fb11a1Sshidokht 	 *		TG_GETBLOCKSIZE:
162e8fb11a1Sshidokht 	 *			Report the block size of the target
163e8fb11a1Sshidokht 	 *			in the space pointed to by arg, a uint32_t.
164e8fb11a1Sshidokht 	 *
165e8fb11a1Sshidokht 	 *		TG_GETATTR:
166e8fb11a1Sshidokht 	 * 			Report the information requested on
167e8fb11a1Sshidokht 	 *			device/media and store in area pointed to by
168e8fb11a1Sshidokht 	 *			arg, a tg_attribute_t structure.
169e8fb11a1Sshidokht 	 *			Return values:
1703ccda647Slclee 	 *
1713ccda647Slclee 	 * Return values:
1723ccda647Slclee 	 *	0		success
173e8fb11a1Sshidokht 	 *
1743ccda647Slclee 	 *	EACCESS		reservation conflict
1753ccda647Slclee 	 *
1763ccda647Slclee 	 *	ENXIO		internal error/invalid devi
177e8fb11a1Sshidokht 	 *
178e8fb11a1Sshidokht 	 *	EINVAL		When command is TG_GETPHYGEOM or
179e8fb11a1Sshidokht 	 *			TG_GETVIRTGEOM, or TG_GETATTR, this return code
180e8fb11a1Sshidokht 	 *			indicates the operation is not applicable to
181e8fb11a1Sshidokht 	 *			target.
182e8fb11a1Sshidokht 	 *			In case of TG_GETCAP, this return code
183e8fb11a1Sshidokht 	 *			indicates no media in the drive.
184e8fb11a1Sshidokht 	 *
185b9ccdc5aScth 	 *	EIO		An error occurred during obtaining info
186e8fb11a1Sshidokht 	 *			from device/media.
187e8fb11a1Sshidokht 	 *
188e8fb11a1Sshidokht 	 *	ENOTSUP		In case of TG_GETCAP, target does not
189e8fb11a1Sshidokht 	 *			support getting capacity info.
190e8fb11a1Sshidokht 	 *
191e8fb11a1Sshidokht 	 *	ENOTTY		Unknown command.
192e8fb11a1Sshidokht 	 *
193e8fb11a1Sshidokht 	 *
1943ccda647Slclee 	 */
195e8fb11a1Sshidokht 	int (*tg_getinfo)(dev_info_t *devi, int cmd, void *arg,
196e8fb11a1Sshidokht 	    void *tg_cookie);
197e8fb11a1Sshidokht 
1983ccda647Slclee } cmlb_tg_ops_t;
1993ccda647Slclee 
2003ccda647Slclee 
2013ccda647Slclee typedef struct __cmlb_handle *cmlb_handle_t;
2023ccda647Slclee 
2033ccda647Slclee /*
2043ccda647Slclee  *
2053ccda647Slclee  * Functions exported from cmlb
2063ccda647Slclee  *
2073ccda647Slclee  * Note: Most these functions can callback to target driver through the
2083ccda647Slclee  * tg_ops functions. Target driver should consider this for synchronization.
2093ccda647Slclee  * Any functions that may adjust minor nodes should be called when
2103ccda647Slclee  * the target driver ensures it is safe to do so.
2113ccda647Slclee  */
2123ccda647Slclee 
2133ccda647Slclee /*
2143ccda647Slclee  * cmlb_alloc_handle:
2153ccda647Slclee  *
2163ccda647Slclee  *	Allocates a handle.
2173ccda647Slclee  *
2183ccda647Slclee  * Arguments:
2193ccda647Slclee  *	cmlbhandlep	pointer to handle
2203ccda647Slclee  *
2213ccda647Slclee  * Notes:
2223ccda647Slclee  *	Allocates a handle and stores the allocated handle in the area
2233ccda647Slclee  *	pointed to by cmlbhandlep
2243ccda647Slclee  *
2253ccda647Slclee  * Context:
2263ccda647Slclee  *	Kernel thread only (can sleep).
2273ccda647Slclee  */
2283ccda647Slclee void
2293ccda647Slclee cmlb_alloc_handle(cmlb_handle_t *cmlbhandlep);
2303ccda647Slclee 
2313ccda647Slclee 
2323ccda647Slclee /*
2333ccda647Slclee  * cmlb_attach:
2343ccda647Slclee  *
2353ccda647Slclee  *	Attach handle to device, create minor nodes for device.
2363ccda647Slclee  *
2373ccda647Slclee  *
2383ccda647Slclee  * Arguments:
2393ccda647Slclee  * 	devi		pointer to device's dev_info structure.
2403ccda647Slclee  * 	tgopsp		pointer to array of functions cmlb can use to callback
2413ccda647Slclee  *			to target driver.
2423ccda647Slclee  *
2433ccda647Slclee  *	device_type	Peripheral device type as defined in
2443ccda647Slclee  *			scsi/generic/inquiry.h
2453ccda647Slclee  *
2463ccda647Slclee  *	is_removable	whether or not device is removable.
2473ccda647Slclee  *
248e8fb11a1Sshidokht  *	is_hotpluggable	whether or not device is hotpluggable.
249e8fb11a1Sshidokht  *
2503ccda647Slclee  *	node_type	minor node type (as used by ddi_create_minor_node)
2513ccda647Slclee  *
2523ccda647Slclee  *	alter_behavior
2533ccda647Slclee  *			bit flags:
2543ccda647Slclee  *
2553ccda647Slclee  *			CMLB_CREATE_ALTSLICE_VTOC_16_DTYPE_DIRECT: create
2563ccda647Slclee  *			an alternate slice for the default label, if
2573ccda647Slclee  *			device type is DTYPE_DIRECT an architectures default
2583ccda647Slclee  *			label type is VTOC16.
2593ccda647Slclee  *			Otherwise alternate slice will no be created.
2603ccda647Slclee  *
2613ccda647Slclee  *
2623ccda647Slclee  *			CMLB_FAKE_GEOM_LABEL_IOCTLS_VTOC8: report a default
2633ccda647Slclee  *			geometry and label for DKIOCGGEOM and DKIOCGVTOC
2643ccda647Slclee  *			on architecture with VTOC 8 label types.
2653ccda647Slclee  *
266e8fb11a1Sshidokht  * 			CMLB_OFF_BY_ONE: do the workaround for legacy off-by-
267e8fb11a1Sshidokht  *			one bug in obtaining capacity (used for sd).
268e8fb11a1Sshidokht  *
2693ccda647Slclee  *
2703ccda647Slclee  *	cmlbhandle	cmlb handle associated with device
2713ccda647Slclee  *
272e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
273e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
274e8fb11a1Sshidokht  *
275e8fb11a1Sshidokht  *			cmlb does not interpret the values. It is currently
276e8fb11a1Sshidokht  *			used for sd to indicate whether retries are allowed
277e8fb11a1Sshidokht  *			on commands or not. e.g when cmlb entries are called
278e8fb11a1Sshidokht  *			from interrupt context on removable media, sd rather
279e8fb11a1Sshidokht  *			not have retries done.
280e8fb11a1Sshidokht  *
281e8fb11a1Sshidokht  *
282e8fb11a1Sshidokht  *
2833ccda647Slclee  * Notes:
2843ccda647Slclee  *	Assumes a default label based on capacity for non-removable devices.
2853ccda647Slclee  *	If capacity > 1TB, EFI is assumed otherwise VTOC (default VTOC
2863ccda647Slclee  *	for the architecture).
2873ccda647Slclee  *	For removable devices, default label type is assumed to be VTOC
2883ccda647Slclee  *	type. Create minor nodes based on a default label type.
2893ccda647Slclee  *	Label on the media is not validated.
2903ccda647Slclee  *	minor number consists of:
2913ccda647Slclee  *		if _SUNOS_VTOC_8 is defined
2923ccda647Slclee  *			lowest 3 bits is taken as partition number
2933ccda647Slclee  *			the rest is instance number
2943ccda647Slclee  *		if _SUNOS_VTOC_16 is defined
2953ccda647Slclee  *			lowest 6 bits is taken as partition number
2963ccda647Slclee  *			the rest is instance number
2973ccda647Slclee  *
2983ccda647Slclee  *
2993ccda647Slclee  * Return values:
3003ccda647Slclee  *	0 	Success
3013ccda647Slclee  * 	ENXIO 	creating minor nodes failed.
302e8fb11a1Sshidokht  *	EINVAL	invalid arg, unsupported tg_ops version
3033ccda647Slclee  *
3043ccda647Slclee  */
3053ccda647Slclee int
3063ccda647Slclee cmlb_attach(dev_info_t *devi, cmlb_tg_ops_t *tgopsp, int device_type,
307*7f0b8309SEdward Pilatowicz     boolean_t is_removable, boolean_t is_hotpluggable, char *node_type,
308e8fb11a1Sshidokht     int alter_behavior, cmlb_handle_t cmlbhandle, void *tg_cookie);
3093ccda647Slclee 
3103ccda647Slclee 
3113ccda647Slclee /*
3123ccda647Slclee  * cmlb_validate:
3133ccda647Slclee  *
3143ccda647Slclee  *	Validates label.
3153ccda647Slclee  *
3163ccda647Slclee  * Arguments
3173ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
3183ccda647Slclee  *
319e8fb11a1Sshidokht  * 	int 		flags
320e8fb11a1Sshidokht  *			currently used for verbosity control.
321e8fb11a1Sshidokht  *			CMLB_SILENT is the only current definition for it
322e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
323e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
3243ccda647Slclee  * Notes:
3253ccda647Slclee  *	If new label type is different from the current, adjust minor nodes
3263ccda647Slclee  *	accordingly.
3273ccda647Slclee  *
3283ccda647Slclee  * Return values:
3293ccda647Slclee  *	0		success
3303ccda647Slclee  *			Note: having fdisk but no solaris partition is assumed
3313ccda647Slclee  *			success.
3323ccda647Slclee  *
3333ccda647Slclee  *	ENOMEM		memory allocation failed
3343ccda647Slclee  *	EIO		i/o errors during read or get capacity
3353ccda647Slclee  * 	EACCESS		reservation conflicts
3363ccda647Slclee  * 	EINVAL		label was corrupt, or no default label was assumed
3373ccda647Slclee  *	ENXIO		invalid handle
3383ccda647Slclee  *
3393ccda647Slclee  */
3403ccda647Slclee int
341e8fb11a1Sshidokht cmlb_validate(cmlb_handle_t cmlbhandle, int flags, void *tg_cookie);
3423ccda647Slclee 
3433ccda647Slclee /*
3443ccda647Slclee  * cmlb_invalidate:
3453ccda647Slclee  *	Invalidate in core label data
3463ccda647Slclee  *
3473ccda647Slclee  * Arguments:
3483ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
349e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
350e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
3513ccda647Slclee  */
3523ccda647Slclee void
353e8fb11a1Sshidokht cmlb_invalidate(cmlb_handle_t cmlbhandle, void *tg_cookie);
3543ccda647Slclee 
3553ccda647Slclee 
356e8fb11a1Sshidokht 
357e8fb11a1Sshidokht /*
358e8fb11a1Sshidokht  * cmlb_is_valid
359e8fb11a1Sshidokht  *	 Get status on whether the incore label/geom data is valid
360e8fb11a1Sshidokht  *
361e8fb11a1Sshidokht  * Arguments:
362e8fb11a1Sshidokht  *      cmlbhandle      cmlb handle associated with device.
363e8fb11a1Sshidokht  *
364e8fb11a1Sshidokht  * Return values:
365e8fb11a1Sshidokht  *      TRUE if valid
366e8fb11a1Sshidokht  *      FALSE otherwise.
367e8fb11a1Sshidokht  *
368e8fb11a1Sshidokht  */
369*7f0b8309SEdward Pilatowicz boolean_t
370e8fb11a1Sshidokht cmlb_is_valid(cmlb_handle_t cmlbhandle);
371e8fb11a1Sshidokht 
3723ccda647Slclee /*
3733ccda647Slclee  * cmlb_partinfo:
3743ccda647Slclee  *	Get partition info for specified partition number.
3753ccda647Slclee  *
3763ccda647Slclee  * Arguments:
3773ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
3783ccda647Slclee  *	part		partition number
379e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
3803ccda647Slclee  *	nblocksp	pointer to number of blocks
3813ccda647Slclee  *	startblockp	pointer to starting block
3823ccda647Slclee  *	partnamep	pointer to name of partition
3833ccda647Slclee  *	tagp		pointer to tag info
384e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
3853ccda647Slclee  *
3863ccda647Slclee  * Notes:
3873ccda647Slclee  *	If in-core label is not valid, this functions tries to revalidate
3883ccda647Slclee  *	the label. If label is valid, it stores the total number of blocks
3893ccda647Slclee  *	in this partition in the area pointed to by nblocksp, starting
3903ccda647Slclee  *	block number in area pointed to by startblockp,  pointer to partition
3913ccda647Slclee  *	name in area pointed to by partnamep, and tag value in area
3923ccda647Slclee  *	pointed by tagp.
3933ccda647Slclee  *	For EFI labels, tag value will be set to 0.
3943ccda647Slclee  *
3953ccda647Slclee  *	For all nblocksp, startblockp and partnamep, tagp, a value of NULL
3963ccda647Slclee  *	indicates the corresponding info is not requested.
3973ccda647Slclee  *
3983ccda647Slclee  *
3993ccda647Slclee  * Return values:
4003ccda647Slclee  *	0	success
4013ccda647Slclee  *	EINVAL  no valid label or requested partition number is invalid.
4023ccda647Slclee  *
4033ccda647Slclee  */
4043ccda647Slclee int
4053ccda647Slclee cmlb_partinfo(cmlb_handle_t cmlbhandle, int part, diskaddr_t *nblocksp,
406e8fb11a1Sshidokht     diskaddr_t *startblockp, char **partnamep, uint16_t *tagp, void *tg_cookie);
4073ccda647Slclee 
408af007057Syl194034 /*
409af007057Syl194034  * cmlb_efi_label_capacity:
410af007057Syl194034  *	Get capacity stored in EFI disk label.
411af007057Syl194034  *
412af007057Syl194034  * Arguments:
413af007057Syl194034  *	cmlbhandle	cmlb handle associated with device.
414af007057Syl194034  *	capacity	pointer to capacity stored in EFI disk label.
415af007057Syl194034  *	tg_cookie	cookie from target driver to be passed back to target
416af007057Syl194034  *			driver when we call back to it through tg_ops.
417af007057Syl194034  *
418af007057Syl194034  *
419af007057Syl194034  * Notes:
420af007057Syl194034  *	If in-core label is not valid, this functions tries to revalidate
421af007057Syl194034  *	the label. If label is valid and is an EFI label, it stores the capacity
422af007057Syl194034  *      in disk label in the area pointed to by capacity.
423af007057Syl194034  *
424af007057Syl194034  *
425af007057Syl194034  * Return values:
426af007057Syl194034  *	0	success
427af007057Syl194034  *	EINVAL  no valid EFI label or capacity is NULL.
428af007057Syl194034  *
429af007057Syl194034  */
430af007057Syl194034 int
431af007057Syl194034 cmlb_efi_label_capacity(cmlb_handle_t cmlbhandle, diskaddr_t *capacity,
432af007057Syl194034     void *tg_cookie);
4333ccda647Slclee 
4343ccda647Slclee /*
4353ccda647Slclee  * cmlb_ioctl:
4363ccda647Slclee  * Ioctls for label handling will be handled by this function.
4373ccda647Slclee  * These are:
4383ccda647Slclee  *	DKIOCGGEOM
4393ccda647Slclee  *	DKIOCSGEOM
4403ccda647Slclee  *	DKIOCGAPART
4413ccda647Slclee  *	DKIOCSAPART
4423ccda647Slclee  *	DKIOCGVTOC
4433ccda647Slclee  *	DKIOCGETEFI
4443ccda647Slclee  *	DKIOCPARTITION
4453ccda647Slclee  *	DKIOCSVTOC
4463ccda647Slclee  * 	DKIOCSETEFI
4473ccda647Slclee  *	DKIOCGMBOOT
4483ccda647Slclee  *	DKIOCSMBOOT
4493ccda647Slclee  *	DKIOCG_PHYGEOM
4503ccda647Slclee  *	DKIOCG_VIRTGEOM
4513ccda647Slclee  *	DKIOCPARTINFO
4523ccda647Slclee  *
4533ccda647Slclee  *
4543ccda647Slclee  *   Arguments:
4553ccda647Slclee  *	cmlbhandle 	handle associated with device.
4563ccda647Slclee  *      cmd     	ioctl operation to be performed
4573ccda647Slclee  *      arg     	user argument, contains data to be set or reference
4583ccda647Slclee  *                      parameter for get
4593ccda647Slclee  *	flag    	bit flag, indicating open settings, 32/64 bit type
4603ccda647Slclee  *      cred_p  	user credential pointer (not currently used)
4613ccda647Slclee  *	rval_p  	not currently used
462e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
463e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
464e8fb11a1Sshidokht  *
4653ccda647Slclee  *
4663ccda647Slclee  *
4673ccda647Slclee  * Return values:
4683ccda647Slclee  *	0
4693ccda647Slclee  *	EINVAL
4703ccda647Slclee  *	ENOTTY
4713ccda647Slclee  *	ENXIO
4723ccda647Slclee  *	EIO
4733ccda647Slclee  *	EFAULT
4743ccda647Slclee  *	ENOTSUP
4753ccda647Slclee  *	EPERM
4763ccda647Slclee  */
4773ccda647Slclee int
478e8fb11a1Sshidokht cmlb_ioctl(cmlb_handle_t cmlbhandle, dev_t dev, int cmd,
479e8fb11a1Sshidokht     intptr_t arg, int flag, cred_t *cred_p, int *rval_p, void *tg_cookie);
4803ccda647Slclee 
4813ccda647Slclee /*
482b9ccdc5aScth  * cmlb_prop_op:
483b9ccdc5aScth  *	provide common label prop_op(9E) implementation that understands the
484b9ccdc5aScth  *	size(9p) properties.
485b9ccdc5aScth  *
486b9ccdc5aScth  * Arguments:
487b9ccdc5aScth  *	cmlbhandle	cmlb handle associated with device.
488b9ccdc5aScth  *	dev		See prop_op(9E)
489b9ccdc5aScth  *	dip		"
490b9ccdc5aScth  *	prop_op		"
491b9ccdc5aScth  *	mod_flags	"
492b9ccdc5aScth  *	name		"
493b9ccdc5aScth  *	valuep		"
494b9ccdc5aScth  *	lengthp		"
495b9ccdc5aScth  *	part		partition number
496b9ccdc5aScth  *	tg_cookie 	cookie from target driver to be passed back to target
497b9ccdc5aScth  */
498b9ccdc5aScth int
499b9ccdc5aScth cmlb_prop_op(cmlb_handle_t cmlbhandle,
500b9ccdc5aScth     dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, int mod_flags,
501b9ccdc5aScth     char *name, caddr_t valuep, int *lengthp, int part, void *tg_cookie);
502b9ccdc5aScth 
503b9ccdc5aScth /*
5043ccda647Slclee  * cmlb_get_devid_block:
5053ccda647Slclee  *	 get the block number where device id is stored.
5063ccda647Slclee  *
5073ccda647Slclee  * Arguments:
5083ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
5093ccda647Slclee  *	devidblockp	pointer to block number.
510e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
511e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
5123ccda647Slclee  *
5133ccda647Slclee  * Notes:
5143ccda647Slclee  *	It stores the block number of device id in the area pointed to
5153ccda647Slclee  *	by devidblockp.
5163ccda647Slclee  *
5173ccda647Slclee  * Return values:
5183ccda647Slclee  *	0	success
5193ccda647Slclee  *	EINVAL 	device id does not apply to current label type.
5203ccda647Slclee  */
5213ccda647Slclee int
522e8fb11a1Sshidokht cmlb_get_devid_block(cmlb_handle_t cmlbhandle, diskaddr_t *devidblockp,
523e8fb11a1Sshidokht     void *tg_cookie);
5243ccda647Slclee 
5253ccda647Slclee 
5263ccda647Slclee /*
5273ccda647Slclee  * cmlb_close:
5283ccda647Slclee  *
5293ccda647Slclee  * Close the device, revert to a default label minor node for the device,
5303ccda647Slclee  * if it is removable.
5313ccda647Slclee  *
5323ccda647Slclee  * Arguments:
5333ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
5343ccda647Slclee  *
535e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
536e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
5373ccda647Slclee  * Return values:
5383ccda647Slclee  *	0	Success
5393ccda647Slclee  * 	ENXIO	Re-creating minor node failed.
5403ccda647Slclee  */
5413ccda647Slclee int
542e8fb11a1Sshidokht cmlb_close(cmlb_handle_t cmlbhandle, void *tg_cookie);
5433ccda647Slclee 
5443ccda647Slclee /*
5453ccda647Slclee  * cmlb_detach:
5463ccda647Slclee  *
5473ccda647Slclee  * Invalidate in-core labeling data and remove all minor nodes for
5483ccda647Slclee  * the device associate with handle.
5493ccda647Slclee  *
5503ccda647Slclee  * Arguments:
5513ccda647Slclee  *	cmlbhandle	cmlb handle associated with device.
552e8fb11a1Sshidokht  *	tg_cookie 	cookie from target driver to be passed back to target
553e8fb11a1Sshidokht  *			driver when we call back to it through tg_ops.
5543ccda647Slclee  *
5553ccda647Slclee  */
5563ccda647Slclee void
557e8fb11a1Sshidokht cmlb_detach(cmlb_handle_t cmlbhandle, void *tg_cookie);
5583ccda647Slclee 
5593ccda647Slclee /*
5603ccda647Slclee  * cmlb_free_handle
5613ccda647Slclee  *
5623ccda647Slclee  *	Frees handle.
5633ccda647Slclee  *
5643ccda647Slclee  * Arguments:
5653ccda647Slclee  *	cmlbhandlep	pointer to handle
5663ccda647Slclee  *
5673ccda647Slclee  */
5683ccda647Slclee void
5693ccda647Slclee cmlb_free_handle(cmlb_handle_t *cmlbhandlep);
5703ccda647Slclee 
5713ccda647Slclee #ifdef	__cplusplus
5723ccda647Slclee }
5733ccda647Slclee #endif
5743ccda647Slclee 
5753ccda647Slclee #endif /* _SYS_CMLB_H */
576