|
|
f731ee |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
f731ee |
From: Peter Jones <pjones@redhat.com>
|
|
|
f731ee |
Date: Mon, 7 Dec 2015 14:20:49 -0500
|
|
|
f731ee |
Subject: [PATCH] Make efi machines load an env block from a variable
|
|
|
f731ee |
|
|
|
f731ee |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
f731ee |
---
|
|
|
f731ee |
grub-core/Makefile.core.def | 1 +
|
|
|
f731ee |
grub-core/kern/efi/init.c | 34 +++++++++++++++++++++++++++++++++-
|
|
|
f731ee |
2 files changed, 34 insertions(+), 1 deletion(-)
|
|
|
f731ee |
|
|
|
f731ee |
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
|
|
f731ee |
index d73ea6f6c51..4fc74393335 100644
|
|
|
f731ee |
--- a/grub-core/Makefile.core.def
|
|
|
f731ee |
+++ b/grub-core/Makefile.core.def
|
|
|
f731ee |
@@ -173,6 +173,7 @@ kernel = {
|
|
|
f731ee |
efi = kern/efi/init.c;
|
|
|
f731ee |
efi = kern/efi/mm.c;
|
|
|
f731ee |
efi = term/efi/console.c;
|
|
|
f731ee |
+ efi = lib/envblk.c;
|
|
|
f731ee |
|
|
|
f731ee |
x86 = kern/i386/tsc.c;
|
|
|
f731ee |
|
|
|
f731ee |
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
|
|
|
f731ee |
index c391df48236..c5d8a76144a 100644
|
|
|
f731ee |
--- a/grub-core/kern/efi/init.c
|
|
|
f731ee |
+++ b/grub-core/kern/efi/init.c
|
|
|
f731ee |
@@ -25,9 +25,40 @@
|
|
|
f731ee |
#include <grub/env.h>
|
|
|
f731ee |
#include <grub/mm.h>
|
|
|
f731ee |
#include <grub/kernel.h>
|
|
|
f731ee |
+#include <grub/lib/envblk.h>
|
|
|
f731ee |
|
|
|
f731ee |
grub_addr_t grub_modbase;
|
|
|
f731ee |
|
|
|
f731ee |
+#define GRUB_EFI_GRUB_VARIABLE_GUID \
|
|
|
f731ee |
+ { 0x91376aff, 0xcba6, 0x42be, \
|
|
|
f731ee |
+ { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \
|
|
|
f731ee |
+ }
|
|
|
f731ee |
+
|
|
|
f731ee |
+/* Helper for grub_efi_env_init */
|
|
|
f731ee |
+static int
|
|
|
f731ee |
+set_var (const char *name, const char *value,
|
|
|
f731ee |
+ void *whitelist __attribute__((__unused__)))
|
|
|
f731ee |
+{
|
|
|
f731ee |
+ grub_env_set (name, value);
|
|
|
f731ee |
+ return 0;
|
|
|
f731ee |
+}
|
|
|
f731ee |
+
|
|
|
f731ee |
+static void
|
|
|
f731ee |
+grub_efi_env_init (void)
|
|
|
f731ee |
+{
|
|
|
f731ee |
+ grub_efi_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID;
|
|
|
f731ee |
+ struct grub_envblk envblk_s = { NULL, 0 };
|
|
|
f731ee |
+ grub_envblk_t envblk = &envblk_s;
|
|
|
f731ee |
+
|
|
|
f731ee |
+ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid,
|
|
|
f731ee |
+ &envblk_s.size);
|
|
|
f731ee |
+ if (!envblk_s.buf || envblk_s.size < 1)
|
|
|
f731ee |
+ return;
|
|
|
f731ee |
+
|
|
|
f731ee |
+ grub_envblk_iterate (envblk, NULL, set_var);
|
|
|
f731ee |
+ grub_free (envblk_s.buf);
|
|
|
f731ee |
+}
|
|
|
f731ee |
+
|
|
|
f731ee |
void
|
|
|
f731ee |
grub_efi_init (void)
|
|
|
f731ee |
{
|
|
|
f731ee |
@@ -42,10 +73,11 @@ grub_efi_init (void)
|
|
|
f731ee |
efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer,
|
|
|
f731ee |
0, 0, 0, NULL);
|
|
|
f731ee |
|
|
|
f731ee |
+ grub_efi_env_init ();
|
|
|
f731ee |
grub_efidisk_init ();
|
|
|
f731ee |
}
|
|
|
f731ee |
|
|
|
f731ee |
-void (*grub_efi_net_config) (grub_efi_handle_t hnd,
|
|
|
f731ee |
+void (*grub_efi_net_config) (grub_efi_handle_t hnd,
|
|
|
f731ee |
char **device,
|
|
|
f731ee |
char **path);
|
|
|
f731ee |
|