xref: /illumos-gate/usr/src/uts/common/sys/dktp/bbh.h (revision 7f0b8309)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_DKTP_BBH_H
27 #define	_SYS_DKTP_BBH_H
28 
29 #include <sys/scsi/scsi_types.h>
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 struct	bbh_cookie {
36 	lldaddr_t	_ck_sector;	/* sector # on device (union) 	*/
37 	long		ck_seclen;	/* number of contiguous sec	*/
38 };
39 #define	ck_lsector	_ck_sector._f
40 #define	ck_sector	_ck_sector._p._l
41 typedef	struct  bbh_cookie *bbh_cookie_t;
42 
43 struct	bbh_handle {
44 	int	h_totck;
45 	int	h_idx;
46 	struct	bbh_cookie *h_cktab;
47 };
48 
49 struct	bbh_obj {
50 	opaque_t		bbh_data;
51 	struct bbh_objops	*bbh_ops;
52 };
53 
54 struct	bbh_objops {
55 	int		(*bbh_init)(opaque_t);
56 	int		(*bbh_free)(struct bbh_obj *);
57 	opaque_t 	(*bbh_gethandle)(opaque_t, struct buf *);
58 	bbh_cookie_t	(*bbh_htoc)(opaque_t, opaque_t);
59 	void 		(*bbh_freehandle)(opaque_t, opaque_t);
60 	void 		*bbh_resv[2];
61 };
62 
63 #define	BBH_GETCK_SECTOR(X, ckp) ((ckp)->ck_sector)
64 #define	BBH_GETCK_SECLEN(X, ckp) ((ckp)->ck_seclen)
65 
66 #define	BBH_INIT(X) (*((struct bbh_obj *)(X))->bbh_ops->bbh_init)\
67 	(((struct bbh_obj *)(X))->bbh_data)
68 #define	BBH_FREE(X) (*((struct bbh_obj *)(X))->bbh_ops->bbh_free) ((X))
69 #define	BBH_GETHANDLE(X, bp) (*((struct bbh_obj *)(X))->bbh_ops->bbh_gethandle)\
70 	(((struct bbh_obj *)(X))->bbh_data, (bp))
71 #define	BBH_HTOC(X, handle) (*((struct bbh_obj *)(X))->bbh_ops->bbh_htoc) \
72 	(((struct bbh_obj *)(X))->bbh_data, (handle))
73 #define	BBH_FREEHANDLE(X, handle) \
74 	(*((struct bbh_obj *)(X))->bbh_ops->bbh_freehandle) \
75 	(((struct bbh_obj *)(X))->bbh_data, (handle))
76 
77 #ifdef	__cplusplus
78 }
79 #endif
80 
81 #endif	/* _SYS_DKTP_BBH_H */
82