X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FDevicePathDxe%2FDevicePathFromText.c;h=f7e7cdfcfb612cb3daa22a0fd0345940f17e7abe;hb=3069bc194422eea310b17effd6700f6e0b5b58e8;hp=94a4a2b5b7127335b9117402823762a10d44ac55;hpb=859b72fa7e3ff1cf1d7476a3446af4ebbb5fe3e6;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c index 94a4a2b5b7..f7e7cdfcfb 100644 --- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c +++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c @@ -1,74 +1,53 @@ -/*++ +/** @file + DevicePathFromText protocol as defined in the UEFI 2.0 specification. -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2008, Intel Corporation.
+All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php -Module Name: +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - DevicePathFromText.c +**/ -Abstract: +#include "DevicePath.h" - DevicePathFromText protocol as defined in the UEFI 2.0 specification. ---*/ +/** -#include "DevicePath.h" + Duplicates a string. -STATIC + @param Src Source string. + + @return The duplicated string. + +**/ CHAR16 * StrDuplicate ( IN CONST CHAR16 *Src ) -/*++ - - Routine Description: - Duplicate a string - - Arguments: - Src - Source string - - Returns: - Duplicated string - ---*/ { - UINTN Length; - CHAR16 *ReturnStr; + return AllocateCopyPool (StrSize (Src), Src); +} - Length = StrLen ((CHAR16 *) Src); +/** - ReturnStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), (VOID *) Src); + Get parameter in a pair of parentheses follow the given node name. + For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1". - return ReturnStr; -} + @param Str Device Path Text. + @param NodeName Name of the node. + + @return Parameter text for the node. -STATIC +**/ CHAR16 * GetParamByNodeName ( IN CHAR16 *Str, IN CHAR16 *NodeName ) -/*++ - - Routine Description: - Get parameter in a pair of parentheses follow the given node name. - For example, given the "Pci(0,1)" and NodeName "Pci", it returns "0,1". - - Arguments: - Str - Device Path Text - NodeName - Name of the node - - Returns: - Parameter text for the node - ---*/ { CHAR16 *ParamStr; CHAR16 *StrPointer; @@ -120,28 +99,23 @@ GetParamByNodeName ( return ParamStr; } -STATIC +/** + Gets current sub-string from a string list, before return + the list header is moved to next sub-string. The sub-string is separated + by the specified character. For example, the separator is ',', the string + list is "2,0,3", it returns "2", the remain list move to "0,3" + + @param List A string list separated by the specified separator + @param Separator The separator character + + @return A pointer to the current sub-string + +**/ CHAR16 * SplitStr ( IN OUT CHAR16 **List, IN CHAR16 Separator ) -/*++ - - Routine Description: - Get current sub-string from a string list, before return - the list header is moved to next sub-string. The sub-string is separated - by the specified character. For example, the separator is ',', the string - list is "2,0,3", it returns "2", the remain list move to "2,3" - - Arguments: - List - A string list separated by the specified separator - Separator - The separator character - - Returns: - pointer - The current sub-string - ---*/ { CHAR16 *Str; CHAR16 *ReturnStr; @@ -179,7 +153,14 @@ SplitStr ( return ReturnStr; } -STATIC +/** + Gets the next parameter string from the list. + + @param List A string list separated by the specified separator + + @return A pointer to the current sub-string + +**/ CHAR16 * GetNextParamStr ( IN OUT CHAR16 **List @@ -191,26 +172,20 @@ GetNextParamStr ( return SplitStr (List, L','); } -STATIC +/** + Get one device node from entire device path text. + + @param DevicePath On input, the current Device Path node; on output, the next device path node + @param IsInstanceEnd This node is the end of a device path instance + + @return A device node text or NULL if no more device node available + +**/ CHAR16 * GetNextDeviceNodeStr ( IN OUT CHAR16 **DevicePath, OUT BOOLEAN *IsInstanceEnd ) -/*++ - - Routine Description: - Get one device node from entire device path text. - - Arguments: - Str - The entire device path text string - IsInstanceEnd - This node is the end of a device path instance - - Returns: - a pointer - A device node text - NULL - No more device node available - ---*/ { CHAR16 *Str; CHAR16 *ReturnStr; @@ -278,273 +253,116 @@ GetNextDeviceNodeStr ( return ReturnStr; } -STATIC -BOOLEAN -IsHexDigit ( - OUT UINT8 *Digit, - IN CHAR16 Char - ) -/*++ - - Routine Description: - Determines if a Unicode character is a hexadecimal digit. - The test is case insensitive. - - Arguments: - Digit - Pointer to byte that receives the value of the hex character. - Char - Unicode character to test. - - Returns: - TRUE - If the character is a hexadecimal digit. - FALSE - Otherwise. - ---*/ -{ - if ((Char >= L'0') && (Char <= L'9')) { - *Digit = (UINT8) (Char - L'0'); - return TRUE; - } - - if ((Char >= L'A') && (Char <= L'F')) { - *Digit = (UINT8) (Char - L'A' + 0x0A); - return TRUE; - } - - if ((Char >= L'a') && (Char <= L'f')) { - *Digit = (UINT8) (Char - L'a' + 0x0A); - return TRUE; - } - - return FALSE; -} - -STATIC -EFI_STATUS -HexStringToBuf ( - IN OUT UINT8 *Buf, - IN OUT UINTN *Len, - IN CHAR16 *Str, - OUT UINTN *ConvertedStrLen OPTIONAL - ) -/*++ - - Routine Description: - Converts Unicode string to binary buffer. - The conversion may be partial. - The first character in the string that is not hex digit stops the conversion. - At a minimum, any blob of data could be represented as a hex string. - - Arguments: - Buf - Pointer to buffer that receives the data. - Len - Length in bytes of the buffer to hold converted data. - If routine return with EFI_SUCCESS, containing length of converted data. - If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired. - Str - String to be converted from. - ConvertedStrLen - Length of the Hex String consumed. - - Returns: - EFI_SUCCESS: Routine Success. - EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data. - EFI_ - ---*/ -{ - UINTN HexCnt; - UINTN Idx; - UINTN BufferLength; - UINT8 Digit; - UINT8 Byte; - - // - // Find out how many hex characters the string has. - // - for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++); - - if (HexCnt == 0) { - *Len = 0; - return EFI_SUCCESS; - } - // - // Two Unicode characters make up 1 buffer byte. Round up. - // - BufferLength = (HexCnt + 1) / 2; - - // - // Test if buffer is passed enough. - // - if (BufferLength > (*Len)) { - *Len = BufferLength; - return EFI_BUFFER_TOO_SMALL; - } - - *Len = BufferLength; - for (Idx = 0; Idx < HexCnt; Idx++) { +/** + Skip the leading white space and '0x' or '0X' of a integer string - IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]); + @param Str The integer string + @param IsHex TRUE: Hex string, FALSE: Decimal string - // - // For odd charaters, write the lower nibble for each buffer byte, - // and for even characters, the upper nibble. - // - if ((Idx & 1) == 0) { - Byte = Digit; - } else { - Byte = Buf[Idx / 2]; - Byte &= 0x0F; - Byte = (UINT8) (Byte | Digit << 4); - } - - Buf[Idx / 2] = Byte; - } - - if (ConvertedStrLen != NULL) { - *ConvertedStrLen = HexCnt; - } - - return EFI_SUCCESS; -} + @return The trimmed Hex string. -STATIC +**/ CHAR16 * TrimHexStr ( - IN CHAR16 *Str + IN CHAR16 *Str, + OUT BOOLEAN *IsHex ) -/*++ - - Routine Description: - Skip the leading white space and '0x' or '0X' of a hex string - - Arguments: - Str - The hex string - - Returns: - ---*/ { + *IsHex = FALSE; + // // skip preceeding white space // - while (*Str && *Str == ' ') { + while ((*Str != 0) && *Str == ' ') { Str += 1; } // // skip preceeding zeros // - while (*Str && *Str == '0') { + while ((*Str != 0) && *Str == '0') { Str += 1; } // // skip preceeding character 'x' or 'X' // - if (*Str && (*Str == 'x' || *Str == 'X')) { + if ((*Str != 0) && (*Str == 'x' || *Str == 'X')) { Str += 1; + *IsHex = TRUE; } return Str; } -STATIC -UINTN -Xtoi ( - IN CHAR16 *Str - ) -/*++ +/** -Routine Description: + Convert hex string to uint. - Convert hex string to uint + @param Str The hex string -Arguments: + @return A UINTN value represented by Str - Str - The string - -Returns: - ---*/ +**/ +UINTN +Xtoi ( + IN CHAR16 *Str + ) { - UINTN Rvalue; - UINTN Length; + return StrHexToUintn (Str); +} - ASSERT (Str != NULL); +/** - // - // convert hex digits - // - Rvalue = 0; - Length = sizeof (UINTN); - HexStringToBuf ((UINT8 *) &Rvalue, &Length, TrimHexStr (Str), NULL); + Convert hex string to 64 bit data. - return Rvalue; -} + @param Str The hex string + @param Data A pointer to the UINT64 value represented by Str -STATIC +**/ VOID Xtoi64 ( - IN CHAR16 *Str, - IN UINT64 *Data + IN CHAR16 *Str, + OUT UINT64 *Data ) -/*++ - -Routine Description: - - Convert hex string to 64 bit data. - -Arguments: - - Str - The string - -Returns: - ---*/ { - UINTN Length; - - *Data = 0; - Length = sizeof (UINT64); - HexStringToBuf ((UINT8 *) Data, &Length, TrimHexStr (Str), NULL); + *Data = StrHexToUint64 (Str); } -STATIC -UINTN -Atoi ( - IN CHAR16 *str - ) -/*++ +/** -Routine Description: + Convert decimal string to uint. - Convert decimal string to uint + @param Str The decimal string -Arguments: + @return A UINTN value represented by Str - Str - The string - -Returns: - ---*/ +**/ +UINTN +Dtoi ( + IN CHAR16 *Str + ) { UINTN Rvalue; CHAR16 Char; UINTN High; UINTN Low; - ASSERT (str != NULL); + ASSERT (Str != NULL); High = (UINTN) -1 / 10; Low = (UINTN) -1 % 10; // // skip preceeding white space // - while (*str && *str == ' ') { - str += 1; + while ((*Str != 0) && *Str == ' ') { + Str += 1; } // // convert digits // Rvalue = 0; - Char = *(str++); - while (Char) { + Char = *(Str++); + while (Char != 0) { if (Char >= '0' && Char <= '9') { if ((Rvalue > High || Rvalue == High) && (Char - '0' > (INTN) Low)) { return (UINTN) -1; @@ -555,14 +373,121 @@ Returns: break; } - Char = *(str++); + Char = *(Str++); } return Rvalue; } -STATIC -EFI_STATUS +/** + + Convert decimal string to uint. + + @param Str The decimal string + @param Data A pointer to the UINT64 value represented by Str + +**/ +VOID +Dtoi64 ( + IN CHAR16 *Str, + OUT UINT64 *Data + ) +{ + UINT64 Rvalue; + CHAR16 Char; + UINT64 High; + UINT64 Low; + + ASSERT (Str != NULL); + ASSERT (Data != NULL); + + // + // skip preceeding white space + // + while ((*Str != 0) && *Str == ' ') { + Str += 1; + } + // + // convert digits + // + Rvalue = 0; + Char = *(Str++); + while (Char != 0) { + if (Char >= '0' && Char <= '9') { + High = LShiftU64 (Rvalue, 3); + Low = LShiftU64 (Rvalue, 1); + Rvalue = High + Low + Char - '0'; + } else { + break; + } + + Char = *(Str++); + } + + *Data = Rvalue; +} + +/** + + Convert integer string to uint. + + @param Str The integer string. If leading with "0x" or "0X", it's heximal. + + @return A UINTN value represented by Str + +**/ +UINTN +Strtoi ( + IN CHAR16 *Str + ) +{ + BOOLEAN IsHex; + + Str = TrimHexStr (Str, &IsHex); + + if (IsHex) { + return Xtoi (Str); + } else { + return Dtoi (Str); + } +} + +/** + + Convert integer string to 64 bit data. + + @param Str The integer string. If leading with "0x" or "0X", it's heximal. + @param Data A pointer to the UINT64 value represented by Str + +**/ +VOID +Strtoi64 ( + IN CHAR16 *Str, + OUT UINT64 *Data + ) +{ + BOOLEAN IsHex; + + Str = TrimHexStr (Str, &IsHex); + + if (IsHex) { + Xtoi64 (Str, Data); + } else { + Dtoi64 (Str, Data); + } +} + +/** + Converts a list of string to a specified buffer. + + @param Buf The output buffer that contains the string. + @param BufferLength The length of the buffer + @param Str The input string that contains the hex number + + @retval EFI_SUCCESS The string was successfully converted to the buffer. + +**/ +EFI_STATUS StrToBuf ( OUT UINT8 *Buf, IN UINTN BufferLength, @@ -574,6 +499,8 @@ StrToBuf ( UINT8 Digit; UINT8 Byte; + Digit = 0; + // // Two hex char make up one byte // @@ -581,7 +508,15 @@ StrToBuf ( for(Index = 0; Index < StrLength; Index++, Str++) { - IsHexDigit (&Digit, *Str); + if ((*Str >= L'a') && (*Str <= L'f')) { + Digit = (UINT8) (*Str - L'a' + 0x0A); + } else if ((*Str >= L'A') && (*Str <= L'F')) { + Digit = (UINT8) (*Str - L'A' + 0x0A); + } else if ((*Str >= L'0') && (*Str <= L'9')) { + Digit = (UINT8) (*Str - L'0'); + } else { + return EFI_INVALID_PARAMETER; + } // // For odd charaters, write the upper nibble for each buffer byte, @@ -601,53 +536,69 @@ StrToBuf ( return EFI_SUCCESS; } -STATIC +/** + Converts a string to GUID value. + Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + + @param Str The registry format GUID string that contains the GUID value. + @param Guid A pointer to the converted GUID value. + + @retval EFI_SUCCESS The GUID string was successfully converted to the GUID value. + @retval EFI_UNSUPPORTED The input string is not in registry format. + @return others Some error occurred when converting part of GUID value. + +**/ EFI_STATUS StrToGuid ( IN CHAR16 *Str, OUT EFI_GUID *Guid ) { - UINTN BufferLength; - UINTN ConvertedStrLen; - EFI_STATUS Status; - - BufferLength = sizeof (Guid->Data1); - Status = HexStringToBuf ((UINT8 *) &Guid->Data1, &BufferLength, Str, &ConvertedStrLen); - if (EFI_ERROR (Status)) { - return Status; + // + // Get the first UINT32 data + // + Guid->Data1 = (UINT32) StrHexToUint64 (Str); + while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) { + Str ++; } - Str += ConvertedStrLen; + if (IS_HYPHEN (*Str)) { - Str++; + Str++; } else { return EFI_UNSUPPORTED; } - - BufferLength = sizeof (Guid->Data2); - Status = HexStringToBuf ((UINT8 *) &Guid->Data2, &BufferLength, Str, &ConvertedStrLen); - if (EFI_ERROR (Status)) { - return Status; + + // + // Get the second UINT16 data + // + Guid->Data2 = (UINT16) StrHexToUint64 (Str); + while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) { + Str ++; } - Str += ConvertedStrLen; + if (IS_HYPHEN (*Str)) { Str++; } else { return EFI_UNSUPPORTED; } - - BufferLength = sizeof (Guid->Data3); - Status = HexStringToBuf ((UINT8 *) &Guid->Data3, &BufferLength, Str, &ConvertedStrLen); - if (EFI_ERROR (Status)) { - return Status; + + // + // Get the third UINT16 data + // + Guid->Data3 = (UINT16) StrHexToUint64 (Str); + while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) { + Str ++; } - Str += ConvertedStrLen; + if (IS_HYPHEN (*Str)) { Str++; } else { return EFI_UNSUPPORTED; } + // + // Get the followin 8 bytes data + // StrToBuf (&Guid->Data4[0], 2, Str); // // Skip 2 byte hex chars @@ -664,7 +615,13 @@ StrToGuid ( return EFI_SUCCESS; } -STATIC +/** + Converts a string to IPv4 address + + @param Str A string representation of IPv4 address. + @param IPv4Addr A pointer to the converted IPv4 address. + +**/ VOID StrToIPv4Addr ( IN OUT CHAR16 **Str, @@ -674,11 +631,17 @@ StrToIPv4Addr ( UINTN Index; for (Index = 0; Index < 4; Index++) { - IPv4Addr->Addr[Index] = (UINT8) Atoi (SplitStr (Str, L'.')); + IPv4Addr->Addr[Index] = (UINT8) Dtoi (SplitStr (Str, L'.')); } } -STATIC +/** + Converts a string to IPv4 address + + @param Str A string representation of IPv6 address. + @param IPv6Addr A pointer to the converted IPv6 address. + +**/ VOID StrToIPv6Addr ( IN OUT CHAR16 **Str, @@ -695,7 +658,14 @@ StrToIPv6Addr ( } } -STATIC +/** + Converts a Unicode string to ASCII string. + + @param Str The equiventant Unicode string + @param AsciiStr On input, it points to destination ASCII string buffer; on output, it points + to the next ASCII string next to it + +**/ VOID StrToAscii ( IN CHAR16 *Str, @@ -716,7 +686,14 @@ StrToAscii ( *AsciiStr = Dest + 1; } -STATIC +/** + Converts a text device path node to Hardware PCI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to Hardware PCI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextPci ( IN CHAR16 *TextDeviceNode @@ -726,21 +703,28 @@ DevPathFromTextPci ( CHAR16 *DeviceStr; PCI_DEVICE_PATH *Pci; - FunctionStr = GetNextParamStr (&TextDeviceNode); DeviceStr = GetNextParamStr (&TextDeviceNode); + FunctionStr = GetNextParamStr (&TextDeviceNode); Pci = (PCI_DEVICE_PATH *) CreateDeviceNode ( HARDWARE_DEVICE_PATH, HW_PCI_DP, sizeof (PCI_DEVICE_PATH) ); - Pci->Function = (UINT8) Xtoi (FunctionStr); - Pci->Device = (UINT8) Xtoi (DeviceStr); + Pci->Function = (UINT8) Strtoi (FunctionStr); + Pci->Device = (UINT8) Strtoi (DeviceStr); return (EFI_DEVICE_PATH_PROTOCOL *) Pci; } -STATIC +/** + Converts a text device path node to Hardware PC card device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to Hardware PC card device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextPcCard ( IN CHAR16 *TextDeviceNode @@ -756,21 +740,30 @@ DevPathFromTextPcCard ( sizeof (PCCARD_DEVICE_PATH) ); - Pccard->FunctionNumber = (UINT8) Xtoi (FunctionNumberStr); + Pccard->FunctionNumber = (UINT8) Strtoi (FunctionNumberStr); return (EFI_DEVICE_PATH_PROTOCOL *) Pccard; } -STATIC +/** + Converts a text device path node to Hardware memory map device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to Hardware memory map device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextMemoryMapped ( IN CHAR16 *TextDeviceNode ) { + CHAR16 *MemoryTypeStr; CHAR16 *StartingAddressStr; CHAR16 *EndingAddressStr; MEMMAP_DEVICE_PATH *MemMap; + MemoryTypeStr = GetNextParamStr (&TextDeviceNode); StartingAddressStr = GetNextParamStr (&TextDeviceNode); EndingAddressStr = GetNextParamStr (&TextDeviceNode); MemMap = (MEMMAP_DEVICE_PATH *) CreateDeviceNode ( @@ -779,15 +772,24 @@ DevPathFromTextMemoryMapped ( sizeof (MEMMAP_DEVICE_PATH) ); - MemMap->MemoryType = 0; - - Xtoi64 (StartingAddressStr, &MemMap->StartingAddress); - Xtoi64 (EndingAddressStr, &MemMap->EndingAddress); + MemMap->MemoryType = (UINT32) Strtoi (MemoryTypeStr); + Strtoi64 (StartingAddressStr, &MemMap->StartingAddress); + Strtoi64 (EndingAddressStr, &MemMap->EndingAddress); return (EFI_DEVICE_PATH_PROTOCOL *) MemMap; } -STATIC +/** + Converts a text device path node to Vendor device path structure based on the input Type + and SubType. + + @param TextDeviceNode The input Text device path node. + @param Type The type of device path node. + @param SubType The subtype of device path node. + + @return A pointer to the newly-created Vendor device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * ConvertFromTextVendor ( IN CHAR16 *TextDeviceNode, @@ -812,7 +814,7 @@ ConvertFromTextVendor ( Vendor = (VENDOR_DEVICE_PATH *) CreateDeviceNode ( Type, SubType, - sizeof (VENDOR_DEVICE_PATH) + (UINT16) Length + (UINT16) (sizeof (VENDOR_DEVICE_PATH) + Length) ); StrToGuid (GuidStr, &Vendor->Guid); @@ -821,7 +823,14 @@ ConvertFromTextVendor ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to Vendor Hardware device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor Hardware device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenHw ( IN CHAR16 *TextDeviceNode @@ -834,7 +843,14 @@ DevPathFromTextVenHw ( ); } -STATIC +/** + Converts a text device path node to Hardware Controller device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Hardware Controller device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextCtrl ( IN CHAR16 *TextDeviceNode @@ -849,12 +865,41 @@ DevPathFromTextCtrl ( HW_CONTROLLER_DP, sizeof (CONTROLLER_DEVICE_PATH) ); - Controller->ControllerNumber = (UINT32) Xtoi (ControllerStr); + Controller->ControllerNumber = (UINT32) Strtoi (ControllerStr); return (EFI_DEVICE_PATH_PROTOCOL *) Controller; } -STATIC +/** + Converts a string to EisaId. + + @param Text The input string. + @param EisaId A pointer to the output EisaId. + +**/ +VOID +EisaIdFromText ( + IN CHAR16 *Text, + OUT UINT32 *EisaId + ) +{ + UINTN PnpId; + + PnpId = Xtoi (Text + 3); + *EisaId = (((Text[0] - '@') & 0x1f) << 10) + + (((Text[1] - '@') & 0x1f) << 5) + + ((Text[2] - '@') & 0x1f) + + (UINT32) (PnpId << 16); +} + +/** + Converts a text device path node to ACPI HID device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created ACPI HID device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextAcpi ( IN CHAR16 *TextDeviceNode @@ -872,21 +917,25 @@ DevPathFromTextAcpi ( sizeof (ACPI_HID_DEVICE_PATH) ); - if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) { - HIDStr += 3; - } - - Acpi->HID = EISA_PNP_ID (Xtoi (HIDStr)); - Acpi->UID = (UINT32) Xtoi (UIDStr); + EisaIdFromText (HIDStr, &Acpi->HID); + Acpi->UID = (UINT32) Strtoi (UIDStr); return (EFI_DEVICE_PATH_PROTOCOL *) Acpi; } -STATIC +/** + Converts a text device path node to ACPI HID device path structure. + + @param TextDeviceNode The input Text device path node. + @param PnPId The input plug and play identification. + + @return A pointer to the newly-created ACPI HID device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * ConvertFromTextAcpi ( IN CHAR16 *TextDeviceNode, - IN UINT32 Hid + IN UINT32 PnPId ) { CHAR16 *UIDStr; @@ -899,72 +948,114 @@ ConvertFromTextAcpi ( sizeof (ACPI_HID_DEVICE_PATH) ); - Acpi->HID = Hid; - Acpi->UID = (UINT32) Xtoi (UIDStr); + Acpi->HID = EFI_PNP_ID (PnPId); + Acpi->UID = (UINT32) Strtoi (UIDStr); return (EFI_DEVICE_PATH_PROTOCOL *) Acpi; } -STATIC +/** + Converts a text device path node to PCI root device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created PCI root device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextPciRoot ( IN CHAR16 *TextDeviceNode ) { - return ConvertFromTextAcpi (TextDeviceNode, 0x0a0341d0); + return ConvertFromTextAcpi (TextDeviceNode, 0x0a03); } -STATIC +/** + Converts a text device path node to Floppy device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Floppy device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextFloppy ( IN CHAR16 *TextDeviceNode ) { - return ConvertFromTextAcpi (TextDeviceNode, 0x060441d0); + return ConvertFromTextAcpi (TextDeviceNode, 0x0604); } -STATIC +/** + Converts a text device path node to Keyboard device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Keyboard device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextKeyboard ( IN CHAR16 *TextDeviceNode ) { - return ConvertFromTextAcpi (TextDeviceNode, 0x030141d0); + return ConvertFromTextAcpi (TextDeviceNode, 0x0301); } -STATIC +/** + Converts a text device path node to Serial device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Serial device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextSerial ( IN CHAR16 *TextDeviceNode ) { - return ConvertFromTextAcpi (TextDeviceNode, 0x050141d0); + return ConvertFromTextAcpi (TextDeviceNode, 0x0501); } -STATIC +/** + Converts a text device path node to Parallel Port device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Parallel Port device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextParallelPort ( IN CHAR16 *TextDeviceNode ) { - return ConvertFromTextAcpi (TextDeviceNode, 0x040141d0); + return ConvertFromTextAcpi (TextDeviceNode, 0x0401); } -STATIC +/** + Converts a text device path node to ACPI extention device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created ACPI extention device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextAcpiEx ( IN CHAR16 *TextDeviceNode ) { - CHAR16 *HIDStr; - CHAR16 *CIDStr; - CHAR16 *UIDStr; - CHAR16 *HIDSTRStr; - CHAR16 *CIDSTRStr; - CHAR16 *UIDSTRStr; - CHAR8 *AsciiStr; - UINT16 Length; - ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt; + CHAR16 *HIDStr; + CHAR16 *CIDStr; + CHAR16 *UIDStr; + CHAR16 *HIDSTRStr; + CHAR16 *CIDSTRStr; + CHAR16 *UIDSTRStr; + CHAR8 *AsciiStr; + UINT16 Length; + ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx; HIDStr = GetNextParamStr (&TextDeviceNode); CIDStr = GetNextParamStr (&TextDeviceNode); @@ -976,68 +1067,63 @@ DevPathFromTextAcpiEx ( Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (HIDSTRStr) + 1); Length = (UINT16) (Length + StrLen (UIDSTRStr) + 1); Length = (UINT16) (Length + StrLen (CIDSTRStr) + 1); - AcpiExt = (ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *) CreateDeviceNode ( - ACPI_DEVICE_PATH, - ACPI_EXTENDED_DP, - Length - ); - - if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) { - HIDStr += 3; - AcpiExt->HID = EISA_PNP_ID (Xtoi (HIDStr)); - } else { - AcpiExt->HID = (UINT32) Xtoi (HIDStr); - } + AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode ( + ACPI_DEVICE_PATH, + ACPI_EXTENDED_DP, + Length + ); - AcpiExt->UID = (UINT32) Xtoi (UIDStr); - AcpiExt->CID = (UINT32) Xtoi (CIDStr); + EisaIdFromText (HIDStr, &AcpiEx->HID); + EisaIdFromText (CIDStr, &AcpiEx->CID); + AcpiEx->UID = (UINT32) Strtoi (UIDStr); - AsciiStr = AcpiExt->HidUidCidStr; + AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH)); StrToAscii (HIDSTRStr, &AsciiStr); StrToAscii (UIDSTRStr, &AsciiStr); StrToAscii (CIDSTRStr, &AsciiStr); - - return (EFI_DEVICE_PATH_PROTOCOL *) AcpiExt; + + return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx; } -STATIC +/** + Converts a text device path node to ACPI extention device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created ACPI extention device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextAcpiExp ( IN CHAR16 *TextDeviceNode ) { - CHAR16 *HIDStr; - CHAR16 *CIDStr; - CHAR16 *UIDSTRStr; - CHAR8 *AsciiStr; - UINT16 Length; - ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *AcpiExt; + CHAR16 *HIDStr; + CHAR16 *CIDStr; + CHAR16 *UIDSTRStr; + CHAR8 *AsciiStr; + UINT16 Length; + ACPI_EXTENDED_HID_DEVICE_PATH *AcpiEx; HIDStr = GetNextParamStr (&TextDeviceNode); CIDStr = GetNextParamStr (&TextDeviceNode); UIDSTRStr = GetNextParamStr (&TextDeviceNode); - Length = sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + (UINT16) StrLen (UIDSTRStr) + 3; - AcpiExt = (ACPI_EXTENDED_HID_DEVICE_PATH_WITH_STR *) CreateDeviceNode ( - ACPI_DEVICE_PATH, - ACPI_EXTENDED_DP, - Length - ); - - if ((HIDStr[0] == L'P') && (HIDStr[1] == L'N') && (HIDStr[2] == L'P')) { - HIDStr += 3; - AcpiExt->HID = EISA_PNP_ID (Xtoi (HIDStr)); - } else { - AcpiExt->HID = (UINT32) Xtoi (HIDStr); - } + Length = (UINT16) (sizeof (ACPI_EXTENDED_HID_DEVICE_PATH) + StrLen (UIDSTRStr) + 3); + AcpiEx = (ACPI_EXTENDED_HID_DEVICE_PATH *) CreateDeviceNode ( + ACPI_DEVICE_PATH, + ACPI_EXTENDED_DP, + Length + ); - AcpiExt->UID = 0; - AcpiExt->CID = (UINT32) Xtoi (CIDStr); + EisaIdFromText (HIDStr, &AcpiEx->HID); + EisaIdFromText (CIDStr, &AcpiEx->CID); + AcpiEx->UID = 0; - AsciiStr = AcpiExt->HidUidCidStr; + AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH)); // // HID string is NULL // - *AsciiStr = 0; + *AsciiStr = '\0'; // // Convert UID string // @@ -1046,12 +1132,19 @@ DevPathFromTextAcpiExp ( // // CID string is NULL // - *AsciiStr = 0; + *AsciiStr = '\0'; - return (EFI_DEVICE_PATH_PROTOCOL *) AcpiExt; + return (EFI_DEVICE_PATH_PROTOCOL *) AcpiEx; } -STATIC +/** + Converts a text device path node to Parallel Port device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Parallel Port device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextAta ( IN CHAR16 *TextDeviceNode @@ -1074,12 +1167,19 @@ DevPathFromTextAta ( Atapi->PrimarySecondary = (UINT8) ((StrCmp (PrimarySecondaryStr, L"Primary") == 0) ? 0 : 1); Atapi->SlaveMaster = (UINT8) ((StrCmp (SlaveMasterStr, L"Master") == 0) ? 0 : 1); - Atapi->Lun = (UINT16) Xtoi (LunStr); + Atapi->Lun = (UINT16) Strtoi (LunStr); return (EFI_DEVICE_PATH_PROTOCOL *) Atapi; } -STATIC +/** + Converts a text device path node to SCSI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created SCSI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextScsi ( IN CHAR16 *TextDeviceNode @@ -1097,13 +1197,20 @@ DevPathFromTextScsi ( sizeof (SCSI_DEVICE_PATH) ); - Scsi->Pun = (UINT16) Xtoi (PunStr); - Scsi->Lun = (UINT16) Xtoi (LunStr); + Scsi->Pun = (UINT16) Strtoi (PunStr); + Scsi->Lun = (UINT16) Strtoi (LunStr); return (EFI_DEVICE_PATH_PROTOCOL *) Scsi; } -STATIC +/** + Converts a text device path node to Fibre device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Fibre device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextFibre ( IN CHAR16 *TextDeviceNode @@ -1122,35 +1229,49 @@ DevPathFromTextFibre ( ); Fibre->Reserved = 0; - Xtoi64 (WWNStr, &Fibre->WWN); - Xtoi64 (LunStr, &Fibre->Lun); + Strtoi64 (WWNStr, &Fibre->WWN); + Strtoi64 (LunStr, &Fibre->Lun); return (EFI_DEVICE_PATH_PROTOCOL *) Fibre; } -STATIC +/** + Converts a text device path node to 1394 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created 1394 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromText1394 ( IN CHAR16 *TextDeviceNode ) { CHAR16 *GuidStr; - F1394_DEVICE_PATH *F1394; + F1394_DEVICE_PATH *F1394DevPath; GuidStr = GetNextParamStr (&TextDeviceNode); - F1394 = (F1394_DEVICE_PATH *) CreateDeviceNode ( - MESSAGING_DEVICE_PATH, - MSG_1394_DP, - sizeof (F1394_DEVICE_PATH) - ); + F1394DevPath = (F1394_DEVICE_PATH *) CreateDeviceNode ( + MESSAGING_DEVICE_PATH, + MSG_1394_DP, + sizeof (F1394_DEVICE_PATH) + ); - F1394->Reserved = 0; - Xtoi64 (GuidStr, &F1394->Guid); + F1394DevPath->Reserved = 0; + Xtoi64 (GuidStr, &F1394DevPath->Guid); - return (EFI_DEVICE_PATH_PROTOCOL *) F1394; + return (EFI_DEVICE_PATH_PROTOCOL *) F1394DevPath; } -STATIC +/** + Converts a text device path node to USB device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsb ( IN CHAR16 *TextDeviceNode @@ -1168,34 +1289,48 @@ DevPathFromTextUsb ( sizeof (USB_DEVICE_PATH) ); - Usb->ParentPortNumber = (UINT8) Xtoi (PortStr); - Usb->InterfaceNumber = (UINT8) Xtoi (InterfaceStr); + Usb->ParentPortNumber = (UINT8) Strtoi (PortStr); + Usb->InterfaceNumber = (UINT8) Strtoi (InterfaceStr); return (EFI_DEVICE_PATH_PROTOCOL *) Usb; } -STATIC +/** + Converts a text device path node to I20 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created I20 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextI2O ( IN CHAR16 *TextDeviceNode ) { CHAR16 *TIDStr; - I2O_DEVICE_PATH *I2O; + I2O_DEVICE_PATH *I2ODevPath; - TIDStr = GetNextParamStr (&TextDeviceNode); - I2O = (I2O_DEVICE_PATH *) CreateDeviceNode ( + TIDStr = GetNextParamStr (&TextDeviceNode); + I2ODevPath = (I2O_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_I2O_DP, sizeof (I2O_DEVICE_PATH) ); - I2O->Tid = (UINT32) Xtoi (TIDStr); + I2ODevPath->Tid = (UINT32) Strtoi (TIDStr); - return (EFI_DEVICE_PATH_PROTOCOL *) I2O; + return (EFI_DEVICE_PATH_PROTOCOL *) I2ODevPath; } -STATIC +/** + Converts a text device path node to Infini Band device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Infini Band device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextInfiniband ( IN CHAR16 *TextDeviceNode @@ -1220,17 +1355,24 @@ DevPathFromTextInfiniband ( sizeof (INFINIBAND_DEVICE_PATH) ); - InfiniBand->ResourceFlags = (UINT32) Xtoi (FlagsStr); + InfiniBand->ResourceFlags = (UINT32) Strtoi (FlagsStr); StrToGuid (GuidStr, &PortGid); CopyMem (InfiniBand->PortGid, &PortGid, sizeof (EFI_GUID)); - Xtoi64 (SidStr, &InfiniBand->ServiceId); - Xtoi64 (TidStr, &InfiniBand->TargetPortId); - Xtoi64 (DidStr, &InfiniBand->DeviceId); + Strtoi64 (SidStr, &InfiniBand->ServiceId); + Strtoi64 (TidStr, &InfiniBand->TargetPortId); + Strtoi64 (DidStr, &InfiniBand->DeviceId); return (EFI_DEVICE_PATH_PROTOCOL *) InfiniBand; } -STATIC +/** + Converts a text device path node to Vendor-Defined Messaging device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor-Defined Messaging device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenMsg ( IN CHAR16 *TextDeviceNode @@ -1243,7 +1385,14 @@ DevPathFromTextVenMsg ( ); } -STATIC +/** + Converts a text device path node to Vendor defined PC-ANSI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor defined PC-ANSI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenPcAnsi ( IN CHAR16 *TextDeviceNode @@ -1260,7 +1409,14 @@ DevPathFromTextVenPcAnsi ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to Vendor defined VT100 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor defined VT100 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenVt100 ( IN CHAR16 *TextDeviceNode @@ -1277,7 +1433,14 @@ DevPathFromTextVenVt100 ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to Vendor defined VT100 Plus device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor defined VT100 Plus device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenVt100Plus ( IN CHAR16 *TextDeviceNode @@ -1294,7 +1457,14 @@ DevPathFromTextVenVt100Plus ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to Vendor defined UTF8 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor defined UTF8 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenUtf8 ( IN CHAR16 *TextDeviceNode @@ -1311,7 +1481,14 @@ DevPathFromTextVenUtf8 ( return (EFI_DEVICE_PATH_PROTOCOL *) Vendor; } -STATIC +/** + Converts a text device path node to UART Flow Control device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created UART Flow Control device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUartFlowCtrl ( IN CHAR16 *TextDeviceNode @@ -1327,7 +1504,7 @@ DevPathFromTextUartFlowCtrl ( sizeof (UART_FLOW_CONTROL_DEVICE_PATH) ); - CopyGuid (&UartFlowControl->Guid, &mEfiDevicePathMessagingUartFlowControlGuid); + CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid); if (StrCmp (ValueStr, L"XonXoff") == 0) { UartFlowControl->FlowControlMap = 2; } else if (StrCmp (ValueStr, L"Hardware") == 0) { @@ -1339,7 +1516,14 @@ DevPathFromTextUartFlowCtrl ( return (EFI_DEVICE_PATH_PROTOCOL *) UartFlowControl; } -STATIC +/** + Converts a text device path node to Serial Attached SCSI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Serial Attached SCSI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextSAS ( IN CHAR16 *TextDeviceNode @@ -1371,18 +1555,16 @@ DevPathFromTextSAS ( sizeof (SAS_DEVICE_PATH) ); - CopyGuid (&Sas->Guid, &mEfiDevicePathMessagingSASGuid); - Xtoi64 (AddressStr, &Sas->SasAddress); - Xtoi64 (LunStr, &Sas->Lun); - Sas->RelativeTargetPort = (UINT16) Xtoi (RTPStr); - if (StrCmp (SASSATAStr, L"NoTopology") == 0) - ; - else { + CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid); + Strtoi64 (AddressStr, &Sas->SasAddress); + Strtoi64 (LunStr, &Sas->Lun); + Sas->RelativeTargetPort = (UINT16) Strtoi (RTPStr); + if (StrCmp (SASSATAStr, L"NoTopology") != 0) { if (StrCmp (DriveBayStr, L"0") == 0) { Info |= 0x0001; } else { Info |= 0x0002; - Info |= (Xtoi (DriveBayStr) << 8); + Info = (UINT16) (Info | (Strtoi (DriveBayStr) << 8)); } if (StrCmp (SASSATAStr, L"SATA") == 0) { @@ -1399,12 +1581,19 @@ DevPathFromTextSAS ( } Sas->DeviceTopology = Info; - Sas->Reserved = (UINT32) Xtoi (ReservedStr); + Sas->Reserved = (UINT32) Strtoi (ReservedStr); return (EFI_DEVICE_PATH_PROTOCOL *) Sas; } -STATIC +/** + Converts a text device path node to Debug Port device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Debug Port device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextDebugPort ( IN CHAR16 *TextDeviceNode @@ -1423,7 +1612,14 @@ DevPathFromTextDebugPort ( return (EFI_DEVICE_PATH_PROTOCOL *) Vend; } -STATIC +/** + Converts a text device path node to MAC device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created MAC device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextMAC ( IN CHAR16 *TextDeviceNode @@ -1432,25 +1628,32 @@ DevPathFromTextMAC ( CHAR16 *AddressStr; CHAR16 *IfTypeStr; UINTN Length; - MAC_ADDR_DEVICE_PATH *MAC; + MAC_ADDR_DEVICE_PATH *MACDevPath; AddressStr = GetNextParamStr (&TextDeviceNode); IfTypeStr = GetNextParamStr (&TextDeviceNode); - MAC = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode ( + MACDevPath = (MAC_ADDR_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_MAC_ADDR_DP, sizeof (MAC_ADDR_DEVICE_PATH) ); - MAC->IfType = (UINT8) Xtoi (IfTypeStr); + MACDevPath->IfType = (UINT8) Strtoi (IfTypeStr); Length = sizeof (EFI_MAC_ADDRESS); - StrToBuf (&MAC->MacAddress.Addr[0], Length, AddressStr); + StrToBuf (&MACDevPath->MacAddress.Addr[0], Length, AddressStr); - return (EFI_DEVICE_PATH_PROTOCOL *) MAC; + return (EFI_DEVICE_PATH_PROTOCOL *) MACDevPath; } -STATIC +/** + Converts a text device path node to IPV4 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created IPV4 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextIPv4 ( IN CHAR16 *TextDeviceNode @@ -1482,13 +1685,20 @@ DevPathFromTextIPv4 ( StrToIPv4Addr (&LocalIPStr, &IPv4->LocalIpAddress); - IPv4->LocalPort = 0; - IPv4->RemotePort = 0; + IPv4->LocalPort = 0; + IPv4->RemotePort = 0; return (EFI_DEVICE_PATH_PROTOCOL *) IPv4; } -STATIC +/** + Converts a text device path node to IPV6 device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created IPV6 device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextIPv6 ( IN CHAR16 *TextDeviceNode @@ -1526,7 +1736,14 @@ DevPathFromTextIPv6 ( return (EFI_DEVICE_PATH_PROTOCOL *) IPv6; } -STATIC +/** + Converts a text device path node to UART device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created UART device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUart ( IN CHAR16 *TextDeviceNode @@ -1548,8 +1765,8 @@ DevPathFromTextUart ( sizeof (UART_DEVICE_PATH) ); - Uart->BaudRate = (StrCmp (BaudStr, L"DEFAULT") == 0) ? 115200 : Atoi (BaudStr); - Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Atoi (DataBitsStr)); + Uart->BaudRate = (StrCmp (BaudStr, L"DEFAULT") == 0) ? 115200 : Dtoi (BaudStr); + Uart->DataBits = (UINT8) ((StrCmp (DataBitsStr, L"DEFAULT") == 0) ? 8 : Dtoi (DataBitsStr)); switch (*ParityStr) { case L'D': Uart->Parity = 0; @@ -1593,7 +1810,15 @@ DevPathFromTextUart ( return (EFI_DEVICE_PATH_PROTOCOL *) Uart; } -STATIC +/** + Converts a text device path node to USB class device path structure. + + @param TextDeviceNode The input Text device path node. + @param UsbClassText A pointer to USB_CLASS_TEXT structure to be integrated to USB Class Text. + + @return A pointer to the newly-created USB class device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * ConvertFromTextUsbClass ( IN CHAR16 *TextDeviceNode, @@ -1617,28 +1842,35 @@ ConvertFromTextUsbClass ( PIDStr = GetNextParamStr (&TextDeviceNode); if (UsbClassText->ClassExist) { ClassStr = GetNextParamStr (&TextDeviceNode); - UsbClass->DeviceClass = (UINT8) Xtoi (ClassStr); + UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr); } else { UsbClass->DeviceClass = UsbClassText->Class; } if (UsbClassText->SubClassExist) { SubClassStr = GetNextParamStr (&TextDeviceNode); - UsbClass->DeviceSubClass = (UINT8) Xtoi (SubClassStr); + UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr); } else { UsbClass->DeviceSubClass = UsbClassText->SubClass; - } + } ProtocolStr = GetNextParamStr (&TextDeviceNode); - UsbClass->VendorId = (UINT16) Xtoi (VIDStr); - UsbClass->ProductId = (UINT16) Xtoi (PIDStr); - UsbClass->DeviceProtocol = (UINT8) Xtoi (ProtocolStr); + UsbClass->VendorId = (UINT16) Strtoi (VIDStr); + UsbClass->ProductId = (UINT16) Strtoi (PIDStr); + UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr); return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass; } -STATIC +/** + Converts a text device path node to USB class device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB class device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbClass ( IN CHAR16 *TextDeviceNode @@ -1652,7 +1884,14 @@ DevPathFromTextUsbClass ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB audio device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB audio device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbAudio ( IN CHAR16 *TextDeviceNode @@ -1667,7 +1906,14 @@ DevPathFromTextUsbAudio ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB CDC Control device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB CDC Control device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbCDCControl ( IN CHAR16 *TextDeviceNode @@ -1682,7 +1928,14 @@ DevPathFromTextUsbCDCControl ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB HID device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB HID device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbHID ( IN CHAR16 *TextDeviceNode @@ -1697,7 +1950,14 @@ DevPathFromTextUsbHID ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB Image device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB Image device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbImage ( IN CHAR16 *TextDeviceNode @@ -1712,7 +1972,14 @@ DevPathFromTextUsbImage ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB Print device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB Print device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbPrinter ( IN CHAR16 *TextDeviceNode @@ -1727,7 +1994,14 @@ DevPathFromTextUsbPrinter ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB mass storage device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB mass storage device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbMassStorage ( IN CHAR16 *TextDeviceNode @@ -1742,7 +2016,14 @@ DevPathFromTextUsbMassStorage ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB HUB device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB HUB device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbHub ( IN CHAR16 *TextDeviceNode @@ -1757,7 +2038,14 @@ DevPathFromTextUsbHub ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB CDC data device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB CDC data device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbCDCData ( IN CHAR16 *TextDeviceNode @@ -1772,7 +2060,14 @@ DevPathFromTextUsbCDCData ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB smart card device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB smart card device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbSmartCard ( IN CHAR16 *TextDeviceNode @@ -1787,7 +2082,14 @@ DevPathFromTextUsbSmartCard ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB video device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB video device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbVideo ( IN CHAR16 *TextDeviceNode @@ -1802,7 +2104,14 @@ DevPathFromTextUsbVideo ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB diagnostic device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB diagnostic device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbDiagnostic ( IN CHAR16 *TextDeviceNode @@ -1817,7 +2126,14 @@ DevPathFromTextUsbDiagnostic ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB wireless device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB wireless device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbWireless ( IN CHAR16 *TextDeviceNode @@ -1832,7 +2148,14 @@ DevPathFromTextUsbWireless ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB device firmware update device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB device firmware update device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbDeviceFirmwareUpdate ( IN CHAR16 *TextDeviceNode @@ -1848,7 +2171,14 @@ DevPathFromTextUsbDeviceFirmwareUpdate ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB IRDA bridge device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB IRDA bridge device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbIrdaBridge ( IN CHAR16 *TextDeviceNode @@ -1864,7 +2194,14 @@ DevPathFromTextUsbIrdaBridge ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB text and measurement device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB text and measurement device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbTestAndMeasurement ( IN CHAR16 *TextDeviceNode @@ -1880,7 +2217,14 @@ DevPathFromTextUsbTestAndMeasurement ( return ConvertFromTextUsbClass (TextDeviceNode, &UsbClassText); } -STATIC +/** + Converts a text device path node to USB WWID device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created USB WWID device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUsbWwid ( IN CHAR16 *TextDeviceNode @@ -1889,25 +2233,35 @@ DevPathFromTextUsbWwid ( CHAR16 *VIDStr; CHAR16 *PIDStr; CHAR16 *InterfaceNumStr; + CHAR16 *SerialNumberStr; USB_WWID_DEVICE_PATH *UsbWwid; VIDStr = GetNextParamStr (&TextDeviceNode); PIDStr = GetNextParamStr (&TextDeviceNode); InterfaceNumStr = GetNextParamStr (&TextDeviceNode); + SerialNumberStr = GetNextParamStr (&TextDeviceNode); UsbWwid = (USB_WWID_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_USB_WWID_DP, - sizeof (USB_WWID_DEVICE_PATH) + (UINT16) (sizeof (USB_WWID_DEVICE_PATH) + StrSize (SerialNumberStr)) ); - UsbWwid->VendorId = (UINT16) Xtoi (VIDStr); - UsbWwid->ProductId = (UINT16) Xtoi (PIDStr); - UsbWwid->InterfaceNumber = (UINT16) Xtoi (InterfaceNumStr); + UsbWwid->VendorId = (UINT16) Strtoi (VIDStr); + UsbWwid->ProductId = (UINT16) Strtoi (PIDStr); + UsbWwid->InterfaceNumber = (UINT16) Strtoi (InterfaceNumStr); + StrCpy ((CHAR16 *) ((UINT8 *) UsbWwid + sizeof (USB_WWID_DEVICE_PATH)), SerialNumberStr); return (EFI_DEVICE_PATH_PROTOCOL *) UsbWwid; } -STATIC +/** + Converts a text device path node to Logic Unit device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Logic Unit device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextUnit ( IN CHAR16 *TextDeviceNode @@ -1920,15 +2274,22 @@ DevPathFromTextUnit ( LogicalUnit = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_DEVICE_LOGICAL_UNIT_DP, - sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH) + (UINT16) sizeof (DEVICE_LOGICAL_UNIT_DEVICE_PATH) ); - LogicalUnit->Lun = (UINT8) Xtoi (LunStr); + LogicalUnit->Lun = (UINT8) Strtoi (LunStr); return (EFI_DEVICE_PATH_PROTOCOL *) LogicalUnit; } -STATIC +/** + Converts a text device path node to iSCSI device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created iSCSI device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextiSCSI ( IN CHAR16 *TextDeviceNode @@ -1942,7 +2303,8 @@ DevPathFromTextiSCSI ( CHAR16 *DataDigestStr; CHAR16 *AuthenticationStr; CHAR16 *ProtocolStr; - ISCSI_DEVICE_PATH_WITH_NAME *iSCSI; + CHAR8 *AsciiStr; + ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath; NameStr = GetNextParamStr (&TextDeviceNode); PortalGroupStr = GetNextParamStr (&TextDeviceNode); @@ -1951,15 +2313,17 @@ DevPathFromTextiSCSI ( DataDigestStr = GetNextParamStr (&TextDeviceNode); AuthenticationStr = GetNextParamStr (&TextDeviceNode); ProtocolStr = GetNextParamStr (&TextDeviceNode); - iSCSI = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode ( + ISCSIDevPath = (ISCSI_DEVICE_PATH_WITH_NAME *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_ISCSI_DP, - sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + (UINT16) (StrLen (NameStr) * 2) + (UINT16) (sizeof (ISCSI_DEVICE_PATH_WITH_NAME) + StrLen (NameStr)) ); - StrCpy (iSCSI->iSCSITargetName, NameStr); - iSCSI->TargetPortalGroupTag = (UINT16) Xtoi (PortalGroupStr); - Xtoi64 (LunStr, &iSCSI->Lun); + AsciiStr = ISCSIDevPath->iSCSITargetName; + StrToAscii (NameStr, &AsciiStr); + + ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr); + Strtoi64 (LunStr, &ISCSIDevPath->Lun); Options = 0x0000; if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) { @@ -1978,15 +2342,21 @@ DevPathFromTextiSCSI ( Options |= 0x1000; } - iSCSI->LoginOption = (UINT16) Options; + ISCSIDevPath->LoginOption = (UINT16) Options; - iSCSI->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP"); - iSCSI->Reserved = (UINT16) 0; + ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP"); - return (EFI_DEVICE_PATH_PROTOCOL *) iSCSI; + return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath; } -STATIC +/** + Converts a text device path node to HD device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created HD device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextHD ( IN CHAR16 *TextDeviceNode @@ -2012,37 +2382,41 @@ DevPathFromTextHD ( sizeof (HARDDRIVE_DEVICE_PATH) ); - Hd->PartitionNumber = (UINT32) Atoi (PartitionStr); + Hd->PartitionNumber = (UINT32) Dtoi (PartitionStr); ZeroMem (Hd->Signature, 16); Hd->MBRType = (UINT8) 0; - if (StrCmp (TypeStr, L"None") == 0) { - Hd->SignatureType = (UINT8) 0; - } else if (StrCmp (TypeStr, L"MBR") == 0) { + if (StrCmp (TypeStr, L"MBR") == 0) { Hd->SignatureType = SIGNATURE_TYPE_MBR; Hd->MBRType = 0x01; - Signature32 = (UINT32) Xtoi (SignatureStr); + Signature32 = (UINT32) Strtoi (SignatureStr); CopyMem (Hd->Signature, &Signature32, sizeof (UINT32)); - } else if (StrCmp (TypeStr, L"GUID") == 0) { + } else if (StrCmp (TypeStr, L"GPT") == 0) { Hd->SignatureType = SIGNATURE_TYPE_GUID; Hd->MBRType = 0x02; StrToGuid (SignatureStr, &SignatureGuid); CopyMem (Hd->Signature, &SignatureGuid, sizeof (EFI_GUID)); } else { - Hd->SignatureType = 0xff; - + Hd->SignatureType = (UINT8) Strtoi (TypeStr); } - Xtoi64 (StartStr, &Hd->PartitionStart); - Xtoi64 (SizeStr, &Hd->PartitionSize); + Strtoi64 (StartStr, &Hd->PartitionStart); + Strtoi64 (SizeStr, &Hd->PartitionSize); return (EFI_DEVICE_PATH_PROTOCOL *) Hd; } -STATIC +/** + Converts a text device path node to CDROM device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created CDROM device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextCDROM ( IN CHAR16 *TextDeviceNode @@ -2051,25 +2425,32 @@ DevPathFromTextCDROM ( CHAR16 *EntryStr; CHAR16 *StartStr; CHAR16 *SizeStr; - CDROM_DEVICE_PATH *CDROM; + CDROM_DEVICE_PATH *CDROMDevPath; EntryStr = GetNextParamStr (&TextDeviceNode); StartStr = GetNextParamStr (&TextDeviceNode); SizeStr = GetNextParamStr (&TextDeviceNode); - CDROM = (CDROM_DEVICE_PATH *) CreateDeviceNode ( + CDROMDevPath = (CDROM_DEVICE_PATH *) CreateDeviceNode ( MEDIA_DEVICE_PATH, MEDIA_CDROM_DP, sizeof (CDROM_DEVICE_PATH) ); - CDROM->BootEntry = (UINT32) Xtoi (EntryStr); - Xtoi64 (StartStr, &CDROM->PartitionStart); - Xtoi64 (SizeStr, &CDROM->PartitionSize); + CDROMDevPath->BootEntry = (UINT32) Strtoi (EntryStr); + Strtoi64 (StartStr, &CDROMDevPath->PartitionStart); + Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize); - return (EFI_DEVICE_PATH_PROTOCOL *) CDROM; + return (EFI_DEVICE_PATH_PROTOCOL *) CDROMDevPath; } -STATIC +/** + Converts a text device path node to Vendor-defined media device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Vendor-defined media device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextVenMEDIA ( IN CHAR16 *TextDeviceNode @@ -2082,7 +2463,14 @@ DevPathFromTextVenMEDIA ( ); } -STATIC +/** + Converts a text device path node to File device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created File device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextFilePath ( IN CHAR16 *TextDeviceNode @@ -2093,7 +2481,7 @@ DevPathFromTextFilePath ( File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode ( MEDIA_DEVICE_PATH, MEDIA_FILEPATH_DP, - sizeof (FILEPATH_DEVICE_PATH) + (UINT16) (StrLen (TextDeviceNode) * 2) + (UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2) ); StrCpy (File->PathName, TextDeviceNode); @@ -2101,7 +2489,14 @@ DevPathFromTextFilePath ( return (EFI_DEVICE_PATH_PROTOCOL *) File; } -STATIC +/** + Converts a text device path node to Media protocol device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created Media protocol device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextMedia ( IN CHAR16 *TextDeviceNode @@ -2122,7 +2517,70 @@ DevPathFromTextMedia ( return (EFI_DEVICE_PATH_PROTOCOL *) Media; } -STATIC +/** + Converts a text device path node to firmware volume device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created firmware volume device path structure. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +DevPathFromTextFv ( + IN CHAR16 *TextDeviceNode + ) +{ + CHAR16 *GuidStr; + MEDIA_FW_VOL_DEVICE_PATH *Fv; + + GuidStr = GetNextParamStr (&TextDeviceNode); + Fv = (MEDIA_FW_VOL_DEVICE_PATH *) CreateDeviceNode ( + MEDIA_DEVICE_PATH, + MEDIA_PIWG_FW_VOL_DP, + sizeof (MEDIA_FW_VOL_DEVICE_PATH) + ); + + StrToGuid (GuidStr, &Fv->FvName); + + return (EFI_DEVICE_PATH_PROTOCOL *) Fv; +} + +/** + Converts a text device path node to firmware file device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created firmware file device path structure. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +DevPathFromTextFvFile ( + IN CHAR16 *TextDeviceNode + ) +{ + CHAR16 *GuidStr; + MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFile; + + GuidStr = GetNextParamStr (&TextDeviceNode); + FvFile = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) CreateDeviceNode ( + MEDIA_DEVICE_PATH, + MEDIA_PIWG_FW_FILE_DP, + sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH) + ); + + StrToGuid (GuidStr, &FvFile->FvFileName); + + return (EFI_DEVICE_PATH_PROTOCOL *) FvFile; +} + +/** + Converts a text device path node to BIOS Boot Specification device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created BIOS Boot Specificationa device path structure. + +**/ EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextBBS ( IN CHAR16 *TextDeviceNode @@ -2131,7 +2589,7 @@ DevPathFromTextBBS ( CHAR16 *TypeStr; CHAR16 *IdStr; CHAR16 *FlagsStr; - UINT8 *AsciiStr; + CHAR8 *AsciiStr; BBS_BBS_DEVICE_PATH *Bbs; TypeStr = GetNextParamStr (&TextDeviceNode); @@ -2140,7 +2598,7 @@ DevPathFromTextBBS ( Bbs = (BBS_BBS_DEVICE_PATH *) CreateDeviceNode ( BBS_DEVICE_PATH, BBS_BBS_DP, - sizeof (BBS_BBS_DEVICE_PATH) + (UINT16) (StrLen (IdStr)) + (UINT16) (sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr)) ); if (StrCmp (TypeStr, L"Floppy") == 0) { @@ -2156,17 +2614,62 @@ DevPathFromTextBBS ( } else if (StrCmp (TypeStr, L"Network") == 0) { Bbs->DeviceType = BBS_TYPE_EMBEDDED_NETWORK; } else { - Bbs->DeviceType = BBS_TYPE_UNKNOWN; + Bbs->DeviceType = (UINT16) Strtoi (TypeStr); } - AsciiStr = (UINT8 *) Bbs->String; - StrToAscii (IdStr, (CHAR8 **) &AsciiStr); + AsciiStr = Bbs->String; + StrToAscii (IdStr, &AsciiStr); - Bbs->StatusFlag = (UINT16) Xtoi (FlagsStr); + Bbs->StatusFlag = (UINT16) Strtoi (FlagsStr); return (EFI_DEVICE_PATH_PROTOCOL *) Bbs; } +/** + Converts a text device path node to SATA device path structure. + + @param TextDeviceNode The input Text device path node. + + @return A pointer to the newly-created SATA device path structure. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +DevPathFromTextSata ( + IN CHAR16 *TextDeviceNode + ) +{ + SATA_DEVICE_PATH *Sata; + CHAR16 *Param1; + CHAR16 *Param2; + CHAR16 *Param3; + + // + // The PMPN is optional. + // + Param1 = GetNextParamStr (&TextDeviceNode); + Param2 = GetNextParamStr (&TextDeviceNode); + Param3 = NULL; + if (!IS_NULL (TextDeviceNode)) { + Param3 = GetNextParamStr (&TextDeviceNode); + } + + Sata = (SATA_DEVICE_PATH *) CreateDeviceNode ( + MESSAGING_DEVICE_PATH, + MSG_SATA_DP, + sizeof (SATA_DEVICE_PATH) + ); + Sata->HBAPortNumber = (UINT16) Xtoi (Param1); + if (Param3 != NULL) { + Sata->PortMultiplierPortNumber = (UINT16) Xtoi (Param2); + Param2 = Param3; + } else { + Sata->PortMultiplierPortNumber = 0; + } + Sata->Lun = (UINT16) Xtoi (Param2); + + return (EFI_DEVICE_PATH_PROTOCOL *) Sata; +} + GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] = { {L"Pci", DevPathFromTextPci}, {L"PcCard", DevPathFromTextPcCard}, @@ -2223,31 +2726,31 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE DevPathFromTextTable[] {L"CDROM", DevPathFromTextCDROM}, {L"VenMEDIA", DevPathFromTextVenMEDIA}, {L"Media", DevPathFromTextMedia}, + {L"Fv", DevPathFromTextFv}, + {L"FvFile", DevPathFromTextFvFile}, {L"BBS", DevPathFromTextBBS}, + {L"Sata", DevPathFromTextSata}, {NULL, NULL} }; -EFI_DEVICE_PATH_PROTOCOL * -ConvertTextToDeviceNode ( - IN CONST CHAR16 *TextDeviceNode - ) -/*++ - - Routine Description: - Convert text to the binary representation of a device node. +/** + Convert text to the binary representation of a device node. - Arguments: - TextDeviceNode - TextDeviceNode points to the text representation of a device + @param TextDeviceNode TextDeviceNode points to the text representation of a device node. Conversion starts with the first character and continues until the first non-device node character. - Returns: - A pointer - Pointer to the EFI device node. - NULL - If TextDeviceNode is NULL or there was insufficient memory or text unsupported. + @return A pointer to the EFI device node or NULL if TextDeviceNode is NULL or there was + insufficient memory or text unsupported. ---*/ +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +ConvertTextToDeviceNode ( + IN CONST CHAR16 *TextDeviceNode + ) { - EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *); + DUMP_NODE DumpNode; CHAR16 *ParamStr; EFI_DEVICE_PATH_PROTOCOL *DeviceNode; CHAR16 *DeviceNodeStr; @@ -2260,6 +2763,7 @@ ConvertTextToDeviceNode ( ParamStr = NULL; DumpNode = NULL; DeviceNodeStr = StrDuplicate (TextDeviceNode); + ASSERT (DeviceNodeStr != NULL); for (Index = 0; DevPathFromTextTable[Index].Function; Index++) { ParamStr = GetParamByNodeName (DeviceNodeStr, DevPathFromTextTable[Index].DevicePathNodeText); @@ -2285,27 +2789,25 @@ ConvertTextToDeviceNode ( return DeviceNode; } -EFI_DEVICE_PATH_PROTOCOL * -ConvertTextToDevicePath ( - IN CONST CHAR16 *TextDevicePath - ) -/*++ +/** + Convert text to the binary representation of a device path. - Routine Description: - Convert text to the binary representation of a device path. - Arguments: - TextDevicePath - TextDevicePath points to the text representation of a device + @param TextDevicePath TextDevicePath points to the text representation of a device path. Conversion starts with the first character and continues until the first non-device node character. - Returns: - A pointer - Pointer to the allocated device path. - NULL - If TextDeviceNode is NULL or there was insufficient memory. + @return A pointer to the allocated device path or NULL if TextDeviceNode is NULL or + there was insufficient memory. ---*/ +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +ConvertTextToDevicePath ( + IN CONST CHAR16 *TextDevicePath + ) { - EFI_DEVICE_PATH_PROTOCOL * (*DumpNode) (CHAR16 *); + DUMP_NODE DumpNode; CHAR16 *ParamStr; EFI_DEVICE_PATH_PROTOCOL *DeviceNode; UINTN Index; @@ -2321,6 +2823,7 @@ ConvertTextToDevicePath ( } DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH); + ASSERT (DevicePath != NULL); SetDevicePathEndNode (DevicePath); ParamStr = NULL; @@ -2354,9 +2857,10 @@ ConvertTextToDevicePath ( FreePool (DeviceNode); DevicePath = NewDevicePath; - if (IsInstanceEnd) { + if (IsInstanceEnd != 0) { DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH); - SetDevicePathInstanceEndNode (DeviceNode); + ASSERT (DeviceNode != NULL); + SET_DEVICE_PATH_INSTANCE_END_NODE (DeviceNode); NewDevicePath = AppendDeviceNodeProtocolInterface (DevicePath, DeviceNode); FreePool (DevicePath);