nsc_dev.h revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _NSC_DEV_H
#define _NSC_DEV_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __NSC_GEN__
#endif
/*
* Interface to I/O module.
*/
typedef struct nsc_io_s {
int id; /* Module id */
int flag; /* Flags */
char *name; /* Module name */
int refcnt; /* Reference count */
int abufcnt; /* # of allocated anonymous buffers */
int pend; /* Unregister pending */
int (*open)(); /* Open device */
int (*close)(); /* Close device */
int (*attach)(); /* Attach device */
int (*detach)(); /* Detach device */
int (*flush)(); /* Flush device */
int (*alloc_buf)(); /* Allocate buffer */
int (*free_buf)(); /* Free buffer */
int (*read)(); /* Read buffer */
int (*write)(); /* Write buffer */
int (*zero)(); /* Zero buffer */
int (*copy)(); /* Copy buffer between handles */
int (*copy_direct)(); /* Copy buffer between handle & disk */
int (*uncommit)(); /* Uncommit buffer */
int (*free_h)(); /* Free handle */
int (*uread)(); /* User read */
int (*uwrite)(); /* User write */
int (*trksize)(); /* Set track size */
int (*discard)(); /* Discard pinned data */
int (*sizes)(); /* Return size of cache */
int (*getpin)(); /* Get pinned info */
int (*nodehints)(); /* Return current node hints */
int (*partsize)(); /* Partition size */
int (*maxfbas)(); /* Maximum I/O size */
int (*control)(); /* Module control function */
long provide; /* Interface provided */
} nsc_io_t;
typedef struct nsc_path_s {
char *sp_path; /* Pathname */
int sp_type; /* Open type */
int sp_pend; /* Unregister pending */
} nsc_path_t;
/*
* Note: NSC_MAXPATH currently defined here and in nsctl.h
*/
#if !defined(NSC_MAXPATH)
#define NSC_MAXPATH 64
#endif
#define NSC_SETVAL_MAX 32
typedef struct nsc_val_s {
int sv_value; /* Value of name */
} nsc_val_t;
typedef struct nsc_devval_s {
} nsc_devval_t;
/* used for ncall */
typedef struct nsc_rval_s {
int value; /* Value of name */
} nsc_rval_t;
extern int _nsc_maxdev;
typedef struct nsc_iodev_s {
int si_refcnt; /* Reference count */
int si_busy; /* Callback in progress */
int si_pend; /* Operation is pending */
int si_rpend; /* Reserve is pending */
int si_avail; /* Available for I/O */
void *si_active; /* Active I/O chain */
} nsc_iodev_t;
typedef struct nsc_dev_s {
char *nsc_path; /* Pathname */
int nsc_refcnt; /* Reference count */
int nsc_wait; /* Count of waiters */
int nsc_pend; /* Operation is pending */
int nsc_rpend; /* Reserve is pending */
int nsc_drop; /* Detach on release */
int nsc_reopen; /* Doing reopen */
} nsc_dev_t;
/*
* Storage file descriptor.
*/
typedef struct nsc_fd_s {
int sf_avail; /* Availability for I/O */
int sf_pend; /* Operation is pending */
int sf_type; /* Open type */
int sf_flag; /* Open flags */
int sf_reopen; /* Re-open required */
int sf_reserve; /* Device is reserved */
int sf_mode; /* Type of reserve */
void (*sf_pinned)(); /* Callback - Data pinned */
void (*sf_unpinned)(); /* Callback - Data unpinned */
int (*sf_attach)(); /* Callback - Attach */
int (*sf_detach)(); /* Callback - Detach */
int (*sf_flush)(); /* Callback - Flush */
} nsc_fd_t;
/*
* External definitions.
*/
extern nsc_io_t *_nsc_null_io;
#ifdef _KERNEL
extern int _nsc_open_fd(nsc_fd_t *, int);
extern int _nsc_close_fd(nsc_fd_t *, int);
extern int _nsc_detach_fd(nsc_fd_t *, int);
extern int _nsc_wait_dev(nsc_dev_t *, int);
extern void _nsc_wake_dev(nsc_dev_t *, int *);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _NSC_DEV_H */