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