blob: d63b8314432560a7734aa1b5cbe628f1259e9d02 [file] [log] [blame]
AKASHI Takahiroc246b762022-02-09 19:10:35 +09001/* 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
25typedef struct {
26 uint8_t b[16];
27} efi_guid_t __aligned(8);
28
29#define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
30 {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \
31 ((a) >> 24) & 0xff, \
32 (b) & 0xff, ((b) >> 8) & 0xff, \
33 (c) & 0xff, ((c) >> 8) & 0xff, \
34 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } }
35
36#define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \
37 EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
38 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
39
AKASHI Takahiroc246b762022-02-09 19:10:35 +090040#define EFI_CERT_TYPE_PKCS7_GUID \
41 EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \
42 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
43
44/* flags */
45#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000
46
47struct efi_capsule_header {
48 efi_guid_t capsule_guid;
49 uint32_t header_size;
50 uint32_t flags;
51 uint32_t capsule_image_size;
52} __packed;
53
54struct efi_firmware_management_capsule_header {
55 uint32_t version;
56 uint16_t embedded_driver_count;
57 uint16_t payload_item_count;
58 uint32_t item_offset_list[];
59} __packed;
60
61/* image_capsule_support */
62#define CAPSULE_SUPPORT_AUTHENTICATION 0x0000000000000001
63
64struct efi_firmware_management_capsule_image_header {
65 uint32_t version;
66 efi_guid_t update_image_type_id;
67 uint8_t update_image_index;
68 uint8_t reserved[3];
69 uint32_t update_image_size;
70 uint32_t update_vendor_code_size;
71 uint64_t update_hardware_instance;
72 uint64_t image_capsule_support;
73} __packed;
74
75/**
76 * win_certificate_uefi_guid - A certificate that encapsulates
77 * a GUID-specific signature
78 *
79 * @hdr: Windows certificate header, cf. WIN_CERTIFICATE
80 * @cert_type: Certificate type
81 */
82struct win_certificate_uefi_guid {
83 struct {
84 uint32_t dwLength;
85 uint16_t wRevision;
86 uint16_t wCertificateType;
87 } hdr;
88 efi_guid_t cert_type;
89} __packed;
90
91/**
92 * efi_firmware_image_authentication - Capsule authentication method
93 * descriptor
94 *
95 * This structure describes an authentication information for
96 * a capsule with IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED set
97 * and should be included as part of the capsule.
98 * Only EFI_CERT_TYPE_PKCS7_GUID is accepted.
99 *
100 * @monotonic_count: Count to prevent replay
101 * @auth_info: Authentication info
102 */
103struct efi_firmware_image_authentication {
104 uint64_t monotonic_count;
105 struct win_certificate_uefi_guid auth_info;
106} __packed;
107
108#endif /* _EFI_CAPSULE_H */