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
{\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
)\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
{\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
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
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
UINTN BufferSize;\r
SECUREBOOT_CONFIGURATION SecureBootConfiguration;\r
UINT8 *SecureBootEnable;\r
- \r
+\r
\r
if (Configuration == NULL || Progress == NULL) {\r
return EFI_INVALID_PARAMETER;\r
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
)\r
{\r
BOOLEAN SecureBootEnable;\r
- \r
+\r
if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
}\r
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
&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
);\r
PrivateData->DriverHandle = NULL;\r
}\r
- \r
+\r
FreePool (PrivateData);\r
}\r
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
#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
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