]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
Fix execution status & DEBUG message level mismatch. EFI_D_ERROR is used only...
[mirror_edk2.git] / SecurityPkg / VariableAuthenticated / SecureBootConfigDxe / SecureBootConfigImpl.c
index 659952a63a05c7738d5e8235a0237a39deeec207..c6356143bc66721ed7c5fd1ef1b687d4a799194a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   HII Config Access protocol implementation of SecureBoot configuration module.\r
 \r
-Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -48,6 +48,8 @@ HII_VENDOR_DEVICE_PATH          mSecureBootHiiVendorDevicePath = {
 };\r
 \r
 \r
+BOOLEAN mIsEnterSecureBootForm = FALSE;\r
+\r
 //\r
 // OID ASN.1 Value for Hash Algorithms\r
 //\r
@@ -1918,7 +1920,7 @@ DeleteKeyExchangeKey (
   ZeroMem (OldData, KekDataSize);\r
   while ((KekDataSize > 0) && (KekDataSize >= CertList->SignatureListSize)) {\r
     CertCount  = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;\r
-    DEBUG ((DEBUG_ERROR, "       CertCount = %x\n", CertCount));\r
+    DEBUG ((DEBUG_INFO, "       CertCount = %x\n", CertCount));\r
     if (CertCount != 0) {\r
       CopyMem (OldData + Offset, CertList, CertList->SignatureListSize);\r
       Offset += CertList->SignatureListSize;\r
@@ -2116,7 +2118,7 @@ DeleteSignature (
   ZeroMem (OldData, ItemDataSize);\r
   while ((ItemDataSize > 0) && (ItemDataSize >= CertList->SignatureListSize)) {\r
     CertCount  = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;\r
-    DEBUG ((DEBUG_ERROR, "       CertCount = %x\n", CertCount));\r
+    DEBUG ((DEBUG_INFO, "       CertCount = %x\n", CertCount));\r
     if (CertCount != 0) {\r
       CopyMem (OldData + Offset, (UINT8*)(CertList), CertList->SignatureListSize);\r
       Offset += CertList->SignatureListSize;\r
@@ -2407,6 +2409,14 @@ SecureBootRouteConfig (
     return EFI_NOT_FOUND;\r
   }\r
 \r
+  //\r
+  // Get Configuration from Variable.\r
+  //\r
+  SecureBootExtractConfigFromVariable (&IfrNvData);\r
+\r
+  //\r
+  // Map the Configuration to the configuration block.\r
+  //\r
   BufferSize = sizeof (SECUREBOOT_CONFIGURATION);\r
   Status = gHiiConfigRouting->ConfigToBlock (\r
                                 gHiiConfigRouting,\r
@@ -2488,6 +2498,25 @@ SecureBootCallback (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {\r
+    if (QuestionId == KEY_SECURE_BOOT_MODE) {\r
+      mIsEnterSecureBootForm = TRUE;\r
+    }\r
+\r
+    return EFI_SUCCESS;\r
+  }\r
+  \r
+  if (Action == EFI_BROWSER_ACTION_RETRIEVE) {\r
+    Status = EFI_UNSUPPORTED;\r
+    if (QuestionId == KEY_SECURE_BOOT_MODE) {\r
+      if (mIsEnterSecureBootForm) {\r
+        Value->u8 = SECURE_BOOT_MODE_STANDARD;\r
+        Status = EFI_SUCCESS;\r
+      }\r
+    }\r
+    return Status;\r
+  }\r
+  \r
   if ((Action != EFI_BROWSER_ACTION_CHANGED) &&\r
       (Action != EFI_BROWSER_ACTION_CHANGING) &&\r
       (Action != EFI_BROWSER_ACTION_FORM_CLOSE) &&\r
@@ -2508,7 +2537,7 @@ SecureBootCallback (
 \r
   Status = EFI_SUCCESS;\r
 \r
-  HiiGetBrowserData (NULL, NULL, BufferSize, (UINT8 *) IfrNvData);\r
+  HiiGetBrowserData (&gSecureBootConfigFormSetGuid, mSecureBootStorageName, BufferSize, (UINT8 *) IfrNvData);\r
   \r
   if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
 \r
@@ -2685,7 +2714,7 @@ SecureBootCallback (
       break;\r
 \r
     default:\r
-      if (QuestionId >= FILE_OPTION_OFFSET) {\r
+      if (QuestionId >= FILE_OPTION_GOTO_OFFSET) {\r
         UpdateFileExplorer (Private, QuestionId);\r
       } else if ((QuestionId >= OPTION_DEL_KEK_QUESTION_ID) &&\r
                  (QuestionId < (OPTION_DEL_KEK_QUESTION_ID + OPTION_CONFIG_RANGE))) {\r
@@ -2759,19 +2788,7 @@ SecureBootCallback (
       break;\r
       \r
     case KEY_SECURE_BOOT_MODE:\r
-      GetVariable2 (EFI_CUSTOM_MODE_NAME, &gEfiCustomModeEnableGuid, (VOID**)&SecureBootMode, NULL);\r
-      if (NULL != SecureBootMode) {\r
-        Status = gRT->SetVariable (                          \r
-                        EFI_CUSTOM_MODE_NAME,\r
-                        &gEfiCustomModeEnableGuid,\r
-                        EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
-                        sizeof (UINT8),\r
-                        &Value->u8\r
-                        );\r
-        *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
-        IfrNvData->SecureBootMode = Value->u8;\r
-        FreePool (SecureBootMode);\r
-      }        \r
+      mIsEnterSecureBootForm = FALSE;\r
       break;\r
 \r
     case KEY_SECURE_BOOT_KEK_GUID:\r
@@ -2804,7 +2821,14 @@ SecureBootCallback (
       if (SetupMode != NULL) {\r
         FreePool (SetupMode);\r
       }\r
-      break;  \r
+      break;\r
+    default:\r
+      if (QuestionId >= FILE_OPTION_OFFSET && QuestionId < FILE_OPTION_GOTO_OFFSET) {\r
+        if (UpdateFileExplorer (Private, QuestionId)) {\r
+          *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
+        }\r
+      }\r
+      break;\r
     }\r
   } else if (Action == EFI_BROWSER_ACTION_DEFAULT_STANDARD) {\r
     if (QuestionId == KEY_HIDE_SECURE_BOOT) {\r
@@ -2833,7 +2857,7 @@ SecureBootCallback (
   \r
   if (!EFI_ERROR (Status)) {\r
     BufferSize = sizeof (SECUREBOOT_CONFIGURATION);\r
-    HiiSetBrowserData (NULL, NULL, BufferSize, (UINT8*) IfrNvData, NULL);\r
+    HiiSetBrowserData (&gSecureBootConfigFormSetGuid, mSecureBootStorageName, BufferSize, (UINT8*) IfrNvData, NULL);\r
   }\r
   FreePool (IfrNvData);\r
   \r