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