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_TGDK_H 28 #define _SYS_DKTP_TGDK_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 struct tgdk_ext { 37 unsigned tg_rmb : 1; 38 unsigned tg_rdonly : 1; 39 unsigned tg_flag : 6; 40 char *tg_nodetype; 41 char tg_ctype; 42 }; 43 44 struct tgdk_obj { 45 opaque_t tg_data; 46 struct tgdk_objops *tg_ops; 47 struct tgdk_ext *tg_ext; 48 struct tgdk_ext tg_extblk; /* extended blk defined */ 49 /* for easy of alloc */ 50 }; 51 52 struct tgdk_iob { 53 struct buf *b_bp; 54 daddr_t b_lblk; 55 ssize_t b_xfer; 56 daddr_t b_psec; 57 ssize_t b_pbytecnt; 58 short b_pbyteoff; 59 short b_flag; 60 }; 61 typedef struct tgdk_iob *tgdk_iob_handle; 62 #define IOB_BPALLOC 0x0001 63 #define IOB_BPBUFALLOC 0x0002 64 65 struct tgdk_geom { 66 int g_cyl; 67 int g_acyl; 68 int g_head; 69 int g_sec; 70 int g_secsiz; 71 int g_cap; 72 }; 73 74 struct tgdk_objops { 75 int (*tg_init)(opaque_t, opaque_t, opaque_t, opaque_t, opaque_t, 76 void *); 77 int (*tg_free)(struct tgdk_obj *); 78 int (*tg_probe)(opaque_t, int); 79 int (*tg_attach)(opaque_t); 80 int (*tg_open)(opaque_t, int); 81 int (*tg_close)(opaque_t); 82 int (*tg_ioctl)(opaque_t, dev_t, int, intptr_t, int, cred_t *, int *); 83 int (*tg_strategy)(opaque_t, struct buf *); 84 int (*tg_setgeom)(opaque_t, struct tgdk_geom *); 85 int (*tg_getgeom)(opaque_t, struct tgdk_geom *); 86 tgdk_iob_handle (*tg_iob_alloc)(opaque_t, daddr_t, ssize_t, int); 87 int (*tg_iob_free)(opaque_t, struct tgdk_iob *); 88 caddr_t (*tg_iob_htoc)(opaque_t, struct tgdk_iob *); 89 caddr_t (*tg_iob_xfer)(opaque_t, struct tgdk_iob *, int); 90 int (*tg_dump)(opaque_t, struct buf *); 91 int (*tg_getphygeom)(opaque_t, struct tgdk_geom *); 92 int (*tg_set_bbhobj)(opaque_t, opaque_t); 93 int (*tg_check_media)(opaque_t, int *); 94 int (*tg_inquiry)(opaque_t, opaque_t *); 95 void (*tg_cleanup)(struct tgdk_obj *); 96 void *tg_resv[1]; 97 }; 98 99 #define TGDK_GETNODETYPE(X) (((struct tgdk_obj *)(X))->tg_ext->tg_nodetype) 100 #define TGDK_SETNODETYPE(X, Y) \ 101 (((struct tgdk_obj *)(X))->tg_ext->tg_nodetype = (char *)(Y)) 102 #define TGDK_RMB(X) (((struct tgdk_obj *)(X))->tg_ext->tg_rmb) 103 #define TGDK_RDONLY(X) (((struct tgdk_obj *)(X))->tg_ext->tg_rdonly) 104 #define TGDK_GETCTYPE(X) (((struct tgdk_obj *)(X))->tg_ext->tg_ctype) 105 106 107 #define TGDK_INIT(X, devp, flcobjp, queobjp, bbhobjp, lkarg) \ 108 (*((struct tgdk_obj *)(X))->tg_ops->tg_init) \ 109 (((struct tgdk_obj *)(X))->tg_data, (devp), (flcobjp), \ 110 (queobjp), (bbhobjp), (lkarg)) 111 #define TGDK_INIT_X(X, devp, flcobjp, queobjp, bbhobjp, lkarg, cbfunc, cbarg) \ 112 (*((struct tgdk_obj *)(X))->tg_ops->tg_init) \ 113 (((struct tgdk_obj *)(X))->tg_data, (devp), (flcobjp), \ 114 (queobjp), (bbhobjp), (lkarg), (cbfunc), (cbarg)) 115 #define TGDK_FREE(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_free) ((X)) 116 #define TGDK_PROBE(X, WAIT) (*((struct tgdk_obj *)(X))->tg_ops->tg_probe) \ 117 (((struct tgdk_obj *)(X))->tg_data, (WAIT)) 118 #define TGDK_ATTACH(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_attach) \ 119 (((struct tgdk_obj *)(X))->tg_data) 120 #define TGDK_OPEN(X, flag) (*((struct tgdk_obj *)(X))->tg_ops->tg_open) \ 121 (((struct tgdk_obj *)(X))->tg_data, (flag)) 122 #define TGDK_CLOSE(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_close) \ 123 (((struct tgdk_obj *)(X))->tg_data) 124 #define TGDK_IOCTL(X, dev, cmd, arg, flag, cred_p, rval_p) \ 125 (*((struct tgdk_obj *)(X))->tg_ops->tg_ioctl) \ 126 (((struct tgdk_obj *)(X))->tg_data, (dev), (cmd), (arg), (flag), \ 127 (cred_p), (rval_p)) 128 #define TGDK_STRATEGY(X, bp) (*((struct tgdk_obj *)(X))->tg_ops->tg_strategy) \ 129 (((struct tgdk_obj *)(X))->tg_data, (bp)) 130 #define TGDK_GETGEOM(X, datap) (*((struct tgdk_obj *)(X))->tg_ops->tg_getgeom) \ 131 (((struct tgdk_obj *)(X))->tg_data, (datap)) 132 #define TGDK_SETGEOM(X, datap) (*((struct tgdk_obj *)(X))->tg_ops->tg_setgeom) \ 133 (((struct tgdk_obj *)(X))->tg_data, (datap)) 134 #define TGDK_IOB_ALLOC(X, logblk, xfer, sleep) \ 135 (*((struct tgdk_obj *)(X))->tg_ops->tg_iob_alloc) \ 136 (((struct tgdk_obj *)(X))->tg_data, (logblk), (xfer), (sleep)) 137 #define TGDK_IOB_FREE(X, datap) \ 138 (*((struct tgdk_obj *)(X))->tg_ops->tg_iob_free) \ 139 (((struct tgdk_obj *)(X))->tg_data, (datap)) 140 #define TGDK_IOB_HTOC(X, handle) \ 141 (*((struct tgdk_obj *)(X))->tg_ops->tg_iob_htoc) \ 142 (((struct tgdk_obj *)(X))->tg_data, (handle)) 143 #define TGDK_IOB_RD(X, handle) \ 144 (*((struct tgdk_obj *)(X))->tg_ops->tg_iob_xfer) \ 145 (((struct tgdk_obj *)(X))->tg_data, (handle), B_READ) 146 #define TGDK_IOB_WR(X, handle) \ 147 (*((struct tgdk_obj *)(X))->tg_ops->tg_iob_xfer) \ 148 (((struct tgdk_obj *)(X))->tg_data, (handle), B_WRITE) 149 #define TGDK_DUMP(X, bp) (*((struct tgdk_obj *)(X))->tg_ops->tg_dump) \ 150 (((struct tgdk_obj *)(X))->tg_data, (bp)) 151 #define TGDK_GETPHYGEOM(X, datap) \ 152 (*((struct tgdk_obj *)(X))->tg_ops->tg_getphygeom) \ 153 (((struct tgdk_obj *)(X))->tg_data, (datap)) 154 #define TGDK_SET_BBHOBJ(X, objp) \ 155 (*((struct tgdk_obj *)(X))->tg_ops->tg_set_bbhobj) \ 156 (((struct tgdk_obj *)(X))->tg_data, (objp)) 157 #define TGDK_CHECK_MEDIA(X, state) \ 158 (*((struct tgdk_obj *)(X))->tg_ops->tg_check_media) \ 159 (((struct tgdk_obj *)(X))->tg_data, (state)) 160 #define TGDK_INQUIRY(X, inqpp) \ 161 (*((struct tgdk_obj *)(X))->tg_ops->tg_inquiry) \ 162 (((struct tgdk_obj *)(X))->tg_data, (inqpp)) 163 #define TGDK_CLEANUP(X) (*((struct tgdk_obj *)(X))->tg_ops->tg_cleanup) ((X)) 164 165 #define LBLK2SEC(BLK, SHF) (daddr_t)((BLK) >> (SHF)) 166 167 #define SETBPERR bioerror 168 169 #define DK_MAXRECSIZE (256<<10) /* maximum io record size */ 170 171 #ifdef __cplusplus 172 } 173 #endif 174 175 #endif /* _SYS_DKTP_TGDK_H */ 176