fm.c revision 1cf6ec7e017216c75e94928e94bc5a1c4b94dd62
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * CDDL HEADER START
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * The contents of this file are subject to the terms of the
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * Common Development and Distribution License (the "License").
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * You may not use this file except in compliance with the License.
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * See the License for the specific language governing permissions
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * and limitations under the License.
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * When distributing Covered Code, include this CDDL HEADER in each
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * If applicable, add the following below this CDDL HEADER, with the
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * fields enclosed by brackets "[]" replaced with your own identifying
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * information: Portions Copyright [yyyy] [name of copyright owner]
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * CDDL HEADER END
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * Use is subject to license terms.
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc#pragma ident "%Z%%M% %I% %E% SMI"
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * Fault Management Architecture (FMA) Resource and Protocol Support
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * The routines contained herein provide services to support kernel subsystems
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * in publishing fault management telemetry (see PSARC 2002/412 and 2003/089).
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * Name-Value Pair Lists
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * The embodiment of an FMA protocol element (event, fmri or authority) is a
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * name-value pair list (nvlist_t). FMA-specific nvlist construtor and
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * destructor functions, fm_nvlist_create() and fm_nvlist_destroy(), are used
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * to create an nvpair list using custom allocators. Callers may choose to
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * allocate either from the kernel memory allocator, or from a preallocated
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * buffer, useful in constrained contexts like high-level interrupt routines.
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * Protocol Event and FMRI Construction
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * Convenience routines are provided to construct nvlist events according to
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * the FMA Event Protocol and Naming Schema specification for ereports and
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * FMRIs for the dev, cpu, hc, mem, legacy hc and de schemes.
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * ENA Manipulation
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * Routines to generate ENA formats 0, 1 and 2 are available as well as
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * routines to increment formats 1 and 2. Individual fields within the
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * ENA are extractable via fm_ena_time_get(), fm_ena_id_get(),
ee5416c9d7e449233197d5d20bc6b81e4ff091b2yc * fm_ena_format_get() and fm_ena_gen_get().
void *ereport_dumpbuf;
struct erpt_kstat {
if (!panicstr)
fm_init(void)
if (ereport_qlen == 0)
if (ereport_size == 0)
int width;
char c1;
boolean_t b;
char *str;
switch (type) {
case DATA_TYPE_BOOLEAN:
case DATA_TYPE_BOOLEAN_VALUE:
case DATA_TYPE_BYTE:
case DATA_TYPE_INT8:
case DATA_TYPE_UINT8:
case DATA_TYPE_INT16:
case DATA_TYPE_UINT16:
case DATA_TYPE_INT32:
case DATA_TYPE_UINT32:
case DATA_TYPE_INT64:
case DATA_TYPE_UINT64:
case DATA_TYPE_HRTIME:
case DATA_TYPE_STRING:
case DATA_TYPE_NVLIST:
case DATA_TYPE_BOOLEAN_ARRAY:
case DATA_TYPE_BYTE_ARRAY:
case DATA_TYPE_INT8_ARRAY:
case DATA_TYPE_UINT8_ARRAY:
case DATA_TYPE_INT16_ARRAY:
case DATA_TYPE_UINT16_ARRAY:
case DATA_TYPE_INT32_ARRAY:
case DATA_TYPE_UINT32_ARRAY:
case DATA_TYPE_INT64_ARRAY:
case DATA_TYPE_UINT64_ARRAY:
case DATA_TYPE_STRING_ARRAY:
case DATA_TYPE_NVLIST_ARRAY:
case DATA_TYPE_UNKNOWN:
char *class;
fm_banner(void)
if (!fm_panicstr)
if (panicstr) {
fm_ereport_dump(void)
char *buf;
if (panicstr) {
!panicstr)
NULL,
NULL,
return (NULL);
return (nvhdl);
nvlist_t *
int hdl_alloced = 0;
return (NULL);
if (hdl_alloced) {
return (NULL);
return (nvl);
switch (type) {
case DATA_TYPE_BYTE:
case DATA_TYPE_BYTE_ARRAY:
case DATA_TYPE_BOOLEAN_VALUE:
case DATA_TYPE_BOOLEAN_ARRAY:
case DATA_TYPE_INT8:
case DATA_TYPE_INT8_ARRAY:
case DATA_TYPE_UINT8:
case DATA_TYPE_UINT8_ARRAY:
case DATA_TYPE_INT16:
case DATA_TYPE_INT16_ARRAY:
case DATA_TYPE_UINT16:
case DATA_TYPE_UINT16_ARRAY:
case DATA_TYPE_INT32:
case DATA_TYPE_INT32_ARRAY:
case DATA_TYPE_UINT32:
case DATA_TYPE_UINT32_ARRAY:
case DATA_TYPE_INT64:
case DATA_TYPE_INT64_ARRAY:
case DATA_TYPE_UINT64:
case DATA_TYPE_UINT64_ARRAY:
case DATA_TYPE_STRING:
case DATA_TYPE_STRING_ARRAY:
case DATA_TYPE_NVLIST:
case DATA_TYPE_NVLIST_ARRAY:
return (ret);
int ret;
const char *name;
if (ret)
const char *name;
int ret;
if (ret)
for (i = 0; i < npairs; i++) {
for (i = 0; i < npairs; i++)
FM_FMRI_SCHEME_DEV) != 0) {
FM_FMRI_SCHEME_CPU) != 0) {
*cpu_maskp) != 0)
offset) != 0) {
if (vdev_guid != 0) {
case FM_ENA_FMT1:
case FM_ENA_FMT2:
new_ena = 0;
return (new_ena);
switch (format) {
case FM_ENA_FMT1:
if (timestamp) {
case FM_ENA_FMT2:
return (ena);
case FM_ENA_FMT1:
case FM_ENA_FMT2:
gen = 0;
return (gen);
case FM_ENA_FMT1:
case FM_ENA_FMT2:
id = 0;
return (id);
case FM_ENA_FMT1:
case FM_ENA_FMT2:
time = 0;
return (time);
char *sym;