• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2019 Intel Corporation
4  */
5 
6 #ifndef _INTEL_UC_FW_ABI_H
7 #define _INTEL_UC_FW_ABI_H
8 
9 #include <linux/types.h>
10 #include <linux/build_bug.h>
11 
12 /**
13  * DOC: Firmware Layout
14  *
15  * The GuC/HuC firmware layout looks like this::
16  *
17  *      +======================================================================+
18  *      |  Firmware blob                                                       |
19  *      +===============+===============+============+============+============+
20  *      |  CSS header   |     uCode     |  RSA key   |  modulus   |  exponent  |
21  *      +===============+===============+============+============+============+
22  *       <-header size->                 <---header size continued ----------->
23  *       <--- size ----------------------------------------------------------->
24  *                                       <-key size->
25  *                                                    <-mod size->
26  *                                                                 <-exp size->
27  *
28  * The firmware may or may not have modulus key and exponent data. The header,
29  * uCode and RSA signature are must-have components that will be used by driver.
30  * Length of each components, which is all in dwords, can be found in header.
31  * In the case that modulus and exponent are not present in fw, a.k.a truncated
32  * image, the length value still appears in header.
33  *
34  * Driver will do some basic fw size validation based on the following rules:
35  *
36  * 1. Header, uCode and RSA are must-have components.
37  * 2. All firmware components, if they present, are in the sequence illustrated
38  *    in the layout table above.
39  * 3. Length info of each component can be found in header, in dwords.
40  * 4. Modulus and exponent key are not required by driver. They may not appear
41  *    in fw. So driver will load a truncated firmware in this case.
42  */
43 
44 struct uc_css_header {
45 	u32 module_type;
46 	/*
47 	 * header_size includes all non-uCode bits, including css_header, rsa
48 	 * key, modulus key and exponent data.
49 	 */
50 	u32 header_size_dw;
51 	u32 header_version;
52 	u32 module_id;
53 	u32 module_vendor;
54 	u32 date;
55 #define CSS_DATE_DAY			(0xFF << 0)
56 #define CSS_DATE_MONTH			(0xFF << 8)
57 #define CSS_DATE_YEAR			(0xFFFF << 16)
58 	u32 size_dw; /* uCode plus header_size_dw */
59 	u32 key_size_dw;
60 	u32 modulus_size_dw;
61 	u32 exponent_size_dw;
62 	u32 time;
63 #define CSS_TIME_HOUR			(0xFF << 0)
64 #define CSS_DATE_MIN			(0xFF << 8)
65 #define CSS_DATE_SEC			(0xFFFF << 16)
66 	char username[8];
67 	char buildnumber[12];
68 	u32 sw_version;
69 #define CSS_SW_VERSION_UC_MAJOR		(0xFF << 16)
70 #define CSS_SW_VERSION_UC_MINOR		(0xFF << 8)
71 #define CSS_SW_VERSION_UC_PATCH		(0xFF << 0)
72 	u32 reserved0[13];
73 	union {
74 		u32 private_data_size; /* only applies to GuC */
75 		u32 reserved1;
76 	};
77 	u32 header_info;
78 } __packed;
79 static_assert(sizeof(struct uc_css_header) == 128);
80 
81 #endif /* _INTEL_UC_FW_ABI_H */
82