xref: /titanic_44/usr/src/uts/common/sys/devcache.h (revision 83c4dfe9546fd839e7a52bca7e9920da918f916e)
1*83c4dfe9Sjg /*
2*83c4dfe9Sjg  * CDDL HEADER START
3*83c4dfe9Sjg  *
4*83c4dfe9Sjg  * The contents of this file are subject to the terms of the
5*83c4dfe9Sjg  * Common Development and Distribution License (the "License").
6*83c4dfe9Sjg  * You may not use this file except in compliance with the License.
7*83c4dfe9Sjg  *
8*83c4dfe9Sjg  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*83c4dfe9Sjg  * or http://www.opensolaris.org/os/licensing.
10*83c4dfe9Sjg  * See the License for the specific language governing permissions
11*83c4dfe9Sjg  * and limitations under the License.
12*83c4dfe9Sjg  *
13*83c4dfe9Sjg  * When distributing Covered Code, include this CDDL HEADER in each
14*83c4dfe9Sjg  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*83c4dfe9Sjg  * If applicable, add the following below this CDDL HEADER, with the
16*83c4dfe9Sjg  * fields enclosed by brackets "[]" replaced with your own identifying
17*83c4dfe9Sjg  * information: Portions Copyright [yyyy] [name of copyright owner]
18*83c4dfe9Sjg  *
19*83c4dfe9Sjg  * CDDL HEADER END
20*83c4dfe9Sjg  */
21*83c4dfe9Sjg /*
22*83c4dfe9Sjg  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*83c4dfe9Sjg  * Use is subject to license terms.
24*83c4dfe9Sjg  */
25*83c4dfe9Sjg 
26*83c4dfe9Sjg #ifndef	_SYS_DEVCACHE_H
27*83c4dfe9Sjg #define	_SYS_DEVCACHE_H
28*83c4dfe9Sjg 
29*83c4dfe9Sjg #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*83c4dfe9Sjg 
31*83c4dfe9Sjg #ifdef	__cplusplus
32*83c4dfe9Sjg extern "C" {
33*83c4dfe9Sjg #endif
34*83c4dfe9Sjg 
35*83c4dfe9Sjg #include <sys/list.h>
36*83c4dfe9Sjg 
37*83c4dfe9Sjg #ifdef	_KERNEL
38*83c4dfe9Sjg 
39*83c4dfe9Sjg /*
40*83c4dfe9Sjg  * Handle reference to a registered file
41*83c4dfe9Sjg  */
42*83c4dfe9Sjg typedef struct __nvf_handle *nvf_handle_t;
43*83c4dfe9Sjg 
44*83c4dfe9Sjg /*
45*83c4dfe9Sjg  * Registration descriptor for a cache file within /etc/devices
46*83c4dfe9Sjg  *
47*83c4dfe9Sjg  * path			- cache file path path
48*83c4dfe9Sjg  * unpack_list		- when reading, called to unpack nvlist
49*83c4dfe9Sjg  * pack_list		- when writing, called to pack nvlist
50*83c4dfe9Sjg  * list_free		- free data contained within list
51*83c4dfe9Sjg  * write_complete	- called when write is completed
52*83c4dfe9Sjg  */
53*83c4dfe9Sjg typedef struct nvf_ops {
54*83c4dfe9Sjg 	char		*nvfr_cache_path;
55*83c4dfe9Sjg 	int		(*nvfr_unpack_nvlist)(nvf_handle_t, nvlist_t *, char *);
56*83c4dfe9Sjg 	int		(*nvfr_pack_list)(nvf_handle_t, nvlist_t **);
57*83c4dfe9Sjg 	void		(*nvfr_list_free)(nvf_handle_t);
58*83c4dfe9Sjg 	void		(*nvfr_write_complete)(nvf_handle_t);
59*83c4dfe9Sjg } nvf_ops_t;
60*83c4dfe9Sjg 
61*83c4dfe9Sjg /*
62*83c4dfe9Sjg  * Client interfaces
63*83c4dfe9Sjg  */
64*83c4dfe9Sjg 
65*83c4dfe9Sjg nvf_handle_t	nvf_register_file(nvf_ops_t *);
66*83c4dfe9Sjg int		nvf_read_file(nvf_handle_t);
67*83c4dfe9Sjg void		nvf_wake_daemon(void);
68*83c4dfe9Sjg void		nvf_error(const char *, ...);
69*83c4dfe9Sjg char		*nvf_cache_name(nvf_handle_t);
70*83c4dfe9Sjg krwlock_t	*nvf_lock(nvf_handle_t);
71*83c4dfe9Sjg list_t		*nvf_list(nvf_handle_t);
72*83c4dfe9Sjg void		nvf_mark_dirty(nvf_handle_t);
73*83c4dfe9Sjg int		nvf_is_dirty(nvf_handle_t);
74*83c4dfe9Sjg 
75*83c4dfe9Sjg #endif	/* _KERNEL */
76*83c4dfe9Sjg 
77*83c4dfe9Sjg #ifdef	__cplusplus
78*83c4dfe9Sjg }
79*83c4dfe9Sjg #endif
80*83c4dfe9Sjg 
81*83c4dfe9Sjg #endif	/* _SYS_DEVCACHE_H */
82