xref: /illumos-gate/usr/src/uts/i86pc/sys/cpu_module_impl.h (revision 2a613b5974ae49c8b068a3998ff554f8c6f0f593)
17aec1d6eScindi /*
27aec1d6eScindi  * CDDL HEADER START
37aec1d6eScindi  *
47aec1d6eScindi  * The contents of this file are subject to the terms of the
53ad553a7Sgavinm  * Common Development and Distribution License (the "License").
63ad553a7Sgavinm  * You may not use this file except in compliance with the License.
77aec1d6eScindi  *
87aec1d6eScindi  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97aec1d6eScindi  * or http://www.opensolaris.org/os/licensing.
107aec1d6eScindi  * See the License for the specific language governing permissions
117aec1d6eScindi  * and limitations under the License.
127aec1d6eScindi  *
137aec1d6eScindi  * When distributing Covered Code, include this CDDL HEADER in each
147aec1d6eScindi  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157aec1d6eScindi  * If applicable, add the following below this CDDL HEADER, with the
167aec1d6eScindi  * fields enclosed by brackets "[]" replaced with your own identifying
177aec1d6eScindi  * information: Portions Copyright [yyyy] [name of copyright owner]
187aec1d6eScindi  *
197aec1d6eScindi  * CDDL HEADER END
207aec1d6eScindi  */
217aec1d6eScindi 
227aec1d6eScindi /*
23e3d60c9bSAdrian Frost  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247aec1d6eScindi  * Use is subject to license terms.
25*2a613b59SRobert Mustacchi  * Copyright (c) 2018, Joyent, Inc.
267aec1d6eScindi  */
277aec1d6eScindi 
287aec1d6eScindi #ifndef _SYS_CPU_MODULE_IMPL_H
297aec1d6eScindi #define	_SYS_CPU_MODULE_IMPL_H
307aec1d6eScindi 
317aec1d6eScindi #include <sys/cpu_module.h>
327aec1d6eScindi #include <sys/cpuvar.h>
337aec1d6eScindi #include <sys/types.h>
347aec1d6eScindi 
357aec1d6eScindi #ifdef __cplusplus
367aec1d6eScindi extern "C" {
377aec1d6eScindi #endif
387aec1d6eScindi 
3920c794b3Sgavinm typedef uint32_t cmi_api_ver_t;
4020c794b3Sgavinm 
4120c794b3Sgavinm #define	_CMI_API_VERSION_MAGIC	0xa5100000
4220c794b3Sgavinm #define	_CMI_API_VERSION(n)	(_CMI_API_VERSION_MAGIC | (n))
4320c794b3Sgavinm 
4420c794b3Sgavinm #define	CMI_API_VERSION_CHKMAGIC(v) \
4520c794b3Sgavinm 	(((v) & 0xfff00000) == _CMI_API_VERSION_MAGIC)
4620c794b3Sgavinm #define	CMI_API_VERSION_TOPRINT(v) ((v) & 0x000fffff)
4720c794b3Sgavinm 
4820c794b3Sgavinm #define	CMI_API_VERSION_0	_CMI_API_VERSION(0)
4920c794b3Sgavinm #define	CMI_API_VERSION_1	_CMI_API_VERSION(1)
50e3d60c9bSAdrian Frost #define	CMI_API_VERSION_2	_CMI_API_VERSION(2)
51e4b86885SCheng Sean Ye #define	CMI_API_VERSION_3	_CMI_API_VERSION(3)
5220c794b3Sgavinm 
53e4b86885SCheng Sean Ye #define	CMI_API_VERSION		CMI_API_VERSION_3
547aec1d6eScindi 
557aec1d6eScindi typedef struct cmi_ops {
5620c794b3Sgavinm 	int (*cmi_init)(cmi_hdl_t, void **);
5720c794b3Sgavinm 	void (*cmi_post_startup)(cmi_hdl_t);
5820c794b3Sgavinm 	void (*cmi_post_mpstartup)(cmi_hdl_t);
5920c794b3Sgavinm 	void (*cmi_faulted_enter)(cmi_hdl_t);
6020c794b3Sgavinm 	void (*cmi_faulted_exit)(cmi_hdl_t);
6120c794b3Sgavinm 	void (*cmi_mca_init)(cmi_hdl_t);
6220c794b3Sgavinm 	uint64_t (*cmi_mca_trap)(cmi_hdl_t, struct regs *);
63e3d60c9bSAdrian Frost 	void (*cmi_cmci_trap)();
6420c794b3Sgavinm 	cmi_errno_t (*cmi_msrinject)(cmi_hdl_t, cmi_mca_regs_t *, uint_t, int);
6520c794b3Sgavinm 	void (*cmi_hdl_poke)(cmi_hdl_t);
6620c794b3Sgavinm 	void (*cmi_fini)(cmi_hdl_t);
67e4b86885SCheng Sean Ye 	void (*cmi_panic_callback)(void);
68*2a613b59SRobert Mustacchi 	const char *(*cmi_ident)(cmi_hdl_t);
697aec1d6eScindi } cmi_ops_t;
707aec1d6eScindi 
7120c794b3Sgavinm /*
7220c794b3Sgavinm  * Utility functions provided by the cpu module interface for the sole
7320c794b3Sgavinm  * use of cpu module implementations.
7420c794b3Sgavinm  */
7520c794b3Sgavinm extern int cmi_mce_response(struct regs *, uint64_t);
7620c794b3Sgavinm 
7720c794b3Sgavinm /*
7820c794b3Sgavinm  * Terminal dispositions to be returned by cmi_mca_trap entry point
7920c794b3Sgavinm  */
8020c794b3Sgavinm #define	CMI_ERRDISP_CURCTXBAD		0x00000001ULL
8120c794b3Sgavinm #define	CMI_ERRDISP_RIPV_INVALID	0x00000002ULL
8220c794b3Sgavinm #define	CMI_ERRDISP_UC_UNCONSTRAINED	0x00000004ULL
8320c794b3Sgavinm #define	CMI_ERRDISP_FORCEFATAL		0x00000008ULL
847aec1d6eScindi 
8520c794b3Sgavinm /*
8620c794b3Sgavinm  * Non-terminal errors dispositions that can be returned by cmi_mca_trap
8720c794b3Sgavinm  */
8820c794b3Sgavinm #define	CMI_ERRDISP_IGNORED		0x00010000ULL
8920c794b3Sgavinm #define	CMI_ERRDISP_PCC_CLEARED		0x00020000ULL
9020c794b3Sgavinm #define	CMI_ERRDISP_UC_CLEARED		0x00040000ULL
9120c794b3Sgavinm #define	CMI_ERRDISP_POISONED		0x00080000ULL
9220c794b3Sgavinm #define	CMI_ERRDISP_INCONSISTENT	0x00100000ULL
937aec1d6eScindi 
947aec1d6eScindi #ifdef __cplusplus
957aec1d6eScindi }
967aec1d6eScindi #endif
977aec1d6eScindi 
987aec1d6eScindi #endif /* _SYS_CPU_MODULE_IMPL_H */
99