]> git.proxmox.com Git - mirror_edk2.git/commitdiff
According to UEFI spec 2.3.1a. hardware error record variable should use the EFI_HARD...
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 30 May 2012 02:53:10 +0000 (02:53 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 30 May 2012 02:53:10 +0000 (02:53 +0000)
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13373 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.c
SecurityPkg/VariableAuthenticated/RuntimeDxe/Variable.h
SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableRuntimeDxe.inf
SecurityPkg/VariableAuthenticated/RuntimeDxe/VariableSmm.inf

index 8f1ae7b130d2d775193722f6a11d1f2367f008a3..54126782a029a615784efec630f079ac795b3996 100644 (file)
@@ -1760,6 +1760,63 @@ Done:
   return Status;\r
 }\r
 \r
+/**\r
+  Check if a Unicode character is a hexadecimal character.\r
+\r
+  This function checks if a Unicode character is a \r
+  hexadecimal character.  The valid hexadecimal character is \r
+  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
+\r
+\r
+  @param Char           The character to check against.\r
+\r
+  @retval TRUE          If the Char is a hexadecmial character.\r
+  @retval FALSE         If the Char is not a hexadecmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsHexaDecimalDigitCharacter (\r
+  IN CHAR16             Char\r
+  )\r
+{\r
+  return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F') || (Char >= L'a' && Char <= L'f'));\r
+}\r
+\r
+/**\r
+\r
+  This code checks if variable is hardware error record variable or not.\r
+\r
+  According to UEFI spec, hardware error record variable should use the EFI_HARDWARE_ERROR_VARIABLE VendorGuid\r
+  and have the L"HwErrRec####" name convention, #### is a printed hex value and no 0x or h is included in the hex value.\r
+\r
+  @param VariableName   Pointer to variable name.\r
+  @param VendorGuid     Variable Vendor Guid.\r
+\r
+  @retval TRUE          Variable is hardware error record variable.\r
+  @retval FALSE         Variable is not hardware error record variable.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsHwErrRecVariable (\r
+  IN CHAR16             *VariableName,\r
+  IN EFI_GUID           *VendorGuid\r
+  )\r
+{\r
+  if (!CompareGuid (VendorGuid, &gEfiHardwareErrorVariableGuid) ||\r
+      (StrLen (VariableName) != StrLen (L"HwErrRec####")) ||\r
+      (StrnCmp(VariableName, L"HwErrRec", StrLen (L"HwErrRec")) != 0) ||\r
+      !IsHexaDecimalDigitCharacter (VariableName[0x8]) ||\r
+      !IsHexaDecimalDigitCharacter (VariableName[0x9]) ||\r
+      !IsHexaDecimalDigitCharacter (VariableName[0xA]) ||\r
+      !IsHexaDecimalDigitCharacter (VariableName[0xB])) {\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
 /**\r
 \r
   This code finds variable in storage blocks (Volatile or Non-Volatile).\r
@@ -2050,10 +2107,7 @@ VariableServiceSetVariable (
         (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + DataSize > PcdGet32 (PcdMaxHardwareErrorVariableSize))) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
-    //\r
-    // According to UEFI spec, HARDWARE_ERROR_RECORD variable name convention should be L"HwErrRecXXXX".\r
-    //\r
-    if (StrnCmp(VariableName, L"HwErrRec", StrLen(L"HwErrRec")) != 0) {\r
+    if (!IsHwErrRecVariable(VariableName, VendorGuid)) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   } else {\r
index 76c62059785efde50d3aba997aab6b1c007a57a4..c4a16e6f6326a9ce5503b5035b79817c531ce0c7 100644 (file)
@@ -3,7 +3,7 @@
   The internal header file includes the common header files, defines\r
   internal structure and functions used by Variable modules.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2012, 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
@@ -38,6 +38,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/EventGroup.h>\r
 #include <Guid/VariableFormat.h>\r
 #include <Guid/SystemNvDataGuid.h>\r
+#include <Guid/HardwareErrorVariable.h>\r
 \r
 #define VARIABLE_RECLAIM_THRESHOLD (1024)\r
 \r
index 0acc7ed1b292b4128f87fa889b5b239c9050d48f..28b69c34deb4859885d5c57335b7275778f1b1f7 100644 (file)
@@ -2,7 +2,7 @@
 # Component description file for Variable module.\r
 #\r
 # This module installs three EFI_RUNTIME_SERVICES: SetVariable, GetVariable, GetNextVariableName.\r
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -65,6 +65,7 @@
   gEfiGlobalVariableGuid                        ## PRODUCES ## Variable Guid\r
   gEfiEventVirtualAddressChangeGuid             ## PRODUCES ## Event\r
   gEfiSystemNvDataFvGuid                        ## CONSUMES\r
+  gEfiHardwareErrorVariableGuid                 ## SOMETIMES_CONSUMES\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
index 25aae7b4407b5d00fd7e94d255e8904a8d22c037..da0a0e9ff83ecdc9c4261244059b83caff09bd82 100644 (file)
@@ -8,7 +8,7 @@
 #  This module should be used with SMM Runtime DXE module together. The 
 #  SMM Runtime DXE module would install variable arch protocol and variable 
 #  write arch protocol based on SMM variable module.
-# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
 #
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
@@ -68,6 +68,7 @@
   gEfiGlobalVariableGuid                        ## PRODUCES ## Variable Guid
   gSmmVariableWriteGuid                         ## PRODUCES ## SMM Variable Write Guid 
   gEfiSystemNvDataFvGuid                        ## CONSUMES
+  gEfiHardwareErrorVariableGuid                 ## SOMETIMES_CONSUMES
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
index d3e0b7766e8d96d065dba767abcc52eeececd1cd..49358de0138cafe3f33a39a8cf9f822e09709710 100644 (file)
@@ -1884,6 +1884,63 @@ Done:
   return Status;\r
 }\r
 \r
+/**\r
+  Check if a Unicode character is a hexadecimal character.\r
+\r
+  This function checks if a Unicode character is a \r
+  hexadecimal character.  The valid hexadecimal character is \r
+  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
+\r
+\r
+  @param Char           The character to check against.\r
+\r
+  @retval TRUE          If the Char is a hexadecmial character.\r
+  @retval FALSE         If the Char is not a hexadecmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsHexaDecimalDigitCharacter (\r
+  IN CHAR16             Char\r
+  )\r
+{\r
+  return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F') || (Char >= L'a' && Char <= L'f'));\r
+}\r
+\r
+/**\r
+\r
+  This code checks if variable is hardware error record variable or not.\r
+\r
+  According to UEFI spec, hardware error record variable should use the EFI_HARDWARE_ERROR_VARIABLE VendorGuid\r
+  and have the L"HwErrRec####" name convention, #### is a printed hex value and no 0x or h is included in the hex value.\r
+\r
+  @param VariableName   Pointer to variable name.\r
+  @param VendorGuid     Variable Vendor Guid.\r
+\r
+  @retval TRUE          Variable is hardware error record variable.\r
+  @retval FALSE         Variable is not hardware error record variable.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsHwErrRecVariable (\r
+  IN CHAR16             *VariableName,\r
+  IN EFI_GUID           *VendorGuid\r
+  )\r
+{\r
+  if (!CompareGuid (VendorGuid, &gEfiHardwareErrorVariableGuid) ||\r
+      (StrLen (VariableName) != StrLen (L"HwErrRec####")) ||\r
+      (StrnCmp(VariableName, L"HwErrRec", StrLen (L"HwErrRec")) != 0) ||\r
+      !IsHexaDecimalDigitCharacter (VariableName[0x8]) ||\r
+      !IsHexaDecimalDigitCharacter (VariableName[0x9]) ||\r
+      !IsHexaDecimalDigitCharacter (VariableName[0xA]) ||\r
+      !IsHexaDecimalDigitCharacter (VariableName[0xB])) {\r
+    return FALSE;\r
+  }\r
+\r
+  return TRUE;\r
+}\r
+\r
 /**\r
 \r
   This code finds variable in storage blocks (Volatile or Non-Volatile).\r
@@ -2199,10 +2256,7 @@ VariableServiceSetVariable (
         (sizeof (VARIABLE_HEADER) + StrSize (VariableName) + PayloadSize > PcdGet32 (PcdMaxHardwareErrorVariableSize))) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
-    //\r
-    // According to UEFI spec, HARDWARE_ERROR_RECORD variable name convention should be L"HwErrRecXXXX".\r
-    //\r
-    if (StrnCmp(VariableName, L"HwErrRec", StrLen(L"HwErrRec")) != 0) {\r
+    if (!IsHwErrRecVariable(VariableName, VendorGuid)) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
   } else {\r
index be3e632a2a771d8c89189a194705481a6266bbd6..bfb2f4e8f70f84341439febba4aa9fffe87cd93d 100644 (file)
@@ -40,6 +40,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/AuthenticatedVariableFormat.h>\r
 #include <Guid/ImageAuthentication.h>\r
 #include <Guid/SystemNvDataGuid.h>\r
+#include <Guid/HardwareErrorVariable.h>\r
 \r
 #define VARIABLE_RECLAIM_THRESHOLD (1024)\r
 \r
index 7b151863539b0c9faf595f0202af782beefdfce8..6765efbf2ba3ef0c2c7e21a4e5baefac0af04b7f 100644 (file)
@@ -76,6 +76,7 @@
   gEfiCustomModeEnableGuid\r
   gEfiSystemNvDataFvGuid                        ## CONSUMES\r
   gEfiCertDbGuid\r
+  gEfiHardwareErrorVariableGuid                 ## SOMETIMES_CONSUMES\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
index a62fd43989b2666bb1a8c1150bd7e427ef6ae408..cb9787df9c06e951bc6a9f29ed82300ff2293ca9 100644 (file)
@@ -81,6 +81,7 @@
   gEfiCustomModeEnableGuid\r
   gEfiSystemNvDataFvGuid                        ## CONSUMES\r
   gEfiCertDbGuid\r
+  gEfiHardwareErrorVariableGuid                 ## SOMETIMES_CONSUMES\r
 \r
 [Pcd]\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r