/** @file\r
DevicePathFromText protocol as defined in the UEFI 2.0 specification.\r
\r
-Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
while ((*Str != 0) && *Str == L'0') {\r
Str ++;\r
}\r
- \r
+\r
return (BOOLEAN) (*Str == L'x' || *Str == L'X');\r
}\r
\r
);\r
\r
AcpiEx->HID = EisaIdFromText (HIDStr);\r
- AcpiEx->CID = EisaIdFromText (CIDStr);\r
+ //\r
+ // According to UEFI spec, the CID parametr is optional and has a default value of 0.\r
+ // So when the CID parametr is not specified or specified as 0 in the text device node.\r
+ // Set the CID to 0 in the ACPI extension device path structure.\r
+ //\r
+ if (*CIDStr == L'\0' || *CIDStr == L'0') {\r
+ AcpiEx->CID = 0;\r
+ } else {\r
+ AcpiEx->CID = EisaIdFromText (CIDStr);\r
+ }\r
AcpiEx->UID = 0;\r
\r
AsciiStr = (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH));\r
ASSERT (AcpiAdr != NULL);\r
SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32));\r
}\r
- \r
+\r
(&AcpiAdr->ADR)[Index] = (UINT32) Strtoi (DisplayDeviceStr);\r
}\r
\r
IN CHAR16 *TextDeviceNode\r
)\r
{\r
- VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend;\r
+ VENDOR_DEVICE_PATH *Vend;\r
\r
- Vend = (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode (\r
+ Vend = (VENDOR_DEVICE_PATH *) CreateDeviceNode (\r
MESSAGING_DEVICE_PATH,\r
MSG_VENDOR_DP,\r
- (UINT16) sizeof (VENDOR_DEFINED_MESSAGING_DEVICE_PATH)\r
+ (UINT16) sizeof (VENDOR_DEVICE_PATH)\r
);\r
\r
CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid);\r
PIDStr = GetNextParamStr (&TextDeviceNode);\r
if (UsbClassText->ClassExist) {\r
ClassStr = GetNextParamStr (&TextDeviceNode);\r
- UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
+ if (*ClassStr == L'\0') {\r
+ UsbClass->DeviceClass = 0xFF;\r
+ } else {\r
+ UsbClass->DeviceClass = (UINT8) Strtoi (ClassStr);\r
+ }\r
} else {\r
UsbClass->DeviceClass = UsbClassText->Class;\r
}\r
if (UsbClassText->SubClassExist) {\r
SubClassStr = GetNextParamStr (&TextDeviceNode);\r
- UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
+ if (*SubClassStr == L'\0') {\r
+ UsbClass->DeviceSubClass = 0xFF;\r
+ } else {\r
+ UsbClass->DeviceSubClass = (UINT8) Strtoi (SubClassStr);\r
+ }\r
} else {\r
UsbClass->DeviceSubClass = UsbClassText->SubClass;\r
}\r
\r
ProtocolStr = GetNextParamStr (&TextDeviceNode);\r
\r
- UsbClass->VendorId = (UINT16) Strtoi (VIDStr);\r
- UsbClass->ProductId = (UINT16) Strtoi (PIDStr);\r
- UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);\r
+ if (*VIDStr == L'\0') {\r
+ UsbClass->VendorId = 0xFFFF;\r
+ } else {\r
+ UsbClass->VendorId = (UINT16) Strtoi (VIDStr);\r
+ }\r
+ if (*PIDStr == L'\0') {\r
+ UsbClass->ProductId = 0xFFFF;\r
+ } else {\r
+ UsbClass->ProductId = (UINT16) Strtoi (PIDStr);\r
+ }\r
+ if (*ProtocolStr == L'\0') {\r
+ UsbClass->DeviceProtocol = 0xFF;\r
+ } else {\r
+ UsbClass->DeviceProtocol = (UINT8) Strtoi (ProtocolStr);\r
+ }\r
\r
return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass;\r
}\r
CHAR16 *ProtocolStr;\r
CHAR8 *AsciiStr;\r
ISCSI_DEVICE_PATH_WITH_NAME *ISCSIDevPath;\r
+ UINT64 Lun;\r
\r
NameStr = GetNextParamStr (&TextDeviceNode);\r
PortalGroupStr = GetNextParamStr (&TextDeviceNode);\r
StrToAscii (NameStr, &AsciiStr);\r
\r
ISCSIDevPath->TargetPortalGroupTag = (UINT16) Strtoi (PortalGroupStr);\r
- Strtoi64 (LunStr, &ISCSIDevPath->Lun);\r
+ Strtoi64 (LunStr, &Lun);\r
+ WriteUnaligned64 ((UINT64 *) &ISCSIDevPath->Lun, SwapBytes64 (Lun));\r
\r
Options = 0x0000;\r
if (StrCmp (HeaderDigestStr, L"CRC32C") == 0) {\r
\r
ISCSIDevPath->LoginOption = (UINT16) Options;\r
\r
- ISCSIDevPath->NetworkProtocol = (UINT16) StrCmp (ProtocolStr, L"TCP");\r
+ if (IS_NULL (*ProtocolStr) || (StrCmp (ProtocolStr, L"TCP") == 0)) {\r
+ ISCSIDevPath->NetworkProtocol = 0;\r
+ } else {\r
+ //\r
+ // Undefined and reserved.\r
+ //\r
+ ISCSIDevPath->NetworkProtocol = 1;\r
+ }\r
\r
return (EFI_DEVICE_PATH_PROTOCOL *) ISCSIDevPath;\r
}\r
)\r
{\r
CHAR16 *BluetoothStr;\r
- CHAR16 *Walker;\r
- CHAR16 *TempNumBuffer;\r
- UINTN TempBufferSize;\r
- INT32 Index;\r
BLUETOOTH_DEVICE_PATH *BluetoothDp;\r
\r
BluetoothStr = GetNextParamStr (&TextDeviceNode);\r
- BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (\r
- MESSAGING_DEVICE_PATH,\r
- MSG_BLUETOOTH_DP,\r
- (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)\r
- );\r
-\r
- Index = sizeof (BLUETOOTH_ADDRESS) - 1;\r
- Walker = BluetoothStr;\r
- while (!IS_NULL(*Walker) && Index >= 0) {\r
- TempBufferSize = 2 * sizeof(CHAR16) + StrSize(L"0x");\r
- TempNumBuffer = AllocateZeroPool (TempBufferSize);\r
- if (TempNumBuffer == NULL) {\r
- break;\r
- }\r
- StrCpyS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), L"0x");\r
- StrnCatS (TempNumBuffer, TempBufferSize / sizeof (CHAR16), Walker, 2);\r
- BluetoothDp->BD_ADDR.Address[Index] = (UINT8)Strtoi (TempNumBuffer);\r
- FreePool (TempNumBuffer);\r
- Walker += 2;\r
- Index--;\r
- }\r
- \r
+ BluetoothDp = (BLUETOOTH_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_BLUETOOTH_DP,\r
+ (UINT16) sizeof (BLUETOOTH_DEVICE_PATH)\r
+ );\r
+ StrHexToBytes (\r
+ BluetoothStr,\r
+ sizeof (BLUETOOTH_ADDRESS) * 2,\r
+ BluetoothDp->BD_ADDR.Address,\r
+ sizeof (BLUETOOTH_ADDRESS)\r
+ );\r
return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothDp;\r
}\r
\r
return (EFI_DEVICE_PATH_PROTOCOL *) WiFiDp;\r
}\r
\r
+/**\r
+ Converts a text device path node to Bluetooth LE device path structure.\r
+\r
+ @param TextDeviceNode The input Text device path node.\r
+\r
+ @return A pointer to the newly-created Bluetooth LE device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextBluetoothLE (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *BluetoothLeAddrStr;\r
+ CHAR16 *BluetoothLeAddrTypeStr;\r
+ BLUETOOTH_LE_DEVICE_PATH *BluetoothLeDp;\r
+\r
+ BluetoothLeAddrStr = GetNextParamStr (&TextDeviceNode);\r
+ BluetoothLeAddrTypeStr = GetNextParamStr (&TextDeviceNode);\r
+ BluetoothLeDp = (BLUETOOTH_LE_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_BLUETOOTH_LE_DP,\r
+ (UINT16) sizeof (BLUETOOTH_LE_DEVICE_PATH)\r
+ );\r
+\r
+ BluetoothLeDp->Address.Type = (UINT8) Strtoi (BluetoothLeAddrTypeStr);\r
+ StrHexToBytes (\r
+ BluetoothLeAddrStr, sizeof (BluetoothLeDp->Address.Address) * 2,\r
+ BluetoothLeDp->Address.Address, sizeof (BluetoothLeDp->Address.Address)\r
+ );\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) BluetoothLeDp;\r
+}\r
+\r
+/**\r
+ Converts a text device path node to DNS device path structure.\r
+\r
+ @param TextDeviceNode The input Text device path node.\r
+\r
+ @return A pointer to the newly-created DNS device path structure.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+DevPathFromTextDns (\r
+ IN CHAR16 *TextDeviceNode\r
+ )\r
+{\r
+ CHAR16 *DeviceNodeStr;\r
+ CHAR16 *DeviceNodeStrPtr;\r
+ UINT32 DnsServerIpCount;\r
+ UINT16 DnsDeviceNodeLength;\r
+ DNS_DEVICE_PATH *DnsDeviceNode;\r
+ UINT32 DnsServerIpIndex;\r
+ CHAR16 *DnsServerIp;\r
+\r
+\r
+ //\r
+ // Count the DNS server address number.\r
+ //\r
+ DeviceNodeStr = UefiDevicePathLibStrDuplicate (TextDeviceNode);\r
+ if (DeviceNodeStr == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ DeviceNodeStrPtr = DeviceNodeStr;\r
+\r
+ DnsServerIpCount = 0;\r
+ while (DeviceNodeStrPtr != NULL && *DeviceNodeStrPtr != L'\0') {\r
+ GetNextParamStr (&DeviceNodeStrPtr);\r
+ DnsServerIpCount ++;\r
+ }\r
+\r
+ FreePool (DeviceNodeStr);\r
+ DeviceNodeStr = NULL;\r
+\r
+ //\r
+ // One or more instances of the DNS server address in EFI_IP_ADDRESS,\r
+ // otherwise, NULL will be returned.\r
+ //\r
+ if (DnsServerIpCount == 0) {\r
+ return NULL;\r
+ }\r
+\r
+ //\r
+ // Create the DNS DeviceNode.\r
+ //\r
+ DnsDeviceNodeLength = (UINT16) (sizeof (EFI_DEVICE_PATH_PROTOCOL) + sizeof (UINT8) + DnsServerIpCount * sizeof (EFI_IP_ADDRESS));\r
+ DnsDeviceNode = (DNS_DEVICE_PATH *) CreateDeviceNode (\r
+ MESSAGING_DEVICE_PATH,\r
+ MSG_DNS_DP,\r
+ DnsDeviceNodeLength\r
+ );\r
+ if (DnsDeviceNode == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ //\r
+ // Confirm the DNS server address is IPv4 or IPv6 type.\r
+ //\r
+ DeviceNodeStrPtr = TextDeviceNode;\r
+ while (!IS_NULL (*DeviceNodeStrPtr)) {\r
+ if (*DeviceNodeStrPtr == L'.') {\r
+ DnsDeviceNode->IsIPv6 = 0x00;\r
+ break;\r
+ }\r
+\r
+ if (*DeviceNodeStrPtr == L':') {\r
+ DnsDeviceNode->IsIPv6 = 0x01;\r
+ break;\r
+ }\r
+\r
+ DeviceNodeStrPtr++;\r
+ }\r
+\r
+ for (DnsServerIpIndex = 0; DnsServerIpIndex < DnsServerIpCount; DnsServerIpIndex++) {\r
+ DnsServerIp = GetNextParamStr (&TextDeviceNode);\r
+ if (DnsDeviceNode->IsIPv6 == 0x00) {\r
+ StrToIpv4Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v4), NULL);\r
+ } else {\r
+ StrToIpv6Address (DnsServerIp, NULL, &(DnsDeviceNode->DnsServerIp[DnsServerIpIndex].v6), NULL);\r
+ }\r
+ }\r
+\r
+ return (EFI_DEVICE_PATH_PROTOCOL *) DnsDeviceNode;\r
+}\r
+\r
/**\r
Converts a text device path node to URI device path structure.\r
\r
(UINT16) sizeof (SATA_DEVICE_PATH)\r
);\r
Sata->HBAPortNumber = (UINT16) Strtoi (Param1);\r
- Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);\r
+\r
+ //\r
+ // According to UEFI spec, if PMPN is not provided, the default is 0xFFFF\r
+ //\r
+ if (*Param2 == L'\0' ) {\r
+ Sata->PortMultiplierPortNumber = 0xFFFF;\r
+ } else {\r
+ Sata->PortMultiplierPortNumber = (UINT16) Strtoi (Param2);\r
+ }\r
Sata->Lun = (UINT16) Strtoi (Param3);\r
\r
return (EFI_DEVICE_PATH_PROTOCOL *) Sata;\r
{L"Unit", DevPathFromTextUnit },\r
{L"iSCSI", DevPathFromTextiSCSI },\r
{L"Vlan", DevPathFromTextVlan },\r
+ {L"Dns", DevPathFromTextDns },\r
{L"Uri", DevPathFromTextUri },\r
{L"Bluetooth", DevPathFromTextBluetooth },\r
{L"Wi-Fi", DevPathFromTextWiFi },\r
+ {L"BluetoothLE", DevPathFromTextBluetoothLE },\r
{L"MediaPath", DevPathFromTextMediaPath },\r
{L"HD", DevPathFromTextHD },\r
{L"CDROM", DevPathFromTextCDROM },\r