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