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*8863SEdward.Pilatowicz@Sun.COM * Common Development and Distribution License (the "License"). 6*8863SEdward.Pilatowicz@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 */ 210Sstevel@tonic-gate /* 22*8863SEdward.Pilatowicz@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_DKTP_BBH_H 270Sstevel@tonic-gate #define _SYS_DKTP_BBH_H 280Sstevel@tonic-gate 29*8863SEdward.Pilatowicz@Sun.COM #include <sys/scsi/scsi_types.h> 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate struct bbh_cookie { 360Sstevel@tonic-gate lldaddr_t _ck_sector; /* sector # on device (union) */ 370Sstevel@tonic-gate long ck_seclen; /* number of contiguous sec */ 380Sstevel@tonic-gate }; 390Sstevel@tonic-gate #define ck_lsector _ck_sector._f 400Sstevel@tonic-gate #define ck_sector _ck_sector._p._l 410Sstevel@tonic-gate typedef struct bbh_cookie *bbh_cookie_t; 420Sstevel@tonic-gate 430Sstevel@tonic-gate struct bbh_handle { 440Sstevel@tonic-gate int h_totck; 450Sstevel@tonic-gate int h_idx; 460Sstevel@tonic-gate struct bbh_cookie *h_cktab; 470Sstevel@tonic-gate }; 480Sstevel@tonic-gate 490Sstevel@tonic-gate struct bbh_obj { 500Sstevel@tonic-gate opaque_t bbh_data; 510Sstevel@tonic-gate struct bbh_objops *bbh_ops; 520Sstevel@tonic-gate }; 530Sstevel@tonic-gate 540Sstevel@tonic-gate struct bbh_objops { 550Sstevel@tonic-gate int (*bbh_init)(opaque_t); 560Sstevel@tonic-gate int (*bbh_free)(struct bbh_obj *); 570Sstevel@tonic-gate opaque_t (*bbh_gethandle)(opaque_t, struct buf *); 580Sstevel@tonic-gate bbh_cookie_t (*bbh_htoc)(opaque_t, opaque_t); 590Sstevel@tonic-gate void (*bbh_freehandle)(opaque_t, opaque_t); 600Sstevel@tonic-gate void *bbh_resv[2]; 610Sstevel@tonic-gate }; 620Sstevel@tonic-gate 630Sstevel@tonic-gate #define BBH_GETCK_SECTOR(X, ckp) ((ckp)->ck_sector) 640Sstevel@tonic-gate #define BBH_GETCK_SECLEN(X, ckp) ((ckp)->ck_seclen) 650Sstevel@tonic-gate 660Sstevel@tonic-gate #define BBH_INIT(X) (*((struct bbh_obj *)(X))->bbh_ops->bbh_init)\ 670Sstevel@tonic-gate (((struct bbh_obj *)(X))->bbh_data) 680Sstevel@tonic-gate #define BBH_FREE(X) (*((struct bbh_obj *)(X))->bbh_ops->bbh_free) ((X)) 690Sstevel@tonic-gate #define BBH_GETHANDLE(X, bp) (*((struct bbh_obj *)(X))->bbh_ops->bbh_gethandle)\ 700Sstevel@tonic-gate (((struct bbh_obj *)(X))->bbh_data, (bp)) 710Sstevel@tonic-gate #define BBH_HTOC(X, handle) (*((struct bbh_obj *)(X))->bbh_ops->bbh_htoc) \ 720Sstevel@tonic-gate (((struct bbh_obj *)(X))->bbh_data, (handle)) 730Sstevel@tonic-gate #define BBH_FREEHANDLE(X, handle) \ 740Sstevel@tonic-gate (*((struct bbh_obj *)(X))->bbh_ops->bbh_freehandle) \ 750Sstevel@tonic-gate (((struct bbh_obj *)(X))->bbh_data, (handle)) 760Sstevel@tonic-gate 770Sstevel@tonic-gate #ifdef __cplusplus 780Sstevel@tonic-gate } 790Sstevel@tonic-gate #endif 800Sstevel@tonic-gate 810Sstevel@tonic-gate #endif /* _SYS_DKTP_BBH_H */ 82