]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/BaseLib.h
MdePkg/BaseLib: Add Base64Encode() and Base64Decode()
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
index 2fae312f2f98a9d28a3c3d6bcf4a861ca85cca1d..9c42f82a7d91366304eda8fb2c8a567bb824980a 100644 (file)
@@ -2,7 +2,7 @@
   Provides string functions, linked list functions, math functions, synchronization\r
   functions, file path functions, and CPU architecture-specific functions.\r
 \r
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2019, 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
@@ -2720,6 +2720,102 @@ AsciiStrnToUnicodeStrS (
   OUT     UINTN                     *DestinationLength\r
   );\r
 \r
+/**\r
+  Convert a Unicode character to upper case only if\r
+  it maps to a valid small-case ASCII character.\r
+\r
+  This internal function only deal with Unicode character\r
+  which maps to a valid small-case ASCII character, i.e.\r
+  L'a' to L'z'. For other Unicode character, the input character\r
+  is returned directly.\r
+\r
+  @param  Char  The character to convert.\r
+\r
+  @retval LowerCharacter   If the Char is with range L'a' to L'z'.\r
+  @retval Unchanged        Otherwise.\r
+\r
+**/\r
+CHAR16\r
+EFIAPI\r
+CharToUpper (\r
+  IN      CHAR16                    Char\r
+  );\r
+\r
+/**\r
+  Converts a lowercase Ascii character to upper one.\r
+\r
+  If Chr is lowercase Ascii character, then converts it to upper one.\r
+\r
+  If Value >= 0xA0, then ASSERT().\r
+  If (Value & 0x0F) >= 0x0A, then ASSERT().\r
+\r
+  @param  Chr   one Ascii character\r
+\r
+  @return The uppercase value of Ascii character\r
+\r
+**/\r
+CHAR8\r
+EFIAPI\r
+AsciiCharToUpper (\r
+  IN      CHAR8                     Chr\r
+  );\r
+\r
+/**\r
+  Convert binary data to a Base64 encoded ascii string based on RFC4648.\r
+\r
+  Produce a Null-terminated Ascii string in the output buffer specified by Destination and DestinationSize.\r
+  The Ascii string is produced by converting the data string specified by Source and SourceLength.\r
+\r
+  @param Source           Input UINT8 data\r
+  @param SourceLength     Number of UINT8 bytes of data\r
+  @param Destination      Pointer to output string buffer\r
+  @param DestinationSize  Size of ascii buffer. Set to 0 to get the size needed.\r
+                          Caller is responsible for passing in buffer of DestinationSize\r
+\r
+  @retval RETURN_SUCCESS             When ascii buffer is filled in.\r
+  @retval RETURN_INVALID_PARAMETER   If Source is NULL or DestinationSize is NULL.\r
+  @retval RETURN_INVALID_PARAMETER   If SourceLength or DestinationSize is bigger than (MAX_ADDRESS - (UINTN)Destination).\r
+  @retval RETURN_BUFFER_TOO_SMALL    If SourceLength is 0 and DestinationSize is <1.\r
+  @retval RETURN_BUFFER_TOO_SMALL    If Destination is NULL or DestinationSize is smaller than required buffersize.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+Base64Encode (\r
+  IN  CONST UINT8  *Source,\r
+  IN        UINTN   SourceLength,\r
+  OUT       CHAR8  *Destination  OPTIONAL,\r
+  IN OUT    UINTN  *DestinationSize\r
+  );\r
+\r
+/**\r
+  Convert Base64 ascii string to binary data based on RFC4648.\r
+\r
+  Produce Null-terminated binary data in the output buffer specified by Destination and DestinationSize.\r
+  The binary data is produced by converting the Base64 ascii string specified by Source and SourceLength.\r
+\r
+  @param Source          Input ASCII characters\r
+  @param SourceLength    Number of ASCII characters\r
+  @param Destination     Pointer to output buffer\r
+  @param DestinationSize Caller is responsible for passing in buffer of at least DestinationSize.\r
+                         Set 0 to get the size needed. Set to bytes stored on return.\r
+\r
+  @retval RETURN_SUCCESS             When binary buffer is filled in.\r
+  @retval RETURN_INVALID_PARAMETER   If Source is NULL or DestinationSize is NULL.\r
+  @retval RETURN_INVALID_PARAMETER   If SourceLength or DestinationSize is bigger than (MAX_ADDRESS -(UINTN)Destination ).\r
+  @retval RETURN_INVALID_PARAMETER   If there is any invalid character in input stream.\r
+  @retval RETURN_BUFFER_TOO_SMALL    If buffer length is smaller than required buffer size.\r
+\r
+ **/\r
+RETURN_STATUS\r
+EFIAPI\r
+Base64Decode (\r
+  IN  CONST CHAR8  *Source,\r
+  IN        UINTN   SourceLength,\r
+  OUT       UINT8  *Destination  OPTIONAL,\r
+  IN OUT    UINTN  *DestinationSize\r
+  );\r
+\r
 /**\r
   Converts an 8-bit value to an 8-bit BCD value.\r
 \r
@@ -5111,6 +5207,21 @@ CpuDeadLoop (
   VOID\r
   );\r
 \r
+\r
+/**\r
+  Uses as a barrier to stop speculative execution.\r
+\r
+  Ensures that no later instruction will execute speculatively, until all prior\r
+  instructions have completed.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+SpeculationBarrier (\r
+  VOID\r
+  );\r
+\r
+\r
 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
 ///\r
 /// IA32 and x64 Specific Functions.\r
@@ -7696,6 +7807,19 @@ AsmWriteTr (
   IN UINT16 Selector\r
   );\r
 \r
+/**\r
+  Performs a serializing operation on all load-from-memory instructions that\r
+  were issued prior the AsmLfence function.\r
+\r
+  Executes a LFENCE instruction. This function is only available on IA-32 and x64.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsmLfence (\r
+  VOID\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