xref: /illumos-gate/usr/src/uts/i86pc/sys/cpu_module_impl.h (revision 74e7dc986c89efca1f2e4451c7a572e05e4a6e4f)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_CPU_MODULE_IMPL_H
28 #define	_SYS_CPU_MODULE_IMPL_H
29 
30 #include <sys/cpu_module.h>
31 #include <sys/cpuvar.h>
32 #include <sys/types.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 typedef uint32_t cmi_api_ver_t;
39 
40 #define	_CMI_API_VERSION_MAGIC	0xa5100000
41 #define	_CMI_API_VERSION(n)	(_CMI_API_VERSION_MAGIC | (n))
42 
43 #define	CMI_API_VERSION_CHKMAGIC(v) \
44 	(((v) & 0xfff00000) == _CMI_API_VERSION_MAGIC)
45 #define	CMI_API_VERSION_TOPRINT(v) ((v) & 0x000fffff)
46 
47 #define	CMI_API_VERSION_0	_CMI_API_VERSION(0)
48 #define	CMI_API_VERSION_1	_CMI_API_VERSION(1)
49 #define	CMI_API_VERSION_2	_CMI_API_VERSION(2)
50 
51 #define	CMI_API_VERSION		CMI_API_VERSION_2
52 
53 typedef struct cmi_mc_ops {
54 	cmi_errno_t (*cmi_mc_patounum)(void *, uint64_t, uint8_t, uint8_t,
55 	    uint32_t, int, mc_unum_t *);
56 	cmi_errno_t (*cmi_mc_unumtopa)(void *, mc_unum_t *, nvlist_t *,
57 	    uint64_t *);
58 	void (*cmi_mc_logout)(cmi_hdl_t, boolean_t, boolean_t);
59 } cmi_mc_ops_t;
60 
61 typedef struct cmi_ops {
62 	int (*cmi_init)(cmi_hdl_t, void **);
63 	void (*cmi_post_startup)(cmi_hdl_t);
64 	void (*cmi_post_mpstartup)(cmi_hdl_t);
65 	void (*cmi_faulted_enter)(cmi_hdl_t);
66 	void (*cmi_faulted_exit)(cmi_hdl_t);
67 	void (*cmi_mca_init)(cmi_hdl_t);
68 	uint64_t (*cmi_mca_trap)(cmi_hdl_t, struct regs *);
69 	void (*cmi_cmci_trap)();
70 	cmi_errno_t (*cmi_msrinject)(cmi_hdl_t, cmi_mca_regs_t *, uint_t, int);
71 	void (*cmi_hdl_poke)(cmi_hdl_t);
72 	void (*cmi_fini)(cmi_hdl_t);
73 } cmi_ops_t;
74 
75 /*
76  * Utility functions provided by the cpu module interface for the sole
77  * use of cpu module implementations.
78  */
79 extern int cmi_mce_response(struct regs *, uint64_t);
80 
81 /*
82  * Terminal dispositions to be returned by cmi_mca_trap entry point
83  */
84 #define	CMI_ERRDISP_CURCTXBAD		0x00000001ULL
85 #define	CMI_ERRDISP_RIPV_INVALID	0x00000002ULL
86 #define	CMI_ERRDISP_UC_UNCONSTRAINED	0x00000004ULL
87 #define	CMI_ERRDISP_FORCEFATAL		0x00000008ULL
88 
89 /*
90  * Non-terminal errors dispositions that can be returned by cmi_mca_trap
91  */
92 #define	CMI_ERRDISP_IGNORED		0x00010000ULL
93 #define	CMI_ERRDISP_PCC_CLEARED		0x00020000ULL
94 #define	CMI_ERRDISP_UC_CLEARED		0x00040000ULL
95 #define	CMI_ERRDISP_POISONED		0x00080000ULL
96 #define	CMI_ERRDISP_INCONSISTENT	0x00100000ULL
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif /* _SYS_CPU_MODULE_IMPL_H */
103