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 (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #ifndef _NSC_DISK_H
  27 #define _NSC_DISK_H
  28 
  29 #ifdef __cplusplus
  30 extern "C" {
  31 #endif
  32 
  33 #ifndef __NSC_GEN__
  34 Error: Illegal #include - private file.
  35 #endif
  36 
  37 #include <sys/types.h>
  38 #include <sys/file.h>
  39 #include <sys/uio.h>
  40 
  41 #include <sys/nsctl/nsc_dev.h>
  42 #include <sys/nsctl/nsctl.h>
  43 
  44 #define _NSC_DBUF_NVEC  5
  45 
  46 /*
  47  * Buffer structure for disk I/O.
  48  */
  49 
  50 typedef struct nsc_dbuf_s {
  51         nsc_buf_t db_buf;               /* Generic buffer header */
  52         void    (*db_disc)();           /* Disconnect callback */
  53         uio_t   db_uio;                 /* Scatter/gather list */
  54         iovec_t db_iov[_NSC_DBUF_NVEC]; /* Data transfer address */
  55         char    *db_addr;               /* Address of data buffer */
  56         nsc_vec_t db_bvec[2];           /* Pointers to data */
  57         struct nsc_dbuf_s *db_next;     /* Link to next buffer */
  58         nsc_size_t db_maxfbas;          /* Maxfbas value for the device */
  59 } nsc_dbuf_t;
  60 
  61 
  62 #define db_fd           db_buf.sb_fd
  63 #define db_pos          db_buf.sb_pos
  64 #define db_len          db_buf.sb_len
  65 #define db_flag         db_buf.sb_flag
  66 #define db_error        db_buf.sb_error
  67 #define db_vec          db_buf.sb_vec
  68 
  69 
  70 /*
  71  * Sector Mode definitions.
  72  */
  73 
  74 #define FPOS_TO_FBA(u)  ((nsc_off_t)(FBA_NUM((u)->uio_loffset)))
  75 #define FPOS_TO_OFF(u)  ((nsc_off_t)(FBA_OFF((u)->uio_loffset)))
  76 #define SET_FPOS(u, f)  ((u)->uio_loffset = (offset_t)FBA_SIZE((offset_t)f))
  77 
  78 
  79 #ifdef __cplusplus
  80 }
  81 #endif
  82 
  83 #endif /* _NSC_DISK_H */