xref: /illumos-gate/usr/src/uts/intel/sys/ucode_intel.h (revision d32f26eec03290baae31e85e7c5840280d5c4292)
1*d32f26eeSAndy Fiddaman /*
2*d32f26eeSAndy Fiddaman  * CDDL HEADER START
3*d32f26eeSAndy Fiddaman  *
4*d32f26eeSAndy Fiddaman  * The contents of this file are subject to the terms of the
5*d32f26eeSAndy Fiddaman  * Common Development and Distribution License (the "License").
6*d32f26eeSAndy Fiddaman  * You may not use this file except in compliance with the License.
7*d32f26eeSAndy Fiddaman  *
8*d32f26eeSAndy Fiddaman  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*d32f26eeSAndy Fiddaman  * or http://www.opensolaris.org/os/licensing.
10*d32f26eeSAndy Fiddaman  * See the License for the specific language governing permissions
11*d32f26eeSAndy Fiddaman  * and limitations under the License.
12*d32f26eeSAndy Fiddaman  *
13*d32f26eeSAndy Fiddaman  * When distributing Covered Code, include this CDDL HEADER in each
14*d32f26eeSAndy Fiddaman  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*d32f26eeSAndy Fiddaman  * If applicable, add the following below this CDDL HEADER, with the
16*d32f26eeSAndy Fiddaman  * fields enclosed by brackets "[]" replaced with your own identifying
17*d32f26eeSAndy Fiddaman  * information: Portions Copyright [yyyy] [name of copyright owner]
18*d32f26eeSAndy Fiddaman  *
19*d32f26eeSAndy Fiddaman  * CDDL HEADER END
20*d32f26eeSAndy Fiddaman  */
21*d32f26eeSAndy Fiddaman /*
22*d32f26eeSAndy Fiddaman  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23*d32f26eeSAndy Fiddaman  * Use is subject to license terms.
24*d32f26eeSAndy Fiddaman  *
25*d32f26eeSAndy Fiddaman  * Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
26*d32f26eeSAndy Fiddaman  * Copyright 2022 Joyent, Inc.
27*d32f26eeSAndy Fiddaman  * Copyright 2023 Oxide Computer Company
28*d32f26eeSAndy Fiddaman  */
29*d32f26eeSAndy Fiddaman 
30*d32f26eeSAndy Fiddaman #ifndef	_SYS_UCODE_INTEL_H
31*d32f26eeSAndy Fiddaman #define	_SYS_UCODE_INTEL_H
32*d32f26eeSAndy Fiddaman 
33*d32f26eeSAndy Fiddaman #include <sys/types.h>
34*d32f26eeSAndy Fiddaman #include <ucode/ucode_errno.h>
35*d32f26eeSAndy Fiddaman 
36*d32f26eeSAndy Fiddaman #ifdef __cplusplus
37*d32f26eeSAndy Fiddaman extern "C" {
38*d32f26eeSAndy Fiddaman #endif
39*d32f26eeSAndy Fiddaman 
40*d32f26eeSAndy Fiddaman /*
41*d32f26eeSAndy Fiddaman  * Intel Microcode file information
42*d32f26eeSAndy Fiddaman  */
43*d32f26eeSAndy Fiddaman typedef struct ucode_header_intel {
44*d32f26eeSAndy Fiddaman 	uint32_t	uh_header_ver;
45*d32f26eeSAndy Fiddaman 	uint32_t	uh_rev;
46*d32f26eeSAndy Fiddaman 	uint32_t	uh_date;
47*d32f26eeSAndy Fiddaman 	uint32_t	uh_signature;
48*d32f26eeSAndy Fiddaman 	uint32_t	uh_checksum;
49*d32f26eeSAndy Fiddaman 	uint32_t	uh_loader_ver;
50*d32f26eeSAndy Fiddaman 	uint32_t	uh_proc_flags;
51*d32f26eeSAndy Fiddaman 	uint32_t	uh_body_size;
52*d32f26eeSAndy Fiddaman 	uint32_t	uh_total_size;
53*d32f26eeSAndy Fiddaman 	uint32_t	uh_reserved[3];
54*d32f26eeSAndy Fiddaman } ucode_header_intel_t;
55*d32f26eeSAndy Fiddaman 
56*d32f26eeSAndy Fiddaman typedef struct ucode_ext_sig_intel {
57*d32f26eeSAndy Fiddaman 	uint32_t	ues_signature;
58*d32f26eeSAndy Fiddaman 	uint32_t	ues_proc_flags;
59*d32f26eeSAndy Fiddaman 	uint32_t	ues_checksum;
60*d32f26eeSAndy Fiddaman } ucode_ext_sig_intel_t;
61*d32f26eeSAndy Fiddaman 
62*d32f26eeSAndy Fiddaman typedef struct ucode_ext_table_intel {
63*d32f26eeSAndy Fiddaman 	uint32_t	uet_count;
64*d32f26eeSAndy Fiddaman 	uint32_t	uet_checksum;
65*d32f26eeSAndy Fiddaman 	uint32_t	uet_reserved[3];
66*d32f26eeSAndy Fiddaman 	ucode_ext_sig_intel_t uet_ext_sig[1];
67*d32f26eeSAndy Fiddaman } ucode_ext_table_intel_t;
68*d32f26eeSAndy Fiddaman 
69*d32f26eeSAndy Fiddaman typedef struct ucode_file_intel {
70*d32f26eeSAndy Fiddaman 	ucode_header_intel_t	*uf_header;
71*d32f26eeSAndy Fiddaman 	uint8_t			*uf_body;
72*d32f26eeSAndy Fiddaman 	ucode_ext_table_intel_t	*uf_ext_table;
73*d32f26eeSAndy Fiddaman } ucode_file_intel_t;
74*d32f26eeSAndy Fiddaman 
75*d32f26eeSAndy Fiddaman /*					"32-bit-sig"-"8-bit-platid"\0 */
76*d32f26eeSAndy Fiddaman #define	UCODE_MAX_NAME_LEN_INTEL	(sizeof ("XXXXXXXX-XX"))
77*d32f26eeSAndy Fiddaman 
78*d32f26eeSAndy Fiddaman #define	UCODE_HEADER_SIZE_INTEL		(sizeof (struct ucode_header_intel))
79*d32f26eeSAndy Fiddaman #define	UCODE_EXT_TABLE_SIZE_INTEL	(20)	/* 20-bytes */
80*d32f26eeSAndy Fiddaman #define	UCODE_EXT_SIG_SIZE_INTEL	(sizeof (struct ucode_ext_sig_intel))
81*d32f26eeSAndy Fiddaman 
82*d32f26eeSAndy Fiddaman #define	UCODE_DEFAULT_TOTAL_SIZE	UCODE_KB(2)
83*d32f26eeSAndy Fiddaman #define	UCODE_DEFAULT_BODY_SIZE		(UCODE_KB(2) - UCODE_HEADER_SIZE_INTEL)
84*d32f26eeSAndy Fiddaman 
85*d32f26eeSAndy Fiddaman #define	UCODE_SIZE_CONVERT(size, default_size) \
86*d32f26eeSAndy Fiddaman 	((size) == 0 ? (default_size) : (size))
87*d32f26eeSAndy Fiddaman 
88*d32f26eeSAndy Fiddaman #define	UCODE_BODY_SIZE_INTEL(size) \
89*d32f26eeSAndy Fiddaman 	UCODE_SIZE_CONVERT((size), UCODE_DEFAULT_BODY_SIZE)
90*d32f26eeSAndy Fiddaman 
91*d32f26eeSAndy Fiddaman #define	UCODE_TOTAL_SIZE_INTEL(size)			\
92*d32f26eeSAndy Fiddaman 	UCODE_SIZE_CONVERT((size), UCODE_DEFAULT_TOTAL_SIZE)
93*d32f26eeSAndy Fiddaman 
94*d32f26eeSAndy Fiddaman #define	UCODE_MATCH_INTEL(sig1, sig2, pf1, pf2) \
95*d32f26eeSAndy Fiddaman 	(((sig1) == (sig2)) && \
96*d32f26eeSAndy Fiddaman 	(((pf1) & (pf2)) || (((pf1) == 0) && ((pf2) == 0))))
97*d32f26eeSAndy Fiddaman 
98*d32f26eeSAndy Fiddaman #ifdef __cplusplus
99*d32f26eeSAndy Fiddaman }
100*d32f26eeSAndy Fiddaman #endif
101*d32f26eeSAndy Fiddaman 
102*d32f26eeSAndy Fiddaman #endif	/* _SYS_UCODE_INTEL_H */
103