#include <Guid/FileInfo.h>\r
#include <Guid/Gpt.h>\r
\r
+#define IS_HYPHEN(a) ((a) == L'-')\r
+#define IS_NULL(a) ((a) == L'\0')\r
+\r
#define MAX_ARG_NUM 11\r
\r
UINTN Argc;\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Converts a list of string to a specified buffer.\r
+\r
+ @param[out] Buf The output buffer that contains the string.\r
+ @param[in] BufferLength The length of the buffer\r
+ @param[in] Str The input string that contains the hex number\r
+\r
+ @retval EFI_SUCCESS The string was successfully converted to the buffer.\r
+\r
+**/\r
+EFI_STATUS\r
+StrToBuf (\r
+ OUT UINT8 *Buf,\r
+ IN UINTN BufferLength,\r
+ IN CHAR16 *Str\r
+ )\r
+{\r
+ UINTN Index;\r
+ UINTN StrLength;\r
+ UINT8 Digit;\r
+ UINT8 Byte;\r
+\r
+ Digit = 0;\r
+\r
+ //\r
+ // Two hex char make up one byte\r
+ //\r
+ StrLength = BufferLength * sizeof (CHAR16);\r
+\r
+ for(Index = 0; Index < StrLength; Index++, Str++) {\r
+\r
+ if ((*Str >= L'a') && (*Str <= L'f')) {\r
+ Digit = (UINT8) (*Str - L'a' + 0x0A);\r
+ } else if ((*Str >= L'A') && (*Str <= L'F')) {\r
+ Digit = (UINT8) (*Str - L'A' + 0x0A);\r
+ } else if ((*Str >= L'0') && (*Str <= L'9')) {\r
+ Digit = (UINT8) (*Str - L'0');\r
+ } else {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ //\r
+ // For odd characters, write the upper nibble for each buffer byte,\r
+ // and for even characters, the lower nibble.\r
+ //\r
+ if ((Index & 1) == 0) {\r
+ Byte = (UINT8) (Digit << 4);\r
+ } else {\r
+ Byte = Buf[Index / 2];\r
+ Byte &= 0xF0;\r
+ Byte = (UINT8) (Byte | Digit);\r
+ }\r
+\r
+ Buf[Index / 2] = Byte;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Converts a string to GUID value.\r
+ Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r
+\r
+ @param[in] Str The registry format GUID string that contains the GUID value.\r
+ @param[out] Guid A pointer to the converted GUID value.\r
+\r
+ @retval EFI_SUCCESS The GUID string was successfully converted to the GUID value.\r
+ @retval EFI_UNSUPPORTED The input string is not in registry format.\r
+ @return others Some error occurred when converting part of GUID value.\r
+\r
+**/\r
+EFI_STATUS\r
+StrToGuid (\r
+ IN CHAR16 *Str,\r
+ OUT EFI_GUID *Guid\r
+ )\r
+{\r
+ //\r
+ // Get the first UINT32 data\r
+ //\r
+ Guid->Data1 = (UINT32) StrHexToUint64 (Str);\r
+ while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
+ Str ++;\r
+ }\r
+\r
+ if (IS_HYPHEN (*Str)) {\r
+ Str++;\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Get the second UINT16 data\r
+ //\r
+ Guid->Data2 = (UINT16) StrHexToUint64 (Str);\r
+ while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
+ Str ++;\r
+ }\r
+\r
+ if (IS_HYPHEN (*Str)) {\r
+ Str++;\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Get the third UINT16 data\r
+ //\r
+ Guid->Data3 = (UINT16) StrHexToUint64 (Str);\r
+ while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {\r
+ Str ++;\r
+ }\r
+\r
+ if (IS_HYPHEN (*Str)) {\r
+ Str++;\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+\r
+ //\r
+ // Get the following 8 bytes data\r
+ //\r
+ StrToBuf (&Guid->Data4[0], 2, Str);\r
+ //\r
+ // Skip 2 byte hex chars\r
+ //\r
+ Str += 2 * 2;\r
+\r
+ if (IS_HYPHEN (*Str)) {\r
+ Str++;\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ StrToBuf (&Guid->Data4[2], 6, Str);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
/**\r
Return File System Volume containing this shell application.\r
\r