[PATCH v2 061/113] efi: add efi_is_loader/efi_is_payload helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux