fm.c revision 3ddd2818ac8897094b3a1e147b4788ccbe199a0f
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * CDDL HEADER START
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * The contents of this file are subject to the terms of the
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Common Development and Distribution License, Version 1.0 only
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * (the "License"). You may not use this file except in compliance
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * with the License.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * See the License for the specific language governing permissions
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * and limitations under the License.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * When distributing Covered Code, include this CDDL HEADER in each
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * If applicable, add the following below this CDDL HEADER, with the
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * fields enclosed by brackets "[]" replaced with your own identifying
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * information: Portions Copyright [yyyy] [name of copyright owner]
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * CDDL HEADER END
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Use is subject to license terms.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy#pragma ident "%Z%%M% %I% %E% SMI"
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Fault Management Architecture (FMA) Resource and Protocol Support
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * The routines contained herein provide services to support kernel subsystems
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * in publishing fault management telemetry (see PSARC 2002/412 and 2003/089).
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Name-Value Pair Lists
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * The embodiment of an FMA protocol element (event, fmri or authority) is a
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * name-value pair list (nvlist_t). FMA-specific nvlist construtor and
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * destructor functions, fm_nvlist_create() and fm_nvlist_destroy(), are used
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * to create an nvpair list using custom allocators. Callers may choose to
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * allocate either from the kernel memory allocator, or from a preallocated
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * buffer, useful in constrained contexts like high-level interrupt routines.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Protocol Event and FMRI Construction
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Convenience routines are provided to construct nvlist events according to
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * the FMA Event Protocol and Naming Schema specification for ereports and
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * FMRIs for the dev, cpu, hc, mem, legacy hc and de schemes.
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * ENA Manipulation
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * Routines to generate ENA formats 0, 1 and 2 are available as well as
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * routines to increment formats 1 and 2. Individual fields within the
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * ENA are extractable via fm_ena_time_get(), fm_ena_id_get(),
15d9d0b528387242011cdcc6190c9e598cfe3a07yy * 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) {
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;