From 91213ad3dd948000e7764352533d60eb183aa234 Mon Sep 17 00:00:00 2001
From: oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Date: Thu, 9 Feb 2012 15:34:16 +0000
Subject: [PATCH] ArmPlatformPkg/Bds: Add support for 'BootCurrent'

The UEFI variable 'BootCurrent' defines the EFI application started by the Boot Manager.



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13000 6f19259b-4bc3-4df7-8a09-765794883524
---
 ArmPlatformPkg/Bds/BootOption.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
index 3710178a43..289d36a50b 100644
--- a/ArmPlatformPkg/Bds/BootOption.c
+++ b/ArmPlatformPkg/Bds/BootOption.c
@@ -32,6 +32,7 @@ BootOptionStart (
   UINTN                                 CmdLineSize;
   UINTN                                 InitrdSize;
   EFI_DEVICE_PATH*                      Initrd;
+  UINT16                                LoadOptionIndexSize;
 
   if (IS_ARM_BDS_BOOTENTRY (BootOption)) {
     Status = EFI_UNSUPPORTED;
@@ -86,7 +87,19 @@ BootOptionStart (
       FreePool (FdtDevicePath);
     }
   } else {
+    // Set BootCurrent variable
+    LoadOptionIndexSize = sizeof(UINT16);
+    gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
+              EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+              LoadOptionIndexSize, &(BootOption->LoadOptionIndex));
+
     Status = BdsStartEfiApplication (mImageHandle, BootOption->FilePathList, BootOption->OptionalDataSize, BootOption->OptionalData);
+
+    // Clear BootCurrent variable
+    LoadOptionIndexSize = sizeof(UINT16);
+    gRT->SetVariable (L"BootCurrent", &gEfiGlobalVariableGuid,
+              EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+              0, NULL);
   }
 
   return Status;