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
35extern "C" {
36#endif
37
38typedef 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#define	CMI_API_VERSION_3	_CMI_API_VERSION(3)
51
52#define	CMI_API_VERSION		CMI_API_VERSION_3
53
54typedef struct cmi_ops {
55	int (*cmi_init)(cmi_hdl_t, void **);
56	void (*cmi_post_startup)(cmi_hdl_t);
57	void (*cmi_post_mpstartup)(cmi_hdl_t);
58	void (*cmi_faulted_enter)(cmi_hdl_t);
59	void (*cmi_faulted_exit)(cmi_hdl_t);
60	void (*cmi_mca_init)(cmi_hdl_t);
61	uint64_t (*cmi_mca_trap)(cmi_hdl_t, struct regs *);
62	void (*cmi_cmci_trap)();
63	cmi_errno_t (*cmi_msrinject)(cmi_hdl_t, cmi_mca_regs_t *, uint_t, int);
64	void (*cmi_hdl_poke)(cmi_hdl_t);
65	void (*cmi_fini)(cmi_hdl_t);
66	void (*cmi_panic_callback)(void);
67} cmi_ops_t;
68
69/*
70 * Utility functions provided by the cpu module interface for the sole
71 * use of cpu module implementations.
72 */
73extern int cmi_mce_response(struct regs *, uint64_t);
74
75/*
76 * Terminal dispositions to be returned by cmi_mca_trap entry point
77 */
78#define	CMI_ERRDISP_CURCTXBAD		0x00000001ULL
79#define	CMI_ERRDISP_RIPV_INVALID	0x00000002ULL
80#define	CMI_ERRDISP_UC_UNCONSTRAINED	0x00000004ULL
81#define	CMI_ERRDISP_FORCEFATAL		0x00000008ULL
82
83/*
84 * Non-terminal errors dispositions that can be returned by cmi_mca_trap
85 */
86#define	CMI_ERRDISP_IGNORED		0x00010000ULL
87#define	CMI_ERRDISP_PCC_CLEARED		0x00020000ULL
88#define	CMI_ERRDISP_UC_CLEARED		0x00040000ULL
89#define	CMI_ERRDISP_POISONED		0x00080000ULL
90#define	CMI_ERRDISP_INCONSISTENT	0x00100000ULL
91
92#ifdef __cplusplus
93}
94#endif
95
96#endif /* _SYS_CPU_MODULE_IMPL_H */
97