]> git.proxmox.com Git - efi-boot-shim.git/blob - shim.h
Fix typo in debug path in shim.h
[efi-boot-shim.git] / shim.h
1 #ifndef SHIM_H_
2 #define SHIM_H_
3
4 #if defined __GNUC__ && defined __GNUC_MINOR__
5 # define GNUC_PREREQ(maj, min) \
6 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
7 #else
8 # define GNUC_PREREQ(maj, min) 0
9 #endif
10 #if defined __clang_major__ && defined __clang_minor__
11 # define CLANG_PREREQ(maj, min) \
12 ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
13 #else
14 # define CLANG_PREREQ(maj, min) 0
15 #endif
16
17 #if defined(__x86_64__)
18 #if !defined(GNU_EFI_USE_MS_ABI)
19 #error On x86_64 you must use ms_abi (GNU_EFI_USE_MS_ABI) in gnu-efi and shim.
20 #endif
21 /* gcc 4.5.4 is the first documented release with -mabi=ms */
22 #if !GNUC_PREREQ(4, 7) && !CLANG_PREREQ(3, 4)
23 #error On x86_64 you must have a compiler new enough to support __attribute__((__ms_abi__))
24 #endif
25 #endif
26
27 #include <efi.h>
28 #include <efilib.h>
29 #undef uefi_call_wrapper
30
31 #include <stddef.h>
32
33 #define min(a, b) ({(a) < (b) ? (a) : (b);})
34
35 #ifdef __x86_64__
36 #ifndef DEFAULT_LOADER
37 #define DEFAULT_LOADER L"\\grubx64.efi"
38 #endif
39 #ifndef DEFAULT_LOADER_CHAR
40 #define DEFAULT_LOADER_CHAR "\\grubx64.efi"
41 #endif
42 #ifndef EFI_ARCH
43 #define EFI_ARCH L"x64"
44 #endif
45 #ifndef DEBUGDIR
46 #define DEBUGDIR L"/usr/lib/debug/usr/share/shim/x64/"
47 #endif
48 #endif
49
50 #if defined(__i686__) || defined(__i386__)
51 #ifndef DEFAULT_LOADER
52 #define DEFAULT_LOADER L"\\grubia32.efi"
53 #endif
54 #ifndef DEFAULT_LOADER_CHAR
55 #define DEFAULT_LOADER_CHAR "\\grubia32.efi"
56 #endif
57 #ifndef EFI_ARCH
58 #define EFI_ARCH L"ia32"
59 #endif
60 #ifndef DEBUGDIR
61 #define DEBUGDIR L"/usr/lib/debug/usr/share/shim/ia32/"
62 #endif
63 #endif
64
65 #if defined(__aarch64__)
66 #ifndef DEFAULT_LOADER
67 #define DEFAULT_LOADER L"\\grubaa64.efi"
68 #endif
69 #ifndef DEFAULT_LOADER_CHAR
70 #define DEFAULT_LOADER_CHAR "\\grubaa64.efi"
71 #endif
72 #ifndef EFI_ARCH
73 #define EFI_ARCH L"aa64"
74 #endif
75 #ifndef DEBUGDIR
76 #define DEBUGDIR L"/usr/lib/debug/usr/share/shim/aa64/"
77 #endif
78 #endif
79
80 #if defined(__arm__)
81 #ifndef DEFAULT_LOADER
82 #define DEFAULT_LOADER L"\\grubarm.efi"
83 #endif
84 #ifndef DEFAULT_LOADER_CHAR
85 #define DEFAULT_LOADER_CHAR "\\grubarm.efi"
86 #endif
87 #ifndef EFI_ARCH
88 #define EFI_ARCH L"arm"
89 #endif
90 #ifndef DEBUGDIR
91 #define DEBUGDIR L"/usr/lib/debug/usr/share/shim/arm/"
92 #endif
93 #endif
94
95 #define FALLBACK L"\\fb" EFI_ARCH L".efi"
96 #define MOK_MANAGER L"\\mm" EFI_ARCH L".efi"
97
98 #include "include/configtable.h"
99 #include "include/console.h"
100 #include "include/crypt_blowfish.h"
101 #include "include/efiauthenticated.h"
102 #include "include/errors.h"
103 #include "include/execute.h"
104 #include "include/guid.h"
105 #include "include/Http.h"
106 #include "include/httpboot.h"
107 #include "include/Ip4Config2.h"
108 #include "include/Ip6Config.h"
109 #include "include/netboot.h"
110 #include "include/PasswordCrypt.h"
111 #include "include/PeImage.h"
112 #include "include/replacements.h"
113 #if defined(OVERRIDE_SECURITY_POLICY)
114 #include "include/security_policy.h"
115 #endif
116 #include "include/simple_file.h"
117 #include "include/str.h"
118 #include "include/tpm.h"
119 #include "include/ucs2.h"
120 #include "include/variables.h"
121
122 #include "version.h"
123 #ifdef ENABLE_SHIM_CERT
124 #include "shim_cert.h"
125 #endif
126
127 INTERFACE_DECL(_SHIM_LOCK);
128
129 typedef
130 EFI_STATUS
131 (*EFI_SHIM_LOCK_VERIFY) (
132 IN VOID *buffer,
133 IN UINT32 size
134 );
135
136 typedef
137 EFI_STATUS
138 (*EFI_SHIM_LOCK_HASH) (
139 IN char *data,
140 IN int datasize,
141 PE_COFF_LOADER_IMAGE_CONTEXT *context,
142 UINT8 *sha256hash,
143 UINT8 *sha1hash
144 );
145
146 typedef
147 EFI_STATUS
148 (*EFI_SHIM_LOCK_CONTEXT) (
149 IN VOID *data,
150 IN unsigned int datasize,
151 PE_COFF_LOADER_IMAGE_CONTEXT *context
152 );
153
154 typedef struct _SHIM_LOCK {
155 EFI_SHIM_LOCK_VERIFY Verify;
156 EFI_SHIM_LOCK_HASH Hash;
157 EFI_SHIM_LOCK_CONTEXT Context;
158 } SHIM_LOCK;
159
160 extern EFI_STATUS shim_init(void);
161 extern void shim_fini(void);
162 extern EFI_STATUS LogError_(const char *file, int line, const char *func, CHAR16 *fmt, ...);
163 extern EFI_STATUS VLogError(const char *file, int line, const char *func, CHAR16 *fmt, va_list args);
164 extern VOID PrintErrors(VOID);
165 extern VOID ClearErrors(VOID);
166 extern EFI_STATUS start_image(EFI_HANDLE image_handle, CHAR16 *ImagePath);
167 extern EFI_STATUS import_mok_state(EFI_HANDLE image_handle);
168
169 extern UINT32 vendor_cert_size;
170 extern UINT32 vendor_dbx_size;
171 extern UINT8 *vendor_cert;
172 extern UINT8 *vendor_dbx;
173
174 extern UINT8 user_insecure_mode;
175 extern UINT8 ignore_db;
176 extern UINT8 in_protocol;
177
178 #define perror_(file, line, func, fmt, ...) ({ \
179 UINTN __perror_ret = 0; \
180 if (!in_protocol) \
181 __perror_ret = console_print((fmt), ##__VA_ARGS__); \
182 LogError_(file, line, func, fmt, ##__VA_ARGS__); \
183 __perror_ret; \
184 })
185 #define perror(fmt, ...) perror_(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
186 #define LogError(fmt, ...) LogError_(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
187
188 #endif /* SHIM_H_ */