* [U-Boot] [PATCH 1/1] efi_loader: memory reservations according to e820 table
@ 2018-01-14 3:27 Heinrich Schuchardt
2018-01-14 15:59 ` Heinrich Schuchardt
0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2018-01-14 3:27 UTC (permalink / raw)
To: u-boot
On the x86 architecture the e820 BIOS table defines reserved memory.
Mark it as EFI reserved memory.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
lib/efi_loader/efi_memory.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index aaf64421a3..bee0a0c97d 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -10,6 +10,9 @@
#include <efi_loader.h>
#include <malloc.h>
#include <asm/global_data.h>
+#ifdef CONFIG_X86
+#include <asm/e820.h>
+#endif
#include <libfdt_env.h>
#include <linux/list_sort.h>
#include <inttypes.h>
@@ -493,6 +496,30 @@ __weak void efi_add_known_memory(void)
}
}
+/*
+ * Create reservations according to the BIOS e820 table.
+ */
+static void e820_memory_reservation(void)
+{
+#ifdef CONFIG_X86
+ struct e820entry e820[32];
+ unsigned int i, num;
+ unsigned long start, pages;
+
+ num = install_e820_map(ARRAY_SIZE(e820), e820);
+
+ for (i = 0; i < num; ++i) {
+ if (e820[i].type == E820_RESERVED) {
+ start = e820[i].addr;
+ pages = ALIGN(e820[i].size, EFI_PAGE_SIZE) >>
+ EFI_PAGE_SHIFT;
+ efi_add_memory_map(start, pages,
+ EFI_RESERVED_MEMORY_TYPE, false);
+ }
+ }
+#endif
+}
+
int efi_memory_init(void)
{
unsigned long runtime_start, runtime_end, runtime_pages;
@@ -525,6 +552,7 @@ int efi_memory_init(void)
efi_bounce_buffer = (void*)(uintptr_t)efi_bounce_buffer_addr;
#endif
+ e820_memory_reservation();
return 0;
}
--
2.15.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH 1/1] efi_loader: memory reservations according to e820 table
2018-01-14 3:27 [U-Boot] [PATCH 1/1] efi_loader: memory reservations according to e820 table Heinrich Schuchardt
@ 2018-01-14 15:59 ` Heinrich Schuchardt
2018-01-16 14:40 ` Alexander Graf
0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2018-01-14 15:59 UTC (permalink / raw)
To: u-boot
On 01/14/2018 04:27 AM, Heinrich Schuchardt wrote:
> On the x86 architecture the e820 BIOS table defines reserved memory.
> Mark it as EFI reserved memory.
>
Hello Simon, hello Bin,
is there a place in the x86 start up code where we could put the new
e820_memory_reservation() function?
Putting this into the EFI mainline code is a bit awkward.
Best regards
Heinrich
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> lib/efi_loader/efi_memory.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index aaf64421a3..bee0a0c97d 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -10,6 +10,9 @@
> #include <efi_loader.h>
> #include <malloc.h>
> #include <asm/global_data.h>
> +#ifdef CONFIG_X86
> +#include <asm/e820.h>
> +#endif
> #include <libfdt_env.h>
> #include <linux/list_sort.h>
> #include <inttypes.h>
> @@ -493,6 +496,30 @@ __weak void efi_add_known_memory(void)
> }
> }
>
> +/*
> + * Create reservations according to the BIOS e820 table.
> + */
> +static void e820_memory_reservation(void)
> +{
> +#ifdef CONFIG_X86
> + struct e820entry e820[32];
> + unsigned int i, num;
> + unsigned long start, pages;
> +
> + num = install_e820_map(ARRAY_SIZE(e820), e820);
> +
> + for (i = 0; i < num; ++i) {
> + if (e820[i].type == E820_RESERVED) {
> + start = e820[i].addr;
> + pages = ALIGN(e820[i].size, EFI_PAGE_SIZE) >>
> + EFI_PAGE_SHIFT;
> + efi_add_memory_map(start, pages,
> + EFI_RESERVED_MEMORY_TYPE, false);
> + }
> + }
> +#endif
> +}
> +
> int efi_memory_init(void)
> {
> unsigned long runtime_start, runtime_end, runtime_pages;
> @@ -525,6 +552,7 @@ int efi_memory_init(void)
>
> efi_bounce_buffer = (void*)(uintptr_t)efi_bounce_buffer_addr;
> #endif
> + e820_memory_reservation();
>
> return 0;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH 1/1] efi_loader: memory reservations according to e820 table
2018-01-14 15:59 ` Heinrich Schuchardt
@ 2018-01-16 14:40 ` Alexander Graf
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Graf @ 2018-01-16 14:40 UTC (permalink / raw)
To: u-boot
On 14.01.18 16:59, Heinrich Schuchardt wrote:
> On 01/14/2018 04:27 AM, Heinrich Schuchardt wrote:
>> On the x86 architecture the e820 BIOS table defines reserved memory.
>> Mark it as EFI reserved memory.
>>
>
> Hello Simon, hello Bin,
>
> is there a place in the x86 start up code where we could put the new
> e820_memory_reservation() function?
>
> Putting this into the EFI mainline code is a bit awkward.
Maybe you could just use the e820 table for all RAM population?
Something like this:
diff --git a/arch/x86/lib/e820.c b/arch/x86/lib/e820.c
index 5babfde268..b88a4f8d3c 100644
--- a/arch/x86/lib/e820.c
+++ b/arch/x86/lib/e820.c
@@ -35,3 +35,32 @@ __weak unsigned install_e820_map(unsigned max_entries,
return 4;
}
+
+#ifdef CONFIG_EFI_LOADER
+#include <efi_loader.h>
+
+void efi_add_known_memory(void)
+{
+ struct e820entry e820[32];
+ unsigned int i, num;
+ unsigned long start, pages;
+
+ num = install_e820_map(ARRAY_SIZE(e820), e820);
+
+ for (i = 0; i < num; ++i) {
+ start = e820[i].addr;
+ pages = ALIGN(e820[i].size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT;
+
+ switch (e820[i].type) {
+ case E820_RESERVED:
+ efi_add_memory_map(start, pages,
+ EFI_RESERVED_MEMORY_TYPE, false);
+ break;
+ case E820_RAM:
+ efi_add_memory_map(start, pages,
+ EFI_CONVENTIONAL_MEMORY, false);
+ break;
+ }
+ }
+}
+#endif
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-16 14:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-14 3:27 [U-Boot] [PATCH 1/1] efi_loader: memory reservations according to e820 table Heinrich Schuchardt
2018-01-14 15:59 ` Heinrich Schuchardt
2018-01-16 14:40 ` Alexander Graf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.