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
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
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
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
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
+ 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
+RETURN_STATUS\r
+EFIAPI\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
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
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
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
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
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
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
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
\r
#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
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
#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
UINT64 Uint64;\r
} IA32_IDT_GATE_DESCRIPTOR;\r
\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\r
\r
#if defined (MDE_CPU_X64)\r
} Uint128; \r
} IA32_IDT_GATE_DESCRIPTOR;\r
\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\r
\r
///\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
#endif\r
#endif\r
\r