xref: /titanic_44/usr/src/cmd/fm/modules/sun4v/generic-mem/gmem_fmri.h (revision 1529f529004c61fcfd0d95ab79b0f257d6ad4451)
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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _GMEM_FMRI_H
27 #define	_GMEM_FMRI_H
28 
29 /*
30  * Each general-purpose state structure is named by an FMRI - the FMRI of the
31  * piece of hardware being described.  FMRIs are nvlists, and thus require
32  * special handling if they are to be persisted along with the general-purpose
33  * buffer.  The gmem_fmri_t manages the FMRI, both in packed (persistable) and
34  * unpacked formats.  The packed FMRI is stored in a separate buffer (named by
35  * the fmri_packnm member), from which it can be unpacked on restore.
36  *
37  * Data structures:
38  *
39  *     ,--------.
40  *     |G.P.    |
41  *     |buffer  |
42  *     |,-------|         ,-------------.
43  *     ||fmri_t |   ----> |packed nvlist|
44  *     |`-------|         `-------------'
45  *     `--------'
46  *
47  * The buffer for the general purpose buffer is named and stored independently.
48  * This subsystem creates and manages the packed nvlist buffer, using a name
49  * provided by the caller.
50  */
51 
52 #include <libnvpair.h>
53 #include <fm/fmd_api.h>
54 #include <sys/types.h>
55 
56 #include <gmem_state.h>
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 typedef struct gmem_fmri {
63 	nvlist_t *fmri_nvl;		/* The unpacked FMRI FMRI */
64 	char *fmri_packbuf;		/* In-core packed nvlist buffer */
65 	size_t fmri_packsz;		/* Size of packed nvlist buffer */
66 	char fmri_packnm[GMEM_BUFNMLEN]; /* Persistent buffer name for FMRI */
67 } gmem_fmri_t;
68 
69 extern void gmem_fmri_init(fmd_hdl_t *, gmem_fmri_t *, nvlist_t *,
70     const char *, ...);
71 extern void gmem_fmri_fini(fmd_hdl_t *, gmem_fmri_t *, int);
72 
73 extern void gmem_fmri_restore(fmd_hdl_t *, gmem_fmri_t *);
74 extern void gmem_fmri_write(fmd_hdl_t *, gmem_fmri_t *);
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif /* _GMEM_FMRI_H */
81