]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/UefiBootManagerLib: API BmIsValidLoadOptionVariableName
authorThomas Palmer <thomas.palmer@hpe.com>
Mon, 4 Apr 2016 19:51:42 +0000 (03:51 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Fri, 8 Apr 2016 04:28:02 +0000 (12:28 +0800)
Redfine the BmIsValidLoadOptionVariableName function to allow public use. Change name to EfiBootManagerIsValidLoadOptionVariableName to match naming scheme. Check that VariableName is never NULL and allow OptionType and OptionNumber to be optional.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Thomas Palmer <thomas.palmer@hpe.com>
Reviewed-by: Sunny Wang <sunnywang@hpe.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
MdeModulePkg/Include/Library/UefiBootManagerLib.h
MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c

index afb4271e3d4d6dfefcdf6ea60ab2ccfb693a86de..91926fc638f921484cdb3fcd76ad4ab9c4495097 100644 (file)
@@ -2,7 +2,7 @@
   Provide Boot Manager related library APIs.\r
 \r
 Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<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
@@ -731,4 +731,25 @@ EFIAPI
 EfiBootManagerProcessLoadOption (\r
   EFI_BOOT_MANAGER_LOAD_OPTION       *LoadOption\r
   );\r
+\r
+/**\r
+  Check whether the VariableName is a valid load option variable name\r
+  and return the load option type and option number.\r
+\r
+  @param VariableName The name of the load option variable.\r
+  @param OptionType   Return the load option type.\r
+  @param OptionNumber Return the load option number.\r
+\r
+  @retval TRUE  The variable name is valid; The load option type and\r
+                load option number are returned.\r
+  @retval FALSE The variable name is NOT valid.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EfiBootManagerIsValidLoadOptionVariableName (\r
+  IN CHAR16                             *VariableName,\r
+  OUT EFI_BOOT_MANAGER_LOAD_OPTION_TYPE *OptionType   OPTIONAL,\r
+  OUT UINT16                            *OptionNumber OPTIONAL\r
+  );\r
+\r
 #endif\r
index 696e995bb64e3516e45b31e8b554ba203be3eb7d..8201255484cf4a5c1e8403a121bdf74c61e64f9a 100644 (file)
@@ -2,7 +2,7 @@
   Load option library functions which relate with creating and processing load options.\r
 \r
 Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<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
@@ -775,16 +775,21 @@ BmValidateOption (
   @retval FALSE The variable name is NOT valid.\r
 **/\r
 BOOLEAN\r
-BmIsValidLoadOptionVariableName (\r
+EFIAPI\r
+EfiBootManagerIsValidLoadOptionVariableName (\r
   IN CHAR16                             *VariableName,\r
-  OUT EFI_BOOT_MANAGER_LOAD_OPTION_TYPE *OptionType,\r
-  OUT UINT16                            *OptionNumber\r
+  OUT EFI_BOOT_MANAGER_LOAD_OPTION_TYPE *OptionType   OPTIONAL,\r
+  OUT UINT16                            *OptionNumber OPTIONAL\r
   )\r
 {\r
   UINTN                             VariableNameLen;\r
   UINTN                             Index;\r
   UINTN                             Uint;\r
 \r
+  if (VariableName == NULL) {\r
+    return FALSE;\r
+  }\r
+\r
   VariableNameLen = StrLen (VariableName);\r
 \r
   if (VariableNameLen <= 4) {\r
@@ -803,14 +808,19 @@ BmIsValidLoadOptionVariableName (
     return FALSE;\r
   }\r
 \r
-  *OptionType = (EFI_BOOT_MANAGER_LOAD_OPTION_TYPE) Index;\r
-  *OptionNumber = 0;\r
-  for (Index = VariableNameLen - 4; Index < VariableNameLen; Index++) {\r
-    Uint = BmCharToUint (VariableName[Index]);\r
-    if (Uint == -1) {\r
-      break;\r
-    } else {\r
-      *OptionNumber = (UINT16) Uint + *OptionNumber * 0x10;\r
+  if (OptionType != NULL) {\r
+    *OptionType = (EFI_BOOT_MANAGER_LOAD_OPTION_TYPE) Index;\r
+  }\r
+\r
+  if (OptionNumber != NULL) {\r
+    *OptionNumber = 0;\r
+    for (Index = VariableNameLen - 4; Index < VariableNameLen; Index++) {\r
+      Uint = BmCharToUint (VariableName[Index]);\r
+      if (Uint == -1) {\r
+        break;\r
+      } else {\r
+        *OptionNumber = (UINT16) Uint + *OptionNumber * 0x10;\r
+      }\r
     }\r
   }\r
 \r
@@ -853,7 +863,7 @@ EfiBootManagerVariableToLoadOptionEx (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (!BmIsValidLoadOptionVariableName (VariableName, &OptionType, &OptionNumber)) {\r
+  if (!EfiBootManagerIsValidLoadOptionVariableName (VariableName, &OptionType, &OptionNumber)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -979,7 +989,7 @@ BmCollectLoadOptions (
 \r
   if (CompareGuid (Guid, Param->Guid) && (\r
       Param->OptionType == LoadOptionTypePlatformRecovery &&\r
-      BmIsValidLoadOptionVariableName (Name, &OptionType, &OptionNumber) &&\r
+      EfiBootManagerIsValidLoadOptionVariableName (Name, &OptionType, &OptionNumber) &&\r
       OptionType == LoadOptionTypePlatformRecovery\r
      )) {\r
     Status = EfiBootManagerVariableToLoadOptionEx (Name, Guid, &Option);\r