4 #if defined __GNUC__ && defined __GNUC_MINOR__
5 # define GNUC_PREREQ(maj, min) \
6 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
8 # define GNUC_PREREQ(maj, min) 0
10 #if defined __clang_major__ && defined __clang_minor__
11 # define CLANG_PREREQ(maj, min) \
12 ((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
14 # define CLANG_PREREQ(maj, min) 0
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.
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__))
29 #undef uefi_call_wrapper
33 #define min(a, b) ({(a) < (b) ? (a) : (b);})
36 #ifndef DEFAULT_LOADER
37 #define DEFAULT_LOADER L"\\grubx64.efi"
39 #ifndef DEFAULT_LOADER_CHAR
40 #define DEFAULT_LOADER_CHAR "\\grubx64.efi"
43 #define EFI_ARCH L"x64"
46 #define DEBUGDIR L"/usr/lib/debug/usr/share/shim/x64/"
50 #if defined(__i686__) || defined(__i386__)
51 #ifndef DEFAULT_LOADER
52 #define DEFAULT_LOADER L"\\grubia32.efi"
54 #ifndef DEFAULT_LOADER_CHAR
55 #define DEFAULT_LOADER_CHAR "\\grubia32.efi"
58 #define EFI_ARCH L"ia32"
61 #define DEBUGDIR L"/usr/lib/debug/usr/share/shim/ia32/"
65 #if defined(__aarch64__)
66 #ifndef DEFAULT_LOADER
67 #define DEFAULT_LOADER L"\\grubaa64.efi"
69 #ifndef DEFAULT_LOADER_CHAR
70 #define DEFAULT_LOADER_CHAR "\\grubaa64.efi"
73 #define EFI_ARCH L"aa64"
76 #define DEBUGDIR L"/usr/lib/debug/usr/share/shim/aa64/"
81 #ifndef DEFAULT_LOADER
82 #define DEFAULT_LOADER L"\\grubarm.efi"
84 #ifndef DEFAULT_LOADER_CHAR
85 #define DEFAULT_LOADER_CHAR "\\grubarm.efi"
88 #define EFI_ARCH L"arm"
91 #define DEBUGDIR L"/usr/lib/debug/usr/share/shim/arm/"
95 #define FALLBACK L"\\fb" EFI_ARCH L".efi"
96 #define MOK_MANAGER L"\\mm" EFI_ARCH L".efi"
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"
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"
123 #ifdef ENABLE_SHIM_CERT
124 #include "shim_cert.h"
127 INTERFACE_DECL(_SHIM_LOCK
);
131 (*EFI_SHIM_LOCK_VERIFY
) (
138 (*EFI_SHIM_LOCK_HASH
) (
141 PE_COFF_LOADER_IMAGE_CONTEXT
*context
,
148 (*EFI_SHIM_LOCK_CONTEXT
) (
150 IN
unsigned int datasize
,
151 PE_COFF_LOADER_IMAGE_CONTEXT
*context
154 typedef struct _SHIM_LOCK
{
155 EFI_SHIM_LOCK_VERIFY Verify
;
156 EFI_SHIM_LOCK_HASH Hash
;
157 EFI_SHIM_LOCK_CONTEXT Context
;
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
);
169 extern UINT32 vendor_cert_size
;
170 extern UINT32 vendor_dbx_size
;
171 extern UINT8
*vendor_cert
;
172 extern UINT8
*vendor_dbx
;
174 extern UINT8 user_insecure_mode
;
175 extern UINT8 ignore_db
;
176 extern UINT8 in_protocol
;
178 #define perror_(file, line, func, fmt, ...) ({ \
179 UINTN __perror_ret = 0; \
181 __perror_ret = console_print((fmt), ##__VA_ARGS__); \
182 LogError_(file, line, func, fmt, ##__VA_ARGS__); \
185 #define perror(fmt, ...) perror_(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
186 #define LogError(fmt, ...) LogError_(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)