xref: /illumos-gate/usr/src/uts/intel/sys/ucode_intel.h (revision d32f26eec03290baae31e85e7c5840280d5c4292)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
26  * Copyright 2022 Joyent, Inc.
27  * Copyright 2023 Oxide Computer Company
28  */
29 
30 #ifndef	_SYS_UCODE_INTEL_H
31 #define	_SYS_UCODE_INTEL_H
32 
33 #include <sys/types.h>
34 #include <ucode/ucode_errno.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Intel Microcode file information
42  */
43 typedef struct ucode_header_intel {
44 	uint32_t	uh_header_ver;
45 	uint32_t	uh_rev;
46 	uint32_t	uh_date;
47 	uint32_t	uh_signature;
48 	uint32_t	uh_checksum;
49 	uint32_t	uh_loader_ver;
50 	uint32_t	uh_proc_flags;
51 	uint32_t	uh_body_size;
52 	uint32_t	uh_total_size;
53 	uint32_t	uh_reserved[3];
54 } ucode_header_intel_t;
55 
56 typedef struct ucode_ext_sig_intel {
57 	uint32_t	ues_signature;
58 	uint32_t	ues_proc_flags;
59 	uint32_t	ues_checksum;
60 } ucode_ext_sig_intel_t;
61 
62 typedef struct ucode_ext_table_intel {
63 	uint32_t	uet_count;
64 	uint32_t	uet_checksum;
65 	uint32_t	uet_reserved[3];
66 	ucode_ext_sig_intel_t uet_ext_sig[1];
67 } ucode_ext_table_intel_t;
68 
69 typedef struct ucode_file_intel {
70 	ucode_header_intel_t	*uf_header;
71 	uint8_t			*uf_body;
72 	ucode_ext_table_intel_t	*uf_ext_table;
73 } ucode_file_intel_t;
74 
75 /*					"32-bit-sig"-"8-bit-platid"\0 */
76 #define	UCODE_MAX_NAME_LEN_INTEL	(sizeof ("XXXXXXXX-XX"))
77 
78 #define	UCODE_HEADER_SIZE_INTEL		(sizeof (struct ucode_header_intel))
79 #define	UCODE_EXT_TABLE_SIZE_INTEL	(20)	/* 20-bytes */
80 #define	UCODE_EXT_SIG_SIZE_INTEL	(sizeof (struct ucode_ext_sig_intel))
81 
82 #define	UCODE_DEFAULT_TOTAL_SIZE	UCODE_KB(2)
83 #define	UCODE_DEFAULT_BODY_SIZE		(UCODE_KB(2) - UCODE_HEADER_SIZE_INTEL)
84 
85 #define	UCODE_SIZE_CONVERT(size, default_size) \
86 	((size) == 0 ? (default_size) : (size))
87 
88 #define	UCODE_BODY_SIZE_INTEL(size) \
89 	UCODE_SIZE_CONVERT((size), UCODE_DEFAULT_BODY_SIZE)
90 
91 #define	UCODE_TOTAL_SIZE_INTEL(size)			\
92 	UCODE_SIZE_CONVERT((size), UCODE_DEFAULT_TOTAL_SIZE)
93 
94 #define	UCODE_MATCH_INTEL(sig1, sig2, pf1, pf2) \
95 	(((sig1) == (sig2)) && \
96 	(((pf1) & (pf2)) || (((pf1) == 0) && ((pf2) == 0))))
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif	/* _SYS_UCODE_INTEL_H */
103