2 BDS internal function define the default device path string, it can be
3 replaced by platform device path.
5 Copyright (c) 2004 - 2008, Intel Corporation. <BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "InternalBdsLib.h"
19 EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid
= DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL
;
21 EFI_GUID mEfiDevicePathMessagingSASGuid
= DEVICE_PATH_MESSAGING_SAS
;
26 Adjusts the size of a previously allocated buffer.
29 @param OldPool A pointer to the buffer whose size is being adjusted.
30 @param OldSize The size of the current buffer.
31 @param NewSize The size of the new buffer.
33 @return The new buffer allocated. If allocatio failed, NULL will be returned.
47 NewPool
= AllocateZeroPool (NewSize
);
50 if (OldPool
!= NULL
) {
51 if (NewPool
!= NULL
) {
52 CopyMem (NewPool
, OldPool
, OldSize
< NewSize
? OldSize
: NewSize
);
55 gBS
->FreePool (OldPool
);
63 Concatenates a formatted unicode string to allocated pool.
64 The caller must free the resulting buffer.
66 @param Str Tracks the allocated pool, size in use, and amount of pool
68 @param fmt The format string
70 @param ... Variable argument list.
72 @return Allocated buffer with the formatted string printed in it.
73 The caller must free the allocated buffer. The buffer
74 allocation is not packed.
80 IN OUT POOL_PRINT
*Str
,
89 AppendStr
= AllocateZeroPool (0x1000);
90 if (AppendStr
== NULL
) {
95 UnicodeVSPrint (AppendStr
, 0x1000, fmt
, Args
);
97 if (NULL
== Str
->str
) {
98 StringSize
= StrSize (AppendStr
);
99 Str
->str
= AllocateZeroPool (StringSize
);
100 ASSERT (Str
->str
!= NULL
);
102 StringSize
= StrSize (AppendStr
);
103 StringSize
+= (StrSize (Str
->str
) - sizeof (UINT16
));
105 Str
->str
= ReallocatePool (
110 ASSERT (Str
->str
!= NULL
);
113 Str
->maxlen
= MAX_CHAR
* sizeof (UINT16
);
114 if (StringSize
< Str
->maxlen
) {
115 StrCat (Str
->str
, AppendStr
);
116 Str
->len
= StringSize
- sizeof (UINT16
);
119 gBS
->FreePool (AppendStr
);
125 Function unpacks a device path data structure so that all the nodes
126 of a device path are naturally aligned.
128 @param DevPath A pointer to a device path data structure
130 @return A ponter to new device If the memory for the device path is successfully allocated, then a
131 pointer to the new device path is returned. Otherwise, NULL is returned.
134 EFI_DEVICE_PATH_PROTOCOL
*
136 BdsLibUnpackDevicePath (
137 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
140 EFI_DEVICE_PATH_PROTOCOL
*Src
;
141 EFI_DEVICE_PATH_PROTOCOL
*Dest
;
142 EFI_DEVICE_PATH_PROTOCOL
*NewPath
;
146 // Walk device path and round sizes to valid boundries
151 Size
+= DevicePathNodeLength (Src
);
152 Size
+= ALIGN_SIZE (Size
);
154 if (IsDevicePathEnd (Src
)) {
158 Src
= NextDevicePathNode (Src
);
161 // Allocate space for the unpacked path
163 NewPath
= AllocateZeroPool (Size
);
164 if (NewPath
!= NULL
) {
166 ASSERT (((UINTN
) NewPath
) % MIN_ALIGNMENT_SIZE
== 0);
174 Size
= DevicePathNodeLength (Src
);
175 CopyMem (Dest
, Src
, Size
);
176 Size
+= ALIGN_SIZE (Size
);
177 SetDevicePathNodeLength (Dest
, Size
);
178 Dest
->Type
|= EFI_DP_TYPE_UNPACKED
;
179 Dest
= (EFI_DEVICE_PATH_PROTOCOL
*) (((UINT8
*) Dest
) + Size
);
181 if (IsDevicePathEnd (Src
)) {
185 Src
= NextDevicePathNode (Src
);
193 Convert Device Path to a Unicode string for printing.
195 @param Str The buffer holding the output string.
196 This buffer contains the length of the
197 string and the maixmum length reserved
198 for the string buffer.
199 @param DevPath The device path.
204 IN OUT POOL_PRINT
*Str
,
208 PCI_DEVICE_PATH
*Pci
;
211 CatPrint (Str
, L
"Pci(%x|%x)", (UINTN
) Pci
->Device
, (UINTN
) Pci
->Function
);
215 Convert Device Path to a Unicode string for printing.
217 @param Str The buffer holding the output string.
218 This buffer contains the length of the
219 string and the maixmum length reserved
220 for the string buffer.
221 @param DevPath The device path.
226 IN OUT POOL_PRINT
*Str
,
230 PCCARD_DEVICE_PATH
*Pccard
;
233 CatPrint (Str
, L
"Pcmcia(Function%x)", (UINTN
) Pccard
->FunctionNumber
);
237 Convert Device Path to a Unicode string for printing.
239 @param Str The buffer holding the output string.
240 This buffer contains the length of the
241 string and the maixmum length reserved
242 for the string buffer.
243 @param DevPath The device path.
248 IN OUT POOL_PRINT
*Str
,
252 MEMMAP_DEVICE_PATH
*MemMap
;
257 L
"MemMap(%d:%lx-%lx)",
259 MemMap
->StartingAddress
,
260 MemMap
->EndingAddress
265 Convert Device Path to a Unicode string for printing.
267 @param Str The buffer holding the output string.
268 This buffer contains the length of the
269 string and the maixmum length reserved
270 for the string buffer.
271 @param DevPath The device path.
276 IN OUT POOL_PRINT
*Str
,
280 CONTROLLER_DEVICE_PATH
*Controller
;
282 Controller
= DevPath
;
283 CatPrint (Str
, L
"Ctrl(%d)", (UINTN
) Controller
->ControllerNumber
);
288 Convert Device Path to a Unicode string for printing.
290 @param Str The buffer holding the output string.
291 This buffer contains the length of the
292 string and the maixmum length reserved
293 for the string buffer.
294 @param DevPath The device path.
300 IN OUT POOL_PRINT
*Str
,
304 VENDOR_DEVICE_PATH
*Vendor
;
308 UINT32 FlowControlMap
;
314 switch (DevicePathType (&Vendor
->Header
)) {
315 case HARDWARE_DEVICE_PATH
:
317 // bugbug: nt 32 specific definition
320 // If the device is a winntbus device, we will give it a readable device name.
322 if (CompareGuid (&Vendor
->Guid
, &mEfiWinNtThunkProtocolGuid
)) {
323 CatPrint (Str
, L
"%s", L
"WinNtBus");
325 } else if (CompareGuid (&Vendor
->Guid
, &mEfiWinNtGopGuid
)) {
326 CatPrint (Str
, L
"%s", L
"GOP");
328 } else if (CompareGuid (&Vendor
->Guid
, &mEfiWinNtSerialPortGuid
)) {
329 CatPrint (Str
, L
"%s", L
"Serial");
335 case MESSAGING_DEVICE_PATH
:
337 if (CompareGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
)) {
338 CatPrint (Str
, L
"VenPcAnsi()");
340 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100Guid
)) {
341 CatPrint (Str
, L
"VenVt100()");
343 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
)) {
344 CatPrint (Str
, L
"VenVt100Plus()");
346 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
)) {
347 CatPrint (Str
, L
"VenUft8()");
349 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingUartFlowControlGuid
)) {
350 FlowControlMap
= (((UART_FLOW_CONTROL_DEVICE_PATH
*) Vendor
)->FlowControlMap
);
351 switch (FlowControlMap
& 0x00000003) {
353 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"None");
357 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"Hardware");
361 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"XonXoff");
370 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingSASGuid
)) {
374 ((SAS_DEVICE_PATH
*) Vendor
)->SasAddress
,
375 ((SAS_DEVICE_PATH
*) Vendor
)->Lun
,
376 ((SAS_DEVICE_PATH
*) Vendor
)->RelativeTargetPort
378 Info
= (((SAS_DEVICE_PATH
*) Vendor
)->DeviceTopology
);
379 if ((Info
& 0x0f) == 0) {
380 CatPrint (Str
, L
"NoTopology,0,0,0,");
381 } else if (((Info
& 0x0f) == 1) || ((Info
& 0x0f) == 2)) {
385 ((Info
& (0x1 << 4)) != 0) ? L
"SATA" : L
"SAS",
386 ((Info
& (0x1 << 5)) != 0) ? L
"External" : L
"Internal",
387 ((Info
& (0x1 << 6)) != 0) ? L
"Expanded" : L
"Direct"
389 if ((Info
& 0x0f) == 1) {
390 CatPrint (Str
, L
"0,");
392 CatPrint (Str
, L
"%x,", (UINTN
) ((Info
>> 8) & 0xff));
395 CatPrint (Str
, L
"0,0,0,0,");
398 CatPrint (Str
, L
"%x)", (UINTN
) ((SAS_DEVICE_PATH
*) Vendor
)->Reserved
);
401 } else if (CompareGuid (&Vendor
->Guid
, &gEfiDebugPortProtocolGuid
)) {
402 CatPrint (Str
, L
"DebugPort()");
407 case MEDIA_DEVICE_PATH
:
416 CatPrint (Str
, L
"Ven%s(%g", Type
, &Vendor
->Guid
);
417 DataLength
= DevicePathNodeLength (&Vendor
->Header
) - sizeof (VENDOR_DEVICE_PATH
);
418 if (DataLength
> 0) {
419 CatPrint (Str
, L
",");
420 for (Index
= 0; Index
< DataLength
; Index
++) {
421 CatPrint (Str
, L
"%02x", (UINTN
) ((VENDOR_DEVICE_PATH_WITH_DATA
*) Vendor
)->VendorDefinedData
[Index
]);
424 CatPrint (Str
, L
")");
429 Convert Device Path to a Unicode string for printing.
431 @param Str The buffer holding the output string.
432 This buffer contains the length of the
433 string and the maixmum length reserved
434 for the string buffer.
435 @param DevPath The device path.
440 IN OUT POOL_PRINT
*Str
,
444 ACPI_HID_DEVICE_PATH
*Acpi
;
447 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
448 CatPrint (Str
, L
"Acpi(PNP%04x,%x)", (UINTN
) EISA_ID_TO_NUM (Acpi
->HID
), (UINTN
) Acpi
->UID
);
450 CatPrint (Str
, L
"Acpi(%08x,%x)", (UINTN
) Acpi
->HID
, (UINTN
) Acpi
->UID
);
455 Convert Device Path to a Unicode string for printing.
457 @param Str The buffer holding the output string.
458 This buffer contains the length of the
459 string and the maixmum length reserved
460 for the string buffer.
461 @param DevPath The device path.
465 DevPathExtendedAcpi (
466 IN OUT POOL_PRINT
*Str
,
470 ACPI_EXTENDED_HID_DEVICE_PATH
*ExtendedAcpi
;
472 // Index for HID, UID and CID strings, 0 for non-exist
482 ASSERT (Str
!= NULL
);
483 ASSERT (DevPath
!= NULL
);
488 ExtendedAcpi
= DevPath
;
489 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) ExtendedAcpi
);
491 ASSERT (Length
>= 19);
492 AsChar8Array
= (CHAR8
*) ExtendedAcpi
;
498 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
] != '\0'; Index
++) {
501 if (Index
> Anchor
) {
507 Anchor
= (UINT16
) (Index
+ 1);
508 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
] != '\0'; Index
++) {
511 if (Index
> Anchor
) {
517 Anchor
= (UINT16
) (Index
+ 1);
518 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
] != '\0'; Index
++) {
521 if (Index
> Anchor
) {
525 if (HIDSTRIdx
== 0 && CIDSTRIdx
== 0 && ExtendedAcpi
->UID
== 0) {
526 CatPrint (Str
, L
"AcpiExp(");
527 if ((ExtendedAcpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
528 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->HID
));
530 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->HID
);
532 if ((ExtendedAcpi
->CID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
533 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->CID
));
535 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->CID
);
537 if (UIDSTRIdx
!= 0) {
538 CatPrint (Str
, L
"%a)", AsChar8Array
+ UIDSTRIdx
);
540 CatPrint (Str
, L
"\"\")");
543 CatPrint (Str
, L
"AcpiEx(");
544 if ((ExtendedAcpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
545 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->HID
));
547 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->HID
);
549 if ((ExtendedAcpi
->CID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
550 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->CID
));
552 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->CID
);
554 CatPrint (Str
, L
"%x,", (UINTN
) ExtendedAcpi
->UID
);
556 if (HIDSTRIdx
!= 0) {
557 CatPrint (Str
, L
"%a,", AsChar8Array
+ HIDSTRIdx
);
559 CatPrint (Str
, L
"\"\",");
561 if (CIDSTRIdx
!= 0) {
562 CatPrint (Str
, L
"%a,", AsChar8Array
+ CIDSTRIdx
);
564 CatPrint (Str
, L
"\"\",");
566 if (UIDSTRIdx
!= 0) {
567 CatPrint (Str
, L
"%a)", AsChar8Array
+ UIDSTRIdx
);
569 CatPrint (Str
, L
"\"\")");
576 Convert Device Path to a Unicode string for printing.
578 @param Str The buffer holding the output string.
579 This buffer contains the length of the
580 string and the maixmum length reserved
581 for the string buffer.
582 @param DevPath The device path.
587 IN OUT POOL_PRINT
*Str
,
591 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
594 UINT16 AdditionalAdrCount
;
597 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
);
598 AdditionalAdrCount
= (UINT16
) ((Length
- 8) / 4);
600 CatPrint (Str
, L
"AcpiAdr(%x", (UINTN
) AcpiAdr
->ADR
);
601 for (Index
= 0; Index
< AdditionalAdrCount
; Index
++) {
602 CatPrint (Str
, L
",%x", (UINTN
) *(UINT32
*) ((UINT8
*) AcpiAdr
+ 8 + Index
* 4));
604 CatPrint (Str
, L
")");
608 Convert Device Path to a Unicode string for printing.
610 @param Str The buffer holding the output string.
611 This buffer contains the length of the
612 string and the maixmum length reserved
613 for the string buffer.
614 @param DevPath The device path.
619 IN OUT POOL_PRINT
*Str
,
623 ATAPI_DEVICE_PATH
*Atapi
;
629 Atapi
->PrimarySecondary
? L
"Secondary" : L
"Primary",
630 Atapi
->SlaveMaster
? L
"Slave" : L
"Master"
635 Convert Device Path to a Unicode string for printing.
637 @param Str The buffer holding the output string.
638 This buffer contains the length of the
639 string and the maixmum length reserved
640 for the string buffer.
641 @param DevPath The device path.
646 IN OUT POOL_PRINT
*Str
,
650 SCSI_DEVICE_PATH
*Scsi
;
653 CatPrint (Str
, L
"Scsi(Pun%x,Lun%x)", (UINTN
) Scsi
->Pun
, (UINTN
) Scsi
->Lun
);
657 Convert Device Path to a Unicode string for printing.
659 @param Str The buffer holding the output string.
660 This buffer contains the length of the
661 string and the maixmum length reserved
662 for the string buffer.
663 @param DevPath The device path.
668 IN OUT POOL_PRINT
*Str
,
672 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
675 CatPrint (Str
, L
"Fibre(Wwn%lx,Lun%x)", Fibre
->WWN
, Fibre
->Lun
);
679 Convert Device Path to a Unicode string for printing.
681 @param Str The buffer holding the output string.
682 This buffer contains the length of the
683 string and the maixmum length reserved
684 for the string buffer.
685 @param DevPath The device path.
690 IN OUT POOL_PRINT
*Str
,
694 F1394_DEVICE_PATH
*F1394Path
;
697 CatPrint (Str
, L
"1394(%g)", &F1394Path
->Guid
);
701 Convert Device Path to a Unicode string for printing.
703 @param Str The buffer holding the output string.
704 This buffer contains the length of the
705 string and the maixmum length reserved
706 for the string buffer.
707 @param DevPath The device path.
712 IN OUT POOL_PRINT
*Str
,
716 USB_DEVICE_PATH
*Usb
;
719 CatPrint (Str
, L
"Usb(%x,%x)", (UINTN
) Usb
->ParentPortNumber
, (UINTN
) Usb
->InterfaceNumber
);
723 Convert Device Path to a Unicode string for printing.
725 @param Str The buffer holding the output string.
726 This buffer contains the length of the
727 string and the maixmum length reserved
728 for the string buffer.
729 @param DevPath The device path.
734 IN OUT POOL_PRINT
*Str
,
738 USB_WWID_DEVICE_PATH
*UsbWWId
;
743 L
"UsbWwid(%x,%x,%x,\"WWID\")",
744 (UINTN
) UsbWWId
->VendorId
,
745 (UINTN
) UsbWWId
->ProductId
,
746 (UINTN
) UsbWWId
->InterfaceNumber
751 Convert Device Path to a Unicode string for printing.
753 @param Str The buffer holding the output string.
754 This buffer contains the length of the
755 string and the maixmum length reserved
756 for the string buffer.
757 @param DevPath The device path.
762 IN OUT POOL_PRINT
*Str
,
766 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
768 LogicalUnit
= DevPath
;
769 CatPrint (Str
, L
"Unit(%x)", (UINTN
) LogicalUnit
->Lun
);
773 Convert Device Path to a Unicode string for printing.
775 @param Str The buffer holding the output string.
776 This buffer contains the length of the
777 string and the maixmum length reserved
778 for the string buffer.
779 @param DevPath The device path.
784 IN OUT POOL_PRINT
*Str
,
788 USB_CLASS_DEVICE_PATH
*UsbClass
;
793 L
"Usb Class(%x,%x,%x,%x,%x)",
794 (UINTN
) UsbClass
->VendorId
,
795 (UINTN
) UsbClass
->ProductId
,
796 (UINTN
) UsbClass
->DeviceClass
,
797 (UINTN
) UsbClass
->DeviceSubClass
,
798 (UINTN
) UsbClass
->DeviceProtocol
803 Convert Device Path to a Unicode string for printing.
805 @param Str The buffer holding the output string.
806 This buffer contains the length of the
807 string and the maixmum length reserved
808 for the string buffer.
809 @param DevPath The device path.
814 IN OUT POOL_PRINT
*Str
,
818 SATA_DEVICE_PATH
*Sata
;
824 (UINTN
) Sata
->HBAPortNumber
,
825 (UINTN
) Sata
->PortMultiplierPortNumber
,
831 Convert Device Path to a Unicode string for printing.
833 @param Str The buffer holding the output string.
834 This buffer contains the length of the
835 string and the maixmum length reserved
836 for the string buffer.
837 @param DevPath The device path.
842 IN OUT POOL_PRINT
*Str
,
846 I2O_DEVICE_PATH
*I2OPath
;
849 CatPrint (Str
, L
"I2O(%x)", (UINTN
) I2OPath
->Tid
);
853 Convert Device Path to a Unicode string for printing.
855 @param Str The buffer holding the output string.
856 This buffer contains the length of the
857 string and the maixmum length reserved
858 for the string buffer.
859 @param DevPath The device path.
864 IN OUT POOL_PRINT
*Str
,
868 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
872 MACDevPath
= DevPath
;
874 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
875 if (MACDevPath
->IfType
== 0x01 || MACDevPath
->IfType
== 0x00) {
879 CatPrint (Str
, L
"Mac(");
881 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
882 CatPrint (Str
, L
"%02x", (UINTN
) MACDevPath
->MacAddress
.Addr
[Index
]);
885 CatPrint (Str
, L
")");
889 Convert Device Path to a Unicode string for printing.
891 @param Str The buffer holding the output string.
892 This buffer contains the length of the
893 string and the maixmum length reserved
894 for the string buffer.
895 @param DevPath The device path.
900 IN OUT POOL_PRINT
*Str
,
904 IPv4_DEVICE_PATH
*IPDevPath
;
909 L
"IPv4(%d.%d.%d.%d:%d)",
910 (UINTN
) IPDevPath
->RemoteIpAddress
.Addr
[0],
911 (UINTN
) IPDevPath
->RemoteIpAddress
.Addr
[1],
912 (UINTN
) IPDevPath
->RemoteIpAddress
.Addr
[2],
913 (UINTN
) IPDevPath
->RemoteIpAddress
.Addr
[3],
914 (UINTN
) IPDevPath
->RemotePort
919 Convert Device Path to a Unicode string for printing.
921 @param Str The buffer holding the output string.
922 This buffer contains the length of the
923 string and the maixmum length reserved
924 for the string buffer.
925 @param DevPath The device path.
930 IN OUT POOL_PRINT
*Str
,
934 IPv6_DEVICE_PATH
*IPv6DevPath
;
936 IPv6DevPath
= DevPath
;
939 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
940 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[0],
941 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[1],
942 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[2],
943 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[3],
944 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[4],
945 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[5],
946 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[6],
947 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[7],
948 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[8],
949 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[9],
950 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[10],
951 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[11],
952 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[12],
953 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[13],
954 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[14],
955 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[15]
960 Convert Device Path to a Unicode string for printing.
962 @param Str The buffer holding the output string.
963 This buffer contains the length of the
964 string and the maixmum length reserved
965 for the string buffer.
966 @param DevPath The device path.
971 IN OUT POOL_PRINT
*Str
,
975 INFINIBAND_DEVICE_PATH
*InfiniBand
;
977 InfiniBand
= DevPath
;
980 L
"Infiniband(%x,%g,%lx,%lx,%lx)",
981 (UINTN
) InfiniBand
->ResourceFlags
,
983 InfiniBand
->ServiceId
,
984 InfiniBand
->TargetPortId
,
990 Convert Device Path to a Unicode string for printing.
992 @param Str The buffer holding the output string.
993 This buffer contains the length of the
994 string and the maixmum length reserved
995 for the string buffer.
996 @param DevPath The device path.
1001 IN OUT POOL_PRINT
*Str
,
1005 UART_DEVICE_PATH
*Uart
;
1009 switch (Uart
->Parity
) {
1039 if (Uart
->BaudRate
== 0) {
1040 CatPrint (Str
, L
"Uart(DEFAULT,%c,", Parity
);
1042 CatPrint (Str
, L
"Uart(%d,%c,", Uart
->BaudRate
, Parity
);
1045 if (Uart
->DataBits
== 0) {
1046 CatPrint (Str
, L
"D,");
1048 CatPrint (Str
, L
"%d,", (UINTN
) Uart
->DataBits
);
1051 switch (Uart
->StopBits
) {
1053 CatPrint (Str
, L
"D)");
1057 CatPrint (Str
, L
"1)");
1061 CatPrint (Str
, L
"1.5)");
1065 CatPrint (Str
, L
"2)");
1069 CatPrint (Str
, L
"x)");
1075 Convert Device Path to a Unicode string for printing.
1077 @param Str The buffer holding the output string.
1078 This buffer contains the length of the
1079 string and the maixmum length reserved
1080 for the string buffer.
1081 @param DevPath The device path.
1086 IN OUT POOL_PRINT
*Str
,
1090 ISCSI_DEVICE_PATH_WITH_NAME
*IScsi
;
1093 ASSERT (Str
!= NULL
);
1094 ASSERT (DevPath
!= NULL
);
1099 L
"iSCSI(%s,%x,%lx,",
1100 IScsi
->iSCSITargetName
,
1101 IScsi
->TargetPortalGroupTag
,
1105 Options
= IScsi
->LoginOption
;
1106 CatPrint (Str
, L
"%s,", (((Options
>> 1) & 0x0001) != 0) ? L
"CRC32C" : L
"None");
1107 CatPrint (Str
, L
"%s,", (((Options
>> 3) & 0x0001) != 0) ? L
"CRC32C" : L
"None");
1108 if (((Options
>> 11) & 0x0001) != 0) {
1109 CatPrint (Str
, L
"%s,", L
"None");
1110 } else if (((Options
>> 12) & 0x0001) != 0) {
1111 CatPrint (Str
, L
"%s,", L
"CHAP_UNI");
1113 CatPrint (Str
, L
"%s,", L
"CHAP_BI");
1117 CatPrint (Str
, L
"%s)", (IScsi
->NetworkProtocol
== 0) ? L
"TCP" : L
"reserved");
1121 Convert Device Path to a Unicode string for printing.
1123 @param Str The buffer holding the output string.
1124 This buffer contains the length of the
1125 string and the maixmum length reserved
1126 for the string buffer.
1127 @param DevPath The device path.
1132 IN OUT POOL_PRINT
*Str
,
1136 HARDDRIVE_DEVICE_PATH
*Hd
;
1139 switch (Hd
->SignatureType
) {
1140 case SIGNATURE_TYPE_MBR
:
1143 L
"HD(Part%d,Sig%08x)",
1144 (UINTN
) Hd
->PartitionNumber
,
1145 (UINTN
) *((UINT32
*) (&(Hd
->Signature
[0])))
1149 case SIGNATURE_TYPE_GUID
:
1152 L
"HD(Part%d,Sig%g)",
1153 (UINTN
) Hd
->PartitionNumber
,
1154 (EFI_GUID
*) &(Hd
->Signature
[0])
1161 L
"HD(Part%d,MBRType=%02x,SigType=%02x)",
1162 (UINTN
) Hd
->PartitionNumber
,
1163 (UINTN
) Hd
->MBRType
,
1164 (UINTN
) Hd
->SignatureType
1171 Convert Device Path to a Unicode string for printing.
1173 @param Str The buffer holding the output string.
1174 This buffer contains the length of the
1175 string and the maixmum length reserved
1176 for the string buffer.
1177 @param DevPath The device path.
1182 IN OUT POOL_PRINT
*Str
,
1186 CDROM_DEVICE_PATH
*Cd
;
1189 CatPrint (Str
, L
"CDROM(Entry%x)", (UINTN
) Cd
->BootEntry
);
1193 Convert Device Path to a Unicode string for printing.
1195 @param Str The buffer holding the output string.
1196 This buffer contains the length of the
1197 string and the maixmum length reserved
1198 for the string buffer.
1199 @param DevPath The device path.
1204 IN OUT POOL_PRINT
*Str
,
1208 FILEPATH_DEVICE_PATH
*Fp
;
1211 CatPrint (Str
, L
"%s", Fp
->PathName
);
1215 Convert Device Path to a Unicode string for printing.
1217 @param Str The buffer holding the output string.
1218 This buffer contains the length of the
1219 string and the maixmum length reserved
1220 for the string buffer.
1221 @param DevPath The device path.
1225 DevPathMediaProtocol (
1226 IN OUT POOL_PRINT
*Str
,
1230 MEDIA_PROTOCOL_DEVICE_PATH
*MediaProt
;
1232 MediaProt
= DevPath
;
1233 CatPrint (Str
, L
"Media(%g)", &MediaProt
->Protocol
);
1237 Convert Device Path to a Unicode string for printing.
1239 @param Str The buffer holding the output string.
1240 This buffer contains the length of the
1241 string and the maixmum length reserved
1242 for the string buffer.
1243 @param DevPath The device path.
1248 IN OUT POOL_PRINT
*Str
,
1252 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFilePath
;
1254 FvFilePath
= DevPath
;
1255 CatPrint (Str
, L
"%g", &FvFilePath
->FvFileName
);
1259 Convert Device Path to a Unicode string for printing.
1261 @param Str The buffer holding the output string.
1262 This buffer contains the length of the
1263 string and the maixmum length reserved
1264 for the string buffer.
1265 @param DevPath The device path.
1270 IN OUT POOL_PRINT
*Str
,
1274 BBS_BBS_DEVICE_PATH
*Bbs
;
1278 switch (Bbs
->DeviceType
) {
1279 case BBS_TYPE_FLOPPY
:
1283 case BBS_TYPE_HARDDRIVE
:
1284 Type
= L
"Harddrive";
1287 case BBS_TYPE_CDROM
:
1291 case BBS_TYPE_PCMCIA
:
1299 case BBS_TYPE_EMBEDDED_NETWORK
:
1311 CatPrint (Str
, L
"Legacy-%s", Type
);
1315 Convert Device Path to a Unicode string for printing.
1317 @param Str The buffer holding the output string.
1318 This buffer contains the length of the
1319 string and the maixmum length reserved
1320 for the string buffer.
1321 @param DevPath The device path.
1325 DevPathEndInstance (
1326 IN OUT POOL_PRINT
*Str
,
1330 CatPrint (Str
, L
",");
1334 Convert Device Path to a Unicode string for printing.
1336 @param Str The buffer holding the output string.
1337 This buffer contains the length of the
1338 string and the maixmum length reserved
1339 for the string buffer.
1340 @param DevPath The device path.
1344 DevPathNodeUnknown (
1345 IN OUT POOL_PRINT
*Str
,
1349 CatPrint (Str
, L
"?");
1352 DEVICE_PATH_STRING_TABLE DevPathTable
[] = {
1353 HARDWARE_DEVICE_PATH
,
1356 HARDWARE_DEVICE_PATH
,
1359 HARDWARE_DEVICE_PATH
,
1362 HARDWARE_DEVICE_PATH
,
1365 HARDWARE_DEVICE_PATH
,
1373 DevPathExtendedAcpi
,
1377 MESSAGING_DEVICE_PATH
,
1380 MESSAGING_DEVICE_PATH
,
1383 MESSAGING_DEVICE_PATH
,
1384 MSG_FIBRECHANNEL_DP
,
1386 MESSAGING_DEVICE_PATH
,
1389 MESSAGING_DEVICE_PATH
,
1392 MESSAGING_DEVICE_PATH
,
1395 MESSAGING_DEVICE_PATH
,
1396 MSG_DEVICE_LOGICAL_UNIT_DP
,
1398 MESSAGING_DEVICE_PATH
,
1401 MESSAGING_DEVICE_PATH
,
1404 MESSAGING_DEVICE_PATH
,
1407 MESSAGING_DEVICE_PATH
,
1410 MESSAGING_DEVICE_PATH
,
1413 MESSAGING_DEVICE_PATH
,
1416 MESSAGING_DEVICE_PATH
,
1419 MESSAGING_DEVICE_PATH
,
1422 MESSAGING_DEVICE_PATH
,
1425 MESSAGING_DEVICE_PATH
,
1442 DevPathMediaProtocol
,
1444 MEDIA_PIWG_FW_FILE_DP
,
1449 END_DEVICE_PATH_TYPE
,
1450 END_INSTANCE_DEVICE_PATH_SUBTYPE
,
1459 This function converts an input device structure to a Unicode string.
1461 @param DevPath A pointer to the device path structure.
1463 @return A new allocated Unicode string that represents the device path.
1469 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1473 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1474 VOID (*DumpNode
) (POOL_PRINT
*, VOID
*);
1481 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*DevPathToText
;
1483 ZeroMem (&Str
, sizeof (Str
));
1485 if (DevPath
== NULL
) {
1489 Status
= gBS
->LocateProtocol (
1490 &gEfiDevicePathToTextProtocolGuid
,
1492 (VOID
**) &DevPathToText
1494 if (!EFI_ERROR (Status
)) {
1495 ToText
= DevPathToText
->ConvertDevicePathToText (
1500 ASSERT (ToText
!= NULL
);
1505 // Unpacked the device path
1507 DevPath
= BdsLibUnpackDevicePath (DevPath
);
1511 // Process each device path node
1513 DevPathNode
= DevPath
;
1514 while (!IsDevicePathEnd (DevPathNode
)) {
1516 // Find the handler to dump this device path node
1519 for (Index
= 0; DevPathTable
[Index
].Function
; Index
+= 1) {
1521 if (DevicePathType (DevPathNode
) == DevPathTable
[Index
].Type
&&
1522 DevicePathSubType (DevPathNode
) == DevPathTable
[Index
].SubType
1524 DumpNode
= DevPathTable
[Index
].Function
;
1529 // If not found, use a generic function
1532 DumpNode
= DevPathNodeUnknown
;
1535 // Put a path seperator in if needed
1537 if (Str
.len
&& DumpNode
!= DevPathEndInstance
) {
1538 CatPrint (&Str
, L
"/");
1541 // Print this node of the device path
1543 DumpNode (&Str
, DevPathNode
);
1546 // Next device path node
1548 DevPathNode
= NextDevicePathNode (DevPathNode
);
1551 // Shrink pool used for string allocation
1553 gBS
->FreePool (DevPath
);
1556 NewSize
= (Str
.len
+ 1) * sizeof (CHAR16
);
1557 Str
.str
= ReallocatePool (Str
.str
, NewSize
, NewSize
);
1558 ASSERT (Str
.str
!= NULL
);
1559 Str
.str
[Str
.len
] = 0;
1565 Function creates a device path data structure that identically matches the
1566 device path passed in.
1568 @param DevPath A pointer to a device path data structure.
1570 @return The new copy of DevPath is created to identically match the input.
1571 @return Otherwise, NULL is returned.
1574 EFI_DEVICE_PATH_PROTOCOL
*
1575 LibDuplicateDevicePathInstance (
1576 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1579 EFI_DEVICE_PATH_PROTOCOL
*NewDevPath
;
1580 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
1581 EFI_DEVICE_PATH_PROTOCOL
*Temp
;
1585 // get the size of an instance from the input
1588 DevicePathInst
= GetNextDevicePathInstance (&Temp
, &Size
);
1595 NewDevPath
= AllocateZeroPool (Size
);
1596 ASSERT (NewDevPath
!= NULL
);
1599 if (NewDevPath
!= NULL
) {
1600 CopyMem (NewDevPath
, DevicePathInst
, Size
);