xref: /illumos-gate/usr/src/uts/sun4v/sys/error.h (revision 1ae08745)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_ERROR_H
27 #define	_ERROR_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Resumable and Non-resumable queues
37  */
38 #define	CPU_RQ_ENTRIES		64
39 #define	CPU_NRQ_ENTRIES		64
40 #define	Q_ENTRY_SIZE		64
41 #define	CPU_RQ_SIZE		(CPU_RQ_ENTRIES * Q_ENTRY_SIZE)
42 #define	CPU_NRQ_SIZE		(CPU_NRQ_ENTRIES * Q_ENTRY_SIZE)
43 
44 /*
45  * Sun4v Error Report error Descriptor describes the type of the error
46  */
47 #define	ERRH_DESC_UNDEFINED	0	/* Undefined */
48 #define	ERRH_DESC_UCOR_RE	1	/* Uncorrected resumable error */
49 #define	ERRH_DESC_PR_NRE	2	/* Precise non-resumable error */
50 #define	ERRH_DESC_DEF_NRE	3	/* Deferred non-resumalbe error */
51 #define	ERRH_DESC_WARN_RE	4	/* Power-off for vBSC HostShutdown() */
52 
53 /*
54  * Sun4v Error Report Error Attributes specifies the attributes of the error
55  */
56 #define	ERRH_ATTR_CPU		0x00000001
57 #define	ERRH_ATTR_MEM		0x00000002
58 #define	ERRH_ATTR_PIO		0x00000004
59 #define	ERRH_ATTR_IRF		0x00000008	/* Integer register file */
60 /* Floating-point register file */
61 #define	ERRH_ATTR_FRF		0x00000010
62 #define	ERRH_ATTR_RQF		0x80000000	/* Resumablee Queue Full */
63 
64 /*
65  * For Excution mode
66  */
67 #define	ERRH_MODE_MASK		0x03000000
68 #define	ERRH_MODE_SHIFT		24
69 #define	ERRH_MODE_UNKNOWN	0
70 #define	ERRH_MODE_USER		1
71 #define	ERRH_MODE_PRIV		2
72 
73 /*
74  * For the second argument passed to process_nonresumable_error(), it is
75  * an uint64_t. The upper 32 bits are reserved for various flags, the
76  * lower 32 bits are used to pass the "current tl-1". Right now only bit
77  * 32 in the upper 32 bits is being used as user's fill/spill flag.
78  * If bit 32 is set, it means the first error in the error
79  * queue happened in user fill/spill trap and it needs to be handled
80  * differently.
81  *
82  * -Argument 2 of process_nonresumable_error()
83  *    ----------------------------------------------
84  *    |  reserved        |x|  current_tl - 1       |
85  *    ----------------------------------------------
86  *    63                 32 31                     0
87  * x - bit 32, user fill/spill trap flag
88  */
89 #define	ERRH_U_SPILL_FILL		0x100000000
90 #define	ERRH_U_SPILL_FILL_SHIFT		32
91 #define	ERRH_TL_MASK			0xffffffff
92 
93 #ifndef	_ASM
94 /*
95  * For debug print out
96  */
97 #define	ER_SZ_IN_EXT_WORD	(Q_ENTRY_SIZE / sizeof (uint64_t))
98 
99 /*
100  * Sun4v Error Report record
101  */
102 typedef	struct {
103 	uint64_t	ehdl;		/* Unique error handle */
104 	uint64_t	stick;		/* Value of the %STICK register */
105 	uint32_t	desc;		/* Error Descriptor */
106 	uint32_t	attr;		/* error attributes bit field */
107 	uint64_t	ra;		/* Real address */
108 	uint32_t	sz;		/* Size of affected mem region */
109 	uint16_t	cpuid;		/* Virtual ID of the affected CPU */
110 } errh_er_t;
111 
112 typedef struct errh_async_flt {
113 	struct async_flt 	cmn_asyncflt;	/* common fault structure */
114 	errh_er_t		errh_er;	/* sun4v er record */
115 } errh_async_flt_t;
116 
117 /*
118  * Global functions
119  */
120 void mem_scrub(uint64_t, uint64_t);
121 void errh_cpu_run_bus_error_handlers(struct async_flt *, int);
122 void error_init(void);
123 void cpu_async_log_err(void *);
124 void cpu_ce_log_err(struct async_flt *);
125 void cpu_ue_log_err(struct async_flt *);
126 void mem_sync(caddr_t, size_t);
127 
128 #endif	/* _ASM */
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif /* _ERROR_H */
135