diff mbox series

[RFC,03/14] efi: move efi_info_get() to a new header file

Message ID 20241124-b4-efistub-arm64-v1-3-3e33f0340071@linaro.org
State New
Headers show
Series efi: implement EFISTUB support for ARM64 and Qualcomm | expand

Commit Message

Caleb Connolly Nov. 24, 2024, 8:26 p.m. UTC
Split out the EFI stub specific code to a new efi_stub.h header file.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 arch/x86/cpu/efi/payload.c |  1 +
 cmd/efi.c                  |  1 +
 drivers/video/efi.c        |  1 +
 include/efi.h              | 25 -------------------------
 include/efi_stub.h         | 38 ++++++++++++++++++++++++++++++++++++++
 lib/efi/efi_app.c          |  1 +
 lib/efi/efi_info.c         |  1 +
 lib/efi/efi_stub_arm64.c   |  1 +
 lib/efi/efi_stub_x86.c     |  1 +
 9 files changed, 45 insertions(+), 25 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/cpu/efi/payload.c b/arch/x86/cpu/efi/payload.c
index 6845ce72ff94..68cda25aca63 100644
--- a/arch/x86/cpu/efi/payload.c
+++ b/arch/x86/cpu/efi/payload.c
@@ -6,8 +6,9 @@ 
 
 #include <cpu_func.h>
 #include <efi.h>
 #include <efi_api.h>
+#include <efi_stub.h>
 #include <errno.h>
 #include <event.h>
 #include <init.h>
 #include <log.h>
diff --git a/cmd/efi.c b/cmd/efi.c
index 1fb67a83aae5..53213be0a2fa 100644
--- a/cmd/efi.c
+++ b/cmd/efi.c
@@ -6,8 +6,9 @@ 
 
 #include <command.h>
 #include <efi.h>
 #include <efi_api.h>
+#include <efi_stub.h>
 #include <errno.h>
 #include <log.h>
 #include <malloc.h>
 #include <sort.h>
diff --git a/drivers/video/efi.c b/drivers/video/efi.c
index 78d123fad4be..a7b6d47f9a15 100644
--- a/drivers/video/efi.c
+++ b/drivers/video/efi.c
@@ -8,8 +8,9 @@ 
 #define LOG_CATEGORY LOGC_EFI
 
 #include <dm.h>
 #include <efi_api.h>
+#include <efi_stub.h>
 #include <log.h>
 #include <vesa.h>
 #include <video.h>
 
diff --git a/include/efi.h b/include/efi.h
index a6eff13a6bbb..933be35852df 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -321,18 +321,8 @@  struct efi_open_protocol_info_entry {
 	u32 attributes;
 	u32 open_count;
 };
 
-enum efi_entry_t {
-	EFIET_END,	/* Signals this is the last (empty) entry */
-	EFIET_MEMORY_MAP,
-	EFIET_GOP_MODE,
-	EFIET_SYS_TABLE,
-
-	/* Number of entries */
-	EFIET_MEMORY_COUNT,
-};
-
 #define EFI_TABLE_VERSION	1
 
 /**
  * struct efi_info_hdr - Header for the EFI info table
@@ -609,23 +599,8 @@  void efi_puts(struct efi_priv *priv, const char *str);
  * @ch:		Character to write (note this is not unicode)
  */
 void efi_putc(struct efi_priv *priv, const char ch);
 
-/**
- * efi_info_get() - get an entry from an EFI table
- *
- * This function is called from U-Boot proper to read information set up by the
- * EFI stub. It can only be used when running from the EFI stub, not when U-Boot
- * is running as an app.
- *
- * @type:	Entry type to search for
- * @datap:	Returns pointer to entry data
- * @sizep:	Returns entry size
- * Return: 0 if OK, -ENODATA if there is no table, -ENOENT if there is no entry
- * of the requested type, -EPROTONOSUPPORT if the table has the wrong version
- */
-int efi_info_get(enum efi_entry_t type, void **datap, int *sizep);
-
 /**
  * efi_store_memory_map() - Collect the memory-map info from EFI
  *
  * Collect the memory info and store it for later use, e.g. in calling
diff --git a/include/efi_stub.h b/include/efi_stub.h
new file mode 100644
index 000000000000..4780badd3ac4
--- /dev/null
+++ b/include/efi_stub.h
@@ -0,0 +1,38 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Helpers for U-Boot running as an EFI payload.
+ *
+ * Copyright (c) 2024 Linaro, Ltd
+ */
+
+#ifndef _EFI_STUB_H
+#define _EFI_STUB_H
+
+#include <linux/types.h>
+
+enum efi_entry_t {
+	EFIET_END,	/* Signals this is the last (empty) entry */
+	EFIET_MEMORY_MAP,
+	EFIET_GOP_MODE,
+	EFIET_SYS_TABLE,
+
+	/* Number of entries */
+	EFIET_MEMORY_COUNT,
+};
+
+/**
+ * efi_info_get() - get an entry from an EFI table
+ *
+ * This function is called from U-Boot proper to read information set up by the
+ * EFI stub. It can only be used when running from the EFI stub, not when U-Boot
+ * is running as an app.
+ *
+ * @type:	Entry type to search for
+ * @datap:	Returns pointer to entry data
+ * @sizep:	Returns entry size
+ * Return: 0 if OK, -ENODATA if there is no table, -ENOENT if there is no entry
+ * of the requested type, -EPROTONOSUPPORT if the table has the wrong version
+ */
+int efi_info_get(enum efi_entry_t type, void **datap, int *sizep);
+
+#endif /* _EFI_STUB_H */
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 9b94a93ee4f1..2c66133648e4 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -12,8 +12,9 @@ 
 #include <debug_uart.h>
 #include <dm.h>
 #include <efi.h>
 #include <efi_api.h>
+#include <efi_stub.h>
 #include <errno.h>
 #include <init.h>
 #include <malloc.h>
 #include <sysreset.h>
diff --git a/lib/efi/efi_info.c b/lib/efi/efi_info.c
index 5fa4baeec635..32ba7e499c57 100644
--- a/lib/efi/efi_info.c
+++ b/lib/efi/efi_info.c
@@ -5,8 +5,9 @@ 
  * Access to the EFI information table
  */
 
 #include <efi.h>
+#include <efi_stub.h>
 #include <errno.h>
 #include <mapmem.h>
 #include <asm/global_data.h>
 
diff --git a/lib/efi/efi_stub_arm64.c b/lib/efi/efi_stub_arm64.c
index 54bee6c55d7e..2cabb16f2414 100644
--- a/lib/efi/efi_stub_arm64.c
+++ b/lib/efi/efi_stub_arm64.c
@@ -11,8 +11,9 @@ 
 
 #include <debug_uart.h>
 #include <efi.h>
 #include <efi_api.h>
+#include <efi_stub.h>
 #include <malloc.h>
 #include <asm/io.h>
 #include <linux/err.h>
 #include <linux/types.h>
diff --git a/lib/efi/efi_stub_x86.c b/lib/efi/efi_stub_x86.c
index 40fc29d9adf7..ea1993f745d3 100644
--- a/lib/efi/efi_stub_x86.c
+++ b/lib/efi/efi_stub_x86.c
@@ -11,8 +11,9 @@ 
 
 #include <debug_uart.h>
 #include <efi.h>
 #include <efi_api.h>
+#include <efi_stub.h>
 #include <errno.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <asm/cpu.h>