1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef _INTEL_GSC_BINARY_HEADERS_H_
7 #define _INTEL_GSC_BINARY_HEADERS_H_
8 
9 #include <linux/types.h>
10 
11 /* Code partition directory (CPD) structures */
12 struct intel_gsc_cpd_header_v2 {
13 	u32 header_marker;
14 #define INTEL_GSC_CPD_HEADER_MARKER 0x44504324
15 
16 	u32 num_of_entries;
17 	u8 header_version;
18 	u8 entry_version;
19 	u8 header_length; /* in bytes */
20 	u8 flags;
21 	u32 partition_name;
22 	u32 crc32;
23 } __packed;
24 
25 struct intel_gsc_cpd_entry {
26 	u8 name[12];
27 
28 	/*
29 	 * Bits 0-24: offset from the beginning of the code partition
30 	 * Bit 25: huffman compressed
31 	 * Bits 26-31: reserved
32 	 */
33 	u32 offset;
34 #define INTEL_GSC_CPD_ENTRY_OFFSET_MASK GENMASK(24, 0)
35 #define INTEL_GSC_CPD_ENTRY_HUFFMAN_COMP BIT(25)
36 
37 	/*
38 	 * Module/Item length, in bytes. For Huffman-compressed modules, this
39 	 * refers to the uncompressed size. For software-compressed modules,
40 	 * this refers to the compressed size.
41 	 */
42 	u32 length;
43 
44 	u8 reserved[4];
45 } __packed;
46 
47 struct intel_gsc_version {
48 	u16 major;
49 	u16 minor;
50 	u16 hotfix;
51 	u16 build;
52 } __packed;
53 
54 struct intel_gsc_manifest_header {
55 	u32 header_type; /* 0x4 for manifest type */
56 	u32 header_length; /* in dwords */
57 	u32 header_version;
58 	u32 flags;
59 	u32 vendor;
60 	u32 date;
61 	u32 size; /* In dwords, size of entire manifest (header + extensions) */
62 	u32 header_id;
63 	u32 internal_data;
64 	struct intel_gsc_version fw_version;
65 	u32 security_version;
66 	struct intel_gsc_version meu_kit_version;
67 	u32 meu_manifest_version;
68 	u8 general_data[4];
69 	u8 reserved3[56];
70 	u32 modulus_size; /* in dwords */
71 	u32 exponent_size; /* in dwords */
72 } __packed;
73 
74 #endif
75