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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_ASYNC_H 287c478bd9Sstevel@tonic-gate #define _SYS_ASYNC_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/privregs.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifndef _ASM 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #include <sys/errorq.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * The async_flt structure is used to record all pertinent information about 447c478bd9Sstevel@tonic-gate * an asynchronous CPU or bus-related memory error. Typically, the structure 457c478bd9Sstevel@tonic-gate * is initialized by a high-level interrupt or trap handler, and then enqueued 467c478bd9Sstevel@tonic-gate * for later processing. Separate queues are maintained for correctable and 477c478bd9Sstevel@tonic-gate * uncorrectable errors. The current CPU module determines the size of the 487c478bd9Sstevel@tonic-gate * queue elements, so that it may declare a CPU-specific fault structure 497c478bd9Sstevel@tonic-gate * which contains a struct async_flt as its first member. Each async_flt also 507c478bd9Sstevel@tonic-gate * contains a callback function (flt_func) that is invoked by the processing 517c478bd9Sstevel@tonic-gate * code in order to actually log messages when the event is dequeued. This 527c478bd9Sstevel@tonic-gate * function may be called from a softint, from trap() as part of AST handling 537c478bd9Sstevel@tonic-gate * before the victim thread returns to userland, or as part of panic(). As 547c478bd9Sstevel@tonic-gate * such, the flt_func should basically only be calling cmn_err (but NOT with 557c478bd9Sstevel@tonic-gate * the CE_PANIC flag). It must not call panic(), acquire locks, or block. 567c478bd9Sstevel@tonic-gate * The owner of the event is responsible for determining whether the event is 577c478bd9Sstevel@tonic-gate * fatal; if so, the owner should set flt_panic and panic() after enqueuing 587c478bd9Sstevel@tonic-gate * the event. The event will then be dequeued and logged as part of panic 597c478bd9Sstevel@tonic-gate * processing. If flt_panic is not set, the queue function will schedule a 607c478bd9Sstevel@tonic-gate * soft interrupt to process the event. 617c478bd9Sstevel@tonic-gate */ 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate struct async_flt; 647c478bd9Sstevel@tonic-gate typedef void (*async_func_t)(struct async_flt *, char *); 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate struct async_flt { 677c478bd9Sstevel@tonic-gate uint64_t flt_id; /* gethrtime() at time of fault */ 687c478bd9Sstevel@tonic-gate uint64_t flt_stat; /* async fault status register */ 697c478bd9Sstevel@tonic-gate uint64_t flt_addr; /* async fault address register */ 707c478bd9Sstevel@tonic-gate caddr_t flt_pc; /* program counter from error trap */ 717c478bd9Sstevel@tonic-gate async_func_t flt_func; /* logging function */ 727c478bd9Sstevel@tonic-gate uint_t flt_bus_id; /* hardware bus id# of cpu/sbus/pci */ 737c478bd9Sstevel@tonic-gate uint_t flt_inst; /* software instance of cpu/sbus/pci */ 747c478bd9Sstevel@tonic-gate ushort_t flt_status; /* error information */ 757c478bd9Sstevel@tonic-gate ushort_t flt_synd; /* ECC syndrome */ 767c478bd9Sstevel@tonic-gate uchar_t flt_in_memory; /* fault occurred in memory if != 0 */ 777c478bd9Sstevel@tonic-gate uchar_t flt_class; /* fault class (cpu or bus) */ 787c478bd9Sstevel@tonic-gate uchar_t flt_prot; /* type of fault protection (if any) */ 797c478bd9Sstevel@tonic-gate uchar_t flt_priv; /* fault occurred in kernel if != 0 */ 807c478bd9Sstevel@tonic-gate uchar_t flt_panic; /* fault caused owner to panic() */ 817c478bd9Sstevel@tonic-gate uchar_t flt_tl; /* fault occurred at TL > 0 */ 827c478bd9Sstevel@tonic-gate uchar_t flt_core; /* fault occurred during core() dump */ 837c478bd9Sstevel@tonic-gate uchar_t flt_pad; /* reserved for future use */ 847c478bd9Sstevel@tonic-gate uint64_t flt_disp; /* error disposition information */ 857c478bd9Sstevel@tonic-gate uint64_t flt_payload; /* ereport payload information */ 867c478bd9Sstevel@tonic-gate char *flt_erpt_class; /* ereport class string */ 877c478bd9Sstevel@tonic-gate }; 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate /* 907c478bd9Sstevel@tonic-gate * Bus nexus drivers can use the bus_func_register() interface to register 917c478bd9Sstevel@tonic-gate * callback functions for error handling and panic handling. The handler 927c478bd9Sstevel@tonic-gate * functions should be registered and unregistered from driver attach and 937c478bd9Sstevel@tonic-gate * detach context, where it is safe to perform a sleeping allocation. The 947c478bd9Sstevel@tonic-gate * callbacks themselves can be invoked from panic, or from the CPU module's 957c478bd9Sstevel@tonic-gate * asynchronous trap handler at high PIL. As such, these routines may only 967c478bd9Sstevel@tonic-gate * test for errors and enqueue async_flt events. They may not grab adaptive 977c478bd9Sstevel@tonic-gate * locks, call panic(), or invoke bus_func_register() or bus_func_unregister(). 987c478bd9Sstevel@tonic-gate * Each callback function should return one of the BF_* return status values 997c478bd9Sstevel@tonic-gate * below. The bus_func_invoke() function calls all the registered handlers of 1007c478bd9Sstevel@tonic-gate * the specified type, and returns the maximum of their return values (e.g. 1017c478bd9Sstevel@tonic-gate * BF_FATAL if any callback returned BF_FATAL). If any callback returns 1027c478bd9Sstevel@tonic-gate * BF_FATAL, the system will panic at the end of callback processing. 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate typedef uint_t (*busfunc_t)(void *); 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #define BF_TYPE_UE 1 /* check for uncorrectable errors */ 1087c478bd9Sstevel@tonic-gate #define BF_TYPE_ERRDIS 2 /* disable error detection */ 1097c478bd9Sstevel@tonic-gate #define BF_TYPE_RESINTR 3 /* reset interrupts */ 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate #define BF_NONE 0 /* no errors were detected */ 1127c478bd9Sstevel@tonic-gate #define BF_NONFATAL 1 /* one or more non-fatal errors found */ 1137c478bd9Sstevel@tonic-gate #define BF_FATAL 2 /* one or more fatal errors found */ 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate typedef struct bus_func_desc { 1167c478bd9Sstevel@tonic-gate int bf_type; /* type of function (see above) */ 1177c478bd9Sstevel@tonic-gate busfunc_t bf_func; /* function to call */ 1187c478bd9Sstevel@tonic-gate void *bf_arg; /* function argument */ 1197c478bd9Sstevel@tonic-gate struct bus_func_desc *bf_next; /* pointer to next registered desc */ 1207c478bd9Sstevel@tonic-gate } bus_func_desc_t; 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate extern void bus_func_register(int, busfunc_t, void *); 1237c478bd9Sstevel@tonic-gate extern void bus_func_unregister(int, busfunc_t, void *); 1247c478bd9Sstevel@tonic-gate extern void bus_async_log_err(struct async_flt *); 1257c478bd9Sstevel@tonic-gate extern uint_t bus_func_invoke(int); 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate extern void ecc_cpu_call(struct async_flt *, char *, int); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate extern void ce_scrub(struct async_flt *); 1307c478bd9Sstevel@tonic-gate extern void ecc_page_zero(void *); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate extern void error_init(void); 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate extern int ce_verbose_memory; 1357c478bd9Sstevel@tonic-gate extern int ce_verbose_other; 1367c478bd9Sstevel@tonic-gate extern int ce_show_data; 1377c478bd9Sstevel@tonic-gate extern int ce_debug; 1387c478bd9Sstevel@tonic-gate extern int ue_debug; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate extern int aft_verbose; 1417c478bd9Sstevel@tonic-gate extern int aft_panic; 1427c478bd9Sstevel@tonic-gate extern int aft_testfatal; 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate extern struct async_flt panic_aflt; 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate extern errorq_t *ce_queue; 1477c478bd9Sstevel@tonic-gate extern errorq_t *ue_queue; 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate #endif /* !_ASM */ 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* 1527c478bd9Sstevel@tonic-gate * ECC or parity error status for async_flt.flt_status. 1537c478bd9Sstevel@tonic-gate */ 1547c478bd9Sstevel@tonic-gate #define ECC_C_TRAP 0x0001 /* Trap 0x63 Corrected ECC Error */ 1557c478bd9Sstevel@tonic-gate #define ECC_I_TRAP 0x0002 /* Trap 0x0A Instr Access Error */ 1567c478bd9Sstevel@tonic-gate #define ECC_ECACHE 0x0004 /* Ecache ECC Error */ 1577c478bd9Sstevel@tonic-gate #define ECC_IOBUS 0x0008 /* Pci or sysio ECC Error */ 1587c478bd9Sstevel@tonic-gate #define ECC_INTERMITTENT 0x0010 /* Intermittent ECC Error */ 1597c478bd9Sstevel@tonic-gate #define ECC_PERSISTENT 0x0020 /* Persistent ECC Error */ 1607c478bd9Sstevel@tonic-gate #define ECC_STICKY 0x0040 /* Sticky ECC Error */ 1617c478bd9Sstevel@tonic-gate #define ECC_D_TRAP 0x0080 /* Trap 0x32 Data Access Error */ 1627c478bd9Sstevel@tonic-gate #define ECC_F_TRAP 0x0100 /* Cheetah Trap 0x70 Fast ECC Error */ 1637c478bd9Sstevel@tonic-gate #define ECC_DP_TRAP 0x0200 /* Cheetah+ Trap 0x71 D$ Parity Error */ 1647c478bd9Sstevel@tonic-gate #define ECC_IP_TRAP 0x0400 /* Cheetah+ Trap 0x72 I$ Parity Error */ 1657c478bd9Sstevel@tonic-gate #define ECC_ITLB_TRAP 0x0800 /* Panther ITLB Parity Error */ 1667c478bd9Sstevel@tonic-gate #define ECC_DTLB_TRAP 0x1000 /* Panther DTLB Parity Error */ 1677c478bd9Sstevel@tonic-gate #define ECC_IO_CE 0x2000 /* Pci or sysio CE */ 1687c478bd9Sstevel@tonic-gate #define ECC_IO_UE 0x4000 /* Pci or sysio UE */ 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate /* 1717c478bd9Sstevel@tonic-gate * Trap type numbers corresponding to the fault types defined above. 1727c478bd9Sstevel@tonic-gate */ 1737c478bd9Sstevel@tonic-gate #define TRAP_TYPE_ECC_I 0x0A 1747c478bd9Sstevel@tonic-gate #define TRAP_TYPE_ECC_D 0x32 1757c478bd9Sstevel@tonic-gate #define TRAP_TYPE_ECC_F 0x70 1767c478bd9Sstevel@tonic-gate #define TRAP_TYPE_ECC_C 0x63 1777c478bd9Sstevel@tonic-gate #define TRAP_TYPE_ECC_DP 0x71 1787c478bd9Sstevel@tonic-gate #define TRAP_TYPE_ECC_IP 0x72 1797c478bd9Sstevel@tonic-gate #define TRAP_TYPE_ECC_ITLB 0x08 1807c478bd9Sstevel@tonic-gate #define TRAP_TYPE_ECC_DTLB 0x30 1817c478bd9Sstevel@tonic-gate #define TRAP_TYPE_UNKNOWN 0 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate /* 1847c478bd9Sstevel@tonic-gate * Fault classes for async_flt.flt_class. 1857c478bd9Sstevel@tonic-gate */ 1867c478bd9Sstevel@tonic-gate #define BUS_FAULT 0 /* originating from bus drivers */ 1877c478bd9Sstevel@tonic-gate #define CPU_FAULT 1 /* originating from CPUs */ 1887c478bd9Sstevel@tonic-gate #define RECIRC_BUS_FAULT 2 /* scheduled diagnostic */ 1897c478bd9Sstevel@tonic-gate #define RECIRC_CPU_FAULT 3 /* scheduled diagnostic */ 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate /* 1927c478bd9Sstevel@tonic-gate * Invalid or unknown physical address for async_flt.flt_addr. 1937c478bd9Sstevel@tonic-gate */ 1947c478bd9Sstevel@tonic-gate #define AFLT_INV_ADDR (-1ULL) 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* 1977c478bd9Sstevel@tonic-gate * Fault protection values for async_flt.flt_prot. The async error handling 1987c478bd9Sstevel@tonic-gate * code may be able to recover from errors when kernel code has explicitly 1997c478bd9Sstevel@tonic-gate * protected itself using one of the mechanisms specified here. 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate #define AFLT_PROT_NONE 0 /* no protection active */ 2027c478bd9Sstevel@tonic-gate #define AFLT_PROT_ACCESS 1 /* on_trap OT_DATA_ACCESS protection */ 2037c478bd9Sstevel@tonic-gate #define AFLT_PROT_EC 2 /* on_trap OT_DATA_EC protection */ 2047c478bd9Sstevel@tonic-gate #define AFLT_PROT_COPY 3 /* t_lofault protection (ucopy, etc.) */ 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate /* 2077c478bd9Sstevel@tonic-gate * These flags are used to indicate the validity of certain data based on 2087c478bd9Sstevel@tonic-gate * the various overwrite priority features of the AFSR/AFAR: 2097c478bd9Sstevel@tonic-gate * AFAR, ESYND and MSYND, each of which have different overwrite priorities. 2107c478bd9Sstevel@tonic-gate * 2117c478bd9Sstevel@tonic-gate * Given a specific afsr error bit and the entire afsr, there are three cases: 2127c478bd9Sstevel@tonic-gate * INVALID: The specified bit is lower overwrite priority than some other 2137c478bd9Sstevel@tonic-gate * error bit which is on in the afsr (or IVU/IVC). 2147c478bd9Sstevel@tonic-gate * VALID: The specified bit is higher priority than all other error bits 2157c478bd9Sstevel@tonic-gate * which are on in the afsr. 2167c478bd9Sstevel@tonic-gate * AMBIGUOUS: Another error bit (or bits) of equal priority to the specified 2177c478bd9Sstevel@tonic-gate * bit is on in the afsr. 2187c478bd9Sstevel@tonic-gate * 2197c478bd9Sstevel@tonic-gate * NB: The domain-to-SC communications depend on these values. If they are 2207c478bd9Sstevel@tonic-gate * changed, plat_ecc_unum.[ch] must be updated to match. 2217c478bd9Sstevel@tonic-gate */ 2227c478bd9Sstevel@tonic-gate #define AFLT_STAT_INVALID 0 /* higher priority afsr bit is on */ 2237c478bd9Sstevel@tonic-gate #define AFLT_STAT_VALID 1 /* this is highest priority afsr bit */ 2247c478bd9Sstevel@tonic-gate #define AFLT_STAT_AMBIGUOUS 2 /* two afsr bits of equal priority */ 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate /* 2277c478bd9Sstevel@tonic-gate * Maximum length of unum string. 2287c478bd9Sstevel@tonic-gate */ 2297c478bd9Sstevel@tonic-gate #define UNUM_NAMLEN 60 2307c478bd9Sstevel@tonic-gate 231*d00f0155Sayznaga /* 232*d00f0155Sayznaga * Maximum length of a DIMM serial id string + null 233*d00f0155Sayznaga */ 234*d00f0155Sayznaga #define DIMM_SERIAL_ID_LEN 16 235*d00f0155Sayznaga 2367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2377c478bd9Sstevel@tonic-gate } 2387c478bd9Sstevel@tonic-gate #endif 2397c478bd9Sstevel@tonic-gate 2407c478bd9Sstevel@tonic-gate #endif /* _SYS_ASYNC_H */ 241