]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update ConfigAcess Protocol which is produced by SecureBootConfigDxe to follow the...
authorqianouyang <qianouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 15 Nov 2011 10:22:35 +0000 (10:22 +0000)
committerqianouyang <qianouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 15 Nov 2011 10:22:35 +0000 (10:22 +0000)
Signed-off-by: qianouyang
Reviewed-by: ydong10
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12707 6f19259b-4bc3-4df7-8a09-765794883524

SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h

index f0a3f076378c5a9f43b07ffaddd015250734e832..73d75d1f190b4155b841d6b37663c09f9bb59ffc 100644 (file)
@@ -2,12 +2,12 @@
   HII Config Access protocol implementation of SecureBoot configuration module.\r
 \r
 Copyright (c) 2011, 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
+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
 http://opensource.org/licenses/bsd-license.php\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
@@ -40,7 +40,7 @@ HII_VENDOR_DEVICE_PATH          mSecureBootHiiVendorDevicePath = {
   {\r
     END_DEVICE_PATH_TYPE,\r
     END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    { \r
+    {\r
       (UINT8) (END_DEVICE_PATH_LENGTH),\r
       (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
     }\r
@@ -62,12 +62,12 @@ SaveSecureBootVariable (
   )\r
 {\r
   EFI_STATUS                       Status;\r
-  \r
+\r
   Status = gRT->SetVariable (\r
-             EFI_SECURE_BOOT_ENABLE_NAME, \r
+             EFI_SECURE_BOOT_ENABLE_NAME,\r
              &gEfiSecureBootEnableDisableGuid,\r
-             EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, \r
-             sizeof (UINT8), \r
+             EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
+             sizeof (UINT8),\r
              &VarValue\r
              );\r
   if (EFI_ERROR (Status)) {\r
@@ -114,25 +114,36 @@ SecureBootExtractConfig (
 {\r
   EFI_STATUS                        Status;\r
   UINTN                             BufferSize;\r
+  UINTN                             Size;\r
   SECUREBOOT_CONFIGURATION          Configuration;\r
-  \r
+\r
   EFI_STRING                        ConfigRequest;\r
+  EFI_STRING                        ConfigRequestHdr;\r
   UINT8                             *SecureBootEnable;\r
-  \r
+  SECUREBOOT_CONFIG_PRIVATE_DATA    *PrivateData;\r
+  BOOLEAN                           AllocatedRequest;\r
+\r
   if (Progress == NULL || Results == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-\r
-  *Progress = Request;\r
+  AllocatedRequest = FALSE;\r
+  ConfigRequestHdr = NULL;\r
+  ConfigRequest    = NULL;\r
+  Size             = 0;\r
+  \r
+  PrivateData      = SECUREBOOT_CONFIG_PRIVATE_FROM_THIS (This);\r
+  *Progress        = Request;\r
+  \r
   if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gSecureBootConfigFormSetGuid, mSecureBootStorageName)) {\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
+  \r
   //\r
   // Get the SecureBoot Variable\r
   //\r
-  SecureBootEnable = GetVariable (EFI_SECURE_BOOT_ENABLE_NAME, &gEfiSecureBootEnableDisableGuid);  \r
-  \r
+  SecureBootEnable = GetVariable (EFI_SECURE_BOOT_ENABLE_NAME, &gEfiSecureBootEnableDisableGuid);\r
+\r
   //\r
   // If the SecureBoot Variable doesn't exist, hide the SecureBoot Enable/Disable\r
   // Checkbox.\r
@@ -144,8 +155,26 @@ SecureBootExtractConfig (
     Configuration.SecureBootState = *SecureBootEnable;\r
   }\r
   \r
-  BufferSize = sizeof (Configuration);\r
+  BufferSize = sizeof (SECUREBOOT_CONFIGURATION);\r
   ConfigRequest = Request;\r
+  if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+    //\r
+    // Request is set to NULL or OFFSET is NULL, construct full request string.\r
+    //\r
+\r
+    //\r
+    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+    //\r
+    ConfigRequestHdr = HiiConstructConfigHdr (&gSecureBootConfigFormSetGuid, mSecureBootStorageName, PrivateData->DriverHandle);\r
+    Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+    ConfigRequest = AllocateZeroPool (Size);\r
+    ASSERT (ConfigRequest != NULL);\r
+    AllocatedRequest = TRUE;\r
+    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+    FreePool (ConfigRequestHdr);\r
+    ConfigRequestHdr = NULL;\r
+  }\r
 \r
   Status = gHiiConfigRouting->BlockToConfig (\r
                                 gHiiConfigRouting,\r
@@ -155,7 +184,14 @@ SecureBootExtractConfig (
                                 Results,\r
                                 Progress\r
                                 );\r
-  \r
+\r
+  //\r
+  // Free the allocated config request string.\r
+  //\r
+  if (AllocatedRequest) {\r
+    FreePool (ConfigRequest);\r
+  }\r
+\r
   //\r
   // Set Progress string to the original request string.\r
   //\r
@@ -198,7 +234,7 @@ SecureBootRouteConfig (
   UINTN                            BufferSize;\r
   SECUREBOOT_CONFIGURATION         SecureBootConfiguration;\r
   UINT8                            *SecureBootEnable;\r
-    \r
+\r
 \r
   if (Configuration == NULL || Progress == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -224,17 +260,17 @@ SecureBootRouteConfig (
     return Status;\r
   }\r
 \r
-  SecureBootEnable = GetVariable (EFI_SECURE_BOOT_ENABLE_NAME, &gEfiSecureBootEnableDisableGuid);  \r
+  SecureBootEnable = GetVariable (EFI_SECURE_BOOT_ENABLE_NAME, &gEfiSecureBootEnableDisableGuid);\r
   if (SecureBootEnable == NULL) {\r
     return EFI_SUCCESS;\r
-  } \r
-  \r
+  }\r
+\r
   if ((*SecureBootEnable) != SecureBootConfiguration.SecureBootState) {\r
     //\r
     // If the configure is changed, update the SecureBoot Variable.\r
     //\r
-    SaveSecureBootVariable (SecureBootConfiguration.SecureBootState); \r
-  }  \r
+    SaveSecureBootVariable (SecureBootConfiguration.SecureBootState);\r
+  }\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -272,7 +308,7 @@ SecureBootCallback (
   )\r
 {\r
   BOOLEAN           SecureBootEnable;\r
-  \r
+\r
   if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -280,13 +316,13 @@ SecureBootCallback (
   if ((Action != EFI_BROWSER_ACTION_CHANGING) || (QuestionId != KEY_SECURE_BOOT_ENABLE)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
-  \r
+\r
   if (NULL == GetVariable (EFI_SECURE_BOOT_ENABLE_NAME, &gEfiSecureBootEnableDisableGuid)) {\r
     return EFI_SUCCESS;\r
   }\r
-  \r
+\r
   SecureBootEnable = Value->u8;\r
-  SaveSecureBootVariable (Value->u8); \r
+  SaveSecureBootVariable (Value->u8);\r
   return EFI_SUCCESS;\r
 \r
 }\r
@@ -346,13 +382,13 @@ InstallSecureBootConfigForm (
            &gEfiHiiConfigAccessProtocolGuid,\r
            ConfigAccess,\r
            NULL\r
-           );  \r
+           );\r
 \r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-  \r
+\r
   PrivateData->HiiHandle = HiiHandle;\r
-  return EFI_SUCCESS;  \r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
@@ -388,6 +424,6 @@ UninstallSecureBootConfigForm (
            );\r
     PrivateData->DriverHandle = NULL;\r
   }\r
-  \r
+\r
   FreePool (PrivateData);\r
 }\r
index ffc4720aea2d2f8a3c67b67c29096778be79ebdb..603044d26e33745d6671f49aa466495568b3ae51 100644 (file)
@@ -3,12 +3,12 @@
   configuration module.\r
 \r
 Copyright (c) 2011, 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
+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
 http://opensource.org/licenses/bsd-license.php\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 **/\r
@@ -31,6 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiLib.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/DevicePathLib.h>\r
+#include <Library/PrintLib.h>\r
 \r
 #include <Guid/MdeModuleHii.h>\r
 #include <Guid/AuthenticatedVariableFormat.h>\r
@@ -63,6 +64,8 @@ typedef struct {
 extern SECUREBOOT_CONFIG_PRIVATE_DATA      mSecureBootConfigPrivateDateTemplate;\r
 \r
 #define SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE     SIGNATURE_32 ('S', 'E', 'C', 'B')\r
+#define SECUREBOOT_CONFIG_PRIVATE_FROM_THIS(a)  CR (a, SECUREBOOT_CONFIG_PRIVATE_DATA, ConfigAccess, SECUREBOOT_CONFIG_PRIVATE_DATA_SIGNATURE)\r
+\r
 \r
 /**\r
   This function publish the SecureBoot configuration Form.\r