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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
30 * Case management and saved state restoration
33 #include <gmem_util.h>
35 #include <fm/fmd_api.h>
42 * Our maximum persistent buffer name length, used to allocate fixed-size
43 * arrays for name storage.
46 * The current name DIMM_+serial number
48 #define GMEM_BUFNMLEN 48
50 /* gmem_evdisp_t, gmem_evdisp_stat_t, and gmem_evdisp_names must be in sync */
51 typedef enum gmem_evdisp
{
59 * Each handled ereport type has four statistics, designed to indicate the
60 * eventual disposition of the ereport.
62 typedef struct gmem_evdisp_stat
{
63 fmd_stat_t evs_ok
; /* # of erpts processed successfully */
64 fmd_stat_t evs_bad
; /* # of malformed ereports */
65 fmd_stat_t evs_unused
; /* # of erpts unusable or not needed */
66 fmd_stat_t evs_redund
; /* # of erpts already explained */
69 /* Must be in sync with gmem_case_restorers */
70 typedef enum gmem_nodetype
{
76 * Must be in sync with gmem_case_closers. Additional types must be
77 * appended to this enum otherwise interpretation of existing logs
78 * and checkpoints will be confused.
80 typedef enum gmem_ptrsubtype
{
81 GMEM_PTR_DIMM_CASE
= 1,
86 * There are three types of general-purpose buffers, used to track DIMMs,
87 * and pages. Created on-demand as ereports arrive, one buffer is created for
88 * each thing tracked. The general-purpose buffers are used to track common
89 * state, and are used to support case-specific buffers. Each open case has
90 * a case-specific pointer buffer, used to aid in the rediscovery of the
91 * associated general-purpose buffer. When restoration begins, we iterate
92 * through each of the open cases, restoring the case-specific pointer buffers
93 * for each. The pointer buffers are then used to restore the general-purpose
97 typedef struct gmem_case_ptr
{
98 gmem_nodetype_t ptr_type
; /* The type of associated G.P. buffer */
99 gmem_ptrsubtype_t ptr_subtype
; /* The case within the G.P. buffer */
100 char ptr_name
[GMEM_BUFNMLEN
]; /* G.P. buffer name */
104 * All general-purpose buffers begin with a common header. This header contains
105 * identification information used in the construction of new cases.
107 * Note that versioned structs depend upon the size of
108 * this struct remaining fixed.
110 typedef struct gmem_header
{
111 gmem_list_t hdr_list
; /* List of G.P. structs of this type */
112 gmem_nodetype_t hdr_nodetype
; /* Type of this G.P. struct */
113 char hdr_bufname
[GMEM_BUFNMLEN
]; /* G.P. buffer name */
117 * Per-case-subtype case closing routines. Stored in per-case state when the
118 * case is generated, and regenerated from saved state upon restore.
120 typedef void gmem_case_closer_f(fmd_hdl_t
*, void *);
121 typedef void *gmem_case_restorer_f(fmd_hdl_t
*, fmd_case_t
*,
124 typedef struct gmem_case_closer
{
125 gmem_case_closer_f
*cl_func
;
127 } gmem_case_closer_t
;
129 typedef struct gmem_case
{
135 * Utility functions which ease the management of cases.
137 extern fmd_case_t
*gmem_case_create(fmd_hdl_t
*, gmem_header_t
*,
138 gmem_ptrsubtype_t
, const char **);
139 extern void gmem_case_redirect(fmd_hdl_t
*, fmd_case_t
*, gmem_ptrsubtype_t
);
140 extern void gmem_case_fini(fmd_hdl_t
*, fmd_case_t
*, int);
141 extern void gmem_case_restore(fmd_hdl_t
*, gmem_case_t
*, fmd_case_t
*, char *);
143 extern int gmem_state_restore(fmd_hdl_t
*);
149 #endif /* _GMEM_STATE_H */