xref: /onnv-gate/usr/src/uts/common/sys/dktp/tgdk.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _SYS_DKTP_TGDK_H
28*0Sstevel@tonic-gate #define	_SYS_DKTP_TGDK_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef	__cplusplus
33*0Sstevel@tonic-gate extern "C" {
34*0Sstevel@tonic-gate #endif
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate struct	tgdk_ext {
37*0Sstevel@tonic-gate 	unsigned	tg_rmb	: 1;
38*0Sstevel@tonic-gate 	unsigned	tg_rdonly  : 1;
39*0Sstevel@tonic-gate 	unsigned	tg_flag    : 6;
40*0Sstevel@tonic-gate 	char		*tg_nodetype;
41*0Sstevel@tonic-gate 	char		tg_ctype;
42*0Sstevel@tonic-gate };
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate struct	tgdk_obj {
45*0Sstevel@tonic-gate 	opaque_t		tg_data;
46*0Sstevel@tonic-gate 	struct tgdk_objops	*tg_ops;
47*0Sstevel@tonic-gate 	struct tgdk_ext		*tg_ext;
48*0Sstevel@tonic-gate 	struct tgdk_ext		tg_extblk;	/* extended blk defined	*/
49*0Sstevel@tonic-gate 						/* for easy of alloc	*/
50*0Sstevel@tonic-gate };
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate struct	tgdk_iob {
53*0Sstevel@tonic-gate 	struct	buf *b_bp;
54*0Sstevel@tonic-gate 	daddr_t	b_lblk;
55*0Sstevel@tonic-gate 	ssize_t	b_xfer;
56*0Sstevel@tonic-gate 	daddr_t	b_psec;
57*0Sstevel@tonic-gate 	ssize_t	b_pbytecnt;
58*0Sstevel@tonic-gate 	short	b_pbyteoff;
59*0Sstevel@tonic-gate 	short	b_flag;
60*0Sstevel@tonic-gate };
61*0Sstevel@tonic-gate typedef struct tgdk_iob *tgdk_iob_handle;
62*0Sstevel@tonic-gate #define	IOB_BPALLOC	0x0001
63*0Sstevel@tonic-gate #define	IOB_BPBUFALLOC	0x0002
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate struct	tgdk_geom {
66*0Sstevel@tonic-gate 	int	g_cyl;
67*0Sstevel@tonic-gate 	int	g_acyl;
68*0Sstevel@tonic-gate 	int	g_head;
69*0Sstevel@tonic-gate 	int	g_sec;
70*0Sstevel@tonic-gate 	int	g_secsiz;
71*0Sstevel@tonic-gate 	int	g_cap;
72*0Sstevel@tonic-gate };
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate struct	tgdk_objops {
75*0Sstevel@tonic-gate 	int  (*tg_init)(opaque_t, opaque_t, opaque_t, opaque_t, opaque_t,
76*0Sstevel@tonic-gate 	    void *);
77*0Sstevel@tonic-gate 	int  (*tg_free)(struct tgdk_obj *);
78*0Sstevel@tonic-gate 	int  (*tg_probe)(opaque_t, int);
79*0Sstevel@tonic-gate 	int  (*tg_attach)(opaque_t);
80*0Sstevel@tonic-gate 	int  (*tg_open)(opaque_t, int);
81*0Sstevel@tonic-gate 	int  (*tg_close)(opaque_t);
82*0Sstevel@tonic-gate 	int  (*tg_ioctl)(opaque_t, dev_t, int, intptr_t, int, cred_t *, int *);
83*0Sstevel@tonic-gate 	int  (*tg_strategy)(opaque_t, struct buf *);
84*0Sstevel@tonic-gate 	int  (*tg_setgeom)(opaque_t, struct tgdk_geom *);
85*0Sstevel@tonic-gate 	int  (*tg_getgeom)(opaque_t, struct tgdk_geom *);
86*0Sstevel@tonic-gate 	tgdk_iob_handle	(*tg_iob_alloc)(opaque_t, daddr_t, ssize_t, int);
87*0Sstevel@tonic-gate 	int  (*tg_iob_free)(opaque_t, struct tgdk_iob *);
88*0Sstevel@tonic-gate 	caddr_t	(*tg_iob_htoc)(opaque_t, struct tgdk_iob *);
89*0Sstevel@tonic-gate 	caddr_t	(*tg_iob_xfer)(opaque_t, struct tgdk_iob *, int);
90*0Sstevel@tonic-gate 	int  (*tg_dump)(opaque_t, struct buf *);
91*0Sstevel@tonic-gate 	int  (*tg_getphygeom)(opaque_t, struct tgdk_geom *);
92*0Sstevel@tonic-gate 	int  (*tg_set_bbhobj)(opaque_t, opaque_t);
93*0Sstevel@tonic-gate 	int  (*tg_check_media)(opaque_t, int *);
94*0Sstevel@tonic-gate 	int  (*tg_inquiry)(opaque_t, opaque_t *);
95*0Sstevel@tonic-gate 	void (*tg_cleanup)(struct tgdk_obj *);
96*0Sstevel@tonic-gate 	void *tg_resv[1];
97*0Sstevel@tonic-gate };
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate #define	TGDK_GETNODETYPE(X) (((struct tgdk_obj *)(X))->tg_ext->tg_nodetype)
100*0Sstevel@tonic-gate #define	TGDK_SETNODETYPE(X, Y) \
101*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_ext->tg_nodetype = (char *)(Y))
102*0Sstevel@tonic-gate #define	TGDK_RMB(X) 	(((struct tgdk_obj *)(X))->tg_ext->tg_rmb)
103*0Sstevel@tonic-gate #define	TGDK_RDONLY(X) 	(((struct tgdk_obj *)(X))->tg_ext->tg_rdonly)
104*0Sstevel@tonic-gate #define	TGDK_GETCTYPE(X) (((struct tgdk_obj *)(X))->tg_ext->tg_ctype)
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate #define	TGDK_INIT(X, devp, flcobjp, queobjp, bbhobjp, lkarg) \
108*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_init) \
109*0Sstevel@tonic-gate 		(((struct tgdk_obj *)(X))->tg_data, (devp), (flcobjp), \
110*0Sstevel@tonic-gate 		(queobjp), (bbhobjp), (lkarg))
111*0Sstevel@tonic-gate #define	TGDK_INIT_X(X, devp, flcobjp, queobjp, bbhobjp, lkarg, cbfunc, cbarg) \
112*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_init) \
113*0Sstevel@tonic-gate 		(((struct tgdk_obj *)(X))->tg_data, (devp), (flcobjp), \
114*0Sstevel@tonic-gate 		(queobjp), (bbhobjp), (lkarg), (cbfunc), (cbarg))
115*0Sstevel@tonic-gate #define	TGDK_FREE(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_free) ((X))
116*0Sstevel@tonic-gate #define	TGDK_PROBE(X, WAIT) (*((struct tgdk_obj *)(X))->tg_ops->tg_probe) \
117*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (WAIT))
118*0Sstevel@tonic-gate #define	TGDK_ATTACH(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_attach) \
119*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data)
120*0Sstevel@tonic-gate #define	TGDK_OPEN(X, flag) (*((struct tgdk_obj *)(X))->tg_ops->tg_open) \
121*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (flag))
122*0Sstevel@tonic-gate #define	TGDK_CLOSE(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_close) \
123*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data)
124*0Sstevel@tonic-gate #define	TGDK_IOCTL(X, dev, cmd, arg, flag, cred_p, rval_p) \
125*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_ioctl) \
126*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (dev), (cmd), (arg), (flag), \
127*0Sstevel@tonic-gate 		(cred_p), (rval_p))
128*0Sstevel@tonic-gate #define	TGDK_STRATEGY(X, bp) (*((struct tgdk_obj *)(X))->tg_ops->tg_strategy) \
129*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (bp))
130*0Sstevel@tonic-gate #define	TGDK_GETGEOM(X, datap) (*((struct tgdk_obj *)(X))->tg_ops->tg_getgeom) \
131*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (datap))
132*0Sstevel@tonic-gate #define	TGDK_SETGEOM(X, datap) (*((struct tgdk_obj *)(X))->tg_ops->tg_setgeom) \
133*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (datap))
134*0Sstevel@tonic-gate #define	TGDK_IOB_ALLOC(X, logblk, xfer, sleep) \
135*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_alloc) \
136*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (logblk), (xfer), (sleep))
137*0Sstevel@tonic-gate #define	TGDK_IOB_FREE(X, datap) \
138*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_free) \
139*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (datap))
140*0Sstevel@tonic-gate #define	TGDK_IOB_HTOC(X, handle) \
141*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_htoc) \
142*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (handle))
143*0Sstevel@tonic-gate #define	TGDK_IOB_RD(X, handle) \
144*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_xfer) \
145*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (handle), B_READ)
146*0Sstevel@tonic-gate #define	TGDK_IOB_WR(X, handle) \
147*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_xfer) \
148*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (handle), B_WRITE)
149*0Sstevel@tonic-gate #define	TGDK_DUMP(X, bp) (*((struct tgdk_obj *)(X))->tg_ops->tg_dump) \
150*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (bp))
151*0Sstevel@tonic-gate #define	TGDK_GETPHYGEOM(X, datap) \
152*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_getphygeom) \
153*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (datap))
154*0Sstevel@tonic-gate #define	TGDK_SET_BBHOBJ(X, objp) \
155*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_set_bbhobj) \
156*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (objp))
157*0Sstevel@tonic-gate #define	TGDK_CHECK_MEDIA(X, state) \
158*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_check_media) \
159*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (state))
160*0Sstevel@tonic-gate #define	TGDK_INQUIRY(X, inqpp) \
161*0Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_inquiry) \
162*0Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (inqpp))
163*0Sstevel@tonic-gate #define	TGDK_CLEANUP(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_cleanup) ((X))
164*0Sstevel@tonic-gate 
165*0Sstevel@tonic-gate #define	LBLK2SEC(BLK, SHF) (daddr_t)((BLK) >> (SHF))
166*0Sstevel@tonic-gate 
167*0Sstevel@tonic-gate #define	SETBPERR	bioerror
168*0Sstevel@tonic-gate 
169*0Sstevel@tonic-gate #define	DK_MAXRECSIZE	(256<<10)	/* maximum io record size 	*/
170*0Sstevel@tonic-gate 
171*0Sstevel@tonic-gate #ifdef	__cplusplus
172*0Sstevel@tonic-gate }
173*0Sstevel@tonic-gate #endif
174*0Sstevel@tonic-gate 
175*0Sstevel@tonic-gate #endif	/* _SYS_DKTP_TGDK_H */
176