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 552d60c84Sgavinm * Common Development and Distribution License (the "License"). 652d60c84Sgavinm * 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 */ 217aec1d6eScindi 227c478bd9Sstevel@tonic-gate /* 23*f6e214c7SGavin Maltby * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_FM_UTIL_H 277c478bd9Sstevel@tonic-gate #define _SYS_FM_UTIL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/nvpair.h> 347c478bd9Sstevel@tonic-gate #include <sys/errorq.h> 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate /* 377c478bd9Sstevel@tonic-gate * Shared user/kernel definitions for class length, error channel name, 387c478bd9Sstevel@tonic-gate * and kernel event publisher string. 397c478bd9Sstevel@tonic-gate */ 407c478bd9Sstevel@tonic-gate #define FM_MAX_CLASS 100 417c478bd9Sstevel@tonic-gate #define FM_ERROR_CHAN "com.sun:fm:error" 427c478bd9Sstevel@tonic-gate #define FM_PUB "fm" 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * ereport dump device transport support 467c478bd9Sstevel@tonic-gate * 477c478bd9Sstevel@tonic-gate * Ereports are written out to the dump device at a proscribed offset from the 487c478bd9Sstevel@tonic-gate * end, similar to in-transit log messages. The ereports are represented as a 497c478bd9Sstevel@tonic-gate * erpt_dump_t header followed by ed_size bytes of packed native nvlist data. 507c478bd9Sstevel@tonic-gate * 517c478bd9Sstevel@tonic-gate * NOTE: All of these constants and the header must be defined so they have the 527c478bd9Sstevel@tonic-gate * same representation for *both* 32-bit and 64-bit producers and consumers. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate #define ERPT_MAGIC 0xf00d4eddU 5552d60c84Sgavinm #define ERPT_MAX_ERRS 16 5652d60c84Sgavinm #define ERPT_DATA_SZ (6 * 1024) 577c478bd9Sstevel@tonic-gate #define ERPT_EVCH_MAX 256 587c478bd9Sstevel@tonic-gate #define ERPT_HIWAT 64 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate typedef struct erpt_dump { 617c478bd9Sstevel@tonic-gate uint32_t ed_magic; /* ERPT_MAGIC or zero to indicate end */ 627c478bd9Sstevel@tonic-gate uint32_t ed_chksum; /* checksum32() of packed nvlist data */ 637c478bd9Sstevel@tonic-gate uint32_t ed_size; /* ereport (nvl) fixed buf size */ 647c478bd9Sstevel@tonic-gate uint32_t ed_pad; /* reserved for future use */ 657c478bd9Sstevel@tonic-gate hrtime_t ed_hrt_nsec; /* hrtime of this ereport */ 667c478bd9Sstevel@tonic-gate hrtime_t ed_hrt_base; /* hrtime sample corresponding to ed_tod_base */ 677c478bd9Sstevel@tonic-gate struct { 687c478bd9Sstevel@tonic-gate uint64_t sec; /* seconds since gettimeofday() Epoch */ 697c478bd9Sstevel@tonic-gate uint64_t nsec; /* nanoseconds past ed_tod_base.sec */ 707c478bd9Sstevel@tonic-gate } ed_tod_base; 717c478bd9Sstevel@tonic-gate } erpt_dump_t; 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #ifdef _KERNEL 747aec1d6eScindi #include <sys/systm.h> 757c478bd9Sstevel@tonic-gate 767aec1d6eScindi #define FM_STK_DEPTH 20 /* maximum stack depth */ 777aec1d6eScindi #define FM_SYM_SZ 64 /* maximum symbol size */ 787c478bd9Sstevel@tonic-gate #define FM_ERR_PIL 2 /* PIL for ereport_errorq drain processing */ 797c478bd9Sstevel@tonic-gate 807aec1d6eScindi #define FM_EREPORT_PAYLOAD_NAME_STACK "stack" 817aec1d6eScindi 827c478bd9Sstevel@tonic-gate extern errorq_t *ereport_errorq; 837c478bd9Sstevel@tonic-gate extern void *ereport_dumpbuf; 847c478bd9Sstevel@tonic-gate extern size_t ereport_dumplen; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate extern void fm_init(void); 877c478bd9Sstevel@tonic-gate extern void fm_nvprint(nvlist_t *); 887c478bd9Sstevel@tonic-gate extern void fm_panic(const char *, ...); 897c478bd9Sstevel@tonic-gate extern void fm_banner(void); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate extern void fm_ereport_dump(void); 927c478bd9Sstevel@tonic-gate extern void fm_ereport_post(nvlist_t *, int); 937c478bd9Sstevel@tonic-gate 947aec1d6eScindi extern void fm_payload_stack_add(nvlist_t *, const pc_t *, int); 957aec1d6eScindi 96*f6e214c7SGavin Maltby extern int is_fm_panic(); 977c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1007c478bd9Sstevel@tonic-gate } 1017c478bd9Sstevel@tonic-gate #endif 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate #endif /* _SYS_FM_UTIL_H */ 104