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