]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/BaseLib.h
MdePkg/BaseLib: add PatchInstructionX86()
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
index 992c5387f957c4c62046f895fd1961e71dafcd27..eb2899f8524e7a8e1856d68f0c25ced58c4253fb 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Provides string functions, linked list functions, math functions, synchronization\r
-  functions, and CPU architecture-specific functions.\r
+  functions, file path functions, and CPU architecture-specific functions.\r
 \r
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 Portions copyright (c) 2008 - 2009, Apple Inc. 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
@@ -146,11 +146,910 @@ typedef struct {
 \r
 #endif  // defined (MDE_CPU_ARM)\r
 \r
+#if defined (MDE_CPU_AARCH64)\r
+typedef struct {\r
+  // GP regs\r
+  UINT64    X19;\r
+  UINT64    X20;\r
+  UINT64    X21;\r
+  UINT64    X22;\r
+  UINT64    X23;\r
+  UINT64    X24;\r
+  UINT64    X25;\r
+  UINT64    X26;\r
+  UINT64    X27;\r
+  UINT64    X28;\r
+  UINT64    FP;\r
+  UINT64    LR;\r
+  UINT64    IP0;\r
+\r
+  // FP regs\r
+  UINT64    D8;\r
+  UINT64    D9;\r
+  UINT64    D10;\r
+  UINT64    D11;\r
+  UINT64    D12;\r
+  UINT64    D13;\r
+  UINT64    D14;\r
+  UINT64    D15;\r
+} BASE_LIBRARY_JUMP_BUFFER;\r
+\r
+#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
+\r
+#endif  // defined (MDE_CPU_AARCH64)\r
+\r
+\r
 //\r
 // String Services\r
 //\r
 \r
+\r
+/**\r
+  Returns the length of a Null-terminated Unicode string.\r
+\r
+  This function is similar as strlen_s defined in C11.\r
+\r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  String   A pointer to a Null-terminated Unicode string.\r
+  @param  MaxSize  The maximum number of Destination Unicode\r
+                   char, including terminating null char.\r
+\r
+  @retval 0        If String is NULL.\r
+  @retval MaxSize  If there is no null character in the first MaxSize characters of String.\r
+  @return The number of characters that percede the terminating null character.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+StrnLenS (\r
+  IN CONST CHAR16              *String,\r
+  IN UINTN                     MaxSize\r
+  );\r
+\r
+/**\r
+  Returns the size of a Null-terminated Unicode string in bytes, including the\r
+  Null terminator.\r
+\r
+  This function returns the size of the Null-terminated Unicode string\r
+  specified by String in bytes, including the Null terminator.\r
+\r
+  If String is not aligned on a 16-bit boundary, then ASSERT().\r
+\r
+  @param  String   A pointer to a Null-terminated Unicode string.\r
+  @param  MaxSize  The maximum number of Destination Unicode\r
+                   char, including the Null terminator.\r
+\r
+  @retval 0  If String is NULL.\r
+  @retval (sizeof (CHAR16) * (MaxSize + 1))\r
+             If there is no Null terminator in the first MaxSize characters of\r
+             String.\r
+  @return The size of the Null-terminated Unicode string in bytes, including\r
+          the Null terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+StrnSizeS (\r
+  IN CONST CHAR16              *String,\r
+  IN UINTN                     MaxSize\r
+  );\r
+\r
+/**\r
+  Copies the string pointed to by Source (including the terminating null char)\r
+  to the array pointed to by Destination.\r
+\r
+  This function is similar as strcpy_s defined in C11.\r
+\r
+  If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Destination              A pointer to a Null-terminated Unicode string.\r
+  @param  DestMax                  The maximum number of Destination Unicode\r
+                                   char, including terminating null char.\r
+  @param  Source                   A pointer to a Null-terminated Unicode string.\r
+\r
+  @retval RETURN_SUCCESS           String is copied.\r
+  @retval RETURN_BUFFER_TOO_SMALL  If DestMax is NOT greater than StrLen(Source).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumUnicodeStringLength is not zero,\r
+                                    and DestMax is greater than \r
+                                    PcdMaximumUnicodeStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrCpyS (\r
+  OUT CHAR16       *Destination,\r
+  IN  UINTN        DestMax,\r
+  IN  CONST CHAR16 *Source\r
+  );\r
+\r
+/**\r
+  Copies not more than Length successive char from the string pointed to by\r
+  Source to the array pointed to by Destination. If no null char is copied from\r
+  Source, then Destination[Length] is always set to null.\r
+\r
+  This function is similar as strncpy_s defined in C11.\r
+\r
+  If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Destination              A pointer to a Null-terminated Unicode string.\r
+  @param  DestMax                  The maximum number of Destination Unicode\r
+                                   char, including terminating null char.\r
+  @param  Source                   A pointer to a Null-terminated Unicode string.\r
+  @param  Length                   The maximum number of Unicode characters to copy.\r
+\r
+  @retval RETURN_SUCCESS           String is copied.\r
+  @retval RETURN_BUFFER_TOO_SMALL  If DestMax is NOT greater than \r
+                                   MIN(StrLen(Source), Length).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumUnicodeStringLength is not zero,\r
+                                    and DestMax is greater than \r
+                                    PcdMaximumUnicodeStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrnCpyS (\r
+  OUT CHAR16       *Destination,\r
+  IN  UINTN        DestMax,\r
+  IN  CONST CHAR16 *Source,\r
+  IN  UINTN        Length\r
+  );\r
+\r
+/**\r
+  Appends a copy of the string pointed to by Source (including the terminating\r
+  null char) to the end of the string pointed to by Destination.\r
+\r
+  This function is similar as strcat_s defined in C11.\r
+\r
+  If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Destination              A pointer to a Null-terminated Unicode string.\r
+  @param  DestMax                  The maximum number of Destination Unicode\r
+                                   char, including terminating null char.\r
+  @param  Source                   A pointer to a Null-terminated Unicode string.\r
+\r
+  @retval RETURN_SUCCESS           String is appended.\r
+  @retval RETURN_BAD_BUFFER_SIZE   If DestMax is NOT greater than \r
+                                   StrLen(Destination).\r
+  @retval RETURN_BUFFER_TOO_SMALL  If (DestMax - StrLen(Destination)) is NOT\r
+                                   greater than StrLen(Source).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumUnicodeStringLength is not zero,\r
+                                    and DestMax is greater than \r
+                                    PcdMaximumUnicodeStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrCatS (\r
+  IN OUT CHAR16       *Destination,\r
+  IN     UINTN        DestMax,\r
+  IN     CONST CHAR16 *Source\r
+  );\r
+\r
+/**\r
+  Appends not more than Length successive char from the string pointed to by\r
+  Source to the end of the string pointed to by Destination. If no null char is\r
+  copied from Source, then Destination[StrLen(Destination) + Length] is always\r
+  set to null.\r
+\r
+  This function is similar as strncat_s defined in C11.\r
+\r
+  If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Destination              A pointer to a Null-terminated Unicode string.\r
+  @param  DestMax                  The maximum number of Destination Unicode\r
+                                   char, including terminating null char.\r
+  @param  Source                   A pointer to a Null-terminated Unicode string.\r
+  @param  Length                   The maximum number of Unicode characters to copy.\r
+\r
+  @retval RETURN_SUCCESS           String is appended.\r
+  @retval RETURN_BAD_BUFFER_SIZE   If DestMax is NOT greater than\r
+                                   StrLen(Destination).\r
+  @retval RETURN_BUFFER_TOO_SMALL  If (DestMax - StrLen(Destination)) is NOT\r
+                                   greater than MIN(StrLen(Source), Length).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumUnicodeStringLength is not zero,\r
+                                    and DestMax is greater than \r
+                                    PcdMaximumUnicodeStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrnCatS (\r
+  IN OUT CHAR16       *Destination,\r
+  IN     UINTN        DestMax,\r
+  IN     CONST CHAR16 *Source,\r
+  IN     UINTN        Length\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode decimal string to a value of type UINTN.\r
+\r
+  This function outputs a value of type UINTN by interpreting the contents of\r
+  the Unicode string specified by String as a decimal number. The format of the\r
+  input Unicode string String is:\r
+\r
+                  [spaces] [decimal digits].\r
+\r
+  The valid decimal digit character is in the range [0-9]. The function will\r
+  ignore the pad space, which includes spaces or tab characters, before\r
+  [decimal digits]. The running zero in the beginning of [decimal digits] will\r
+  be ignored. Then, the function stops at the first character that is a not a\r
+  valid decimal character or a Null-terminator, whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Data is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If String has no valid decimal digits in the above format, then 0 is stored\r
+  at the location pointed to by Data.\r
+  If the number represented by String exceeds the range defined by UINTN, then\r
+  MAX_UINTN is stored at the location pointed to by Data.\r
+\r
+  If EndPointer is not NULL, a pointer to the character that stopped the scan\r
+  is stored at the location pointed to by EndPointer. If String has no valid\r
+  decimal digits right after the optional pad spaces, the value of String is\r
+  stored at the location pointed to by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Unicode string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Data                     Pointer to the converted value.\r
+\r
+  @retval RETURN_SUCCESS           Value is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If PcdMaximumUnicodeStringLength is not\r
+                                   zero, and String contains more than\r
+                                   PcdMaximumUnicodeStringLength Unicode\r
+                                   characters, not including the\r
+                                   Null-terminator.\r
+  @retval RETURN_UNSUPPORTED       If the number represented by String exceeds\r
+                                   the range defined by UINTN.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrDecimalToUintnS (\r
+  IN  CONST CHAR16             *String,\r
+  OUT       CHAR16             **EndPointer,  OPTIONAL\r
+  OUT       UINTN              *Data\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode decimal string to a value of type UINT64.\r
+\r
+  This function outputs a value of type UINT64 by interpreting the contents of\r
+  the Unicode string specified by String as a decimal number. The format of the\r
+  input Unicode string String is:\r
+\r
+                  [spaces] [decimal digits].\r
+\r
+  The valid decimal digit character is in the range [0-9]. The function will\r
+  ignore the pad space, which includes spaces or tab characters, before\r
+  [decimal digits]. The running zero in the beginning of [decimal digits] will\r
+  be ignored. Then, the function stops at the first character that is a not a\r
+  valid decimal character or a Null-terminator, whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Data is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If String has no valid decimal digits in the above format, then 0 is stored\r
+  at the location pointed to by Data.\r
+  If the number represented by String exceeds the range defined by UINT64, then\r
+  MAX_UINT64 is stored at the location pointed to by Data.\r
+\r
+  If EndPointer is not NULL, a pointer to the character that stopped the scan\r
+  is stored at the location pointed to by EndPointer. If String has no valid\r
+  decimal digits right after the optional pad spaces, the value of String is\r
+  stored at the location pointed to by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Unicode string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Data                     Pointer to the converted value.\r
+\r
+  @retval RETURN_SUCCESS           Value is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If PcdMaximumUnicodeStringLength is not\r
+                                   zero, and String contains more than\r
+                                   PcdMaximumUnicodeStringLength Unicode\r
+                                   characters, not including the\r
+                                   Null-terminator.\r
+  @retval RETURN_UNSUPPORTED       If the number represented by String exceeds\r
+                                   the range defined by UINT64.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrDecimalToUint64S (\r
+  IN  CONST CHAR16             *String,\r
+  OUT       CHAR16             **EndPointer,  OPTIONAL\r
+  OUT       UINT64             *Data\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode hexadecimal string to a value of type\r
+  UINTN.\r
+\r
+  This function outputs a value of type UINTN by interpreting the contents of\r
+  the Unicode string specified by String as a hexadecimal number. The format of\r
+  the input Unicode string String is:\r
+\r
+                  [spaces][zeros][x][hexadecimal digits].\r
+\r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r
+  If "x" appears in the input string, it must be prefixed with at least one 0.\r
+  The function will ignore the pad space, which includes spaces or tab\r
+  characters, before [zeros], [x] or [hexadecimal digit]. The running zero\r
+  before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts\r
+  after [x] or the first valid hexadecimal digit. Then, the function stops at\r
+  the first character that is a not a valid hexadecimal character or NULL,\r
+  whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Data is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If String has no valid hexadecimal digits in the above format, then 0 is\r
+  stored at the location pointed to by Data.\r
+  If the number represented by String exceeds the range defined by UINTN, then\r
+  MAX_UINTN is stored at the location pointed to by Data.\r
+\r
+  If EndPointer is not NULL, a pointer to the character that stopped the scan\r
+  is stored at the location pointed to by EndPointer. If String has no valid\r
+  hexadecimal digits right after the optional pad spaces, the value of String\r
+  is stored at the location pointed to by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Unicode string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Data                     Pointer to the converted value.\r
+\r
+  @retval RETURN_SUCCESS           Value is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If PcdMaximumUnicodeStringLength is not\r
+                                   zero, and String contains more than\r
+                                   PcdMaximumUnicodeStringLength Unicode\r
+                                   characters, not including the\r
+                                   Null-terminator.\r
+  @retval RETURN_UNSUPPORTED       If the number represented by String exceeds\r
+                                   the range defined by UINTN.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrHexToUintnS (\r
+  IN  CONST CHAR16             *String,\r
+  OUT       CHAR16             **EndPointer,  OPTIONAL\r
+  OUT       UINTN              *Data\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode hexadecimal string to a value of type\r
+  UINT64.\r
+\r
+  This function outputs a value of type UINT64 by interpreting the contents of\r
+  the Unicode string specified by String as a hexadecimal number. The format of\r
+  the input Unicode string String is:\r
+\r
+                  [spaces][zeros][x][hexadecimal digits].\r
+\r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r
+  If "x" appears in the input string, it must be prefixed with at least one 0.\r
+  The function will ignore the pad space, which includes spaces or tab\r
+  characters, before [zeros], [x] or [hexadecimal digit]. The running zero\r
+  before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts\r
+  after [x] or the first valid hexadecimal digit. Then, the function stops at\r
+  the first character that is a not a valid hexadecimal character or NULL,\r
+  whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Data is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If String has no valid hexadecimal digits in the above format, then 0 is\r
+  stored at the location pointed to by Data.\r
+  If the number represented by String exceeds the range defined by UINT64, then\r
+  MAX_UINT64 is stored at the location pointed to by Data.\r
+\r
+  If EndPointer is not NULL, a pointer to the character that stopped the scan\r
+  is stored at the location pointed to by EndPointer. If String has no valid\r
+  hexadecimal digits right after the optional pad spaces, the value of String\r
+  is stored at the location pointed to by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Unicode string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Data                     Pointer to the converted value.\r
+\r
+  @retval RETURN_SUCCESS           Value is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If PcdMaximumUnicodeStringLength is not\r
+                                   zero, and String contains more than\r
+                                   PcdMaximumUnicodeStringLength Unicode\r
+                                   characters, not including the\r
+                                   Null-terminator.\r
+  @retval RETURN_UNSUPPORTED       If the number represented by String exceeds\r
+                                   the range defined by UINT64.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrHexToUint64S (\r
+  IN  CONST CHAR16             *String,\r
+  OUT       CHAR16             **EndPointer,  OPTIONAL\r
+  OUT       UINT64             *Data\r
+  );\r
+\r
+/**\r
+  Returns the length of a Null-terminated Ascii string.\r
+\r
+  This function is similar as strlen_s defined in C11.\r
+\r
+  @param  String   A pointer to a Null-terminated Ascii string.\r
+  @param  MaxSize  The maximum number of Destination Ascii\r
+                   char, including terminating null char.\r
+\r
+  @retval 0        If String is NULL.\r
+  @retval MaxSize  If there is no null character in the first MaxSize characters of String.\r
+  @return The number of characters that percede the terminating null character.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrnLenS (\r
+  IN CONST CHAR8               *String,\r
+  IN UINTN                     MaxSize\r
+  );\r
+\r
+/**\r
+  Returns the size of a Null-terminated Ascii string in bytes, including the\r
+  Null terminator.\r
+\r
+  This function returns the size of the Null-terminated Ascii string specified\r
+  by String in bytes, including the Null terminator.\r
+\r
+  @param  String   A pointer to a Null-terminated Ascii string.\r
+  @param  MaxSize  The maximum number of Destination Ascii\r
+                   char, including the Null terminator.\r
+\r
+  @retval 0  If String is NULL.\r
+  @retval (sizeof (CHAR8) * (MaxSize + 1))\r
+             If there is no Null terminator in the first MaxSize characters of\r
+             String.\r
+  @return The size of the Null-terminated Ascii string in bytes, including the\r
+          Null terminator.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+AsciiStrnSizeS (\r
+  IN CONST CHAR8               *String,\r
+  IN UINTN                     MaxSize\r
+  );\r
+\r
+/**\r
+  Copies the string pointed to by Source (including the terminating null char)\r
+  to the array pointed to by Destination.\r
+\r
+  This function is similar as strcpy_s defined in C11.\r
+\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Destination              A pointer to a Null-terminated Ascii string.\r
+  @param  DestMax                  The maximum number of Destination Ascii\r
+                                   char, including terminating null char.\r
+  @param  Source                   A pointer to a Null-terminated Ascii string.\r
+\r
+  @retval RETURN_SUCCESS           String is copied.\r
+  @retval RETURN_BUFFER_TOO_SMALL  If DestMax is NOT greater than StrLen(Source).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                    and DestMax is greater than \r
+                                    PcdMaximumAsciiStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrCpyS (\r
+  OUT CHAR8        *Destination,\r
+  IN  UINTN        DestMax,\r
+  IN  CONST CHAR8  *Source\r
+  );\r
+\r
+/**\r
+  Copies not more than Length successive char from the string pointed to by\r
+  Source to the array pointed to by Destination. If no null char is copied from\r
+  Source, then Destination[Length] is always set to null.\r
+\r
+  This function is similar as strncpy_s defined in C11.\r
+\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Destination              A pointer to a Null-terminated Ascii string.\r
+  @param  DestMax                  The maximum number of Destination Ascii\r
+                                   char, including terminating null char.\r
+  @param  Source                   A pointer to a Null-terminated Ascii string.\r
+  @param  Length                   The maximum number of Ascii characters to copy.\r
+\r
+  @retval RETURN_SUCCESS           String is copied.\r
+  @retval RETURN_BUFFER_TOO_SMALL  If DestMax is NOT greater than \r
+                                   MIN(StrLen(Source), Length).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                    and DestMax is greater than \r
+                                    PcdMaximumAsciiStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrnCpyS (\r
+  OUT CHAR8        *Destination,\r
+  IN  UINTN        DestMax,\r
+  IN  CONST CHAR8  *Source,\r
+  IN  UINTN        Length\r
+  );\r
+\r
+/**\r
+  Appends a copy of the string pointed to by Source (including the terminating\r
+  null char) to the end of the string pointed to by Destination.\r
+\r
+  This function is similar as strcat_s defined in C11.\r
+\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Destination              A pointer to a Null-terminated Ascii string.\r
+  @param  DestMax                  The maximum number of Destination Ascii\r
+                                   char, including terminating null char.\r
+  @param  Source                   A pointer to a Null-terminated Ascii string.\r
+\r
+  @retval RETURN_SUCCESS           String is appended.\r
+  @retval RETURN_BAD_BUFFER_SIZE   If DestMax is NOT greater than \r
+                                   StrLen(Destination).\r
+  @retval RETURN_BUFFER_TOO_SMALL  If (DestMax - StrLen(Destination)) is NOT\r
+                                   greater than StrLen(Source).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                    and DestMax is greater than \r
+                                    PcdMaximumAsciiStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrCatS (\r
+  IN OUT CHAR8        *Destination,\r
+  IN     UINTN        DestMax,\r
+  IN     CONST CHAR8  *Source\r
+  );\r
+\r
+/**\r
+  Appends not more than Length successive char from the string pointed to by\r
+  Source to the end of the string pointed to by Destination. If no null char is\r
+  copied from Source, then Destination[StrLen(Destination) + Length] is always\r
+  set to null.\r
+\r
+  This function is similar as strncat_s defined in C11.\r
+\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Destination              A pointer to a Null-terminated Ascii string.\r
+  @param  DestMax                  The maximum number of Destination Ascii\r
+                                   char, including terminating null char.\r
+  @param  Source                   A pointer to a Null-terminated Ascii string.\r
+  @param  Length                   The maximum number of Ascii characters to copy.\r
+\r
+  @retval RETURN_SUCCESS           String is appended.\r
+  @retval RETURN_BAD_BUFFER_SIZE   If DestMax is NOT greater than\r
+                                   StrLen(Destination).\r
+  @retval RETURN_BUFFER_TOO_SMALL  If (DestMax - StrLen(Destination)) is NOT\r
+                                   greater than MIN(StrLen(Source), Length).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                    and DestMax is greater than \r
+                                    PcdMaximumAsciiStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrnCatS (\r
+  IN OUT CHAR8        *Destination,\r
+  IN     UINTN        DestMax,\r
+  IN     CONST CHAR8  *Source,\r
+  IN     UINTN        Length\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Ascii decimal string to a value of type UINTN.\r
+\r
+  This function outputs a value of type UINTN by interpreting the contents of\r
+  the Ascii string specified by String as a decimal number. The format of the\r
+  input Ascii string String is:\r
+\r
+                  [spaces] [decimal digits].\r
+\r
+  The valid decimal digit character is in the range [0-9]. The function will\r
+  ignore the pad space, which includes spaces or tab characters, before\r
+  [decimal digits]. The running zero in the beginning of [decimal digits] will\r
+  be ignored. Then, the function stops at the first character that is a not a\r
+  valid decimal character or a Null-terminator, whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Data is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
+  PcdMaximumAsciiStringLength Ascii characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If String has no valid decimal digits in the above format, then 0 is stored\r
+  at the location pointed to by Data.\r
+  If the number represented by String exceeds the range defined by UINTN, then\r
+  MAX_UINTN is stored at the location pointed to by Data.\r
+\r
+  If EndPointer is not NULL, a pointer to the character that stopped the scan\r
+  is stored at the location pointed to by EndPointer. If String has no valid\r
+  decimal digits right after the optional pad spaces, the value of String is\r
+  stored at the location pointed to by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Ascii string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Data                     Pointer to the converted value.\r
+\r
+  @retval RETURN_SUCCESS           Value is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                   and String contains more than\r
+                                   PcdMaximumAsciiStringLength Ascii\r
+                                   characters, not including the\r
+                                   Null-terminator.\r
+  @retval RETURN_UNSUPPORTED       If the number represented by String exceeds\r
+                                   the range defined by UINTN.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrDecimalToUintnS (\r
+  IN  CONST CHAR8              *String,\r
+  OUT       CHAR8              **EndPointer,  OPTIONAL\r
+  OUT       UINTN              *Data\r
+  );\r
+\r
 /**\r
+  Convert a Null-terminated Ascii decimal string to a value of type UINT64.\r
+\r
+  This function outputs a value of type UINT64 by interpreting the contents of\r
+  the Ascii string specified by String as a decimal number. The format of the\r
+  input Ascii string String is:\r
+\r
+                  [spaces] [decimal digits].\r
+\r
+  The valid decimal digit character is in the range [0-9]. The function will\r
+  ignore the pad space, which includes spaces or tab characters, before\r
+  [decimal digits]. The running zero in the beginning of [decimal digits] will\r
+  be ignored. Then, the function stops at the first character that is a not a\r
+  valid decimal character or a Null-terminator, whichever one comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Data is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
+  PcdMaximumAsciiStringLength Ascii characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If String has no valid decimal digits in the above format, then 0 is stored\r
+  at the location pointed to by Data.\r
+  If the number represented by String exceeds the range defined by UINT64, then\r
+  MAX_UINT64 is stored at the location pointed to by Data.\r
+\r
+  If EndPointer is not NULL, a pointer to the character that stopped the scan\r
+  is stored at the location pointed to by EndPointer. If String has no valid\r
+  decimal digits right after the optional pad spaces, the value of String is\r
+  stored at the location pointed to by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Ascii string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Data                     Pointer to the converted value.\r
+\r
+  @retval RETURN_SUCCESS           Value is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                   and String contains more than\r
+                                   PcdMaximumAsciiStringLength Ascii\r
+                                   characters, not including the\r
+                                   Null-terminator.\r
+  @retval RETURN_UNSUPPORTED       If the number represented by String exceeds\r
+                                   the range defined by UINT64.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrDecimalToUint64S (\r
+  IN  CONST CHAR8              *String,\r
+  OUT       CHAR8              **EndPointer,  OPTIONAL\r
+  OUT       UINT64             *Data\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN.\r
+\r
+  This function outputs a value of type UINTN by interpreting the contents of\r
+  the Ascii string specified by String as a hexadecimal number. The format of\r
+  the input Ascii string String is:\r
+\r
+                  [spaces][zeros][x][hexadecimal digits].\r
+\r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If\r
+  "x" appears in the input string, it must be prefixed with at least one 0. The\r
+  function will ignore the pad space, which includes spaces or tab characters,\r
+  before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or\r
+  [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or\r
+  the first valid hexadecimal digit. Then, the function stops at the first\r
+  character that is a not a valid hexadecimal character or Null-terminator,\r
+  whichever on comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Data is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
+  PcdMaximumAsciiStringLength Ascii characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If String has no valid hexadecimal digits in the above format, then 0 is\r
+  stored at the location pointed to by Data.\r
+  If the number represented by String exceeds the range defined by UINTN, then\r
+  MAX_UINTN is stored at the location pointed to by Data.\r
+\r
+  If EndPointer is not NULL, a pointer to the character that stopped the scan\r
+  is stored at the location pointed to by EndPointer. If String has no valid\r
+  hexadecimal digits right after the optional pad spaces, the value of String\r
+  is stored at the location pointed to by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Ascii string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Data                     Pointer to the converted value.\r
+\r
+  @retval RETURN_SUCCESS           Value is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                   and String contains more than\r
+                                   PcdMaximumAsciiStringLength Ascii\r
+                                   characters, not including the\r
+                                   Null-terminator.\r
+  @retval RETURN_UNSUPPORTED       If the number represented by String exceeds\r
+                                   the range defined by UINTN.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrHexToUintnS (\r
+  IN  CONST CHAR8              *String,\r
+  OUT       CHAR8              **EndPointer,  OPTIONAL\r
+  OUT       UINTN              *Data\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64.\r
+\r
+  This function outputs a value of type UINT64 by interpreting the contents of\r
+  the Ascii string specified by String as a hexadecimal number. The format of\r
+  the input Ascii string String is:\r
+\r
+                  [spaces][zeros][x][hexadecimal digits].\r
+\r
+  The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
+  The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If\r
+  "x" appears in the input string, it must be prefixed with at least one 0. The\r
+  function will ignore the pad space, which includes spaces or tab characters,\r
+  before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or\r
+  [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or\r
+  the first valid hexadecimal digit. Then, the function stops at the first\r
+  character that is a not a valid hexadecimal character or Null-terminator,\r
+  whichever on comes first.\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Data is NULL, then ASSERT().\r
+  If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
+  PcdMaximumAsciiStringLength Ascii characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If String has no valid hexadecimal digits in the above format, then 0 is\r
+  stored at the location pointed to by Data.\r
+  If the number represented by String exceeds the range defined by UINT64, then\r
+  MAX_UINT64 is stored at the location pointed to by Data.\r
+\r
+  If EndPointer is not NULL, a pointer to the character that stopped the scan\r
+  is stored at the location pointed to by EndPointer. If String has no valid\r
+  hexadecimal digits right after the optional pad spaces, the value of String\r
+  is stored at the location pointed to by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Ascii string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Data                     Pointer to the converted value.\r
+\r
+  @retval RETURN_SUCCESS           Value is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                   and String contains more than\r
+                                   PcdMaximumAsciiStringLength Ascii\r
+                                   characters, not including the\r
+                                   Null-terminator.\r
+  @retval RETURN_UNSUPPORTED       If the number represented by String exceeds\r
+                                   the range defined by UINT64.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrHexToUint64S (\r
+  IN  CONST CHAR8              *String,\r
+  OUT       CHAR8              **EndPointer,  OPTIONAL\r
+  OUT       UINT64             *Data\r
+  );\r
+\r
+\r
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
+\r
+/**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
   string and returns the new Unicode string.\r
 \r
@@ -182,6 +1081,8 @@ StrCpy (
 \r
 \r
 /**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Copies up to a specified length from one Null-terminated Unicode string to \r
   another Null-terminated Unicode string and returns the new Unicode string.\r
 \r
@@ -218,7 +1119,7 @@ StrnCpy (
   IN      CONST CHAR16              *Source,\r
   IN      UINTN                     Length\r
   );\r
-\r
+#endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r
 \r
 /**\r
   Returns the length of a Null-terminated Unicode string.\r
@@ -346,7 +1247,11 @@ StrnCmp (
   );\r
 \r
 \r
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
+\r
 /**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Concatenates one Null-terminated Unicode string to another Null-terminated\r
   Unicode string, and returns the concatenated Unicode string.\r
 \r
@@ -387,6 +1292,8 @@ StrCat (
 \r
 \r
 /**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Concatenates up to a specified length one Null-terminated Unicode to the end \r
   of another Null-terminated Unicode string, and returns the concatenated \r
   Unicode string.\r
@@ -431,6 +1338,7 @@ StrnCat (
   IN      CONST CHAR16              *Source,\r
   IN      UINTN                     Length\r
   );\r
+#endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r
 \r
 /**\r
   Returns the first occurrence of a Null-terminated Unicode sub-string\r
@@ -487,7 +1395,7 @@ StrStr (
   If String has no pad spaces or valid decimal digits,\r
   then 0 is returned.\r
   If the number represented by String overflows according\r
-  to the range defined by UINTN, then ASSERT().\r
+  to the range defined by UINTN, then MAX_UINTN is returned.\r
 \r
   If PcdMaximumUnicodeStringLength is not zero, and String contains\r
   more than PcdMaximumUnicodeStringLength Unicode characters not including\r
@@ -527,7 +1435,7 @@ StrDecimalToUintn (
   If String has no pad spaces or valid decimal digits,\r
   then 0 is returned.\r
   If the number represented by String overflows according\r
-  to the range defined by UINT64, then ASSERT().\r
+  to the range defined by UINT64, then MAX_UINT64 is returned.\r
 \r
   If PcdMaximumUnicodeStringLength is not zero, and String contains\r
   more than PcdMaximumUnicodeStringLength Unicode characters not including\r
@@ -569,7 +1477,7 @@ StrDecimalToUint64 (
   If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r
   then zero is returned.\r
   If the number represented by String overflows according to the range defined by\r
-  UINTN, then ASSERT().\r
+  UINTN, then MAX_UINTN is returned.\r
 \r
   If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
   PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r
@@ -611,24 +1519,259 @@ StrHexToUintn (
   If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r
   then zero is returned.\r
   If the number represented by String overflows according to the range defined by\r
-  UINT64, then ASSERT().\r
+  UINT64, then MAX_UINT64 is returned.\r
 \r
   If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
   PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r
   then ASSERT().\r
 \r
-  @param  String          The pointer to a Null-terminated Unicode string.\r
+  @param  String          The pointer to a Null-terminated Unicode string.\r
+\r
+  @retval Value translated from String.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+StrHexToUint64 (\r
+  IN      CONST CHAR16             *String\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode string to IPv6 address and prefix length.\r
+\r
+  This function outputs a value of type IPv6_ADDRESS and may output a value\r
+  of type UINT8 by interpreting the contents of the Unicode string specified\r
+  by String. The format of the input Unicode string String is as follows:\r
+\r
+                  X:X:X:X:X:X:X:X[/P]\r
+\r
+  X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and\r
+  [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low\r
+  memory address and high byte is stored in high memory address. P contains decimal\r
+  digit characters in the range [0-9]. The running zero in the beginning of P will\r
+  be ignored. /P is optional.\r
+\r
+  When /P is not in the String, the function stops at the first character that is\r
+  not a valid hexadecimal digit character after eight X's are converted.\r
+\r
+  When /P is in the String, the function stops at the first character that is not\r
+  a valid decimal digit character after P is converted.\r
+\r
+  "::" can be used to compress one or more groups of X when X contains only 0.\r
+  The "::" can only appear once in the String.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  If Address is NULL, then ASSERT().\r
+\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If EndPointer is not NULL and Address is translated from String, a pointer\r
+  to the character that stopped the scan is stored at the location pointed to\r
+  by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Unicode string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Address                  Pointer to the converted IPv6 address.\r
+  @param  PrefixLength             Pointer to the converted IPv6 address prefix\r
+                                   length. MAX_UINT8 is returned when /P is\r
+                                   not in the String.\r
+\r
+  @retval RETURN_SUCCESS           Address is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+  @retval RETURN_UNSUPPORTED       If X contains more than four hexadecimal\r
+                                    digit characters.\r
+                                   If String contains "::" and number of X\r
+                                    is not less than 8.\r
+                                   If P starts with character that is not a\r
+                                    valid decimal digit character.\r
+                                   If the decimal number converted from P\r
+                                    exceeds 128.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrToIpv6Address (\r
+  IN  CONST CHAR16       *String,\r
+  OUT CHAR16             **EndPointer, OPTIONAL\r
+  OUT IPv6_ADDRESS       *Address,\r
+  OUT UINT8              *PrefixLength OPTIONAL\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode string to IPv4 address and prefix length.\r
+\r
+  This function outputs a value of type IPv4_ADDRESS and may output a value\r
+  of type UINT8 by interpreting the contents of the Unicode string specified\r
+  by String. The format of the input Unicode string String is as follows:\r
+\r
+                  D.D.D.D[/P]\r
+\r
+  D and P are decimal digit characters in the range [0-9]. The running zero in\r
+  the beginning of D and P will be ignored. /P is optional.\r
+\r
+  When /P is not in the String, the function stops at the first character that is\r
+  not a valid decimal digit character after four D's are converted.\r
+\r
+  When /P is in the String, the function stops at the first character that is not\r
+  a valid decimal digit character after P is converted.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  If Address is NULL, then ASSERT().\r
+\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+\r
+  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
+  Null-terminator, then ASSERT().\r
+\r
+  If EndPointer is not NULL and Address is translated from String, a pointer\r
+  to the character that stopped the scan is stored at the location pointed to\r
+  by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated Unicode string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Address                  Pointer to the converted IPv4 address.\r
+  @param  PrefixLength             Pointer to the converted IPv4 address prefix\r
+                                   length. MAX_UINT8 is returned when /P is\r
+                                   not in the String.\r
+\r
+  @retval RETURN_SUCCESS           Address is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+  @retval RETURN_UNSUPPORTED       If String is not in the correct format.\r
+                                   If any decimal number converted from D\r
+                                    exceeds 255.\r
+                                   If the decimal number converted from P\r
+                                    exceeds 32.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrToIpv4Address (\r
+  IN  CONST CHAR16       *String,\r
+  OUT CHAR16             **EndPointer, OPTIONAL\r
+  OUT IPv4_ADDRESS       *Address,\r
+  OUT UINT8              *PrefixLength OPTIONAL\r
+  );\r
+\r
+#define GUID_STRING_LENGTH  36\r
+\r
+/**\r
+  Convert a Null-terminated Unicode GUID string to a value of type\r
+  EFI_GUID.\r
+\r
+  This function outputs a GUID value by interpreting the contents of\r
+  the Unicode string specified by String. The format of the input\r
+  Unicode string String consists of 36 characters, as follows:\r
+\r
+                  aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\r
+\r
+  The pairs aa - pp are two characters in the range [0-9], [a-f] and\r
+  [A-F], with each pair representing a single byte hexadecimal value.\r
+\r
+  The mapping between String and the EFI_GUID structure is as follows:\r
+                  aa          Data1[24:31]\r
+                  bb          Data1[16:23]\r
+                  cc          Data1[8:15]\r
+                  dd          Data1[0:7]\r
+                  ee          Data2[8:15]\r
+                  ff          Data2[0:7]\r
+                  gg          Data3[8:15]\r
+                  hh          Data3[0:7]\r
+                  ii          Data4[0:7]\r
+                  jj          Data4[8:15]\r
+                  kk          Data4[16:23]\r
+                  ll          Data4[24:31]\r
+                  mm          Data4[32:39]\r
+                  nn          Data4[40:47]\r
+                  oo          Data4[48:55]\r
+                  pp          Data4[56:63]\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Guid is NULL, then ASSERT().\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+\r
+  @param  String                   Pointer to a Null-terminated Unicode string.\r
+  @param  Guid                     Pointer to the converted GUID.\r
+\r
+  @retval RETURN_SUCCESS           Guid is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+  @retval RETURN_UNSUPPORTED       If String is not as the above format.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+StrToGuid (\r
+  IN  CONST CHAR16       *String,\r
+  OUT GUID               *Guid\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated Unicode hexadecimal string to a byte array.\r
+\r
+  This function outputs a byte array by interpreting the contents of\r
+  the Unicode string specified by String in hexadecimal format. The format of\r
+  the input Unicode string String is:\r
+\r
+                  [XX]*\r
+\r
+  X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].\r
+  The function decodes every two hexadecimal digit characters as one byte. The\r
+  decoding stops after Length of characters and outputs Buffer containing\r
+  (Length / 2) bytes.\r
+\r
+  If String is not aligned in a 16-bit boundary, then ASSERT().\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+\r
+  If Length is not multiple of 2, then ASSERT().\r
 \r
-  @retval Value translated from String.\r
+  If PcdMaximumUnicodeStringLength is not zero and Length is greater than\r
+  PcdMaximumUnicodeStringLength, then ASSERT().\r
+\r
+  If MaxBufferSize is less than (Length / 2), then ASSERT().\r
 \r
+  @param  String                   Pointer to a Null-terminated Unicode string.\r
+  @param  Length                   The number of Unicode characters to decode.\r
+  @param  Buffer                   Pointer to the converted bytes array.\r
+  @param  MaxBufferSize            The maximum size of Buffer.\r
+\r
+  @retval RETURN_SUCCESS           Buffer is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If Length is not multiple of 2.\r
+                                   If PcdMaximumUnicodeStringLength is not zero,\r
+                                    and Length is greater than\r
+                                    PcdMaximumUnicodeStringLength.\r
+  @retval RETURN_UNSUPPORTED       If Length of characters from String contain\r
+                                    a character that is not valid hexadecimal\r
+                                    digit characters, or a Null-terminator.\r
+  @retval RETURN_BUFFER_TOO_SMALL  If MaxBufferSize is less than (Length / 2).\r
 **/\r
-UINT64\r
+RETURN_STATUS\r
 EFIAPI\r
-StrHexToUint64 (\r
-  IN      CONST CHAR16             *String\r
+StrHexToBytes (\r
+  IN  CONST CHAR16       *String,\r
+  IN  UINTN              Length,\r
+  OUT UINT8              *Buffer,\r
+  IN  UINTN              MaxBufferSize\r
   );\r
 \r
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
+\r
 /**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Convert a Null-terminated Unicode string to a Null-terminated\r
   ASCII string and returns the ASCII string.\r
 \r
@@ -668,8 +1811,116 @@ UnicodeStrToAsciiStr (
   OUT     CHAR8                     *Destination\r
   );\r
 \r
+#endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r
+\r
+/**\r
+  Convert a Null-terminated Unicode string to a Null-terminated\r
+  ASCII string.\r
+\r
+  This function is similar to AsciiStrCpyS.\r
+\r
+  This function converts the content of the Unicode string Source\r
+  to the ASCII string Destination by copying the lower 8 bits of\r
+  each Unicode character. The function terminates the ASCII string\r
+  Destination by appending a Null-terminator character at the end.\r
+\r
+  The caller is responsible to make sure Destination points to a buffer with size\r
+  equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r
+\r
+  If any Unicode characters in Source contain non-zero value in\r
+  the upper 8 bits, then ASSERT().\r
+\r
+  If Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Source        The pointer to a Null-terminated Unicode string.\r
+  @param  Destination   The pointer to a Null-terminated ASCII string.\r
+  @param  DestMax       The maximum number of Destination Ascii\r
+                        char, including terminating null char.\r
+\r
+  @retval RETURN_SUCCESS           String is converted.\r
+  @retval RETURN_BUFFER_TOO_SMALL  If DestMax is NOT greater than StrLen(Source).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                    and DestMax is greater than\r
+                                    PcdMaximumAsciiStringLength.\r
+                                   If PcdMaximumUnicodeStringLength is not zero,\r
+                                    and DestMax is greater than\r
+                                    PcdMaximumUnicodeStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+UnicodeStrToAsciiStrS (\r
+  IN      CONST CHAR16              *Source,\r
+  OUT     CHAR8                     *Destination,\r
+  IN      UINTN                     DestMax\r
+  );\r
+\r
+/**\r
+  Convert not more than Length successive characters from a Null-terminated\r
+  Unicode string to a Null-terminated Ascii string. If no null char is copied\r
+  from Source, then Destination[Length] is always set to null.\r
+\r
+  This function converts not more than Length successive characters from the\r
+  Unicode string Source to the Ascii string Destination by copying the lower 8\r
+  bits of each Unicode character. The function terminates the Ascii string\r
+  Destination by appending a Null-terminator character at the end.\r
+\r
+  The caller is responsible to make sure Destination points to a buffer with size\r
+  equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r
+\r
+  If any Unicode characters in Source contain non-zero value in the upper 8\r
+  bits, then ASSERT().\r
+  If Source is not aligned on a 16-bit boundary, then ASSERT().\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Source             The pointer to a Null-terminated Unicode string.\r
+  @param  Length             The maximum number of Unicode characters to\r
+                             convert.\r
+  @param  Destination        The pointer to a Null-terminated Ascii string.\r
+  @param  DestMax            The maximum number of Destination Ascii\r
+                             char, including terminating null char.\r
+  @param  DestinationLength  The number of Unicode characters converted.\r
+\r
+  @retval RETURN_SUCCESS            String is converted.\r
+  @retval RETURN_INVALID_PARAMETER  If Destination is NULL.\r
+                                    If Source is NULL.\r
+                                    If DestinationLength is NULL.\r
+                                    If PcdMaximumAsciiStringLength is not zero,\r
+                                    and Length or DestMax is greater than\r
+                                    PcdMaximumAsciiStringLength.\r
+                                    If PcdMaximumUnicodeStringLength is not\r
+                                    zero, and Length or DestMax is greater than\r
+                                    PcdMaximumUnicodeStringLength.\r
+                                    If DestMax is 0.\r
+  @retval RETURN_BUFFER_TOO_SMALL   If DestMax is NOT greater than\r
+                                    MIN(StrLen(Source), Length).\r
+  @retval RETURN_ACCESS_DENIED      If Source and Destination overlap.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+UnicodeStrnToAsciiStrS (\r
+  IN      CONST CHAR16              *Source,\r
+  IN      UINTN                     Length,\r
+  OUT     CHAR8                     *Destination,\r
+  IN      UINTN                     DestMax,\r
+  OUT     UINTN                     *DestinationLength\r
+  );\r
+\r
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
 \r
 /**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
   string and returns the new ASCII string.\r
 \r
@@ -699,6 +1950,8 @@ AsciiStrCpy (
 \r
 \r
 /**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Copies up to a specified length one Null-terminated ASCII string to another \r
   Null-terminated ASCII string and returns the new ASCII string.\r
 \r
@@ -732,7 +1985,7 @@ AsciiStrnCpy (
   IN      CONST CHAR8               *Source,\r
   IN      UINTN                     Length\r
   );\r
-\r
+#endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r
 \r
 /**\r
   Returns the length of a Null-terminated ASCII string.\r
@@ -892,7 +2145,11 @@ AsciiStrnCmp (
   );\r
 \r
 \r
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
+\r
 /**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Concatenates one Null-terminated ASCII string to another Null-terminated\r
   ASCII string, and returns the concatenated ASCII string.\r
 \r
@@ -928,6 +2185,8 @@ AsciiStrCat (
 \r
 \r
 /**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Concatenates up to a specified length one Null-terminated ASCII string to \r
   the end of another Null-terminated ASCII string, and returns the \r
   concatenated ASCII string.\r
@@ -970,7 +2229,7 @@ AsciiStrnCat (
   IN      CONST CHAR8               *Source,\r
   IN      UINTN                     Length\r
   );\r
-\r
+#endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r
 \r
 /**\r
   Returns the first occurrence of a Null-terminated ASCII sub-string\r
@@ -1023,7 +2282,7 @@ AsciiStrStr (
   If String has only pad spaces, then 0 is returned.\r
   If String has no pad spaces or valid decimal digits, then 0 is returned.\r
   If the number represented by String overflows according to the range defined by\r
-  UINTN, then ASSERT().\r
+  UINTN, then MAX_UINTN is returned.\r
   If String is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
   PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
@@ -1060,7 +2319,7 @@ AsciiStrDecimalToUintn (
   If String has only pad spaces, then 0 is returned.\r
   If String has no pad spaces or valid decimal digits, then 0 is returned.\r
   If the number represented by String overflows according to the range defined by\r
-  UINT64, then ASSERT().\r
+  UINT64, then MAX_UINT64 is returned.\r
   If String is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
   PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
@@ -1101,7 +2360,7 @@ AsciiStrDecimalToUint64 (
   0 is returned.\r
 \r
   If the number represented by String overflows according to the range defined by UINTN,\r
-  then ASSERT().\r
+  then MAX_UINTN is returned.\r
   If String is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero,\r
   and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r
@@ -1142,7 +2401,7 @@ AsciiStrHexToUintn (
   0 is returned.\r
 \r
   If the number represented by String overflows according to the range defined by UINT64,\r
-  then ASSERT().\r
+  then MAX_UINT64 is returned.\r
   If String is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero,\r
   and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r
@@ -1159,8 +2418,225 @@ AsciiStrHexToUint64 (
   IN      CONST CHAR8                *String\r
   );\r
 \r
+/**\r
+  Convert a Null-terminated ASCII string to IPv6 address and prefix length.\r
+\r
+  This function outputs a value of type IPv6_ADDRESS and may output a value\r
+  of type UINT8 by interpreting the contents of the ASCII string specified\r
+  by String. The format of the input ASCII string String is as follows:\r
+\r
+                  X:X:X:X:X:X:X:X[/P]\r
+\r
+  X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and\r
+  [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low\r
+  memory address and high byte is stored in high memory address. P contains decimal\r
+  digit characters in the range [0-9]. The running zero in the beginning of P will\r
+  be ignored. /P is optional.\r
+\r
+  When /P is not in the String, the function stops at the first character that is\r
+  not a valid hexadecimal digit character after eight X's are converted.\r
+\r
+  When /P is in the String, the function stops at the first character that is not\r
+  a valid decimal digit character after P is converted.\r
+\r
+  "::" can be used to compress one or more groups of X when X contains only 0.\r
+  The "::" can only appear once in the String.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  If Address is NULL, then ASSERT().\r
+\r
+  If EndPointer is not NULL and Address is translated from String, a pointer\r
+  to the character that stopped the scan is stored at the location pointed to\r
+  by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated ASCII string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Address                  Pointer to the converted IPv6 address.\r
+  @param  PrefixLength             Pointer to the converted IPv6 address prefix\r
+                                   length. MAX_UINT8 is returned when /P is\r
+                                   not in the String.\r
+\r
+  @retval RETURN_SUCCESS           Address is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+  @retval RETURN_UNSUPPORTED       If X contains more than four hexadecimal\r
+                                    digit characters.\r
+                                   If String contains "::" and number of X\r
+                                    is not less than 8.\r
+                                   If P starts with character that is not a\r
+                                    valid decimal digit character.\r
+                                   If the decimal number converted from P\r
+                                    exceeds 128.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrToIpv6Address (\r
+  IN  CONST CHAR8        *String,\r
+  OUT CHAR8              **EndPointer, OPTIONAL\r
+  OUT IPv6_ADDRESS       *Address,\r
+  OUT UINT8              *PrefixLength OPTIONAL\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated ASCII string to IPv4 address and prefix length.\r
+\r
+  This function outputs a value of type IPv4_ADDRESS and may output a value\r
+  of type UINT8 by interpreting the contents of the ASCII string specified\r
+  by String. The format of the input ASCII string String is as follows:\r
+\r
+                  D.D.D.D[/P]\r
+\r
+  D and P are decimal digit characters in the range [0-9]. The running zero in\r
+  the beginning of D and P will be ignored. /P is optional.\r
+\r
+  When /P is not in the String, the function stops at the first character that is\r
+  not a valid decimal digit character after four D's are converted.\r
+\r
+  When /P is in the String, the function stops at the first character that is not\r
+  a valid decimal digit character after P is converted.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  If Address is NULL, then ASSERT().\r
+\r
+  If EndPointer is not NULL and Address is translated from String, a pointer\r
+  to the character that stopped the scan is stored at the location pointed to\r
+  by EndPointer.\r
+\r
+  @param  String                   Pointer to a Null-terminated ASCII string.\r
+  @param  EndPointer               Pointer to character that stops scan.\r
+  @param  Address                  Pointer to the converted IPv4 address.\r
+  @param  PrefixLength             Pointer to the converted IPv4 address prefix\r
+                                   length. MAX_UINT8 is returned when /P is\r
+                                   not in the String.\r
+\r
+  @retval RETURN_SUCCESS           Address is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+  @retval RETURN_UNSUPPORTED       If String is not in the correct format.\r
+                                   If any decimal number converted from D\r
+                                    exceeds 255.\r
+                                   If the decimal number converted from P\r
+                                    exceeds 32.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrToIpv4Address (\r
+  IN  CONST CHAR8        *String,\r
+  OUT CHAR8              **EndPointer, OPTIONAL\r
+  OUT IPv4_ADDRESS       *Address,\r
+  OUT UINT8              *PrefixLength OPTIONAL\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated ASCII GUID string to a value of type\r
+  EFI_GUID.\r
+\r
+  This function outputs a GUID value by interpreting the contents of\r
+  the ASCII string specified by String. The format of the input\r
+  ASCII string String consists of 36 characters, as follows:\r
+\r
+                  aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\r
+\r
+  The pairs aa - pp are two characters in the range [0-9], [a-f] and\r
+  [A-F], with each pair representing a single byte hexadecimal value.\r
+\r
+  The mapping between String and the EFI_GUID structure is as follows:\r
+                  aa          Data1[24:31]\r
+                  bb          Data1[16:23]\r
+                  cc          Data1[8:15]\r
+                  dd          Data1[0:7]\r
+                  ee          Data2[8:15]\r
+                  ff          Data2[0:7]\r
+                  gg          Data3[8:15]\r
+                  hh          Data3[0:7]\r
+                  ii          Data4[0:7]\r
+                  jj          Data4[8:15]\r
+                  kk          Data4[16:23]\r
+                  ll          Data4[24:31]\r
+                  mm          Data4[32:39]\r
+                  nn          Data4[40:47]\r
+                  oo          Data4[48:55]\r
+                  pp          Data4[56:63]\r
+\r
+  If String is NULL, then ASSERT().\r
+  If Guid is NULL, then ASSERT().\r
+\r
+  @param  String                   Pointer to a Null-terminated ASCII string.\r
+  @param  Guid                     Pointer to the converted GUID.\r
+\r
+  @retval RETURN_SUCCESS           Guid is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+  @retval RETURN_UNSUPPORTED       If String is not as the above format.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrToGuid (\r
+  IN  CONST CHAR8        *String,\r
+  OUT GUID               *Guid\r
+  );\r
+\r
+/**\r
+  Convert a Null-terminated ASCII hexadecimal string to a byte array.\r
+\r
+  This function outputs a byte array by interpreting the contents of\r
+  the ASCII string specified by String in hexadecimal format. The format of\r
+  the input ASCII string String is:\r
+\r
+                  [XX]*\r
+\r
+  X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].\r
+  The function decodes every two hexadecimal digit characters as one byte. The\r
+  decoding stops after Length of characters and outputs Buffer containing\r
+  (Length / 2) bytes.\r
+\r
+  If String is NULL, then ASSERT().\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+\r
+  If Length is not multiple of 2, then ASSERT().\r
+\r
+  If PcdMaximumAsciiStringLength is not zero and Length is greater than\r
+  PcdMaximumAsciiStringLength, then ASSERT().\r
+\r
+  If MaxBufferSize is less than (Length / 2), then ASSERT().\r
+\r
+  @param  String                   Pointer to a Null-terminated ASCII string.\r
+  @param  Length                   The number of ASCII characters to decode.\r
+  @param  Buffer                   Pointer to the converted bytes array.\r
+  @param  MaxBufferSize            The maximum size of Buffer.\r
+\r
+  @retval RETURN_SUCCESS           Buffer is translated from String.\r
+  @retval RETURN_INVALID_PARAMETER If String is NULL.\r
+                                   If Data is NULL.\r
+                                   If Length is not multiple of 2.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                    and Length is greater than\r
+                                    PcdMaximumAsciiStringLength.\r
+  @retval RETURN_UNSUPPORTED       If Length of characters from String contain\r
+                                    a character that is not valid hexadecimal\r
+                                    digit characters, or a Null-terminator.\r
+  @retval RETURN_BUFFER_TOO_SMALL  If MaxBufferSize is less than (Length / 2).\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrHexToBytes (\r
+  IN  CONST CHAR8        *String,\r
+  IN  UINTN              Length,\r
+  OUT UINT8              *Buffer,\r
+  IN  UINTN              MaxBufferSize\r
+  );\r
+\r
+#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
 \r
 /**\r
+  [ATTENTION] This function is deprecated for security reason.\r
+\r
   Convert one Null-terminated ASCII string to a Null-terminated\r
   Unicode string and returns the Unicode string.\r
 \r
@@ -1194,6 +2670,105 @@ AsciiStrToUnicodeStr (
   OUT     CHAR16                    *Destination\r
   );\r
 \r
+#endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r
+\r
+/**\r
+  Convert one Null-terminated ASCII string to a Null-terminated\r
+  Unicode string.\r
+\r
+  This function is similar to StrCpyS.\r
+\r
+  This function converts the contents of the ASCII string Source to the Unicode\r
+  string Destination. The function terminates the Unicode string Destination by\r
+  appending a Null-terminator character at the end.\r
+\r
+  The caller is responsible to make sure Destination points to a buffer with size\r
+  equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r
+\r
+  If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then the Destination is unmodified.\r
+\r
+  @param  Source        The pointer to a Null-terminated ASCII string.\r
+  @param  Destination   The pointer to a Null-terminated Unicode string.\r
+  @param  DestMax       The maximum number of Destination Unicode\r
+                        char, including terminating null char.\r
+\r
+  @retval RETURN_SUCCESS           String is converted.\r
+  @retval RETURN_BUFFER_TOO_SMALL  If DestMax is NOT greater than StrLen(Source).\r
+  @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
+                                   If Source is NULL.\r
+                                   If PcdMaximumUnicodeStringLength is not zero,\r
+                                    and DestMax is greater than\r
+                                    PcdMaximumUnicodeStringLength.\r
+                                   If PcdMaximumAsciiStringLength is not zero,\r
+                                    and DestMax is greater than\r
+                                    PcdMaximumAsciiStringLength.\r
+                                   If DestMax is 0.\r
+  @retval RETURN_ACCESS_DENIED     If Source and Destination overlap.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrToUnicodeStrS (\r
+  IN      CONST CHAR8               *Source,\r
+  OUT     CHAR16                    *Destination,\r
+  IN      UINTN                     DestMax\r
+  );\r
+\r
+/**\r
+  Convert not more than Length successive characters from a Null-terminated\r
+  Ascii string to a Null-terminated Unicode string. If no null char is copied\r
+  from Source, then Destination[Length] is always set to null.\r
+\r
+  This function converts not more than Length successive characters from the\r
+  Ascii string Source to the Unicode string Destination. The function\r
+  terminates the Unicode string Destination by appending a Null-terminator\r
+  character at the end.\r
+\r
+  The caller is responsible to make sure Destination points to a buffer with\r
+  size not smaller than\r
+  ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.\r
+\r
+  If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
+  If an error would be returned, then the function will also ASSERT().\r
+\r
+  If an error is returned, then Destination and DestinationLength are\r
+  unmodified.\r
+\r
+  @param  Source             The pointer to a Null-terminated Ascii string.\r
+  @param  Length             The maximum number of Ascii characters to convert.\r
+  @param  Destination        The pointer to a Null-terminated Unicode string.\r
+  @param  DestMax            The maximum number of Destination Unicode char,\r
+                             including terminating null char.\r
+  @param  DestinationLength  The number of Ascii characters converted.\r
+\r
+  @retval RETURN_SUCCESS            String is converted.\r
+  @retval RETURN_INVALID_PARAMETER  If Destination is NULL.\r
+                                    If Source is NULL.\r
+                                    If DestinationLength is NULL.\r
+                                    If PcdMaximumUnicodeStringLength is not\r
+                                    zero, and Length or DestMax is greater than\r
+                                    PcdMaximumUnicodeStringLength.\r
+                                    If PcdMaximumAsciiStringLength is not zero,\r
+                                    and Length or DestMax is greater than\r
+                                    PcdMaximumAsciiStringLength.\r
+                                    If DestMax is 0.\r
+  @retval RETURN_BUFFER_TOO_SMALL   If DestMax is NOT greater than\r
+                                    MIN(AsciiStrLen(Source), Length).\r
+  @retval RETURN_ACCESS_DENIED      If Source and Destination overlap.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AsciiStrnToUnicodeStrS (\r
+  IN      CONST CHAR8               *Source,\r
+  IN      UINTN                     Length,\r
+  OUT     CHAR16                    *Destination,\r
+  IN      UINTN                     DestMax,\r
+  OUT     UINTN                     *DestinationLength\r
+  );\r
 \r
 /**\r
   Converts an 8-bit value to an 8-bit BCD value.\r
@@ -1235,6 +2810,42 @@ BcdToDecimal8 (
   IN      UINT8                     Value\r
   );\r
 \r
+//\r
+//  File Path Manipulation Functions\r
+//\r
+\r
+/**\r
+  Removes the last directory or file entry in a path.\r
+\r
+  @param[in, out] Path    The pointer to the path to modify.\r
+\r
+  @retval FALSE     Nothing was found to remove.\r
+  @retval TRUE      A directory or file was removed.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PathRemoveLastItem(\r
+  IN OUT CHAR16 *Path\r
+  );\r
+\r
+/**\r
+  Function to clean up paths.\r
+    - Single periods in the path are removed.\r
+    - Double periods in the path are removed along with a single parent directory.\r
+    - Forward slashes L'/' are converted to backward slashes L'\'.\r
+\r
+  This will be done inline and the existing buffer may be larger than required\r
+  upon completion.\r
+\r
+  @param[in] Path       The pointer to the string containing the path.\r
+\r
+  @return       Returns Path, otherwise returns NULL to indicate that an error has occurred.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+PathCleanUpDirectories(\r
+  IN CHAR16 *Path\r
+  );\r
 \r
 //\r
 // Linked List Functions and Macros\r
@@ -1257,6 +2868,33 @@ BcdToDecimal8 (
 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead)  {&(ListHead), &(ListHead)}\r
 \r
 \r
+/**\r
+  Checks whether FirstEntry and SecondEntry are part of the same doubly-linked\r
+  list.\r
+\r
+  If FirstEntry is NULL, then ASSERT().\r
+  If FirstEntry->ForwardLink is NULL, then ASSERT().\r
+  If FirstEntry->BackLink is NULL, then ASSERT().\r
+  If SecondEntry is NULL, then ASSERT();\r
+  If PcdMaximumLinkedListLength is not zero, and List contains more than\r
+  PcdMaximumLinkedListLength nodes, then ASSERT().\r
+\r
+  @param  FirstEntry   A pointer to a node in a linked list.\r
+  @param  SecondEntry  A pointer to the node to locate.\r
+\r
+  @retval TRUE   SecondEntry is in the same doubly-linked list as FirstEntry.\r
+  @retval FALSE  SecondEntry isn't in the same doubly-linked list as FirstEntry,\r
+                 or FirstEntry is invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsNodeInList (\r
+  IN      CONST LIST_ENTRY      *FirstEntry,\r
+  IN      CONST LIST_ENTRY      *SecondEntry\r
+  );\r
+\r
+\r
 /**\r
   Initializes the head node of a doubly linked list, and returns the pointer to\r
   the head node of the doubly linked list.\r
@@ -1291,7 +2929,7 @@ InitializeListHead (
   If Entry is NULL, then ASSERT().\r
   If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r
   InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r
   of nodes in ListHead, including the ListHead node, is greater than or\r
   equal to PcdMaximumLinkedListLength, then ASSERT().\r
 \r
@@ -1321,7 +2959,7 @@ InsertHeadList (
   If Entry is NULL, then ASSERT().\r
   If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
   InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
+  If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r
   of nodes in ListHead, including the ListHead node, is greater than or\r
   equal to PcdMaximumLinkedListLength, then ASSERT().\r
 \r
@@ -1350,14 +2988,14 @@ InsertTailList (
   If List is NULL, then ASSERT().\r
   If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
   InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes\r
   in List, including the List node, is greater than or equal to\r
   PcdMaximumLinkedListLength, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
 \r
   @return The first node of a doubly linked list.\r
-  @retval NULL  The list is empty.\r
+  @retval List  The list is empty.\r
 \r
 **/\r
 LIST_ENTRY *\r
@@ -1378,8 +3016,8 @@ GetFirstNode (
   If Node is NULL, then ASSERT().\r
   If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
   InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
-  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLength is not zero, and List contains more than\r
+  PcdMaximumLinkedListLength nodes, then ASSERT().\r
   If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
 \r
   @param  List  A pointer to the head node of a doubly linked list.\r
@@ -1407,8 +3045,8 @@ GetNextNode (
   If Node is NULL, then ASSERT().\r
   If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
   InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
-  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdMaximumLinkedListLength is not zero, and List contains more than\r
+  PcdMaximumLinkedListLength nodes, then ASSERT().\r
   If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
  \r
   @param  List  A pointer to the head node of a doubly linked list.\r
@@ -1434,7 +3072,7 @@ GetPreviousNode (
   If ListHead is NULL, then ASSERT().\r
   If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
   InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes\r
   in List, including the List node, is greater than or equal to\r
   PcdMaximumLinkedListLength, then ASSERT().\r
 \r
@@ -1464,7 +3102,7 @@ IsListEmpty (
   If Node is NULL, then ASSERT().\r
   If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(), \r
   then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes\r
   in List, including the List node, is greater than or equal to\r
   PcdMaximumLinkedListLength, then ASSERT().\r
   If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal \r
@@ -1496,7 +3134,7 @@ IsNull (
   If Node is NULL, then ASSERT().\r
   If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r
   InitializeListHead(), then ASSERT().\r
-  If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
+  If PcdMaximumLinkedListLength is not zero, and the number of nodes\r
   in List, including the List node, is greater than or equal to\r
   PcdMaximumLinkedListLength, then ASSERT().\r
   If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
@@ -3191,6 +4829,25 @@ CalculateCheckSum64 (
   IN      UINTN                     Length\r
   );\r
 \r
+/**\r
+  Computes and returns a 32-bit CRC for a data buffer.\r
+  CRC32 value bases on ITU-T V.42.\r
+\r
+  If Buffer is NULL, then ASSERT().\r
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
+\r
+  @param[in]  Buffer       A pointer to the buffer on which the 32-bit CRC is to be computed.\r
+  @param[in]  Length       The number of bytes in the buffer Data.\r
+\r
+  @retval Crc32            The 32-bit CRC was computed for the data buffer.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+CalculateCrc32(\r
+  IN  VOID                         *Buffer,\r
+  IN  UINTN                        Length\r
+  );\r
 \r
 //\r
 // Base Library CPU Functions\r
@@ -3246,6 +4903,7 @@ MemoryFence (
   @retval 0 Indicates a return from SetJump().\r
 \r
 **/\r
+RETURNS_TWICE\r
 UINTN\r
 EFIAPI\r
 SetJump (\r
@@ -4837,7 +6495,7 @@ AsmPalCall (
   IN UINT64  Arg3,\r
   IN UINT64  Arg4\r
   );\r
-#endif\r
+#endif // defined (MDE_CPU_IPF)\r
 \r
 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
 ///\r
@@ -4990,6 +6648,8 @@ typedef struct {
 #define IA32_IDT_GATE_TYPE_INTERRUPT_32  0x8E\r
 #define IA32_IDT_GATE_TYPE_TRAP_32       0x8F\r
 \r
+#define IA32_GDT_TYPE_TSS               0x9\r
+#define IA32_GDT_ALIGNMENT              8\r
 \r
 #if defined (MDE_CPU_IA32)\r
 ///\r
@@ -5006,7 +6666,71 @@ typedef union {
   UINT64  Uint64;\r
 } IA32_IDT_GATE_DESCRIPTOR;\r
 \r
-#endif\r
+#pragma pack (1)\r
+//\r
+// IA32 Task-State Segment Definition\r
+//\r
+typedef struct {\r
+  UINT16    PreviousTaskLink;\r
+  UINT16    Reserved_2;\r
+  UINT32    ESP0;\r
+  UINT16    SS0;\r
+  UINT16    Reserved_10;\r
+  UINT32    ESP1;\r
+  UINT16    SS1;\r
+  UINT16    Reserved_18;\r
+  UINT32    ESP2;\r
+  UINT16    SS2;\r
+  UINT16    Reserved_26;\r
+  UINT32    CR3;\r
+  UINT32    EIP;\r
+  UINT32    EFLAGS;\r
+  UINT32    EAX;\r
+  UINT32    ECX;\r
+  UINT32    EDX;\r
+  UINT32    EBX;\r
+  UINT32    ESP;\r
+  UINT32    EBP;\r
+  UINT32    ESI;\r
+  UINT32    EDI;\r
+  UINT16    ES;\r
+  UINT16    Reserved_74;\r
+  UINT16    CS;\r
+  UINT16    Reserved_78;\r
+  UINT16    SS;\r
+  UINT16    Reserved_82;\r
+  UINT16    DS;\r
+  UINT16    Reserved_86;\r
+  UINT16    FS;\r
+  UINT16    Reserved_90;\r
+  UINT16    GS;\r
+  UINT16    Reserved_94;\r
+  UINT16    LDTSegmentSelector;\r
+  UINT16    Reserved_98;\r
+  UINT16    T;\r
+  UINT16    IOMapBaseAddress;\r
+} IA32_TASK_STATE_SEGMENT;\r
+\r
+typedef union {\r
+  struct {\r
+    UINT32  LimitLow:16;    ///< Segment Limit 15..00\r
+    UINT32  BaseLow:16;     ///< Base Address  15..00\r
+    UINT32  BaseMid:8;      ///< Base Address  23..16\r
+    UINT32  Type:4;         ///< Type (1 0 B 1)\r
+    UINT32  Reserved_43:1;  ///< 0\r
+    UINT32  DPL:2;          ///< Descriptor Privilege Level\r
+    UINT32  P:1;            ///< Segment Present\r
+    UINT32  LimitHigh:4;    ///< Segment Limit 19..16\r
+    UINT32  AVL:1;          ///< Available for use by system software\r
+    UINT32  Reserved_52:2;  ///< 0 0\r
+    UINT32  G:1;            ///< Granularity\r
+    UINT32  BaseHigh:8;     ///< Base Address 31..24\r
+  } Bits;\r
+  UINT64  Uint64;\r
+} IA32_TSS_DESCRIPTOR;\r
+#pragma pack ()\r
+\r
+#endif // defined (MDE_CPU_IA32)\r
 \r
 #if defined (MDE_CPU_X64)\r
 ///\r
@@ -5028,7 +6752,47 @@ typedef union {
   } Uint128;   \r
 } IA32_IDT_GATE_DESCRIPTOR;\r
 \r
-#endif\r
+#pragma pack (1)\r
+//\r
+// IA32 Task-State Segment Definition\r
+//\r
+typedef struct {\r
+  UINT32    Reserved_0;\r
+  UINT64    RSP0;\r
+  UINT64    RSP1;\r
+  UINT64    RSP2;\r
+  UINT64    Reserved_28;\r
+  UINT64    IST[7];\r
+  UINT64    Reserved_92;\r
+  UINT16    Reserved_100;\r
+  UINT16    IOMapBaseAddress;\r
+} IA32_TASK_STATE_SEGMENT;\r
+\r
+typedef union {\r
+  struct {\r
+    UINT32  LimitLow:16;    ///< Segment Limit 15..00\r
+    UINT32  BaseLow:16;     ///< Base Address  15..00\r
+    UINT32  BaseMidl:8;     ///< Base Address  23..16\r
+    UINT32  Type:4;         ///< Type (1 0 B 1)\r
+    UINT32  Reserved_43:1;  ///< 0\r
+    UINT32  DPL:2;          ///< Descriptor Privilege Level\r
+    UINT32  P:1;            ///< Segment Present\r
+    UINT32  LimitHigh:4;    ///< Segment Limit 19..16\r
+    UINT32  AVL:1;          ///< Available for use by system software\r
+    UINT32  Reserved_52:2;  ///< 0 0\r
+    UINT32  G:1;            ///< Granularity\r
+    UINT32  BaseMidh:8;     ///< Base Address  31..24\r
+    UINT32  BaseHigh:32;    ///< Base Address  63..32\r
+    UINT32  Reserved_96:32; ///< Reserved\r
+  } Bits;\r
+  struct {\r
+    UINT64  Uint64;\r
+    UINT64  Uint64_1;\r
+  } Uint128;\r
+} IA32_TSS_DESCRIPTOR;\r
+#pragma pack ()\r
+\r
+#endif // defined (MDE_CPU_X64)\r
 \r
 ///\r
 /// Byte packed structure for an FP/SSE/SSE2 context.\r
@@ -5117,6 +6881,20 @@ typedef struct {
 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15   0x00000002\r
 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r
 \r
+///\r
+/// Type definition for representing labels in NASM source code that allow for\r
+/// the patching of immediate operands of IA32 and X64 instructions.\r
+///\r
+/// While the type is technically defined as a function type (note: not a\r
+/// pointer-to-function type), such labels in NASM source code never stand for\r
+/// actual functions, and identifiers declared with this function type should\r
+/// never be called. This is also why the EFIAPI calling convention specifier\r
+/// is missing from the typedef, and why the typedef does not follow the usual\r
+/// edk2 coding style for function (or pointer-to-function) typedefs. The VOID\r
+/// return type and the VOID argument list are merely artifacts.\r
+///\r
+typedef VOID (X86_ASSEMBLY_PATCH_LABEL) (VOID);\r
+\r
 /**\r
   Retrieves CPUID information.\r
 \r
@@ -7242,7 +9020,109 @@ AsmPrepareAndThunk16 (
   IN OUT  THUNK_CONTEXT             *ThunkContext\r
   );\r
 \r
-#endif\r
-#endif\r
+/**\r
+  Generates a 16-bit random number through RDRAND instruction.\r
+\r
+  if Rand is NULL, then ASSERT().\r
+\r
+  @param[out]  Rand     Buffer pointer to store the random result.\r
+\r
+  @retval TRUE          RDRAND call was successful.\r
+  @retval FALSE         Failed attempts to call RDRAND.\r
+\r
+ **/\r
+BOOLEAN\r
+EFIAPI\r
+AsmRdRand16 (\r
+  OUT     UINT16                    *Rand\r
+  );\r
+\r
+/**\r
+  Generates a 32-bit random number through RDRAND instruction.\r
+\r
+  if Rand is NULL, then ASSERT().\r
+\r
+  @param[out]  Rand     Buffer pointer to store the random result.\r
+\r
+  @retval TRUE          RDRAND call was successful.\r
+  @retval FALSE         Failed attempts to call RDRAND.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AsmRdRand32 (\r
+  OUT     UINT32                    *Rand\r
+  );\r
+\r
+/**\r
+  Generates a 64-bit random number through RDRAND instruction.\r
+\r
+  if Rand is NULL, then ASSERT().\r
+\r
+  @param[out]  Rand     Buffer pointer to store the random result.\r
+\r
+  @retval TRUE          RDRAND call was successful.\r
+  @retval FALSE         Failed attempts to call RDRAND.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+AsmRdRand64  (\r
+  OUT     UINT64                    *Rand\r
+  );\r
+\r
+/**\r
+  Load given selector into TR register.\r
+\r
+  @param[in] Selector     Task segment selector\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmWriteTr (\r
+  IN UINT16 Selector\r
+  );\r
+\r
+/**\r
+  Patch the immediate operand of an IA32 or X64 instruction such that the byte,\r
+  word, dword or qword operand is encoded at the end of the instruction's\r
+  binary representation.\r
+\r
+  This function should be used to update object code that was compiled with\r
+  NASM from assembly source code. Example:\r
+\r
+  NASM source code:\r
+\r
+        mov     eax, strict dword 0 ; the imm32 zero operand will be patched\r
+    ASM_PFX(gPatchCr3):\r
+        mov     cr3, eax\r
 \r
+  C source code:\r
+\r
+    X86_ASSEMBLY_PATCH_LABEL gPatchCr3;\r
+    PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);\r
+\r
+  @param[out] InstructionEnd  Pointer right past the instruction to patch. The\r
+                              immediate operand to patch is expected to\r
+                              comprise the trailing bytes of the instruction.\r
+                              If InstructionEnd is closer to address 0 than\r
+                              ValueSize permits, then ASSERT().\r
+\r
+  @param[in] PatchValue       The constant to write to the immediate operand.\r
+                              The caller is responsible for ensuring that\r
+                              PatchValue can be represented in the byte, word,\r
+                              dword or qword operand (as indicated through\r
+                              ValueSize); otherwise ASSERT().\r
+\r
+  @param[in] ValueSize        The size of the operand in bytes; must be 1, 2,\r
+                              4, or 8. ASSERT() otherwise.\r
+**/\r
+VOID\r
+EFIAPI\r
+PatchInstructionX86 (\r
+  OUT X86_ASSEMBLY_PATCH_LABEL *InstructionEnd,\r
+  IN  UINT64                   PatchValue,\r
+  IN  UINTN                    ValueSize\r
+  );\r
 \r
+#endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
+#endif // !defined (__BASE_LIB__)\r