mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-28 15:46:53 +00:00
80 lines
2 KiB
Diff
80 lines
2 KiB
Diff
|
From 5804ce3d46ef5792ea4aa53e1460c341137961e9 Mon Sep 17 00:00:00 2001
|
||
|
From: Peter Jones <pjones@redhat.com>
|
||
|
Date: Thu, 25 Jun 2015 11:59:09 -0400
|
||
|
Subject: [PATCH 2/6] Make efi machines load an env block from a variable
|
||
|
|
||
|
Signed-off-by: Peter Jones <pjones@redhat.com>
|
||
|
---
|
||
|
grub-core/Makefile.core.def | 1 +
|
||
|
grub-core/kern/efi/init.c | 32 ++++++++++++++++++++++++++++++++
|
||
|
2 files changed, 33 insertions(+)
|
||
|
|
||
|
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
|
||
|
index 38291ce..b3ba5ed 100644
|
||
|
--- a/grub-core/Makefile.core.def
|
||
|
+++ b/grub-core/Makefile.core.def
|
||
|
@@ -174,6 +174,7 @@ kernel = {
|
||
|
efi = kern/efi/init.c;
|
||
|
efi = kern/efi/mm.c;
|
||
|
efi = term/efi/console.c;
|
||
|
+ efi = lib/envblk.c;
|
||
|
|
||
|
x86 = kern/i386/tsc.c;
|
||
|
|
||
|
diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c
|
||
|
index e9c85de..d17d18e 100644
|
||
|
--- a/grub-core/kern/efi/init.c
|
||
|
+++ b/grub-core/kern/efi/init.c
|
||
|
@@ -25,9 +25,40 @@
|
||
|
#include <grub/env.h>
|
||
|
#include <grub/mm.h>
|
||
|
#include <grub/kernel.h>
|
||
|
+#include <grub/lib/envblk.h>
|
||
|
|
||
|
grub_addr_t grub_modbase;
|
||
|
|
||
|
+#define GRUB_EFI_GRUB_VARIABLE_GUID \
|
||
|
+ { 0x91376aff, 0xcba6, 0x42be, \
|
||
|
+ { 0x94, 0x9d, 0x06, 0xfd, 0xe8, 0x11, 0x28, 0xe8 } \
|
||
|
+ }
|
||
|
+
|
||
|
+/* Helper for grub_efi_env_init */
|
||
|
+static int
|
||
|
+set_var (const char *name, const char *value,
|
||
|
+ void *whitelist __attribute__((__unused__)))
|
||
|
+{
|
||
|
+ grub_env_set (name, value);
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
+static void
|
||
|
+grub_efi_env_init (void)
|
||
|
+{
|
||
|
+ grub_efi_guid_t efi_grub_guid = GRUB_EFI_GRUB_VARIABLE_GUID;
|
||
|
+ struct grub_envblk envblk_s = { NULL, 0 };
|
||
|
+ grub_envblk_t envblk = &envblk_s;
|
||
|
+
|
||
|
+ envblk_s.buf = grub_efi_get_variable ("GRUB_ENV", &efi_grub_guid,
|
||
|
+ &envblk_s.size);
|
||
|
+ if (!envblk_s.buf || envblk_s.size < 1)
|
||
|
+ return;
|
||
|
+
|
||
|
+ grub_envblk_iterate (envblk, NULL, set_var);
|
||
|
+ grub_free (envblk_s.buf);
|
||
|
+}
|
||
|
+
|
||
|
void
|
||
|
grub_efi_init (void)
|
||
|
{
|
||
|
@@ -42,6 +73,7 @@ grub_efi_init (void)
|
||
|
efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer,
|
||
|
0, 0, 0, NULL);
|
||
|
|
||
|
+ grub_efi_env_init ();
|
||
|
grub_efidisk_init ();
|
||
|
}
|
||
|
|
||
|
--
|
||
|
2.4.3
|
||
|
|