]>
Commit | Line | Data |
---|---|---|
1 | /* SPDX-License-Identifier: GPL-2.0 */ | |
2 | /* | |
3 | * Copyright 2021 Linaro Limited | |
4 | * Author: AKASHI Takahiro | |
5 | * | |
6 | * derived from efi.h and efi_api.h to make the file POSIX-compliant | |
7 | */ | |
8 | ||
9 | #ifndef _EFI_CAPSULE_H | |
10 | #define _EFI_CAPSULE_H | |
11 | ||
12 | #include <stdint.h> | |
13 | ||
14 | /* | |
15 | * Gcc's predefined attributes are not recognized by clang. | |
16 | */ | |
17 | #ifndef __packed | |
18 | #define __packed __attribute__((__packed__)) | |
19 | #endif | |
20 | ||
21 | #ifndef __aligned | |
22 | #define __aligned(x) __attribute__((__aligned__(x))) | |
23 | #endif | |
24 | ||
25 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | |
26 | ||
27 | typedef struct { | |
28 | uint8_t b[16]; | |
29 | } efi_guid_t __aligned(8); | |
30 | ||
31 | #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ | |
32 | {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \ | |
33 | ((a) >> 24) & 0xff, \ | |
34 | (b) & 0xff, ((b) >> 8) & 0xff, \ | |
35 | (c) & 0xff, ((c) >> 8) & 0xff, \ | |
36 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } } | |
37 | ||
38 | #define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \ | |
39 | EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \ | |
40 | 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a) | |
41 | ||
42 | #define EFI_CERT_TYPE_PKCS7_GUID \ | |
43 | EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \ | |
44 | 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7) | |
45 | ||
46 | #define FW_ACCEPT_OS_GUID \ | |
47 | EFI_GUID(0x0c996046, 0xbcc0, 0x4d04, 0x85, 0xec, \ | |
48 | 0xe1, 0xfc, 0xed, 0xf1, 0xc6, 0xf8) | |
49 | ||
50 | #define FW_REVERT_OS_GUID \ | |
51 | EFI_GUID(0xacd58b4b, 0xc0e8, 0x475f, 0x99, 0xb5, \ | |
52 | 0x6b, 0x3f, 0x7e, 0x07, 0xaa, 0xf0) | |
53 | ||
54 | /* flags */ | |
55 | #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 | |
56 | ||
57 | struct efi_capsule_header { | |
58 | efi_guid_t capsule_guid; | |
59 | uint32_t header_size; | |
60 | uint32_t flags; | |
61 | uint32_t capsule_image_size; | |
62 | } __packed; | |
63 | ||
64 | struct efi_firmware_management_capsule_header { | |
65 | uint32_t version; | |
66 | uint16_t embedded_driver_count; | |
67 | uint16_t payload_item_count; | |
68 | uint64_t item_offset_list[]; | |
69 | } __packed; | |
70 | ||
71 | /* image_capsule_support */ | |
72 | #define CAPSULE_SUPPORT_AUTHENTICATION 0x0000000000000001 | |
73 | ||
74 | struct efi_firmware_management_capsule_image_header { | |
75 | uint32_t version; | |
76 | efi_guid_t update_image_type_id; | |
77 | uint8_t update_image_index; | |
78 | uint8_t reserved[3]; | |
79 | uint32_t update_image_size; | |
80 | uint32_t update_vendor_code_size; | |
81 | uint64_t update_hardware_instance; | |
82 | uint64_t image_capsule_support; | |
83 | } __packed; | |
84 | ||
85 | /** | |
86 | * win_certificate_uefi_guid - A certificate that encapsulates | |
87 | * a GUID-specific signature | |
88 | * | |
89 | * @hdr: Windows certificate header, cf. WIN_CERTIFICATE | |
90 | * @cert_type: Certificate type | |
91 | */ | |
92 | struct win_certificate_uefi_guid { | |
93 | struct { | |
94 | uint32_t dwLength; | |
95 | uint16_t wRevision; | |
96 | uint16_t wCertificateType; | |
97 | } hdr; | |
98 | efi_guid_t cert_type; | |
99 | } __packed; | |
100 | ||
101 | /** | |
102 | * efi_firmware_image_authentication - Capsule authentication method | |
103 | * descriptor | |
104 | * | |
105 | * This structure describes an authentication information for | |
106 | * a capsule with IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED set | |
107 | * and should be included as part of the capsule. | |
108 | * Only EFI_CERT_TYPE_PKCS7_GUID is accepted. | |
109 | * | |
110 | * @monotonic_count: Count to prevent replay | |
111 | * @auth_info: Authentication info | |
112 | */ | |
113 | struct efi_firmware_image_authentication { | |
114 | uint64_t monotonic_count; | |
115 | struct win_certificate_uefi_guid auth_info; | |
116 | } __packed; | |
117 | ||
118 | /* fmp payload header */ | |
119 | #define SIGNATURE_16(A, B) ((A) | ((B) << 8)) | |
120 | #define SIGNATURE_32(A, B, C, D) \ | |
121 | (SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16)) | |
122 | ||
123 | #define FMP_PAYLOAD_HDR_SIGNATURE SIGNATURE_32('M', 'S', 'S', '1') | |
124 | ||
125 | /** | |
126 | * struct fmp_payload_header - EDK2 header for the FMP payload | |
127 | * | |
128 | * This structure describes the header which is preprended to the | |
129 | * FMP payload by the edk2 capsule generation scripts. | |
130 | * | |
131 | * @signature: Header signature used to identify the header | |
132 | * @header_size: Size of the structure | |
133 | * @fw_version: Firmware versions used | |
134 | * @lowest_supported_version: Lowest supported version (not used) | |
135 | */ | |
136 | struct fmp_payload_header { | |
137 | uint32_t signature; | |
138 | uint32_t header_size; | |
139 | uint32_t fw_version; | |
140 | uint32_t lowest_supported_version; | |
141 | }; | |
142 | ||
143 | struct fmp_payload_header_params { | |
144 | bool have_header; | |
145 | uint32_t fw_version; | |
146 | }; | |
147 | ||
148 | #endif /* _EFI_CAPSULE_H */ |