xref: /titanic_52/usr/src/uts/i86pc/sys/cpu_module_impl.h (revision a93a1f58a8763fa69172980b98e3d24720c1136e)
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 _SYS_CPU_MODULE_IMPL_H
28 #define	_SYS_CPU_MODULE_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/cpu_module.h>
33 #include <sys/cpuvar.h>
34 #include <sys/types.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 typedef uint32_t cmi_api_ver_t;
41 
42 #define	_CMI_API_VERSION_MAGIC	0xa5100000
43 #define	_CMI_API_VERSION(n)	(_CMI_API_VERSION_MAGIC | (n))
44 
45 #define	CMI_API_VERSION_CHKMAGIC(v) \
46 	(((v) & 0xfff00000) == _CMI_API_VERSION_MAGIC)
47 #define	CMI_API_VERSION_TOPRINT(v) ((v) & 0x000fffff)
48 
49 #define	CMI_API_VERSION_0	_CMI_API_VERSION(0)
50 #define	CMI_API_VERSION_1	_CMI_API_VERSION(1)
51 
52 #define	CMI_API_VERSION		CMI_API_VERSION_1
53 
54 typedef struct cmi_mc_ops {
55 	cmi_errno_t (*cmi_mc_patounum)(void *, uint64_t, uint8_t, uint8_t,
56 	    uint32_t, int, mc_unum_t *);
57 	cmi_errno_t (*cmi_mc_unumtopa)(void *, mc_unum_t *, nvlist_t *,
58 	    uint64_t *);
59 	void (*cmi_mc_logout)(cmi_hdl_t, boolean_t, boolean_t);
60 } cmi_mc_ops_t;
61 
62 typedef struct cmi_ops {
63 	int (*cmi_init)(cmi_hdl_t, void **);
64 	void (*cmi_post_startup)(cmi_hdl_t);
65 	void (*cmi_post_mpstartup)(cmi_hdl_t);
66 	void (*cmi_faulted_enter)(cmi_hdl_t);
67 	void (*cmi_faulted_exit)(cmi_hdl_t);
68 	void (*cmi_mca_init)(cmi_hdl_t);
69 	uint64_t (*cmi_mca_trap)(cmi_hdl_t, struct regs *);
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