[PATCH 061/112] efi: add efi_is_loader/efi_is_payload helpers
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Jan 3 10:12:21 PST 2024
So far, whether we are running under EFI was a compile-time decision.
This will change with ARM support, where the same barebox binary can
either probe from DT or from EFI. Prepare for this by adding helpers
to determine whether barebox is acting as EFI loader or as payload.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/efi/efi-mode.h | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100644 include/efi/efi-mode.h
diff --git a/include/efi/efi-mode.h b/include/efi/efi-mode.h
new file mode 100644
index 000000000000..a917c038a1b0
--- /dev/null
+++ b/include/efi/efi-mode.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __EFI_MODE_H
+#define __EFI_MODE_H
+
+#include <linux/stddef.h>
+#include <linux/types.h>
+
+struct efi_boot_services;
+extern struct efi_boot_services *BS;
+
+static inline bool efi_is_payload(void)
+{
+ return IS_ENABLED(CONFIG_EFI_PAYLOAD) && BS;
+}
+
+static inline bool efi_is_loader(void)
+{
+ return false;
+}
+
+static inline struct efi_boot_services *efi_get_boot_services(void)
+{
+ if (efi_is_payload())
+ return BS;
+
+ return NULL;
+}
+
+#endif
--
2.39.2
More information about the barebox
mailing list