summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2014-12-09 13:14:56 +0100
committerWei Xu <xuwei5@huawei.com>2014-12-17 16:56:12 +0800
commit1bf2674138346392644bd9108f7110e815289447 (patch)
treee32bf9e44a86a1f6e279cde877b20f50f41b636e
parent8860ce0d55da6ed0a8479446fbef1f5394c52476 (diff)
HisiPkg: D01: Load bootwrapper when exiting boot services
Today we load the bootwrapper binaries before we enter a kernel using direct kernel boot. But kernels loaded via EFI applications (like grub2) also need to have the bootwrapper code loaded. This patch adds a callback when we exit the runtime services and in that case loads the bootwrapper code. This happens with direct kernel boot as well as with grub2 boot. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Wei Xu <xuwei5@huawei.com>
-rw-r--r--HisiPkg/D01BoardPkg/Bds/Bds.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/HisiPkg/D01BoardPkg/Bds/Bds.c b/HisiPkg/D01BoardPkg/Bds/Bds.c
index c85684daf..600ae64c7 100644
--- a/HisiPkg/D01BoardPkg/Bds/Bds.c
+++ b/HisiPkg/D01BoardPkg/Bds/Bds.c
@@ -711,8 +711,6 @@ BdsEntry (
#if 1
- ReadBootwrapper();
-
/*2.copy image from FLASH to DDR,and start*/
(VOID)AsciiPrint("\nTransmit OS from FLASH to DDR now, please wait!");
@@ -768,12 +766,34 @@ BdsEntry (
// Start the Boot Menu
Status = BootMenuMain ();
ASSERT_EFI_ERROR (Status);
-
-}
-
-EFI_BDS_ARCH_PROTOCOL gBdsProtocol = {
- BdsEntry,
-};
+
+}
+
+/**
+ EFI Exit Event
+
+ Exiting EFI Boot Services can only mean we're bootstrapping into a real OS.
+ So let's copy the bootwrapper code into place to make sure the OS can use it.
+
+ @param[in] Event The Event that is being processed
+ @param[in] Context Event Context
+**/
+
+static EFI_EVENT EfiExitBootServicesEvent;
+
+VOID
+EFIAPI
+ExitBootServicesEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ ReadBootwrapper();
+}
+
+EFI_BDS_ARCH_PROTOCOL gBdsProtocol = {
+ BdsEntry,
+};
EFI_STATUS
EFIAPI
@@ -790,8 +810,12 @@ BdsInitialize (
&ImageHandle,
&gEfiBdsArchProtocolGuid, &gBdsProtocol,
NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ // Register for an ExitBootServicesEvent
+ Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}