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