xref: /titanic_41/usr/src/cmd/fm/fmd/common/fmd_fmri.h (revision e4b86885570d77af552e9cf94f142f4d744fb8c8)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
524db4641Seschrock  * Common Development and Distribution License (the "License").
624db4641Seschrock  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21d9638e54Smws 
227c478bd9Sstevel@tonic-gate /*
2325c6ff4bSstephh  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_FMD_FMRI_H
287c478bd9Sstevel@tonic-gate #define	_FMD_FMRI_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include <sys/types.h>
317c478bd9Sstevel@tonic-gate #include <sys/fm/protocol.h>
327c478bd9Sstevel@tonic-gate #include <libnvpair.h>
337c478bd9Sstevel@tonic-gate #include <errno.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * Fault Management Daemon FMRI Scheme Interfaces
417c478bd9Sstevel@tonic-gate  *
427c478bd9Sstevel@tonic-gate  * Note: The contents of this file are private to the implementation of the
437c478bd9Sstevel@tonic-gate  * Solaris system and FMD subsystem and are subject to change at any time
447c478bd9Sstevel@tonic-gate  * without notice.  Applications and drivers using these interfaces will fail
457c478bd9Sstevel@tonic-gate  * to run on future releases.  These interfaces should not be used for any
467c478bd9Sstevel@tonic-gate  * purpose until they are publicly documented for use outside of Sun.
477c478bd9Sstevel@tonic-gate  */
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * The following utility functions (in addition to libnvpair) are provided by
517c478bd9Sstevel@tonic-gate  * fmd to facilitate the implementation of each FMRI scheme library.
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate 
547aec1d6eScindi struct topo_hdl;
557aec1d6eScindi 
567c478bd9Sstevel@tonic-gate #ifndef	MIN
577c478bd9Sstevel@tonic-gate #define	MIN(x, y) ((x) < (y) ? (x) : (y))
587c478bd9Sstevel@tonic-gate #endif
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #ifndef	MAX
617c478bd9Sstevel@tonic-gate #define	MAX(x, y) ((x) > (y) ? (x) : (y))
627c478bd9Sstevel@tonic-gate #endif
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate extern void *fmd_fmri_alloc(size_t);
657c478bd9Sstevel@tonic-gate extern void *fmd_fmri_zalloc(size_t);
667c478bd9Sstevel@tonic-gate extern void fmd_fmri_free(void *, size_t);
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate extern int fmd_fmri_set_errno(int);
697c478bd9Sstevel@tonic-gate extern void fmd_fmri_warn(const char *, ...);
707c478bd9Sstevel@tonic-gate 
71d9638e54Smws extern char *fmd_fmri_auth2str(nvlist_t *);
727c478bd9Sstevel@tonic-gate extern char *fmd_fmri_strescape(const char *);
737c478bd9Sstevel@tonic-gate extern char *fmd_fmri_strdup(const char *);
747c478bd9Sstevel@tonic-gate extern void fmd_fmri_strfree(char *);
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate extern const char *fmd_fmri_get_rootdir(void);
777c478bd9Sstevel@tonic-gate extern const char *fmd_fmri_get_platform(void);
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate extern uint64_t fmd_fmri_get_drgen(void);
807c478bd9Sstevel@tonic-gate 
8124db4641Seschrock extern struct topo_hdl *fmd_fmri_topo_hold(int);
8224db4641Seschrock extern void fmd_fmri_topo_rele(struct topo_hdl *);
837aec1d6eScindi 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * The following entry points are to be implemented by each scheme:
867c478bd9Sstevel@tonic-gate  */
877c478bd9Sstevel@tonic-gate extern int fmd_fmri_init(void);
887c478bd9Sstevel@tonic-gate extern void fmd_fmri_fini(void);
897c478bd9Sstevel@tonic-gate extern ssize_t fmd_fmri_nvl2str(nvlist_t *, char *, size_t);
907c478bd9Sstevel@tonic-gate extern int fmd_fmri_expand(nvlist_t *);
917c478bd9Sstevel@tonic-gate extern int fmd_fmri_present(nvlist_t *);
9225c6ff4bSstephh extern int fmd_fmri_replaced(nvlist_t *);
9325c6ff4bSstephh extern int fmd_fmri_service_state(nvlist_t *);
947c478bd9Sstevel@tonic-gate extern int fmd_fmri_unusable(nvlist_t *);
95*e4b86885SCheng Sean Ye extern int fmd_fmri_retire(nvlist_t *);
96*e4b86885SCheng Sean Ye extern int fmd_fmri_unretire(nvlist_t *);
977c478bd9Sstevel@tonic-gate extern int fmd_fmri_contains(nvlist_t *, nvlist_t *);
98d9638e54Smws extern nvlist_t *fmd_fmri_translate(nvlist_t *, nvlist_t *);
997c478bd9Sstevel@tonic-gate 
10025c6ff4bSstephh #define	FMD_OBJ_STATE_UNKNOWN		1
10125c6ff4bSstephh #define	FMD_OBJ_STATE_STILL_PRESENT	2
10225c6ff4bSstephh #define	FMD_OBJ_STATE_REPLACED		3
10325c6ff4bSstephh #define	FMD_OBJ_STATE_NOT_PRESENT	4
10425c6ff4bSstephh 
10525c6ff4bSstephh #define	FMD_SERVICE_STATE_UNKNOWN			0
10625c6ff4bSstephh #define	FMD_SERVICE_STATE_OK				1
10725c6ff4bSstephh #define	FMD_SERVICE_STATE_DEGRADED			2
10825c6ff4bSstephh #define	FMD_SERVICE_STATE_UNUSABLE			3
10925c6ff4bSstephh #define	FMD_SERVICE_STATE_DEGRADED_PENDING_RESET	4
11025c6ff4bSstephh #define	FMD_SERVICE_STATE_UNUSABLE_PENDING_RESET	5
11125c6ff4bSstephh #define	FMD_SERVICE_STATE_UNUSABLE_UNTIL_REPLACED	6
112*e4b86885SCheng Sean Ye #define	FMD_SERVICE_STATE_ISOLATE_PENDING		7
11325c6ff4bSstephh 
1147c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate #endif
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #endif	/* _FMD_FMRI_H */
119