xref: /onnv-gate/usr/src/uts/common/avs/ns/nsctl.h (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM 
26*7836SJohn.Forte@Sun.COM #ifndef	_SYS_NSCTL_H
27*7836SJohn.Forte@Sun.COM #define	_SYS_NSCTL_H
28*7836SJohn.Forte@Sun.COM 
29*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
30*7836SJohn.Forte@Sun.COM extern "C" {
31*7836SJohn.Forte@Sun.COM #endif
32*7836SJohn.Forte@Sun.COM 
33*7836SJohn.Forte@Sun.COM #if (defined(lint) || defined(OSDEBUG)) && defined(_KERNEL)
34*7836SJohn.Forte@Sun.COM #define	__NSC_GEN__
35*7836SJohn.Forte@Sun.COM #include <sys/ksynch.h>
36*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsc_dev.h>
37*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsc_gen.h>
38*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsc_mem.h>
39*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsc_rmspin.h>
40*7836SJohn.Forte@Sun.COM #endif
41*7836SJohn.Forte@Sun.COM 
42*7836SJohn.Forte@Sun.COM 
43*7836SJohn.Forte@Sun.COM /*
44*7836SJohn.Forte@Sun.COM  * nsctl multi-terabyte volume support
45*7836SJohn.Forte@Sun.COM  *
46*7836SJohn.Forte@Sun.COM  * To build a multi-terabyte stack, '#define NSC_MULTI_TERABYTE'.
47*7836SJohn.Forte@Sun.COM  */
48*7836SJohn.Forte@Sun.COM 
49*7836SJohn.Forte@Sun.COM #ifdef NSC_MULTI_TERABYTE
50*7836SJohn.Forte@Sun.COM typedef uint64_t	nsc_off_t;	/* positions, offsets */
51*7836SJohn.Forte@Sun.COM typedef uint64_t	nsc_size_t;	/* lengths, sizes */
52*7836SJohn.Forte@Sun.COM #ifdef _LP64
53*7836SJohn.Forte@Sun.COM #define	NSC_SZFMT	"lu"
54*7836SJohn.Forte@Sun.COM #define	NSC_XSZFMT	"lx"
55*7836SJohn.Forte@Sun.COM #else
56*7836SJohn.Forte@Sun.COM #define	NSC_SZFMT	"llu"
57*7836SJohn.Forte@Sun.COM #define	NSC_XSZFMT	"llx"
58*7836SJohn.Forte@Sun.COM #endif
59*7836SJohn.Forte@Sun.COM 
60*7836SJohn.Forte@Sun.COM #else	/* max 1TB volume size */
61*7836SJohn.Forte@Sun.COM typedef int		nsc_off_t;
62*7836SJohn.Forte@Sun.COM typedef int		nsc_size_t;
63*7836SJohn.Forte@Sun.COM #define	NSC_SZFMT	"u"
64*7836SJohn.Forte@Sun.COM #define	NSC_XSZFMT	"x"
65*7836SJohn.Forte@Sun.COM #endif
66*7836SJohn.Forte@Sun.COM 
67*7836SJohn.Forte@Sun.COM 
68*7836SJohn.Forte@Sun.COM #ifdef _KERNEL
69*7836SJohn.Forte@Sun.COM 
70*7836SJohn.Forte@Sun.COM #ifdef sun
71*7836SJohn.Forte@Sun.COM #include <sys/nsc_ddi.h>
72*7836SJohn.Forte@Sun.COM #endif
73*7836SJohn.Forte@Sun.COM 
74*7836SJohn.Forte@Sun.COM /*
75*7836SJohn.Forte@Sun.COM  * Generic parameter definition.
76*7836SJohn.Forte@Sun.COM  */
77*7836SJohn.Forte@Sun.COM 
78*7836SJohn.Forte@Sun.COM typedef struct nsc_def_s {
79*7836SJohn.Forte@Sun.COM 	char	*name;			/* Parameter name */
80*7836SJohn.Forte@Sun.COM 	uintptr_t value;		/* Parameter value */
81*7836SJohn.Forte@Sun.COM 	int	offset;			/* Structure offset */
82*7836SJohn.Forte@Sun.COM } nsc_def_t;
83*7836SJohn.Forte@Sun.COM 
84*7836SJohn.Forte@Sun.COM extern int nsc_inval(), nsc_ioerr();
85*7836SJohn.Forte@Sun.COM extern int nsc_fatal(), nsc_null(), nsc_true();
86*7836SJohn.Forte@Sun.COM extern void nsc_decode_param(nsc_def_t *, nsc_def_t *, long *);
87*7836SJohn.Forte@Sun.COM #endif	/* _KERNEL */
88*7836SJohn.Forte@Sun.COM 
89*7836SJohn.Forte@Sun.COM 
90*7836SJohn.Forte@Sun.COM /* ID and Type flags */
91*7836SJohn.Forte@Sun.COM 
92*7836SJohn.Forte@Sun.COM #define	NSC_ID		0x40000000	/* Module ID */
93*7836SJohn.Forte@Sun.COM #define	NSC_NULL	0x00000100	/* No I/O possible */
94*7836SJohn.Forte@Sun.COM #define	NSC_DEVICE	0x00000200	/* Device interface */
95*7836SJohn.Forte@Sun.COM #define	NSC_FILE	0x00000400	/* File vnode interface */
96*7836SJohn.Forte@Sun.COM #define	NSC_CACHE	0x00000800	/* Cache interface */
97*7836SJohn.Forte@Sun.COM #define	NSC_ANON	0x00001000	/* Supports anonymous buffers */
98*7836SJohn.Forte@Sun.COM #define	NSC_VCHR	0x00002000	/* VCHR vnode device */
99*7836SJohn.Forte@Sun.COM #define	NSC_NCALL	0x00004000	/* ncall-io interface */
100*7836SJohn.Forte@Sun.COM 
101*7836SJohn.Forte@Sun.COM #define	NSC_IDS		0x7ff00000	/* ID mask */
102*7836SJohn.Forte@Sun.COM #define	NSC_TYPES	0x7fffff00	/* Type mask */
103*7836SJohn.Forte@Sun.COM 
104*7836SJohn.Forte@Sun.COM #define	NSC_MKID(x)	(NSC_ID | ((x) << 20))
105*7836SJohn.Forte@Sun.COM 
106*7836SJohn.Forte@Sun.COM #define	NSC_RAW_ID  	NSC_MKID(39)	/* Raw device */
107*7836SJohn.Forte@Sun.COM #define	NSC_FILE_ID	NSC_MKID(40)	/* File vnode device */
108*7836SJohn.Forte@Sun.COM #define	NSC_FREEZE_ID	NSC_MKID(41)	/* Frozen raw device */
109*7836SJohn.Forte@Sun.COM #define	NSC_VCHR_ID	NSC_MKID(42)	/* VCHR vnode device */
110*7836SJohn.Forte@Sun.COM #define	NSC_NCALL_ID	NSC_MKID(43)	/* ncall-io */
111*7836SJohn.Forte@Sun.COM #define	NSC_SDBC_ID	NSC_MKID(80)	/* Block based cache */
112*7836SJohn.Forte@Sun.COM #define	NSC_RDCLR_ID	NSC_MKID(94)	/* RDC (low, raw) */
113*7836SJohn.Forte@Sun.COM #define	NSC_RDCL_ID	NSC_MKID(95)	/* RDC (low, cache) */
114*7836SJohn.Forte@Sun.COM #define	NSC_IIR_ID	NSC_MKID(96)	/* Instant Image (raw) */
115*7836SJohn.Forte@Sun.COM #define	NSC_II_ID	NSC_MKID(98)	/* Instant Image */
116*7836SJohn.Forte@Sun.COM #define	NSC_RDCHR_ID	NSC_MKID(99)	/* RDC (high, raw) */
117*7836SJohn.Forte@Sun.COM #define	NSC_RDCH_ID	NSC_MKID(100)	/* RDC (high, cache) */
118*7836SJohn.Forte@Sun.COM 
119*7836SJohn.Forte@Sun.COM typedef enum nsc_power_ops_e {
120*7836SJohn.Forte@Sun.COM 	Power_Lost,	/* Power Failing initial warning */
121*7836SJohn.Forte@Sun.COM 			/* with timeleft (rideout) minutes */
122*7836SJohn.Forte@Sun.COM 
123*7836SJohn.Forte@Sun.COM 	Power_OK,	/* Power OK or restored before death */
124*7836SJohn.Forte@Sun.COM 
125*7836SJohn.Forte@Sun.COM 	Power_Down 	/* that's all folks machine will */
126*7836SJohn.Forte@Sun.COM 			/* be shutdown, save any state */
127*7836SJohn.Forte@Sun.COM } nsc_power_ops_t;
128*7836SJohn.Forte@Sun.COM 
129*7836SJohn.Forte@Sun.COM #ifdef _KERNEL
130*7836SJohn.Forte@Sun.COM 
131*7836SJohn.Forte@Sun.COM /* Module Flags */
132*7836SJohn.Forte@Sun.COM 
133*7836SJohn.Forte@Sun.COM #define	NSC_REFCNT	0x00000001	/* Counts references */
134*7836SJohn.Forte@Sun.COM #define	NSC_FILTER	0x00000002	/* Uses lower level driver */
135*7836SJohn.Forte@Sun.COM 
136*7836SJohn.Forte@Sun.COM 
137*7836SJohn.Forte@Sun.COM #ifndef _NSC_DEV_H
138*7836SJohn.Forte@Sun.COM typedef struct nsc_io_s { int x; } nsc_io_t;
139*7836SJohn.Forte@Sun.COM typedef struct nsc_path_s { int x; } nsc_path_t;
140*7836SJohn.Forte@Sun.COM #endif
141*7836SJohn.Forte@Sun.COM 
142*7836SJohn.Forte@Sun.COM extern nsc_io_t *nsc_register_io(char *, int, nsc_def_t *);
143*7836SJohn.Forte@Sun.COM extern int nsc_unregister_io(nsc_io_t *, int);
144*7836SJohn.Forte@Sun.COM extern nsc_path_t *nsc_register_path(char *, int, nsc_io_t *);
145*7836SJohn.Forte@Sun.COM extern int nsc_unregister_path(nsc_path_t *, int);
146*7836SJohn.Forte@Sun.COM extern int nsc_cache_sizes(int *, int *);
147*7836SJohn.Forte@Sun.COM extern int nsc_node_hints(unsigned int *);
148*7836SJohn.Forte@Sun.COM extern int nsc_node_hints_set(unsigned int);
149*7836SJohn.Forte@Sun.COM extern blind_t nsc_register_power(char *, nsc_def_t *);
150*7836SJohn.Forte@Sun.COM extern int nsc_unregister_power(blind_t);
151*7836SJohn.Forte@Sun.COM 
152*7836SJohn.Forte@Sun.COM /*
153*7836SJohn.Forte@Sun.COM  *  Strategy function interface
154*7836SJohn.Forte@Sun.COM  */
155*7836SJohn.Forte@Sun.COM #ifndef DS_DDICT
156*7836SJohn.Forte@Sun.COM typedef int (*strategy_fn_t)(struct buf *);
157*7836SJohn.Forte@Sun.COM #endif
158*7836SJohn.Forte@Sun.COM extern strategy_fn_t    nsc_get_strategy(major_t);
159*7836SJohn.Forte@Sun.COM 
160*7836SJohn.Forte@Sun.COM extern void *nsc_get_devops(major_t);
161*7836SJohn.Forte@Sun.COM 
162*7836SJohn.Forte@Sun.COM #endif /* _KERNEL */
163*7836SJohn.Forte@Sun.COM 
164*7836SJohn.Forte@Sun.COM 
165*7836SJohn.Forte@Sun.COM /* Block sizes */
166*7836SJohn.Forte@Sun.COM 
167*7836SJohn.Forte@Sun.COM #define	FBA_SHFT	9
168*7836SJohn.Forte@Sun.COM #define	FBA_MASK	0x1ff
169*7836SJohn.Forte@Sun.COM #define	FBA_SIZE(x)	((x) << FBA_SHFT)		/* fba to bytes */
170*7836SJohn.Forte@Sun.COM #define	FBA_OFF(x)	((x) & FBA_MASK)		/* byte offset */
171*7836SJohn.Forte@Sun.COM #define	FBA_LEN(x)	FBA_NUM((x) + FBA_MASK)		/* len to fba */
172*7836SJohn.Forte@Sun.COM #define	FBA_NUM(x)	((nsc_size_t)((uint64_t)(x) >> FBA_SHFT))
173*7836SJohn.Forte@Sun.COM 							/* bytes to fba */
174*7836SJohn.Forte@Sun.COM 
175*7836SJohn.Forte@Sun.COM 
176*7836SJohn.Forte@Sun.COM /* Return values */
177*7836SJohn.Forte@Sun.COM 
178*7836SJohn.Forte@Sun.COM #define	NSC_DONE	(0)
179*7836SJohn.Forte@Sun.COM #define	NSC_PENDING  	(-1)
180*7836SJohn.Forte@Sun.COM #define	NSC_HIT		(-2)
181*7836SJohn.Forte@Sun.COM 
182*7836SJohn.Forte@Sun.COM 
183*7836SJohn.Forte@Sun.COM #if defined(_KERNEL) || defined(_KMEMUSER)
184*7836SJohn.Forte@Sun.COM 
185*7836SJohn.Forte@Sun.COM /*
186*7836SJohn.Forte@Sun.COM  * External file descriptor.
187*7836SJohn.Forte@Sun.COM  */
188*7836SJohn.Forte@Sun.COM 
189*7836SJohn.Forte@Sun.COM #ifndef _NSC_DEV_H
190*7836SJohn.Forte@Sun.COM typedef struct nsc_fd_s { int x; } nsc_fd_t;
191*7836SJohn.Forte@Sun.COM #endif
192*7836SJohn.Forte@Sun.COM 
193*7836SJohn.Forte@Sun.COM #endif /* _KERNEL || _KMEMUSER */
194*7836SJohn.Forte@Sun.COM 
195*7836SJohn.Forte@Sun.COM 
196*7836SJohn.Forte@Sun.COM #ifdef _KERNEL
197*7836SJohn.Forte@Sun.COM 
198*7836SJohn.Forte@Sun.COM #define	NSC_TRY		(1<<24)		/* Conditional operation */
199*7836SJohn.Forte@Sun.COM #define	NSC_PCATCH	(1<<25)		/* Catch signals */
200*7836SJohn.Forte@Sun.COM #define	NSC_DEFER	(1<<26)		/* Defer if busy */
201*7836SJohn.Forte@Sun.COM #define	NSC_MULTI	(1<<27)		/* Multiple reserves */
202*7836SJohn.Forte@Sun.COM #define	NSC_NOWAIT	(1<<28)		/* Don't wait if busy */
203*7836SJohn.Forte@Sun.COM 
204*7836SJohn.Forte@Sun.COM extern nsc_fd_t *nsc_open(char *, int, nsc_def_t *, blind_t, int *);
205*7836SJohn.Forte@Sun.COM extern int nsc_close(nsc_fd_t *);
206*7836SJohn.Forte@Sun.COM extern char *nsc_pathname(nsc_fd_t *);
207*7836SJohn.Forte@Sun.COM extern int nsc_fdpathcmp(nsc_fd_t *, uint64_t, char *);
208*7836SJohn.Forte@Sun.COM extern int nsc_shared(nsc_fd_t *);
209*7836SJohn.Forte@Sun.COM extern int nsc_setval(nsc_fd_t *, char *, int);
210*7836SJohn.Forte@Sun.COM extern int nsc_getval(nsc_fd_t *, char *, int *);
211*7836SJohn.Forte@Sun.COM extern int nsc_set_trksize(nsc_fd_t *, nsc_size_t);
212*7836SJohn.Forte@Sun.COM extern int nsc_discard_pinned(nsc_fd_t *, nsc_off_t, nsc_size_t);
213*7836SJohn.Forte@Sun.COM extern kmutex_t *nsc_lock_addr(nsc_fd_t *);
214*7836SJohn.Forte@Sun.COM extern int nsc_attach(nsc_fd_t *, int);
215*7836SJohn.Forte@Sun.COM extern int nsc_reserve(nsc_fd_t *, int);
216*7836SJohn.Forte@Sun.COM extern void nsc_reserve_lk(nsc_fd_t *);
217*7836SJohn.Forte@Sun.COM extern void nsc_release(nsc_fd_t *);
218*7836SJohn.Forte@Sun.COM extern int nsc_release_lk(nsc_fd_t *);
219*7836SJohn.Forte@Sun.COM extern int nsc_detach(nsc_fd_t *, int);
220*7836SJohn.Forte@Sun.COM extern int nsc_avail(nsc_fd_t *);
221*7836SJohn.Forte@Sun.COM extern int nsc_held(nsc_fd_t *);
222*7836SJohn.Forte@Sun.COM extern int nsc_waiting(nsc_fd_t *);
223*7836SJohn.Forte@Sun.COM extern int nsc_partsize(nsc_fd_t *, nsc_size_t *);
224*7836SJohn.Forte@Sun.COM extern int nsc_maxfbas(nsc_fd_t *, int, nsc_size_t *);
225*7836SJohn.Forte@Sun.COM extern int nsc_get_pinned(nsc_fd_t *);
226*7836SJohn.Forte@Sun.COM extern int nsc_max_devices(void);
227*7836SJohn.Forte@Sun.COM extern int nsc_control(nsc_fd_t *, int, void *, int);
228*7836SJohn.Forte@Sun.COM 
229*7836SJohn.Forte@Sun.COM #endif /* _KERNEL */
230*7836SJohn.Forte@Sun.COM 
231*7836SJohn.Forte@Sun.COM 
232*7836SJohn.Forte@Sun.COM #if defined(_KERNEL) || defined(_KMEMUSER)
233*7836SJohn.Forte@Sun.COM 
234*7836SJohn.Forte@Sun.COM /*
235*7836SJohn.Forte@Sun.COM  * I/O device structure.
236*7836SJohn.Forte@Sun.COM  */
237*7836SJohn.Forte@Sun.COM 
238*7836SJohn.Forte@Sun.COM #ifndef _NSC_DEV_H
239*7836SJohn.Forte@Sun.COM typedef struct nsc_iodev_s { int x; } nsc_iodev_t;
240*7836SJohn.Forte@Sun.COM #endif
241*7836SJohn.Forte@Sun.COM 
242*7836SJohn.Forte@Sun.COM #ifdef _KERNEL
243*7836SJohn.Forte@Sun.COM extern void nsc_set_owner(nsc_fd_t *, nsc_iodev_t *);
244*7836SJohn.Forte@Sun.COM extern void nsc_pinned_data(nsc_iodev_t *, nsc_off_t, nsc_size_t);
245*7836SJohn.Forte@Sun.COM extern void nsc_unpinned_data(nsc_iodev_t *, nsc_off_t, nsc_size_t);
246*7836SJohn.Forte@Sun.COM #endif
247*7836SJohn.Forte@Sun.COM 
248*7836SJohn.Forte@Sun.COM 
249*7836SJohn.Forte@Sun.COM /*
250*7836SJohn.Forte@Sun.COM  * Data structures used by I/O interface.
251*7836SJohn.Forte@Sun.COM  */
252*7836SJohn.Forte@Sun.COM 
253*7836SJohn.Forte@Sun.COM typedef struct nsc_vec_s {		/* Scatter gather element */
254*7836SJohn.Forte@Sun.COM 	unsigned char	*sv_addr;	/* Virtual address of data */
255*7836SJohn.Forte@Sun.COM 	unsigned long	sv_vme;		/* VME address of data */
256*7836SJohn.Forte@Sun.COM 	int		sv_len;		/* Data length in bytes */
257*7836SJohn.Forte@Sun.COM } nsc_vec_t;
258*7836SJohn.Forte@Sun.COM 
259*7836SJohn.Forte@Sun.COM 
260*7836SJohn.Forte@Sun.COM typedef struct nsc_buf_s {		/* Buffer structure */
261*7836SJohn.Forte@Sun.COM 	nsc_fd_t *sb_fd;		/* File descriptor */
262*7836SJohn.Forte@Sun.COM 	nsc_off_t sb_pos;		/* Block offset of data */
263*7836SJohn.Forte@Sun.COM 	nsc_size_t sb_len;		/* Length of data in blocks */
264*7836SJohn.Forte@Sun.COM 	volatile int sb_flag;		/* Buffer flags */
265*7836SJohn.Forte@Sun.COM 	int sb_error;			/* Error code */
266*7836SJohn.Forte@Sun.COM 	uintptr_t sb_user;		/* User definable */
267*7836SJohn.Forte@Sun.COM 	nsc_vec_t *sb_vec;		/* Scatter gather list */
268*7836SJohn.Forte@Sun.COM } nsc_buf_t;
269*7836SJohn.Forte@Sun.COM 
270*7836SJohn.Forte@Sun.COM #endif /* _KERNEL || _KMEMUSER */
271*7836SJohn.Forte@Sun.COM 
272*7836SJohn.Forte@Sun.COM 
273*7836SJohn.Forte@Sun.COM /* Allocate flags */
274*7836SJohn.Forte@Sun.COM 
275*7836SJohn.Forte@Sun.COM #define	NSC_RDBUF	0x0001
276*7836SJohn.Forte@Sun.COM #define	NSC_WRBUF	0x0002
277*7836SJohn.Forte@Sun.COM #define	NSC_PINNABLE	0x0004
278*7836SJohn.Forte@Sun.COM #define	NSC_NOBLOCK	0x0008
279*7836SJohn.Forte@Sun.COM 
280*7836SJohn.Forte@Sun.COM #define	NSC_READ	(NSC_RDBUF)
281*7836SJohn.Forte@Sun.COM #define	NSC_WRITE	(NSC_WRBUF)
282*7836SJohn.Forte@Sun.COM #define	NSC_RDWR	(NSC_RDBUF | NSC_WRBUF)
283*7836SJohn.Forte@Sun.COM #define	NSC_RDWRBUF	(NSC_RDBUF | NSC_WRBUF)
284*7836SJohn.Forte@Sun.COM 
285*7836SJohn.Forte@Sun.COM 
286*7836SJohn.Forte@Sun.COM /* Other flags */
287*7836SJohn.Forte@Sun.COM 
288*7836SJohn.Forte@Sun.COM #define	NSC_CACHEBLK	0x0008	/* nsc_maxfbas: size of cache block in fbas */
289*7836SJohn.Forte@Sun.COM #define	NSC_HALLOCATED	0x0010	/* handle allocated (IO provider internals) */
290*7836SJohn.Forte@Sun.COM #define	NSC_HACTIVE	0x0020	/* handle active (IO provider internals) */
291*7836SJohn.Forte@Sun.COM #define	NSC_BCOPY	0x0040	/* bcopy, don't DMA when moving data */
292*7836SJohn.Forte@Sun.COM #define	NSC_PAGEIO	0x0080	/* client will use handle for pageio */
293*7836SJohn.Forte@Sun.COM #define	NSC_ABUF	0x0100	/* anonymous buffer handle */
294*7836SJohn.Forte@Sun.COM #define	NSC_MIXED	0x0200	/* data from 2 devs is mixed in this buffer */
295*7836SJohn.Forte@Sun.COM #define	NSC_NODATA	0x0400	/* allocate without data buffer (sb_vec) */
296*7836SJohn.Forte@Sun.COM 
297*7836SJohn.Forte@Sun.COM 
298*7836SJohn.Forte@Sun.COM #define	NSC_FLAGS	0xffff
299*7836SJohn.Forte@Sun.COM 
300*7836SJohn.Forte@Sun.COM #ifdef _KERNEL
301*7836SJohn.Forte@Sun.COM 
302*7836SJohn.Forte@Sun.COM #define	NSC_ANON_CD	((blind_t)(-1)) /* used for IO provider alloc buf */
303*7836SJohn.Forte@Sun.COM 
304*7836SJohn.Forte@Sun.COM extern int nsc_alloc_buf(nsc_fd_t *, nsc_off_t, nsc_size_t, int, nsc_buf_t **);
305*7836SJohn.Forte@Sun.COM extern int nsc_alloc_abuf(nsc_off_t, nsc_size_t, int, nsc_buf_t **);
306*7836SJohn.Forte@Sun.COM extern int nsc_read(nsc_buf_t *, nsc_off_t, nsc_size_t, int);
307*7836SJohn.Forte@Sun.COM extern int nsc_write(nsc_buf_t *, nsc_off_t, nsc_size_t, int);
308*7836SJohn.Forte@Sun.COM extern int nsc_zero(nsc_buf_t *, nsc_off_t, nsc_size_t, int);
309*7836SJohn.Forte@Sun.COM extern int nsc_copy(nsc_buf_t *, nsc_buf_t *, nsc_off_t, nsc_off_t, nsc_size_t);
310*7836SJohn.Forte@Sun.COM extern int nsc_copy_direct(nsc_buf_t *, nsc_buf_t *, nsc_off_t,
311*7836SJohn.Forte@Sun.COM     nsc_off_t, nsc_size_t);
312*7836SJohn.Forte@Sun.COM extern int nsc_uncommit(nsc_buf_t *, nsc_off_t, nsc_size_t, int);
313*7836SJohn.Forte@Sun.COM extern int nsc_free_buf(nsc_buf_t *);
314*7836SJohn.Forte@Sun.COM extern nsc_buf_t *nsc_alloc_handle(nsc_fd_t *,
315*7836SJohn.Forte@Sun.COM 	void (*)(), void (*)(), void (*)());
316*7836SJohn.Forte@Sun.COM extern int nsc_free_handle(nsc_buf_t *);
317*7836SJohn.Forte@Sun.COM extern int nsc_uread(nsc_fd_t *, void *, void *);
318*7836SJohn.Forte@Sun.COM extern int nsc_uwrite(nsc_fd_t *, void *, void *);
319*7836SJohn.Forte@Sun.COM 
320*7836SJohn.Forte@Sun.COM #endif /* _KERNEL */
321*7836SJohn.Forte@Sun.COM 
322*7836SJohn.Forte@Sun.COM 
323*7836SJohn.Forte@Sun.COM /*
324*7836SJohn.Forte@Sun.COM  * Performance hints.
325*7836SJohn.Forte@Sun.COM  */
326*7836SJohn.Forte@Sun.COM 
327*7836SJohn.Forte@Sun.COM #define	NSC_WRTHRU		0x00010000
328*7836SJohn.Forte@Sun.COM #define	NSC_FORCED_WRTHRU  	0x00020000
329*7836SJohn.Forte@Sun.COM #define	NSC_NOCACHE		0x00040000
330*7836SJohn.Forte@Sun.COM #define	NSC_QUEUE		0x00080000
331*7836SJohn.Forte@Sun.COM #define	NSC_RDAHEAD		0x00100000
332*7836SJohn.Forte@Sun.COM #define	NSC_NO_FORCED_WRTHRU	0x00200000
333*7836SJohn.Forte@Sun.COM #define	NSC_METADATA		0x00400000
334*7836SJohn.Forte@Sun.COM #define	NSC_SEQ_IO		0x00800000
335*7836SJohn.Forte@Sun.COM 
336*7836SJohn.Forte@Sun.COM #define	NSC_HINTS		0x00ff0000
337*7836SJohn.Forte@Sun.COM 
338*7836SJohn.Forte@Sun.COM 
339*7836SJohn.Forte@Sun.COM #ifdef _KERNEL
340*7836SJohn.Forte@Sun.COM /*
341*7836SJohn.Forte@Sun.COM  * node hint actions
342*7836SJohn.Forte@Sun.COM  */
343*7836SJohn.Forte@Sun.COM 
344*7836SJohn.Forte@Sun.COM #define	NSC_GET_NODE_HINT	0
345*7836SJohn.Forte@Sun.COM #define	NSC_SET_NODE_HINT	1
346*7836SJohn.Forte@Sun.COM #define	NSC_CLEAR_NODE_HINT	2
347*7836SJohn.Forte@Sun.COM 
348*7836SJohn.Forte@Sun.COM /*
349*7836SJohn.Forte@Sun.COM  * Reflective memory spinlocks.
350*7836SJohn.Forte@Sun.COM  */
351*7836SJohn.Forte@Sun.COM 
352*7836SJohn.Forte@Sun.COM 
353*7836SJohn.Forte@Sun.COM #ifndef _NSC_RMSPIN_H
354*7836SJohn.Forte@Sun.COM typedef struct nsc_rmlock_s { int x; } nsc_rmlock_t;
355*7836SJohn.Forte@Sun.COM #endif
356*7836SJohn.Forte@Sun.COM 
357*7836SJohn.Forte@Sun.COM 
358*7836SJohn.Forte@Sun.COM extern nsc_rmlock_t *nsc_rm_lock_alloc(char *, int, void *);
359*7836SJohn.Forte@Sun.COM extern void nsc_rm_lock_dealloc(nsc_rmlock_t *);
360*7836SJohn.Forte@Sun.COM extern int nsc_rm_lock(nsc_rmlock_t *);
361*7836SJohn.Forte@Sun.COM extern void nsc_rm_unlock(nsc_rmlock_t *);
362*7836SJohn.Forte@Sun.COM 
363*7836SJohn.Forte@Sun.COM #endif /* _KERNEL */
364*7836SJohn.Forte@Sun.COM 
365*7836SJohn.Forte@Sun.COM 
366*7836SJohn.Forte@Sun.COM /*
367*7836SJohn.Forte@Sun.COM  * Memory allocation routines.
368*7836SJohn.Forte@Sun.COM  */
369*7836SJohn.Forte@Sun.COM 
370*7836SJohn.Forte@Sun.COM #define	NSC_MEM_LOCAL	0x1
371*7836SJohn.Forte@Sun.COM #define	NSC_MEM_GLOBAL	0x4
372*7836SJohn.Forte@Sun.COM 
373*7836SJohn.Forte@Sun.COM #define	NSC_MEM_RESIZE  0x100
374*7836SJohn.Forte@Sun.COM #define	NSC_MEM_NVDIRTY 0x400
375*7836SJohn.Forte@Sun.COM 
376*7836SJohn.Forte@Sun.COM 
377*7836SJohn.Forte@Sun.COM #ifdef _KERNEL
378*7836SJohn.Forte@Sun.COM 
379*7836SJohn.Forte@Sun.COM #ifndef _NSC_MEM_H
380*7836SJohn.Forte@Sun.COM typedef struct nsc_mem_s { int x; } nsc_mem_t;
381*7836SJohn.Forte@Sun.COM #endif
382*7836SJohn.Forte@Sun.COM 
383*7836SJohn.Forte@Sun.COM 
384*7836SJohn.Forte@Sun.COM extern nsc_mem_t *nsc_register_mem(char *, int, int);
385*7836SJohn.Forte@Sun.COM extern void nsc_unregister_mem(nsc_mem_t *);
386*7836SJohn.Forte@Sun.COM extern void *nsc_kmem_alloc(size_t, int, nsc_mem_t *);
387*7836SJohn.Forte@Sun.COM extern void *nsc_kmem_zalloc(size_t, int, nsc_mem_t *);
388*7836SJohn.Forte@Sun.COM extern void nsc_kmem_free(void *, size_t);
389*7836SJohn.Forte@Sun.COM extern void nsc_mem_sizes(nsc_mem_t *, size_t *, size_t *, size_t *);
390*7836SJohn.Forte@Sun.COM extern size_t nsc_mem_avail(nsc_mem_t *);
391*7836SJohn.Forte@Sun.COM 
392*7836SJohn.Forte@Sun.COM /* nvmem suppport */
393*7836SJohn.Forte@Sun.COM typedef void (*nsc_mem_err_cb) (void *, void *, size_t, int);
394*7836SJohn.Forte@Sun.COM extern int nsc_commit_mem(void *, void *, size_t, nsc_mem_err_cb);
395*7836SJohn.Forte@Sun.COM 
396*7836SJohn.Forte@Sun.COM extern void nsc_cm_errhdlr(void *, void *, size_t, int);
397*7836SJohn.Forte@Sun.COM 
398*7836SJohn.Forte@Sun.COM #endif /* _KERNEL */
399*7836SJohn.Forte@Sun.COM 
400*7836SJohn.Forte@Sun.COM 
401*7836SJohn.Forte@Sun.COM /*
402*7836SJohn.Forte@Sun.COM  * Max pathname
403*7836SJohn.Forte@Sun.COM  * Note: Currently defined both here and in nsc_dev.h
404*7836SJohn.Forte@Sun.COM  */
405*7836SJohn.Forte@Sun.COM #if !defined(NSC_MAXPATH)
406*7836SJohn.Forte@Sun.COM #define	NSC_MAXPATH	64
407*7836SJohn.Forte@Sun.COM #endif
408*7836SJohn.Forte@Sun.COM 
409*7836SJohn.Forte@Sun.COM #ifdef _KERNEL
410*7836SJohn.Forte@Sun.COM 
411*7836SJohn.Forte@Sun.COM /*
412*7836SJohn.Forte@Sun.COM  * Inter-module function (callback) services
413*7836SJohn.Forte@Sun.COM  */
414*7836SJohn.Forte@Sun.COM 
415*7836SJohn.Forte@Sun.COM #ifndef _NSC_GEN_H
416*7836SJohn.Forte@Sun.COM typedef struct nsc_svc_s { int x; } nsc_svc_t;
417*7836SJohn.Forte@Sun.COM #endif
418*7836SJohn.Forte@Sun.COM 
419*7836SJohn.Forte@Sun.COM extern nsc_svc_t *nsc_register_svc(char *, void (*)(intptr_t));
420*7836SJohn.Forte@Sun.COM extern int nsc_unregister_svc(nsc_svc_t *);
421*7836SJohn.Forte@Sun.COM extern int nsc_call_svc(nsc_svc_t *, intptr_t);
422*7836SJohn.Forte@Sun.COM 
423*7836SJohn.Forte@Sun.COM 
424*7836SJohn.Forte@Sun.COM /*
425*7836SJohn.Forte@Sun.COM  * String manipulation functions.
426*7836SJohn.Forte@Sun.COM  */
427*7836SJohn.Forte@Sun.COM 
428*7836SJohn.Forte@Sun.COM #ifndef sun
429*7836SJohn.Forte@Sun.COM #define	sprintf nsc_sprintf
430*7836SJohn.Forte@Sun.COM #endif /* sun */
431*7836SJohn.Forte@Sun.COM 
432*7836SJohn.Forte@Sun.COM extern char *nsc_strdup(char *);
433*7836SJohn.Forte@Sun.COM extern void nsc_strfree(char *);
434*7836SJohn.Forte@Sun.COM extern int nsc_strmatch(char *, char *);
435*7836SJohn.Forte@Sun.COM extern void nsc_sprintf(char *, char *, ...);
436*7836SJohn.Forte@Sun.COM extern uint64_t nsc_strhash(char *);
437*7836SJohn.Forte@Sun.COM 
438*7836SJohn.Forte@Sun.COM 
439*7836SJohn.Forte@Sun.COM /*
440*7836SJohn.Forte@Sun.COM  * Macro definitions.
441*7836SJohn.Forte@Sun.COM  */
442*7836SJohn.Forte@Sun.COM 
443*7836SJohn.Forte@Sun.COM #define	NSC_HIER	1
444*7836SJohn.Forte@Sun.COM 
445*7836SJohn.Forte@Sun.COM #ifndef NULL
446*7836SJohn.Forte@Sun.COM #define	NULL		0
447*7836SJohn.Forte@Sun.COM #endif
448*7836SJohn.Forte@Sun.COM 
449*7836SJohn.Forte@Sun.COM 
450*7836SJohn.Forte@Sun.COM /*
451*7836SJohn.Forte@Sun.COM  * External definitions.
452*7836SJohn.Forte@Sun.COM  */
453*7836SJohn.Forte@Sun.COM 
454*7836SJohn.Forte@Sun.COM #undef HZ
455*7836SJohn.Forte@Sun.COM extern clock_t HZ;
456*7836SJohn.Forte@Sun.COM extern int nsc_max_nodeid, nsc_min_nodeid;
457*7836SJohn.Forte@Sun.COM 
458*7836SJohn.Forte@Sun.COM extern int nsc_node_id(void);
459*7836SJohn.Forte@Sun.COM extern char *nsc_node_name(void);
460*7836SJohn.Forte@Sun.COM extern int nsc_node_up(int);
461*7836SJohn.Forte@Sun.COM extern time_t nsc_time(void);
462*7836SJohn.Forte@Sun.COM extern clock_t nsc_lbolt(void);
463*7836SJohn.Forte@Sun.COM extern int nsc_delay_sig(clock_t);
464*7836SJohn.Forte@Sun.COM extern clock_t nsc_usec(void);
465*7836SJohn.Forte@Sun.COM extern void nsc_yield(void);
466*7836SJohn.Forte@Sun.COM 
467*7836SJohn.Forte@Sun.COM extern void nsc_membar_stld(void);
468*7836SJohn.Forte@Sun.COM extern uint8_t nsc_ldstub(uint8_t *);
469*7836SJohn.Forte@Sun.COM extern caddr_t nsc_caller(void);
470*7836SJohn.Forte@Sun.COM extern caddr_t nsc_callee(void);
471*7836SJohn.Forte@Sun.COM 
472*7836SJohn.Forte@Sun.COM extern int nsc_create_process(void (*)(void *), void *, boolean_t);
473*7836SJohn.Forte@Sun.COM 
474*7836SJohn.Forte@Sun.COM extern int nsc_power_init(void);
475*7836SJohn.Forte@Sun.COM extern void nsc_power_deinit(void);
476*7836SJohn.Forte@Sun.COM extern int nsc_nodeid_data(void);
477*7836SJohn.Forte@Sun.COM 
478*7836SJohn.Forte@Sun.COM #define	NSC_ALERT_INFO		0	/* Information alert */
479*7836SJohn.Forte@Sun.COM #define	NSC_ALERT_WARNING	1	/* Warning alert */
480*7836SJohn.Forte@Sun.COM #define	NSC_ALERT_ERROR		2	/* Error alert */
481*7836SJohn.Forte@Sun.COM #define	NSC_ALERT_DOWN		3	/* System or Module down */
482*7836SJohn.Forte@Sun.COM 
483*7836SJohn.Forte@Sun.COM extern void nsc_do_sysevent(char *, char *, int, int, char *, dev_info_t *);
484*7836SJohn.Forte@Sun.COM 
485*7836SJohn.Forte@Sun.COM 
486*7836SJohn.Forte@Sun.COM /*
487*7836SJohn.Forte@Sun.COM  * Missing DDI/DKI definition.
488*7836SJohn.Forte@Sun.COM  */
489*7836SJohn.Forte@Sun.COM 
490*7836SJohn.Forte@Sun.COM #if defined(_SYS_CONF_H)
491*7836SJohn.Forte@Sun.COM #ifndef D_MP
492*7836SJohn.Forte@Sun.COM #define	D_MP 0
493*7836SJohn.Forte@Sun.COM #endif
494*7836SJohn.Forte@Sun.COM #endif
495*7836SJohn.Forte@Sun.COM 
496*7836SJohn.Forte@Sun.COM extern void *nsc_threadp(void);
497*7836SJohn.Forte@Sun.COM 
498*7836SJohn.Forte@Sun.COM #endif /* _KERNEL */
499*7836SJohn.Forte@Sun.COM 
500*7836SJohn.Forte@Sun.COM 
501*7836SJohn.Forte@Sun.COM /*
502*7836SJohn.Forte@Sun.COM  * Common defines
503*7836SJohn.Forte@Sun.COM  */
504*7836SJohn.Forte@Sun.COM 
505*7836SJohn.Forte@Sun.COM #ifndef TRUE
506*7836SJohn.Forte@Sun.COM #define	TRUE	1
507*7836SJohn.Forte@Sun.COM #endif
508*7836SJohn.Forte@Sun.COM 
509*7836SJohn.Forte@Sun.COM #ifndef FALSE
510*7836SJohn.Forte@Sun.COM #define	FALSE	0
511*7836SJohn.Forte@Sun.COM #endif
512*7836SJohn.Forte@Sun.COM 
513*7836SJohn.Forte@Sun.COM #ifndef  NBBY
514*7836SJohn.Forte@Sun.COM #define	NBBY	8	/* number of bits per byte */
515*7836SJohn.Forte@Sun.COM #endif
516*7836SJohn.Forte@Sun.COM 
517*7836SJohn.Forte@Sun.COM /*
518*7836SJohn.Forte@Sun.COM  * kstat definition
519*7836SJohn.Forte@Sun.COM  */
520*7836SJohn.Forte@Sun.COM #define	KSTAT_DATA_CHAR_LEN (sizeof (((kstat_named_t *)0)->value.c))
521*7836SJohn.Forte@Sun.COM 
522*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
523*7836SJohn.Forte@Sun.COM }
524*7836SJohn.Forte@Sun.COM #endif
525*7836SJohn.Forte@Sun.COM 
526*7836SJohn.Forte@Sun.COM #endif /* _SYS_NSCTL_H */
527