xref: /onnv-gate/usr/src/uts/common/sys/dktp/tgdk.h (revision 7563:84ec90ffc3f7)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7563SPrasad.Singamsetty@Sun.COM  * Common Development and Distribution License (the "License").
6*7563SPrasad.Singamsetty@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*7563SPrasad.Singamsetty@Sun.COM 
220Sstevel@tonic-gate /*
23*7563SPrasad.Singamsetty@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef _SYS_DKTP_TGDK_H
280Sstevel@tonic-gate #define	_SYS_DKTP_TGDK_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifdef	__cplusplus
310Sstevel@tonic-gate extern "C" {
320Sstevel@tonic-gate #endif
330Sstevel@tonic-gate 
340Sstevel@tonic-gate struct	tgdk_ext {
350Sstevel@tonic-gate 	unsigned	tg_rmb	: 1;
360Sstevel@tonic-gate 	unsigned	tg_rdonly  : 1;
370Sstevel@tonic-gate 	unsigned	tg_flag    : 6;
380Sstevel@tonic-gate 	char		*tg_nodetype;
390Sstevel@tonic-gate 	char		tg_ctype;
400Sstevel@tonic-gate };
410Sstevel@tonic-gate 
420Sstevel@tonic-gate struct	tgdk_obj {
430Sstevel@tonic-gate 	opaque_t		tg_data;
440Sstevel@tonic-gate 	struct tgdk_objops	*tg_ops;
450Sstevel@tonic-gate 	struct tgdk_ext		*tg_ext;
460Sstevel@tonic-gate 	struct tgdk_ext		tg_extblk;	/* extended blk defined	*/
470Sstevel@tonic-gate 						/* for easy of alloc	*/
480Sstevel@tonic-gate };
490Sstevel@tonic-gate 
500Sstevel@tonic-gate struct	tgdk_iob {
510Sstevel@tonic-gate 	struct	buf *b_bp;
520Sstevel@tonic-gate 	daddr_t	b_lblk;
530Sstevel@tonic-gate 	ssize_t	b_xfer;
540Sstevel@tonic-gate 	daddr_t	b_psec;
550Sstevel@tonic-gate 	ssize_t	b_pbytecnt;
560Sstevel@tonic-gate 	short	b_pbyteoff;
570Sstevel@tonic-gate 	short	b_flag;
580Sstevel@tonic-gate };
590Sstevel@tonic-gate typedef struct tgdk_iob *tgdk_iob_handle;
600Sstevel@tonic-gate #define	IOB_BPALLOC	0x0001
610Sstevel@tonic-gate #define	IOB_BPBUFALLOC	0x0002
620Sstevel@tonic-gate 
630Sstevel@tonic-gate struct	tgdk_geom {
640Sstevel@tonic-gate 	int	g_cyl;
650Sstevel@tonic-gate 	int	g_acyl;
660Sstevel@tonic-gate 	int	g_head;
670Sstevel@tonic-gate 	int	g_sec;
680Sstevel@tonic-gate 	int	g_secsiz;
69*7563SPrasad.Singamsetty@Sun.COM 	diskaddr_t 	g_cap;
700Sstevel@tonic-gate };
710Sstevel@tonic-gate 
720Sstevel@tonic-gate struct	tgdk_objops {
730Sstevel@tonic-gate 	int  (*tg_init)(opaque_t, opaque_t, opaque_t, opaque_t, opaque_t,
740Sstevel@tonic-gate 	    void *);
750Sstevel@tonic-gate 	int  (*tg_free)(struct tgdk_obj *);
760Sstevel@tonic-gate 	int  (*tg_probe)(opaque_t, int);
770Sstevel@tonic-gate 	int  (*tg_attach)(opaque_t);
780Sstevel@tonic-gate 	int  (*tg_open)(opaque_t, int);
790Sstevel@tonic-gate 	int  (*tg_close)(opaque_t);
800Sstevel@tonic-gate 	int  (*tg_ioctl)(opaque_t, dev_t, int, intptr_t, int, cred_t *, int *);
810Sstevel@tonic-gate 	int  (*tg_strategy)(opaque_t, struct buf *);
820Sstevel@tonic-gate 	int  (*tg_setgeom)(opaque_t, struct tgdk_geom *);
830Sstevel@tonic-gate 	int  (*tg_getgeom)(opaque_t, struct tgdk_geom *);
840Sstevel@tonic-gate 	tgdk_iob_handle	(*tg_iob_alloc)(opaque_t, daddr_t, ssize_t, int);
850Sstevel@tonic-gate 	int  (*tg_iob_free)(opaque_t, struct tgdk_iob *);
860Sstevel@tonic-gate 	caddr_t	(*tg_iob_htoc)(opaque_t, struct tgdk_iob *);
870Sstevel@tonic-gate 	caddr_t	(*tg_iob_xfer)(opaque_t, struct tgdk_iob *, int);
880Sstevel@tonic-gate 	int  (*tg_dump)(opaque_t, struct buf *);
890Sstevel@tonic-gate 	int  (*tg_getphygeom)(opaque_t, struct tgdk_geom *);
900Sstevel@tonic-gate 	int  (*tg_set_bbhobj)(opaque_t, opaque_t);
910Sstevel@tonic-gate 	int  (*tg_check_media)(opaque_t, int *);
920Sstevel@tonic-gate 	int  (*tg_inquiry)(opaque_t, opaque_t *);
930Sstevel@tonic-gate 	void (*tg_cleanup)(struct tgdk_obj *);
940Sstevel@tonic-gate 	void *tg_resv[1];
950Sstevel@tonic-gate };
960Sstevel@tonic-gate 
97753Slclee struct tgdk_obj *dadk_create();
98753Slclee 
990Sstevel@tonic-gate #define	TGDK_GETNODETYPE(X) (((struct tgdk_obj *)(X))->tg_ext->tg_nodetype)
1000Sstevel@tonic-gate #define	TGDK_SETNODETYPE(X, Y) \
1010Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_ext->tg_nodetype = (char *)(Y))
1020Sstevel@tonic-gate #define	TGDK_RMB(X) 	(((struct tgdk_obj *)(X))->tg_ext->tg_rmb)
1030Sstevel@tonic-gate #define	TGDK_RDONLY(X) 	(((struct tgdk_obj *)(X))->tg_ext->tg_rdonly)
1040Sstevel@tonic-gate #define	TGDK_GETCTYPE(X) (((struct tgdk_obj *)(X))->tg_ext->tg_ctype)
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate #define	TGDK_INIT(X, devp, flcobjp, queobjp, bbhobjp, lkarg) \
1080Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_init) \
1090Sstevel@tonic-gate 		(((struct tgdk_obj *)(X))->tg_data, (devp), (flcobjp), \
1100Sstevel@tonic-gate 		(queobjp), (bbhobjp), (lkarg))
1110Sstevel@tonic-gate #define	TGDK_INIT_X(X, devp, flcobjp, queobjp, bbhobjp, lkarg, cbfunc, cbarg) \
1120Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_init) \
1130Sstevel@tonic-gate 		(((struct tgdk_obj *)(X))->tg_data, (devp), (flcobjp), \
1140Sstevel@tonic-gate 		(queobjp), (bbhobjp), (lkarg), (cbfunc), (cbarg))
1150Sstevel@tonic-gate #define	TGDK_FREE(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_free) ((X))
1160Sstevel@tonic-gate #define	TGDK_PROBE(X, WAIT) (*((struct tgdk_obj *)(X))->tg_ops->tg_probe) \
1170Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (WAIT))
1180Sstevel@tonic-gate #define	TGDK_ATTACH(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_attach) \
1190Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data)
1200Sstevel@tonic-gate #define	TGDK_OPEN(X, flag) (*((struct tgdk_obj *)(X))->tg_ops->tg_open) \
1210Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (flag))
1220Sstevel@tonic-gate #define	TGDK_CLOSE(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_close) \
1230Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data)
1240Sstevel@tonic-gate #define	TGDK_IOCTL(X, dev, cmd, arg, flag, cred_p, rval_p) \
1250Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_ioctl) \
1260Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (dev), (cmd), (arg), (flag), \
1270Sstevel@tonic-gate 		(cred_p), (rval_p))
1280Sstevel@tonic-gate #define	TGDK_STRATEGY(X, bp) (*((struct tgdk_obj *)(X))->tg_ops->tg_strategy) \
1290Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (bp))
1300Sstevel@tonic-gate #define	TGDK_GETGEOM(X, datap) (*((struct tgdk_obj *)(X))->tg_ops->tg_getgeom) \
1310Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (datap))
1320Sstevel@tonic-gate #define	TGDK_SETGEOM(X, datap) (*((struct tgdk_obj *)(X))->tg_ops->tg_setgeom) \
1330Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (datap))
1340Sstevel@tonic-gate #define	TGDK_IOB_ALLOC(X, logblk, xfer, sleep) \
1350Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_alloc) \
1360Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (logblk), (xfer), (sleep))
1370Sstevel@tonic-gate #define	TGDK_IOB_FREE(X, datap) \
1380Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_free) \
1390Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (datap))
1400Sstevel@tonic-gate #define	TGDK_IOB_HTOC(X, handle) \
1410Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_htoc) \
1420Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (handle))
1430Sstevel@tonic-gate #define	TGDK_IOB_RD(X, handle) \
1440Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_xfer) \
1450Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (handle), B_READ)
1460Sstevel@tonic-gate #define	TGDK_IOB_WR(X, handle) \
1470Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_iob_xfer) \
1480Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (handle), B_WRITE)
1490Sstevel@tonic-gate #define	TGDK_DUMP(X, bp) (*((struct tgdk_obj *)(X))->tg_ops->tg_dump) \
1500Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (bp))
1510Sstevel@tonic-gate #define	TGDK_GETPHYGEOM(X, datap) \
1520Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_getphygeom) \
1530Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (datap))
1540Sstevel@tonic-gate #define	TGDK_SET_BBHOBJ(X, objp) \
1550Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_set_bbhobj) \
1560Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (objp))
1570Sstevel@tonic-gate #define	TGDK_CHECK_MEDIA(X, state) \
1580Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_check_media) \
1590Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (state))
1600Sstevel@tonic-gate #define	TGDK_INQUIRY(X, inqpp) \
1610Sstevel@tonic-gate 	(*((struct tgdk_obj *)(X))->tg_ops->tg_inquiry) \
1620Sstevel@tonic-gate 	(((struct tgdk_obj *)(X))->tg_data, (inqpp))
1630Sstevel@tonic-gate #define	TGDK_CLEANUP(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_cleanup) ((X))
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate #define	LBLK2SEC(BLK, SHF) (daddr_t)((BLK) >> (SHF))
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate #define	SETBPERR	bioerror
1680Sstevel@tonic-gate 
1690Sstevel@tonic-gate #define	DK_MAXRECSIZE	(256<<10)	/* maximum io record size 	*/
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate #ifdef	__cplusplus
1720Sstevel@tonic-gate }
1730Sstevel@tonic-gate #endif
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate #endif	/* _SYS_DKTP_TGDK_H */
176