X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=IntelFrameworkModulePkg%2FLibrary%2FGenericBdsLib%2FDevicePath.c;h=855b73b5025fa9a8357af9c326658be3bb7abaef;hb=1ace0001356b9798a57a6cb8b87d545f169543fc;hp=135fa63d1a018995d57a80f652243aad6115ded7;hpb=5c08e1173703234cc2913757f237ee916087498a;p=mirror_edk2.git diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/DevicePath.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/DevicePath.c index 135fa63d1a..855b73b502 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/DevicePath.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/DevicePath.c @@ -2,7 +2,7 @@ BDS internal function define the default device path string, it can be replaced by platform device path. -Copyright (c) 2004 - 2008, Intel Corporation.
+Copyright (c) 2004 - 2009, 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 @@ -20,7 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. The caller must free the resulting buffer. @param Str Tracks the allocated pool, size in use, and amount of pool allocated. - @param fmt The format string + @param Fmt The format string @param ... The data will be printed. @return Allocated buffer with the formatted string printed in it. @@ -32,7 +32,7 @@ CHAR16 * EFIAPI CatPrint ( IN OUT POOL_PRINT *Str, - IN CHAR16 *fmt, + IN CHAR16 *Fmt, ... ) { @@ -42,36 +42,36 @@ CatPrint ( AppendStr = AllocateZeroPool (0x1000); if (AppendStr == NULL) { - return Str->str; + return Str->Str; } - VA_START (Args, fmt); - UnicodeVSPrint (AppendStr, 0x1000, fmt, Args); + VA_START (Args, Fmt); + UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args); VA_END (Args); - if (NULL == Str->str) { + if (NULL == Str->Str) { StringSize = StrSize (AppendStr); - Str->str = AllocateZeroPool (StringSize); - ASSERT (Str->str != NULL); + Str->Str = AllocateZeroPool (StringSize); + ASSERT (Str->Str != NULL); } else { StringSize = StrSize (AppendStr); - StringSize += (StrSize (Str->str) - sizeof (UINT16)); + StringSize += (StrSize (Str->Str) - sizeof (UINT16)); - Str->str = ReallocatePool ( - StrSize (Str->str), + Str->Str = ReallocatePool ( + StrSize (Str->Str), StringSize, - Str->str + Str->Str ); - ASSERT (Str->str != NULL); + ASSERT (Str->Str != NULL); } - Str->maxlen = MAX_CHAR * sizeof (UINT16); - if (StringSize < Str->maxlen) { - StrCat (Str->str, AppendStr); - Str->len = StringSize - sizeof (UINT16); + Str->Maxlen = MAX_CHAR * sizeof (UINT16); + if (StringSize < Str->Maxlen) { + StrCat (Str->Str, AppendStr); + Str->Len = StringSize - sizeof (UINT16); } FreePool (AppendStr); - return Str->str; + return Str->Str; } /** @@ -140,7 +140,7 @@ DevPathMemMap ( CatPrint ( Str, L"MemMap(%d:%lx-%lx)", - MemMap->MemoryType, + (UINTN) MemMap->MemoryType, MemMap->StartingAddress, MemMap->EndingAddress ); @@ -177,7 +177,6 @@ DevPathController ( **/ VOID -EFIAPI DevPathVendor ( IN OUT POOL_PRINT *Str, IN VOID *DevPath @@ -239,7 +238,7 @@ DevPathVendor ( L"SAS(%lx,%lx,%x,", ((SAS_DEVICE_PATH *) Vendor)->SasAddress, ((SAS_DEVICE_PATH *) Vendor)->Lun, - ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort + (UINTN) ((SAS_DEVICE_PATH *) Vendor)->RelativeTargetPort ); Info = (((SAS_DEVICE_PATH *) Vendor)->DeviceTopology); if ((Info & 0x0f) == 0) { @@ -345,16 +344,12 @@ DevPathExtendedAcpi ( UINT16 Anchor; CHAR8 *AsChar8Array; - ASSERT (Str != NULL); - ASSERT (DevPath != NULL); - HIDSTRIdx = 0; UIDSTRIdx = 0; CIDSTRIdx = 0; ExtendedAcpi = DevPath; Length = (UINT16) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL *) ExtendedAcpi); - ASSERT (Length >= 19); AsChar8Array = (CHAR8 *) ExtendedAcpi; // @@ -492,8 +487,8 @@ DevPathAtapi ( CatPrint ( Str, L"Ata(%s,%s)", - Atapi->PrimarySecondary ? L"Secondary" : L"Primary", - Atapi->SlaveMaster ? L"Slave" : L"Master" + (Atapi->PrimarySecondary != 0)? L"Secondary" : L"Primary", + (Atapi->SlaveMaster != 0)? L"Slave" : L"Master" ); } @@ -560,7 +555,7 @@ DevPath1394 ( F1394_DEVICE_PATH *F1394Path; F1394Path = DevPath; - CatPrint (Str, L"1394(%g)", &F1394Path->Guid); + CatPrint (Str, L"1394(%lx)", &F1394Path->Guid); } /** @@ -684,13 +679,22 @@ DevPathSata ( SATA_DEVICE_PATH *Sata; Sata = DevPath; - CatPrint ( - Str, - L"Sata(%x,%x,%x)", - (UINTN) Sata->HBAPortNumber, - (UINTN) Sata->PortMultiplierPortNumber, - (UINTN) Sata->Lun - ); + if ((Sata->PortMultiplierPortNumber & SATA_HBA_DIRECT_CONNECT_FLAG) != 0) { + CatPrint ( + Str, + L"Sata(%x,%x)", + (UINTN) Sata->HBAPortNumber, + (UINTN) Sata->Lun + ); + } else { + CatPrint ( + Str, + L"Sata(%x,%x,%x)", + (UINTN) Sata->HBAPortNumber, + (UINTN) Sata->PortMultiplierPortNumber, + (UINTN) Sata->Lun + ); + } } /** @@ -905,7 +909,7 @@ DevPathUart ( if (Uart->BaudRate == 0) { CatPrint (Str, L"Uart(DEFAULT,%c,", Parity); } else { - CatPrint (Str, L"Uart(%d,%c,", Uart->BaudRate, Parity); + CatPrint (Str, L"Uart(%ld,%c,", Uart->BaudRate, Parity); } if (Uart->DataBits == 0) { @@ -956,15 +960,12 @@ DevPathiSCSI ( ISCSI_DEVICE_PATH_WITH_NAME *IScsi; UINT16 Options; - ASSERT (Str != NULL); - ASSERT (DevPath != NULL); - IScsi = DevPath; CatPrint ( Str, - L"iSCSI(%s,%x,%lx,", - IScsi->iSCSITargetName, - IScsi->TargetPortalGroupTag, + L"iSCSI(%a,%x,%lx,", + IScsi->TargetName, + (UINTN) IScsi->TargetPortalGroupTag, IScsi->Lun ); @@ -983,6 +984,28 @@ DevPathiSCSI ( CatPrint (Str, L"%s)", (IScsi->NetworkProtocol == 0) ? L"TCP" : L"reserved"); } +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathVlan ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + VLAN_DEVICE_PATH *Vlan; + + Vlan = DevPath; + CatPrint (Str, L"Vlan(%d)", (UINTN) Vlan->VlanId); +} + /** Convert Device Path to a Unicode string for printing. @@ -1121,6 +1144,33 @@ DevPathFvFilePath ( CatPrint (Str, L"%g", &FvFilePath->FvFileName); } +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maixmum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathRelativeOffsetRange ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH *Offset; + + Offset = DevPath; + CatPrint ( + Str, + L"Offset(%lx,%lx)", + Offset->StartingOffset, + Offset->EndingOffset + ); +} + /** Convert Device Path to a Unicode string for printing. @@ -1214,6 +1264,27 @@ DevPathNodeUnknown ( { CatPrint (Str, L"?"); } +/** + Convert Device Path to a Unicode string for printing. + + @param Str The buffer holding the output string. + This buffer contains the length of the + string and the maximum length reserved + for the string buffer. + @param DevPath The device path. + +**/ +VOID +DevPathFvPath ( + IN OUT POOL_PRINT *Str, + IN VOID *DevPath + ) +{ + MEDIA_FW_VOL_DEVICE_PATH *FvPath; + + FvPath = DevPath; + CatPrint (Str, L"Fv(%g)", &FvPath->FvName); +} DEVICE_PATH_STRING_TABLE DevPathTable[] = { { @@ -1341,6 +1412,11 @@ DEVICE_PATH_STRING_TABLE DevPathTable[] = { MSG_ISCSI_DP, DevPathiSCSI }, + { + MESSAGING_DEVICE_PATH, + MSG_VLAN_DP, + DevPathVlan + }, { MEDIA_DEVICE_PATH, MEDIA_HARDDRIVE_DP, @@ -1366,11 +1442,21 @@ DEVICE_PATH_STRING_TABLE DevPathTable[] = { MEDIA_PROTOCOL_DP, DevPathMediaProtocol }, + { + MEDIA_DEVICE_PATH, + MEDIA_PIWG_FW_VOL_DP, + DevPathFvPath, + }, { MEDIA_DEVICE_PATH, MEDIA_PIWG_FW_FILE_DP, DevPathFvFilePath }, + { + MEDIA_DEVICE_PATH, + MEDIA_RELATIVE_OFFSET_RANGE_DP, + DevPathRelativeOffsetRange, + }, { BBS_DEVICE_PATH, BBS_BBS_DP, @@ -1444,7 +1530,7 @@ DevicePathToStr ( // Find the handler to dump this device path node // DumpNode = NULL; - for (Index = 0; DevPathTable[Index].Function; Index += 1) { + for (Index = 0; DevPathTable[Index].Function != NULL; Index += 1) { if (DevicePathType (DevPathNode) == DevPathTable[Index].Type && DevicePathSubType (DevPathNode) == DevPathTable[Index].SubType @@ -1462,7 +1548,7 @@ DevicePathToStr ( // // Put a path seperator in if needed // - if (Str.len && DumpNode != DevPathEndInstance) { + if ((Str.Len != 0) && (DumpNode != DevPathEndInstance)) { CatPrint (&Str, L"/"); } // @@ -1477,9 +1563,9 @@ DevicePathToStr ( } Done: - NewSize = (Str.len + 1) * sizeof (CHAR16); - Str.str = ReallocatePool (NewSize, NewSize, Str.str); - ASSERT (Str.str != NULL); - Str.str[Str.len] = 0; - return Str.str; + NewSize = (Str.Len + 1) * sizeof (CHAR16); + Str.Str = ReallocatePool (NewSize, NewSize, Str.Str); + ASSERT (Str.Str != NULL); + Str.Str[Str.Len] = 0; + return Str.Str; }