1 | /* $Id: efi-varstore.h 93115 2022-01-01 11:31:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT, EFI variable store (VarStore) definitions.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021-2022 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef IPRT_INCLUDED_formats_efi_varstore_h
|
---|
28 | #define IPRT_INCLUDED_formats_efi_varstore_h
|
---|
29 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
30 | # pragma once
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #include <iprt/types.h>
|
---|
34 | #include <iprt/assertcompile.h>
|
---|
35 | #include <iprt/formats/efi-common.h>
|
---|
36 |
|
---|
37 |
|
---|
38 | /*
|
---|
39 | * Definitions come from the EDK2 sources MdeModulePkg/Include/Guid/VariableFormat.h
|
---|
40 | */
|
---|
41 |
|
---|
42 | /** The filesystem GUID for a variable store stored in a volume header. */
|
---|
43 | #define EFI_VARSTORE_FILESYSTEM_GUID \
|
---|
44 | { 0xfff12b8d, 0x7696, 0x4c8b, { 0xa9, 0x85, 0x27, 0x47, 0x07, 0x5b, 0x4f, 0x50 }}
|
---|
45 |
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * The variable store header.
|
---|
49 | */
|
---|
50 | typedef struct EFI_VARSTORE_HEADER
|
---|
51 | {
|
---|
52 | /** The GUID identifying a variable store. */
|
---|
53 | EFI_GUID GuidVarStore;
|
---|
54 | /** Size of the variable store including the header. */
|
---|
55 | uint32_t cbVarStore;
|
---|
56 | /** The format state. */
|
---|
57 | uint8_t bFmt;
|
---|
58 | /** The region health state. */
|
---|
59 | uint8_t bState;
|
---|
60 | /** Reserved. */
|
---|
61 | uint8_t abRsvd[6];
|
---|
62 | } EFI_VARSTORE_HEADER;
|
---|
63 | AssertCompileSize(EFI_VARSTORE_HEADER, 28);
|
---|
64 | /** Pointer to a variable store header. */
|
---|
65 | typedef EFI_VARSTORE_HEADER *PEFI_VARSTORE_HEADER;
|
---|
66 | /** Pointer to a const variable store header. */
|
---|
67 | typedef const EFI_VARSTORE_HEADER *PCEFI_VARSTORE_HEADER;
|
---|
68 |
|
---|
69 | /** The GUID for a variable store using the authenticated variable header format. */
|
---|
70 | #define EFI_VARSTORE_HEADER_GUID_AUTHENTICATED_VARIABLE \
|
---|
71 | { 0xaaf32c78, 0x947b, 0x439a, { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 } }
|
---|
72 | /** The GUID for a variable store using the standard variable header format. */
|
---|
73 | #define EFI_VARSTORE_HEADER_GUID_VARIABLE \
|
---|
74 | { 0xddcf3616, 0x3275, 0x4164, { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d } }
|
---|
75 |
|
---|
76 | /** The EFI_VARSTORE_HEADER::bFmt value when the store region is formatted. */
|
---|
77 | #define EFI_VARSTORE_HEADER_FMT_FORMATTED 0x5a
|
---|
78 | /** The EFI_VARSTORE_HEADER::bState value when the store region is healthy. */
|
---|
79 | #define EFI_VARSTORE_HEADER_STATE_HEALTHY 0xfe
|
---|
80 |
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * Authenticated variable header.
|
---|
84 | */
|
---|
85 | #pragma pack(1)
|
---|
86 | typedef struct EFI_AUTH_VAR_HEADER
|
---|
87 | {
|
---|
88 | /** Contains EFI_AUTH_VAR_HEADER_START to identify the start of a new variable header. */
|
---|
89 | uint16_t u16StartId;
|
---|
90 | /** Variable state. */
|
---|
91 | uint8_t bState;
|
---|
92 | /** Reserved. */
|
---|
93 | uint8_t bRsvd;
|
---|
94 | /** Variable attributes. */
|
---|
95 | uint32_t fAttr;
|
---|
96 | /** Monotonic counter value increased with each change to protect against replay attacks. */
|
---|
97 | uint64_t cMonotonic;
|
---|
98 | /** Timestamp value to protect against replay attacks. */
|
---|
99 | EFI_TIME Timestamp;
|
---|
100 | /** Index of associated public key in database. */
|
---|
101 | uint32_t idPubKey;
|
---|
102 | /** Size of the variable zero terminated unicode name in bytes. */
|
---|
103 | uint32_t cbName;
|
---|
104 | /** Size of the variable data without this header. */
|
---|
105 | uint32_t cbData;
|
---|
106 | /** Producer/Consumer GUID for this variable. */
|
---|
107 | EFI_GUID GuidVendor;
|
---|
108 | } EFI_AUTH_VAR_HEADER;
|
---|
109 | #pragma pack()
|
---|
110 | AssertCompileSize(EFI_AUTH_VAR_HEADER, 60);
|
---|
111 | /** Pointer to a authenticated variable header. */
|
---|
112 | typedef EFI_AUTH_VAR_HEADER *PEFI_AUTH_VAR_HEADER;
|
---|
113 | /** Pointer to a const authenticated variable header. */
|
---|
114 | typedef const EFI_AUTH_VAR_HEADER *PCEFI_AUTH_VAR_HEADER;
|
---|
115 |
|
---|
116 | /** Value in EFI_AUTH_VAR_HEADER::u16StartId for a valid variable header. */
|
---|
117 | #define EFI_AUTH_VAR_HEADER_START 0x55aa
|
---|
118 | /** @name Possible variable states.
|
---|
119 | * @{ */
|
---|
120 | /** Variable is in the process of being deleted. */
|
---|
121 | #define EFI_AUTH_VAR_HEADER_STATE_IN_DELETED_TRANSITION 0xfe
|
---|
122 | /** Variable was deleted. */
|
---|
123 | #define EFI_AUTH_VAR_HEADER_STATE_DELETED 0xfd
|
---|
124 | /** Variable has only a valid header right now. */
|
---|
125 | #define EFI_AUTH_VAR_HEADER_STATE_HDR_VALID_ONLY 0x7f
|
---|
126 | /** Variable header, name and data are all valid. */
|
---|
127 | #define EFI_AUTH_VAR_HEADER_STATE_ADDED 0x3f
|
---|
128 | /** @} */
|
---|
129 |
|
---|
130 |
|
---|
131 | /** @name Possible variable attributes.
|
---|
132 | * @{ */
|
---|
133 | /** The variable is stored in non volatile memory. */
|
---|
134 | #define EFI_VAR_HEADER_ATTR_NON_VOLATILE RT_BIT_32(0)
|
---|
135 | /** The variable is accessible by the EFI bootservice stage. */
|
---|
136 | #define EFI_VAR_HEADER_ATTR_BOOTSERVICE_ACCESS RT_BIT_32(1)
|
---|
137 | /** The variable is accessible during runtime. */
|
---|
138 | #define EFI_VAR_HEADER_ATTR_RUNTIME_ACCESS RT_BIT_32(2)
|
---|
139 | /** The variable contains an hardware error record. */
|
---|
140 | #define EFI_VAR_HEADER_ATTR_HW_ERROR_RECORD RT_BIT_32(3)
|
---|
141 | /** The variable can be modified only by an authenticated source. */
|
---|
142 | #define EFI_AUTH_VAR_HEADER_ATTR_AUTH_WRITE_ACCESS RT_BIT_32(4)
|
---|
143 | /** The variable was written with a time based authentication. */
|
---|
144 | #define EFI_AUTH_VAR_HEADER_ATTR_TIME_BASED_AUTH_WRITE_ACCESS RT_BIT_32(5)
|
---|
145 | /** The variable can be appended. */
|
---|
146 | #define EFI_AUTH_VAR_HEADER_ATTR_APPEND_WRITE RT_BIT_32(6)
|
---|
147 | /** @} */
|
---|
148 |
|
---|
149 | #endif /* !IPRT_INCLUDED_formats_efi_varstore_h */
|
---|
150 |
|
---|