xref: /illumos-gate/usr/src/uts/i86pc/sys/cpu_module_ms.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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 /*
23  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_CPU_MODULE_MS_H
28 #define	_CPU_MODULE_MS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/cpuvar.h>
34 #include <sys/nvpair.h>
35 #include <sys/cpu_module.h>
36 
37 #ifdef  __cplusplus
38 extern "C" {
39 #endif
40 
41 #ifdef _KERNEL
42 
43 #define	CMSERR_BASE 0xe000
44 
45 typedef enum cms_errno {
46 	CMS_SUCCESS = 0,
47 	CMSERR_UNKNOWN = CMSERR_BASE,	/* No specific error reason given */
48 	CMSERR_NOTSUP,			/* Unsupported operation */
49 	CMSERR_BADMSRWRITE		/* Error on wrmsr */
50 
51 } cms_errno_t;
52 
53 extern void cms_init(cmi_hdl_t);
54 extern boolean_t cms_present(cmi_hdl_t);
55 extern void *cms_hdl_getcmsdata(cmi_hdl_t);
56 extern void cms_post_startup(cmi_hdl_t);
57 extern void cms_post_mpstartup(cmi_hdl_t);
58 
59 extern size_t cms_logout_size(cmi_hdl_t);
60 
61 extern uint64_t cms_mcgctl_val(cmi_hdl_t, int, uint64_t);
62 
63 extern boolean_t cms_bankctl_skipinit(cmi_hdl_t, int);
64 extern uint64_t cms_bankctl_val(cmi_hdl_t, int, uint64_t);
65 extern boolean_t cms_bankstatus_skipinit(cmi_hdl_t, int);
66 extern uint64_t cms_bankstatus_val(cmi_hdl_t, int, uint64_t);
67 
68 extern void cms_mca_init(cmi_hdl_t, int);
69 
70 extern uint64_t cms_poll_ownermask(cmi_hdl_t, hrtime_t);
71 
72 extern void cms_bank_logout(cmi_hdl_t, int, uint64_t, uint64_t, uint64_t,
73     void *);
74 
75 extern cms_errno_t cms_msrinject(cmi_hdl_t, uint_t, uint64_t);
76 
77 extern void cms_fini(cmi_hdl_t);
78 
79 /*
80  * Return flags for cms_error_action.  The model-specific implementation
81  * can perform additional error handling during this call (e.g., cache
82  * flush). but it needs to return an indication to the caller as to
83  * the high-level impact of the error.
84  *
85  * CMS_ERRSCOPE_CLEAREDUC indicates that a UC error has in some way
86  * been cleared by the model-specific handling, and that no bad data
87  * remains in the system as far as this error is concerned.
88  *
89  * CMS_ERRSCOPE_POISONED indicates that the uncorrected data has
90  * been marked in some way to ensure that is cannot subsequently be mistaken
91  * for good data.
92  *
93  * CMS_ERRSCOPE_CURCONTEXT_OK indicates that the interrupted context is
94  * unaffected by the uncorrected error.
95  *
96  * CMS_ERRSCOPE_IGNORE_ERR indicates that the error should be ignored,
97  * regardless of apparent current context status and presence of uncorrected
98  * data.
99  *
100  * CMS_ERRSCOPE_FORCE_FATAL indicates that the error should be considered
101  * terminal, even if no uncorrected data is present and context appears ok
102  */
103 
104 #define	CMS_ERRSCOPE_CLEARED_UC		0x01
105 #define	CMS_ERRSCOPE_POISONED		0x02
106 #define	CMS_ERRSCOPE_CURCONTEXT_OK	0x04
107 #define	CMS_ERRSCOPE_IGNORE_ERR		0x08
108 #define	CMS_ERRSCOPE_FORCE_FATAL	0x10
109 
110 typedef void *cms_cookie_t;
111 
112 extern uint32_t cms_error_action(cmi_hdl_t, int, int, uint64_t, uint64_t,
113     uint64_t, void *);
114 
115 extern cms_cookie_t cms_disp_match(cmi_hdl_t, int, uint64_t, uint64_t, uint64_t,
116     void *);
117 extern void cms_ereport_class(cmi_hdl_t, cms_cookie_t, const char **,
118     const char **);
119 extern nvlist_t *cms_ereport_detector(cmi_hdl_t, cms_cookie_t, nv_alloc_t *);
120 extern boolean_t cms_ereport_includestack(cmi_hdl_t, cms_cookie_t);
121 extern void cms_ereport_add_logout(cmi_hdl_t, nvlist_t *, nv_alloc_t *, int,
122     uint64_t, uint64_t, uint64_t, void *, cms_cookie_t);
123 
124 #endif /* _KERNEL */
125 
126 #ifdef	__cplusplus
127 }
128 #endif
129 
130 #endif /* _CPU_MODULE_MS_H */
131