xref: /titanic_41/usr/src/cmd/fm/fmd/common/fmd_fmri.h (revision e4b86885570d77af552e9cf94f142f4d744fb8c8)
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 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_FMD_FMRI_H
28 #define	_FMD_FMRI_H
29 
30 #include <sys/types.h>
31 #include <sys/fm/protocol.h>
32 #include <libnvpair.h>
33 #include <errno.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Fault Management Daemon FMRI Scheme Interfaces
41  *
42  * Note: The contents of this file are private to the implementation of the
43  * Solaris system and FMD subsystem and are subject to change at any time
44  * without notice.  Applications and drivers using these interfaces will fail
45  * to run on future releases.  These interfaces should not be used for any
46  * purpose until they are publicly documented for use outside of Sun.
47  */
48 
49 /*
50  * The following utility functions (in addition to libnvpair) are provided by
51  * fmd to facilitate the implementation of each FMRI scheme library.
52  */
53 
54 struct topo_hdl;
55 
56 #ifndef	MIN
57 #define	MIN(x, y) ((x) < (y) ? (x) : (y))
58 #endif
59 
60 #ifndef	MAX
61 #define	MAX(x, y) ((x) > (y) ? (x) : (y))
62 #endif
63 
64 extern void *fmd_fmri_alloc(size_t);
65 extern void *fmd_fmri_zalloc(size_t);
66 extern void fmd_fmri_free(void *, size_t);
67 
68 extern int fmd_fmri_set_errno(int);
69 extern void fmd_fmri_warn(const char *, ...);
70 
71 extern char *fmd_fmri_auth2str(nvlist_t *);
72 extern char *fmd_fmri_strescape(const char *);
73 extern char *fmd_fmri_strdup(const char *);
74 extern void fmd_fmri_strfree(char *);
75 
76 extern const char *fmd_fmri_get_rootdir(void);
77 extern const char *fmd_fmri_get_platform(void);
78 
79 extern uint64_t fmd_fmri_get_drgen(void);
80 
81 extern struct topo_hdl *fmd_fmri_topo_hold(int);
82 extern void fmd_fmri_topo_rele(struct topo_hdl *);
83 
84 /*
85  * The following entry points are to be implemented by each scheme:
86  */
87 extern int fmd_fmri_init(void);
88 extern void fmd_fmri_fini(void);
89 extern ssize_t fmd_fmri_nvl2str(nvlist_t *, char *, size_t);
90 extern int fmd_fmri_expand(nvlist_t *);
91 extern int fmd_fmri_present(nvlist_t *);
92 extern int fmd_fmri_replaced(nvlist_t *);
93 extern int fmd_fmri_service_state(nvlist_t *);
94 extern int fmd_fmri_unusable(nvlist_t *);
95 extern int fmd_fmri_retire(nvlist_t *);
96 extern int fmd_fmri_unretire(nvlist_t *);
97 extern int fmd_fmri_contains(nvlist_t *, nvlist_t *);
98 extern nvlist_t *fmd_fmri_translate(nvlist_t *, nvlist_t *);
99 
100 #define	FMD_OBJ_STATE_UNKNOWN		1
101 #define	FMD_OBJ_STATE_STILL_PRESENT	2
102 #define	FMD_OBJ_STATE_REPLACED		3
103 #define	FMD_OBJ_STATE_NOT_PRESENT	4
104 
105 #define	FMD_SERVICE_STATE_UNKNOWN			0
106 #define	FMD_SERVICE_STATE_OK				1
107 #define	FMD_SERVICE_STATE_DEGRADED			2
108 #define	FMD_SERVICE_STATE_UNUSABLE			3
109 #define	FMD_SERVICE_STATE_DEGRADED_PENDING_RESET	4
110 #define	FMD_SERVICE_STATE_UNUSABLE_PENDING_RESET	5
111 #define	FMD_SERVICE_STATE_UNUSABLE_UNTIL_REPLACED	6
112 #define	FMD_SERVICE_STATE_ISOLATE_PENDING		7
113 
114 #ifdef	__cplusplus
115 }
116 #endif
117 
118 #endif	/* _FMD_FMRI_H */
119