Changeset 108794 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
- Timestamp:
- Mar 31, 2025 11:31:09 AM (2 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168237
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-164365 /vendor/edk2/current 103735-103757,103769-103776,129194-168232
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Library/UefiDevicePathLib/DevicePathFromText.c
r99404 r108794 270 270 // skip preceeding white space 271 271 // 272 while ( (*Str != 0) &&*Str == L' ') {272 while (*Str == L' ') { 273 273 Str++; 274 274 } … … 277 277 // skip preceeding zeros 278 278 // 279 while ( (*Str != 0) &&*Str == L'0') {279 while (*Str == L'0') { 280 280 Str++; 281 281 } … … 389 389 ); 390 390 391 StrHexToBytes (DataStr, DataLength * 2, (UINT8 *)(Node + 1), DataLength); 391 if (Node != NULL) { 392 StrHexToBytes (DataStr, DataLength * 2, (UINT8 *)(Node + 1), DataLength); 393 } 394 392 395 return Node; 393 396 } … … 454 457 ); 455 458 456 Pci->Function = (UINT8)Strtoi (FunctionStr); 457 Pci->Device = (UINT8)Strtoi (DeviceStr); 459 if (Pci != NULL) { 460 Pci->Function = (UINT8)Strtoi (FunctionStr); 461 Pci->Device = (UINT8)Strtoi (DeviceStr); 462 } 458 463 459 464 return (EFI_DEVICE_PATH_PROTOCOL *)Pci; … … 483 488 ); 484 489 485 Pccard->FunctionNumber = (UINT8)Strtoi (FunctionNumberStr); 490 if (Pccard != NULL) { 491 Pccard->FunctionNumber = (UINT8)Strtoi (FunctionNumberStr); 492 } 486 493 487 494 return (EFI_DEVICE_PATH_PROTOCOL *)Pccard; … … 515 522 ); 516 523 517 MemMap->MemoryType = (UINT32)Strtoi (MemoryTypeStr); 518 Strtoi64 (StartingAddressStr, &MemMap->StartingAddress); 519 Strtoi64 (EndingAddressStr, &MemMap->EndingAddress); 524 if (MemMap != NULL) { 525 MemMap->MemoryType = (UINT32)Strtoi (MemoryTypeStr); 526 Strtoi64 (StartingAddressStr, &MemMap->StartingAddress); 527 Strtoi64 (EndingAddressStr, &MemMap->EndingAddress); 528 } 520 529 521 530 return (EFI_DEVICE_PATH_PROTOCOL *)MemMap; … … 560 569 ); 561 570 562 StrToGuid (GuidStr, &Vendor->Guid); 563 StrHexToBytes (DataStr, Length * 2, (UINT8 *)(Vendor + 1), Length); 571 if (Vendor != NULL) { 572 StrToGuid (GuidStr, &Vendor->Guid); 573 StrHexToBytes (DataStr, Length * 2, (UINT8 *)(Vendor + 1), Length); 574 } 564 575 565 576 return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; … … 608 619 (UINT16)sizeof (CONTROLLER_DEVICE_PATH) 609 620 ); 610 Controller->ControllerNumber = (UINT32)Strtoi (ControllerStr); 621 622 if (Controller != NULL) { 623 Controller->ControllerNumber = (UINT32)Strtoi (ControllerStr); 624 } 611 625 612 626 return (EFI_DEVICE_PATH_PROTOCOL *)Controller; … … 638 652 ); 639 653 640 BmcDp->InterfaceType = (UINT8)Strtoi (InterfaceTypeStr); 641 WriteUnaligned64 ( 642 (UINT64 *)(&BmcDp->BaseAddress), 643 StrHexToUint64 (BaseAddressStr) 644 ); 654 if (BmcDp != NULL) { 655 BmcDp->InterfaceType = (UINT8)Strtoi (InterfaceTypeStr); 656 WriteUnaligned64 ( 657 (UINT64 *)(&BmcDp->BaseAddress), 658 StrHexToUint64 (BaseAddressStr) 659 ); 660 } 645 661 646 662 return (EFI_DEVICE_PATH_PROTOCOL *)BmcDp; … … 707 723 ); 708 724 709 Acpi->HID = EisaIdFromText (HIDStr); 710 Acpi->UID = (UINT32)Strtoi (UIDStr); 725 if (Acpi != NULL) { 726 Acpi->HID = EisaIdFromText (HIDStr); 727 Acpi->UID = (UINT32)Strtoi (UIDStr); 728 } 711 729 712 730 return (EFI_DEVICE_PATH_PROTOCOL *)Acpi; … … 738 756 ); 739 757 740 Acpi->HID = EFI_PNP_ID (PnPId); 741 Acpi->UID = (UINT32)Strtoi (UIDStr); 758 if (Acpi != NULL) { 759 Acpi->HID = EFI_PNP_ID (PnPId); 760 Acpi->UID = (UINT32)Strtoi (UIDStr); 761 } 742 762 743 763 return (EFI_DEVICE_PATH_PROTOCOL *)Acpi; … … 879 899 ); 880 900 881 AcpiEx->HID = EisaIdFromText (HIDStr); 882 AcpiEx->CID = EisaIdFromText (CIDStr); 883 AcpiEx->UID = (UINT32)Strtoi (UIDStr); 884 885 AsciiStr = (CHAR8 *)((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH)); 886 StrToAscii (HIDSTRStr, &AsciiStr); 887 StrToAscii (UIDSTRStr, &AsciiStr); 888 StrToAscii (CIDSTRStr, &AsciiStr); 901 if (AcpiEx != NULL) { 902 AcpiEx->HID = EisaIdFromText (HIDStr); 903 AcpiEx->CID = EisaIdFromText (CIDStr); 904 AcpiEx->UID = (UINT32)Strtoi (UIDStr); 905 906 AsciiStr = (CHAR8 *)((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVICE_PATH)); 907 StrToAscii (HIDSTRStr, &AsciiStr); 908 StrToAscii (UIDSTRStr, &AsciiStr); 909 StrToAscii (CIDSTRStr, &AsciiStr); 910 } 889 911 890 912 return (EFI_DEVICE_PATH_PROTOCOL *)AcpiEx; … … 921 943 ); 922 944 945 if (AcpiEx == NULL) { 946 return (EFI_DEVICE_PATH_PROTOCOL *)AcpiEx; 947 } 948 923 949 AcpiEx->HID = EisaIdFromText (HIDStr); 924 950 // 925 // According to UEFI spec, the CID paramet r is optional and has a default value of 0.926 // So when the CID paramet r is not specified or specified as 0 in the text device node.951 // According to UEFI spec, the CID parameter is optional and has a default value of 0. 952 // So when the CID parameter is not specified or specified as 0 in the text device node. 927 953 // Set the CID to 0 in the ACPI extension device path structure. 928 954 // … … 976 1002 (UINT16)sizeof (ACPI_ADR_DEVICE_PATH) 977 1003 ); 978 ASSERT (AcpiAdr != NULL); 1004 if (AcpiAdr == NULL) { 1005 ASSERT (AcpiAdr != NULL); 1006 return (EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr; 1007 } 979 1008 980 1009 for (Index = 0; ; Index++) { … … 991 1020 AcpiAdr 992 1021 ); 993 ASSERT (AcpiAdr != NULL); 1022 1023 if (AcpiAdr == NULL) { 1024 ASSERT (AcpiAdr != NULL); 1025 return (EFI_DEVICE_PATH_PROTOCOL *)AcpiAdr; 1026 } 1027 994 1028 SetDevicePathNodeLength (AcpiAdr, Length + sizeof (UINT32)); 995 1029 } … … 1040 1074 (UINT16)sizeof (ATAPI_DEVICE_PATH) 1041 1075 ); 1076 1077 if (Atapi == NULL) { 1078 return (EFI_DEVICE_PATH_PROTOCOL *)Atapi; 1079 } 1042 1080 1043 1081 PrimarySecondaryStr = GetNextParamStr (&TextDeviceNode); … … 1091 1129 ); 1092 1130 1093 Scsi->Pun = (UINT16)Strtoi (PunStr); 1094 Scsi->Lun = (UINT16)Strtoi (LunStr); 1131 if (Scsi != NULL) { 1132 Scsi->Pun = (UINT16)Strtoi (PunStr); 1133 Scsi->Lun = (UINT16)Strtoi (LunStr); 1134 } 1095 1135 1096 1136 return (EFI_DEVICE_PATH_PROTOCOL *)Scsi; … … 1122 1162 ); 1123 1163 1124 Fibre->Reserved = 0; 1125 Strtoi64 (WWNStr, &Fibre->WWN); 1126 Strtoi64 (LunStr, &Fibre->Lun); 1164 if (Fibre != NULL) { 1165 Fibre->Reserved = 0; 1166 Strtoi64 (WWNStr, &Fibre->WWN); 1167 Strtoi64 (LunStr, &Fibre->Lun); 1168 } 1127 1169 1128 1170 return (EFI_DEVICE_PATH_PROTOCOL *)Fibre; … … 1154 1196 ); 1155 1197 1156 FibreEx->Reserved = 0; 1157 Strtoi64 (WWNStr, (UINT64 *)(&FibreEx->WWN)); 1158 Strtoi64 (LunStr, (UINT64 *)(&FibreEx->Lun)); 1159 1160 *(UINT64 *)(&FibreEx->WWN) = SwapBytes64 (*(UINT64 *)(&FibreEx->WWN)); 1161 *(UINT64 *)(&FibreEx->Lun) = SwapBytes64 (*(UINT64 *)(&FibreEx->Lun)); 1198 if (FibreEx != NULL) { 1199 FibreEx->Reserved = 0; 1200 Strtoi64 (WWNStr, (UINT64 *)(&FibreEx->WWN)); 1201 Strtoi64 (LunStr, (UINT64 *)(&FibreEx->Lun)); 1202 1203 *(UINT64 *)(&FibreEx->WWN) = SwapBytes64 (*(UINT64 *)(&FibreEx->WWN)); 1204 *(UINT64 *)(&FibreEx->Lun) = SwapBytes64 (*(UINT64 *)(&FibreEx->Lun)); 1205 } 1162 1206 1163 1207 return (EFI_DEVICE_PATH_PROTOCOL *)FibreEx; … … 1187 1231 ); 1188 1232 1189 F1394DevPath->Reserved = 0; 1190 F1394DevPath->Guid = StrHexToUint64 (GuidStr); 1233 if (F1394DevPath != NULL) { 1234 F1394DevPath->Reserved = 0; 1235 F1394DevPath->Guid = StrHexToUint64 (GuidStr); 1236 } 1191 1237 1192 1238 return (EFI_DEVICE_PATH_PROTOCOL *)F1394DevPath; … … 1218 1264 ); 1219 1265 1220 Usb->ParentPortNumber = (UINT8)Strtoi (PortStr); 1221 Usb->InterfaceNumber = (UINT8)Strtoi (InterfaceStr); 1266 if (Usb != NULL) { 1267 Usb->ParentPortNumber = (UINT8)Strtoi (PortStr); 1268 Usb->InterfaceNumber = (UINT8)Strtoi (InterfaceStr); 1269 } 1222 1270 1223 1271 return (EFI_DEVICE_PATH_PROTOCOL *)Usb; … … 1247 1295 ); 1248 1296 1249 I2ODevPath->Tid = (UINT32)Strtoi (TIDStr); 1297 if (I2ODevPath != NULL) { 1298 I2ODevPath->Tid = (UINT32)Strtoi (TIDStr); 1299 } 1250 1300 1251 1301 return (EFI_DEVICE_PATH_PROTOCOL *)I2ODevPath; … … 1283 1333 ); 1284 1334 1285 InfiniBand->ResourceFlags = (UINT32)Strtoi (FlagsStr); 1286 StrToGuid (GuidStr, (EFI_GUID *)InfiniBand->PortGid); 1287 Strtoi64 (SidStr, &InfiniBand->ServiceId); 1288 Strtoi64 (TidStr, &InfiniBand->TargetPortId); 1289 Strtoi64 (DidStr, &InfiniBand->DeviceId); 1335 if (InfiniBand != NULL) { 1336 InfiniBand->ResourceFlags = (UINT32)Strtoi (FlagsStr); 1337 StrToGuid (GuidStr, (EFI_GUID *)InfiniBand->PortGid); 1338 Strtoi64 (SidStr, &InfiniBand->ServiceId); 1339 Strtoi64 (TidStr, &InfiniBand->TargetPortId); 1340 Strtoi64 (DidStr, &InfiniBand->DeviceId); 1341 } 1290 1342 1291 1343 return (EFI_DEVICE_PATH_PROTOCOL *)InfiniBand; … … 1332 1384 (UINT16)sizeof (VENDOR_DEVICE_PATH) 1333 1385 ); 1334 CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid); 1386 1387 if (Vendor != NULL) { 1388 CopyGuid (&Vendor->Guid, &gEfiPcAnsiGuid); 1389 } 1335 1390 1336 1391 return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; … … 1357 1412 (UINT16)sizeof (VENDOR_DEVICE_PATH) 1358 1413 ); 1359 CopyGuid (&Vendor->Guid, &gEfiVT100Guid); 1414 1415 if (Vendor != NULL) { 1416 CopyGuid (&Vendor->Guid, &gEfiVT100Guid); 1417 } 1360 1418 1361 1419 return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; … … 1382 1440 (UINT16)sizeof (VENDOR_DEVICE_PATH) 1383 1441 ); 1384 CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid); 1442 1443 if (Vendor != NULL) { 1444 CopyGuid (&Vendor->Guid, &gEfiVT100PlusGuid); 1445 } 1385 1446 1386 1447 return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; … … 1407 1468 (UINT16)sizeof (VENDOR_DEVICE_PATH) 1408 1469 ); 1409 CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid); 1470 1471 if (Vendor != NULL) { 1472 CopyGuid (&Vendor->Guid, &gEfiVTUTF8Guid); 1473 } 1410 1474 1411 1475 return (EFI_DEVICE_PATH_PROTOCOL *)Vendor; … … 1435 1499 ); 1436 1500 1437 CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid); 1438 if (StrCmp (ValueStr, L"XonXoff") == 0) { 1439 UartFlowControl->FlowControlMap = 2; 1440 } else if (StrCmp (ValueStr, L"Hardware") == 0) { 1441 UartFlowControl->FlowControlMap = 1; 1442 } else { 1443 UartFlowControl->FlowControlMap = 0; 1501 if (UartFlowControl != NULL) { 1502 CopyGuid (&UartFlowControl->Guid, &gEfiUartDevicePathGuid); 1503 if (StrCmp (ValueStr, L"XonXoff") == 0) { 1504 UartFlowControl->FlowControlMap = 2; 1505 } else if (StrCmp (ValueStr, L"Hardware") == 0) { 1506 UartFlowControl->FlowControlMap = 1; 1507 } else { 1508 UartFlowControl->FlowControlMap = 0; 1509 } 1444 1510 } 1445 1511 … … 1486 1552 ); 1487 1553 1554 if (Sas == NULL) { 1555 return (EFI_DEVICE_PATH_PROTOCOL *)Sas; 1556 } 1557 1488 1558 CopyGuid (&Sas->Guid, &gEfiSasDevicePathGuid); 1489 1559 Strtoi64 (AddressStr, &Sas->SasAddress); … … 1581 1651 ); 1582 1652 1653 if (SasEx == NULL) { 1654 return (EFI_DEVICE_PATH_PROTOCOL *)SasEx; 1655 } 1656 1583 1657 Strtoi64 (AddressStr, &SasAddress); 1584 1658 Strtoi64 (LunStr, &Lun); … … 1664 1738 ); 1665 1739 1666 Nvme->NamespaceId = (UINT32)Strtoi (NamespaceIdStr); 1667 Uuid = (UINT8 *)&Nvme->NamespaceUuid; 1668 1669 Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8); 1670 while (Index-- != 0) { 1671 Uuid[Index] = (UINT8)StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-')); 1740 if (Nvme != NULL) { 1741 Nvme->NamespaceId = (UINT32)Strtoi (NamespaceIdStr); 1742 Uuid = (UINT8 *)&Nvme->NamespaceUuid; 1743 1744 Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8); 1745 while (Index-- != 0) { 1746 Uuid[Index] = (UINT8)StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-')); 1747 } 1672 1748 } 1673 1749 … … 1700 1776 ); 1701 1777 1702 Ufs->Pun = (UINT8)Strtoi (PunStr); 1703 Ufs->Lun = (UINT8)Strtoi (LunStr); 1778 if (Ufs != NULL) { 1779 Ufs->Pun = (UINT8)Strtoi (PunStr); 1780 Ufs->Lun = (UINT8)Strtoi (LunStr); 1781 } 1704 1782 1705 1783 return (EFI_DEVICE_PATH_PROTOCOL *)Ufs; … … 1729 1807 ); 1730 1808 1731 Sd->SlotNumber = (UINT8)Strtoi (SlotNumberStr); 1809 if (Sd != NULL) { 1810 Sd->SlotNumber = (UINT8)Strtoi (SlotNumberStr); 1811 } 1732 1812 1733 1813 return (EFI_DEVICE_PATH_PROTOCOL *)Sd; … … 1757 1837 ); 1758 1838 1759 Emmc->SlotNumber = (UINT8)Strtoi (SlotNumberStr); 1839 if (Emmc != NULL) { 1840 Emmc->SlotNumber = (UINT8)Strtoi (SlotNumberStr); 1841 } 1760 1842 1761 1843 return (EFI_DEVICE_PATH_PROTOCOL *)Emmc; … … 1783 1865 ); 1784 1866 1785 CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid); 1867 if (Vend != NULL) { 1868 CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid); 1869 } 1786 1870 1787 1871 return (EFI_DEVICE_PATH_PROTOCOL *)Vend; … … 1814 1898 ); 1815 1899 1816 MACDevPath->IfType = (UINT8)Strtoi (IfTypeStr); 1817 1818 Length = sizeof (EFI_MAC_ADDRESS); 1819 if ((MACDevPath->IfType == 0x01) || (MACDevPath->IfType == 0x00)) { 1820 Length = 6; 1821 } 1822 1823 StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length); 1900 if (MACDevPath != NULL) { 1901 MACDevPath->IfType = (UINT8)Strtoi (IfTypeStr); 1902 1903 Length = sizeof (EFI_MAC_ADDRESS); 1904 if ((MACDevPath->IfType == 0x01) || (MACDevPath->IfType == 0x00)) { 1905 Length = 6; 1906 } 1907 1908 StrHexToBytes (AddressStr, Length * 2, MACDevPath->MacAddress.Addr, Length); 1909 } 1824 1910 1825 1911 return (EFI_DEVICE_PATH_PROTOCOL *)MACDevPath; … … 1883 1969 ); 1884 1970 1971 if (IPv4 == NULL) { 1972 return (EFI_DEVICE_PATH_PROTOCOL *)IPv4; 1973 } 1974 1885 1975 StrToIpv4Address (RemoteIPStr, NULL, &IPv4->RemoteIpAddress, NULL); 1886 1976 IPv4->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr); … … 1939 2029 ); 1940 2030 2031 if (IPv6 == NULL) { 2032 return (EFI_DEVICE_PATH_PROTOCOL *)IPv6; 2033 } 2034 1941 2035 StrToIpv6Address (RemoteIPStr, NULL, &IPv6->RemoteIpAddress, NULL); 1942 2036 IPv6->Protocol = (UINT16)NetworkProtocolFromText (ProtocolStr); … … 1992 2086 (UINT16)sizeof (UART_DEVICE_PATH) 1993 2087 ); 2088 2089 if (Uart == NULL) { 2090 return (EFI_DEVICE_PATH_PROTOCOL *)Uart; 2091 } 1994 2092 1995 2093 if (StrCmp (BaudStr, L"DEFAULT") == 0) { … … 2072 2170 (UINT16)sizeof (USB_CLASS_DEVICE_PATH) 2073 2171 ); 2172 2173 if (UsbClass == NULL) { 2174 return (EFI_DEVICE_PATH_PROTOCOL *)UsbClass; 2175 } 2074 2176 2075 2177 VIDStr = GetNextParamStr (&TextDeviceNode); … … 2514 2616 (UINT16)(sizeof (USB_WWID_DEVICE_PATH) + SerialNumberStrLen * sizeof (CHAR16)) 2515 2617 ); 2516 UsbWwid->VendorId = (UINT16)Strtoi (VIDStr); 2517 UsbWwid->ProductId = (UINT16)Strtoi (PIDStr); 2518 UsbWwid->InterfaceNumber = (UINT16)Strtoi (InterfaceNumStr); 2519 2520 // 2521 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr. 2522 // Therefore, the '\0' will not be copied. 2523 // 2524 CopyMem ( 2525 (UINT8 *)UsbWwid + sizeof (USB_WWID_DEVICE_PATH), 2526 SerialNumberStr, 2527 SerialNumberStrLen * sizeof (CHAR16) 2528 ); 2618 2619 if (UsbWwid != NULL) { 2620 UsbWwid->VendorId = (UINT16)Strtoi (VIDStr); 2621 UsbWwid->ProductId = (UINT16)Strtoi (PIDStr); 2622 UsbWwid->InterfaceNumber = (UINT16)Strtoi (InterfaceNumStr); 2623 2624 // 2625 // There is no memory allocated in UsbWwid for the '\0' in SerialNumberStr. 2626 // Therefore, the '\0' will not be copied. 2627 // 2628 CopyMem ( 2629 (UINT8 *)UsbWwid + sizeof (USB_WWID_DEVICE_PATH), 2630 SerialNumberStr, 2631 SerialNumberStrLen * sizeof (CHAR16) 2632 ); 2633 } 2529 2634 2530 2635 return (EFI_DEVICE_PATH_PROTOCOL *)UsbWwid; … … 2554 2659 ); 2555 2660 2556 LogicalUnit->Lun = (UINT8)Strtoi (LunStr); 2661 if (LogicalUnit != NULL) { 2662 LogicalUnit->Lun = (UINT8)Strtoi (LunStr); 2663 } 2557 2664 2558 2665 return (EFI_DEVICE_PATH_PROTOCOL *)LogicalUnit; … … 2597 2704 ); 2598 2705 2706 if (ISCSIDevPath == NULL) { 2707 return (EFI_DEVICE_PATH_PROTOCOL *)ISCSIDevPath; 2708 } 2709 2599 2710 AsciiStr = ISCSIDevPath->TargetName; 2600 2711 StrToAscii (NameStr, &AsciiStr); … … 2658 2769 ); 2659 2770 2660 Vlan->VlanId = (UINT16)Strtoi (VlanStr); 2771 if (Vlan != NULL) { 2772 Vlan->VlanId = (UINT16)Strtoi (VlanStr); 2773 } 2661 2774 2662 2775 return (EFI_DEVICE_PATH_PROTOCOL *)Vlan; … … 2685 2798 (UINT16)sizeof (BLUETOOTH_DEVICE_PATH) 2686 2799 ); 2687 StrHexToBytes ( 2688 BluetoothStr, 2689 sizeof (BLUETOOTH_ADDRESS) * 2, 2690 BluetoothDp->BD_ADDR.Address, 2691 sizeof (BLUETOOTH_ADDRESS) 2692 ); 2800 2801 if (BluetoothDp != NULL) { 2802 StrHexToBytes ( 2803 BluetoothStr, 2804 sizeof (BLUETOOTH_ADDRESS) * 2, 2805 BluetoothDp->BD_ADDR.Address, 2806 sizeof (BLUETOOTH_ADDRESS) 2807 ); 2808 } 2809 2693 2810 return (EFI_DEVICE_PATH_PROTOCOL *)BluetoothDp; 2694 2811 } … … 2719 2836 ); 2720 2837 2721 if ( NULL != SSIdStr) {2838 if ((NULL != SSIdStr) && (NULL != WiFiDp)) { 2722 2839 DataLen = StrLen (SSIdStr); 2723 2840 if (StrLen (SSIdStr) > 32) { … … 2758 2875 ); 2759 2876 2760 BluetoothLeDp->Address.Type = (UINT8)Strtoi (BluetoothLeAddrTypeStr); 2761 StrHexToBytes ( 2762 BluetoothLeAddrStr, 2763 sizeof (BluetoothLeDp->Address.Address) * 2, 2764 BluetoothLeDp->Address.Address, 2765 sizeof (BluetoothLeDp->Address.Address) 2766 ); 2877 if (BluetoothLeDp != NULL) { 2878 BluetoothLeDp->Address.Type = (UINT8)Strtoi (BluetoothLeAddrTypeStr); 2879 StrHexToBytes ( 2880 BluetoothLeAddrStr, 2881 sizeof (BluetoothLeDp->Address.Address) * 2, 2882 BluetoothLeDp->Address.Address, 2883 sizeof (BluetoothLeDp->Address.Address) 2884 ); 2885 } 2886 2767 2887 return (EFI_DEVICE_PATH_PROTOCOL *)BluetoothLeDp; 2768 2888 } … … 2884 3004 ); 2885 3005 2886 while (Uri Length-- != 0) {3006 while (Uri != NULL && UriLength-- != 0) { 2887 3007 Uri->Uri[UriLength] = (CHAR8)UriStr[UriLength]; 2888 3008 } … … 2939 3059 ); 2940 3060 3061 if (Hd == NULL) { 3062 return (EFI_DEVICE_PATH_PROTOCOL *)Hd; 3063 } 3064 2941 3065 Hd->PartitionNumber = (UINT32)Strtoi (PartitionStr); 2942 3066 … … 2992 3116 ); 2993 3117 2994 CDROMDevPath->BootEntry = (UINT32)Strtoi (EntryStr); 2995 Strtoi64 (StartStr, &CDROMDevPath->PartitionStart); 2996 Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize); 3118 if (CDROMDevPath != NULL) { 3119 CDROMDevPath->BootEntry = (UINT32)Strtoi (EntryStr); 3120 Strtoi64 (StartStr, &CDROMDevPath->PartitionStart); 3121 Strtoi64 (SizeStr, &CDROMDevPath->PartitionSize); 3122 } 2997 3123 2998 3124 return (EFI_DEVICE_PATH_PROTOCOL *)CDROMDevPath; … … 3040 3166 ); 3041 3167 3042 StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode); 3168 if (File != NULL) { 3169 StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode); 3170 } 3043 3171 3044 3172 return (EFI_DEVICE_PATH_PROTOCOL *)File; … … 3068 3196 ); 3069 3197 3070 StrToGuid (GuidStr, &Media->Protocol); 3198 if (Media != NULL) { 3199 StrToGuid (GuidStr, &Media->Protocol); 3200 } 3071 3201 3072 3202 return (EFI_DEVICE_PATH_PROTOCOL *)Media; … … 3096 3226 ); 3097 3227 3098 StrToGuid (GuidStr, &Fv->FvName); 3228 if (Fv != NULL) { 3229 StrToGuid (GuidStr, &Fv->FvName); 3230 } 3099 3231 3100 3232 return (EFI_DEVICE_PATH_PROTOCOL *)Fv; … … 3124 3256 ); 3125 3257 3126 StrToGuid (GuidStr, &FvFile->FvFileName); 3258 if (FvFile != NULL) { 3259 StrToGuid (GuidStr, &FvFile->FvFileName); 3260 } 3127 3261 3128 3262 return (EFI_DEVICE_PATH_PROTOCOL *)FvFile; … … 3154 3288 ); 3155 3289 3156 Strtoi64 (StartingOffsetStr, &Offset->StartingOffset); 3157 Strtoi64 (EndingOffsetStr, &Offset->EndingOffset); 3290 if (Offset != NULL) { 3291 Strtoi64 (StartingOffsetStr, &Offset->StartingOffset); 3292 Strtoi64 (EndingOffsetStr, &Offset->EndingOffset); 3293 } 3158 3294 3159 3295 return (EFI_DEVICE_PATH_PROTOCOL *)Offset; … … 3191 3327 ); 3192 3328 3193 Strtoi64 (StartingAddrStr, &StartingAddr); 3194 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3195 Strtoi64 (EndingAddrStr, &EndingAddr); 3196 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3197 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3198 StrToGuid (TypeGuidStr, &RamDisk->TypeGuid); 3329 if (RamDisk != NULL) { 3330 Strtoi64 (StartingAddrStr, &StartingAddr); 3331 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3332 Strtoi64 (EndingAddrStr, &EndingAddr); 3333 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3334 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3335 StrToGuid (TypeGuidStr, &RamDisk->TypeGuid); 3336 } 3199 3337 3200 3338 return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk; … … 3231 3369 ); 3232 3370 3233 Strtoi64 (StartingAddrStr, &StartingAddr); 3234 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3235 Strtoi64 (EndingAddrStr, &EndingAddr); 3236 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3237 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3238 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid); 3371 if (RamDisk != NULL) { 3372 Strtoi64 (StartingAddrStr, &StartingAddr); 3373 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3374 Strtoi64 (EndingAddrStr, &EndingAddr); 3375 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3376 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3377 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualDiskGuid); 3378 } 3239 3379 3240 3380 return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk; … … 3271 3411 ); 3272 3412 3273 Strtoi64 (StartingAddrStr, &StartingAddr); 3274 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3275 Strtoi64 (EndingAddrStr, &EndingAddr); 3276 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3277 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3278 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid); 3413 if (RamDisk != NULL) { 3414 Strtoi64 (StartingAddrStr, &StartingAddr); 3415 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3416 Strtoi64 (EndingAddrStr, &EndingAddr); 3417 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3418 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3419 CopyGuid (&RamDisk->TypeGuid, &gEfiVirtualCdGuid); 3420 } 3279 3421 3280 3422 return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk; … … 3311 3453 ); 3312 3454 3313 Strtoi64 (StartingAddrStr, &StartingAddr); 3314 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3315 Strtoi64 (EndingAddrStr, &EndingAddr); 3316 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3317 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3318 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid); 3455 if (RamDisk != NULL) { 3456 Strtoi64 (StartingAddrStr, &StartingAddr); 3457 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3458 Strtoi64 (EndingAddrStr, &EndingAddr); 3459 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3460 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3461 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualDiskGuid); 3462 } 3319 3463 3320 3464 return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk; … … 3351 3495 ); 3352 3496 3353 Strtoi64 (StartingAddrStr, &StartingAddr); 3354 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3355 Strtoi64 (EndingAddrStr, &EndingAddr); 3356 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3357 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3358 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid); 3497 if (RamDisk != NULL) { 3498 Strtoi64 (StartingAddrStr, &StartingAddr); 3499 WriteUnaligned64 ((UINT64 *)&(RamDisk->StartingAddr[0]), StartingAddr); 3500 Strtoi64 (EndingAddrStr, &EndingAddr); 3501 WriteUnaligned64 ((UINT64 *)&(RamDisk->EndingAddr[0]), EndingAddr); 3502 RamDisk->Instance = (UINT16)Strtoi (InstanceStr); 3503 CopyGuid (&RamDisk->TypeGuid, &gEfiPersistentVirtualCdGuid); 3504 } 3359 3505 3360 3506 return (EFI_DEVICE_PATH_PROTOCOL *)RamDisk; … … 3404 3550 (UINT16)(sizeof (BBS_BBS_DEVICE_PATH) + StrLen (IdStr)) 3405 3551 ); 3552 3553 if (Bbs == NULL) { 3554 return (EFI_DEVICE_PATH_PROTOCOL *)Bbs; 3555 } 3406 3556 3407 3557 if (StrCmp (TypeStr, L"Floppy") == 0) { … … 3456 3606 (UINT16)sizeof (SATA_DEVICE_PATH) 3457 3607 ); 3608 3609 if (Sata == NULL) { 3610 return (EFI_DEVICE_PATH_PROTOCOL *)Sata; 3611 } 3612 3458 3613 Sata->HBAPortNumber = (UINT16)Strtoi (Param1); 3459 3614 … … 3657 3812 3658 3813 DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)AllocatePool (END_DEVICE_PATH_LENGTH); 3659 ASSERT (DevicePath != NULL); 3814 3815 if (DevicePath == NULL) { 3816 ASSERT (DevicePath != NULL); 3817 return NULL; 3818 } 3819 3660 3820 SetDevicePathEndNode (DevicePath); 3661 3821 3662 3822 DevicePathStr = UefiDevicePathLibStrDuplicate (TextDevicePath); 3823 3824 if (DevicePathStr == NULL) { 3825 return NULL; 3826 } 3663 3827 3664 3828 Str = DevicePathStr; … … 3667 3831 3668 3832 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode); 3669 FreePool (DevicePath); 3670 FreePool (DeviceNode); 3833 if (DevicePath != NULL) { 3834 FreePool (DevicePath); 3835 } 3836 3837 if (DeviceNode != NULL) { 3838 FreePool (DeviceNode); 3839 } 3840 3671 3841 DevicePath = NewDevicePath; 3672 3842 3673 3843 if (IsInstanceEnd) { 3674 3844 DeviceNode = (EFI_DEVICE_PATH_PROTOCOL *)AllocatePool (END_DEVICE_PATH_LENGTH); 3675 ASSERT (DeviceNode != NULL); 3845 if (DeviceNode == NULL) { 3846 ASSERT (DeviceNode != NULL); 3847 return NULL; 3848 } 3849 3676 3850 SetDevicePathEndNode (DeviceNode); 3677 3851 DeviceNode->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; 3678 3852 3679 3853 NewDevicePath = AppendDevicePathNode (DevicePath, DeviceNode); 3680 FreePool (DevicePath); 3681 FreePool (DeviceNode); 3854 if (DevicePath != NULL) { 3855 FreePool (DevicePath); 3856 } 3857 3858 if (DeviceNode != NULL) { 3859 FreePool (DeviceNode); 3860 } 3861 3682 3862 DevicePath = NewDevicePath; 3683 3863 }
Note:
See TracChangeset
for help on using the changeset viewer.