[U-Boot] [PATCH 33/38] x86: fsp: Allow the HOBs to be used after relocation
Simon Glass
sjg at chromium.org
Mon Aug 26 15:59:38 UTC 2019
Allocate memory for the HOBs and copy them before relocation. This ensures
that they can still be accessed after relocation.
This is needed when relocating the HOB within U-Boot.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
arch/x86/cpu/cpu.c | 6 ++++++
arch/x86/include/asm/fsp/fsp_support.h | 8 ++++++++
arch/x86/include/asm/hob.h | 8 ++++++++
arch/x86/lib/fsp/fsp_support.c | 16 ++++++++++++++++
arch/x86/lib/hob.c | 11 +++++++++++
5 files changed, 49 insertions(+)
diff --git a/arch/x86/cpu/cpu.c b/arch/x86/cpu/cpu.c
index 290ee084e5..e0b24c8df2 100644
--- a/arch/x86/cpu/cpu.c
+++ b/arch/x86/cpu/cpu.c
@@ -42,6 +42,9 @@
#include <asm/interrupt.h>
#include <asm/tables.h>
#include <linux/compiler.h>
+#ifdef CONFIG_HAVE_FSP
+#include <asm/fsp/fsp_support.h>
+#endif
DECLARE_GLOBAL_DATA_PTR;
@@ -262,6 +265,9 @@ int reserve_arch(void)
#ifdef CONFIG_ENABLE_MRC_CACHE
mrccache_reserve();
#endif
+#ifdef CONFIG_HAVE_FSP
+ fsp_reserve();
+#endif
#ifdef CONFIG_SEABIOS
high_table_reserve();
diff --git a/arch/x86/include/asm/fsp/fsp_support.h b/arch/x86/include/asm/fsp/fsp_support.h
index 4f93cb2a13..2424bc1f5f 100644
--- a/arch/x86/include/asm/fsp/fsp_support.h
+++ b/arch/x86/include/asm/fsp/fsp_support.h
@@ -163,4 +163,12 @@ void *fsp_prepare_mrc_cache(void);
*/
u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase);
+/**
+ * fsp_reserve() - Relocation the HOBs
+ *
+ * Make space for the HOBs in the new memory and copy them there. This must be
+ * called from board_init_f() along with the 'reserve' functions.
+ */
+void fsp_reserve(void);
+
#endif
diff --git a/arch/x86/include/asm/hob.h b/arch/x86/include/asm/hob.h
index 72151ea045..6b00d24071 100644
--- a/arch/x86/include/asm/hob.h
+++ b/arch/x86/include/asm/hob.h
@@ -227,4 +227,12 @@ const struct hob_header *hob_get_next_guid_hob(const efi_guid_t *guid,
void *hob_get_guid_hob_data(const void *hob_list, u32 *len,
const efi_guid_t *guid);
+/**
+ * hob_get_size() - Get the total size of the HOB data
+ *
+ * This scans the list and returns the number of bytes oocupied by the HOB list.
+ * This can be used to copy the list to somewhere else in memory.
+ */
+uint hob_get_size(const void *hob_list);
+
#endif /* __HOB_H__ */
diff --git a/arch/x86/lib/fsp/fsp_support.c b/arch/x86/lib/fsp/fsp_support.c
index 82c59befd9..0f0c41fbf8 100644
--- a/arch/x86/lib/fsp/fsp_support.c
+++ b/arch/x86/lib/fsp/fsp_support.c
@@ -181,3 +181,19 @@ void *fsp_get_graphics_info(const void *hob_list, u32 *len)
return hob_get_guid_hob_data(hob_list, len, &guid);
}
+
+void fsp_reserve(void)
+{
+ void *new_hobs;
+ uint hob_size;
+
+ hob_size = hob_get_size(gd->arch.hob_list);
+ gd->start_addr_sp -= hob_size;
+ new_hobs = (void *)gd->start_addr_sp;
+ memcpy(new_hobs, gd->arch.hob_list, hob_size);
+
+ gd->start_addr_sp &= ~0xf;
+ debug("Copying FSP HOBs from %p to %p, size %x\n", gd->arch.hob_list,
+ new_hobs, hob_size);
+ gd->arch.hob_list = new_hobs;
+}
diff --git a/arch/x86/lib/hob.c b/arch/x86/lib/hob.c
index f2c47240ee..43c53f4bbb 100644
--- a/arch/x86/lib/hob.c
+++ b/arch/x86/lib/hob.c
@@ -82,3 +82,14 @@ void *hob_get_guid_hob_data(const void *hob_list, u32 *len,
return get_guid_hob_data(guid_hob);
}
+
+uint hob_get_size(const void *hob_list)
+{
+ const struct hob_header *hdr;
+
+ for (hdr = hob_list; !end_of_hob(hdr); hdr = get_next_hob(hdr))
+ ;
+ hdr++;
+
+ return (void *)hdr - hob_list;
+}
--
2.23.0.187.g17f5b7556c-goog
More information about the U-Boot
mailing list