]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c
Add EDKII_VARIABLE_LOCK_PROTOCOL and the implementation in MdeModulePkg variable...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BdsEntry.c
index 6eaec886f2317d484021538260a6ba5b0dfc8897..91c6dc72ddbc81176d7ea8a7f3c97d9175b27d47 100644 (file)
@@ -38,6 +38,17 @@ EFI_BDS_ARCH_PROTOCOL  gBds = {
 \r
 UINT16                          *mBootNext = NULL;\r
 \r
+///\r
+/// The read-only variables defined in UEFI Spec.\r
+///\r
+CHAR16  *mReadOnlyVariables[] = {\r
+  L"PlatformLangCodes",\r
+  L"LangCodes",\r
+  L"BootOptionSupport",\r
+  L"HwErrRecSupport",\r
+  L"OsIndicationsSupported"\r
+  };\r
+\r
 /**\r
 \r
   Install Boot Device Selection Protocol\r
@@ -459,6 +470,8 @@ BdsEntry (
   CHAR16                          *FirmwareVendor;\r
   EFI_STATUS                      Status;\r
   UINT16                          BootTimeOut;\r
+  UINTN                           Index;\r
+  EDKII_VARIABLE_LOCK_PROTOCOL    *VariableLock;\r
 \r
   //\r
   // Insert the performance probe\r
@@ -496,6 +509,18 @@ BdsEntry (
   //\r
   BdsFormalizeEfiGlobalVariable();\r
 \r
+  //\r
+  // Mark the read-only variables if the Variable Lock protocol exists\r
+  //\r
+  Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);\r
+  DEBUG ((EFI_D_INFO, "[BdsDxe] Locate Variable Lock protocol - %r\n", Status));\r
+  if (!EFI_ERROR (Status)) {\r
+    for (Index = 0; Index < sizeof (mReadOnlyVariables) / sizeof (mReadOnlyVariables[0]); Index++) {\r
+      Status = VariableLock->RequestToLock (VariableLock, mReadOnlyVariables[Index], &gEfiGlobalVariableGuid);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+  }\r
+\r
   //\r
   // Report Status Code to indicate connecting drivers will happen\r
   //\r
@@ -504,12 +529,6 @@ BdsEntry (
     (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS)\r
     );\r
 \r
-  //\r
-  // Do the platform init, can be customized by OEM/IBV\r
-  //\r
-  PERF_START (NULL, "PlatformBds", "BDS", 0);\r
-  PlatformBdsInit ();\r
-\r
   InitializeHwErrRecSupport();\r
 \r
   //\r
@@ -539,6 +558,12 @@ BdsEntry (
   InitializeLanguage (TRUE);\r
   InitializeFrontPage (TRUE);\r
 \r
+  //\r
+  // Do the platform init, can be customized by OEM/IBV\r
+  //\r
+  PERF_START (NULL, "PlatformBds", "BDS", 0);\r
+  PlatformBdsInit ();\r
+\r
   //\r
   // Set up the device list based on EFI 1.1 variables\r
   // process Driver#### and Load the driver's in the\r