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"
20 Adjusts the size of a previously allocated buffer.
22 @param OldPool A pointer to the buffer whose size is being adjusted.
23 @param OldSize The size of the current buffer.
24 @param NewSize The size of the new buffer.
26 @return The new buffer allocated. If allocatio failed, NULL will be returned.
40 NewPool
= AllocateZeroPool (NewSize
);
43 if (OldPool
!= NULL
) {
44 if (NewPool
!= NULL
) {
45 CopyMem (NewPool
, OldPool
, OldSize
< NewSize
? OldSize
: NewSize
);
55 Concatenates a formatted unicode string to allocated pool.
56 The caller must free the resulting buffer.
58 @param Str Tracks the allocated pool, size in use, and amount of pool
60 @param fmt The format string
62 @param ... Variable argument list.
64 @return Allocated buffer with the formatted string printed in it.
65 The caller must free the allocated buffer. The buffer
66 allocation is not packed.
72 IN OUT POOL_PRINT
*Str
,
81 AppendStr
= AllocateZeroPool (0x1000);
82 if (AppendStr
== NULL
) {
87 UnicodeVSPrint (AppendStr
, 0x1000, fmt
, Args
);
89 if (NULL
== Str
->str
) {
90 StringSize
= StrSize (AppendStr
);
91 Str
->str
= AllocateZeroPool (StringSize
);
92 ASSERT (Str
->str
!= NULL
);
94 StringSize
= StrSize (AppendStr
);
95 StringSize
+= (StrSize (Str
->str
) - sizeof (UINT16
));
97 Str
->str
= ReallocatePool (
102 ASSERT (Str
->str
!= NULL
);
105 Str
->maxlen
= MAX_CHAR
* sizeof (UINT16
);
106 if (StringSize
< Str
->maxlen
) {
107 StrCat (Str
->str
, AppendStr
);
108 Str
->len
= StringSize
- sizeof (UINT16
);
111 FreePool (AppendStr
);
117 Function unpacks a device path data structure so that all the nodes
118 of a device path are naturally aligned.
120 @param DevPath A pointer to a device path data structure
122 @return A ponter to new device If the memory for the device path is successfully allocated, then a
123 pointer to the new device path is returned. Otherwise, NULL is returned.
126 EFI_DEVICE_PATH_PROTOCOL
*
128 BdsLibUnpackDevicePath (
129 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
132 EFI_DEVICE_PATH_PROTOCOL
*Src
;
133 EFI_DEVICE_PATH_PROTOCOL
*Dest
;
134 EFI_DEVICE_PATH_PROTOCOL
*NewPath
;
138 // Walk device path and round sizes to valid boundries
143 Size
+= DevicePathNodeLength (Src
);
144 Size
+= ALIGN_SIZE (Size
);
146 if (IsDevicePathEnd (Src
)) {
150 Src
= NextDevicePathNode (Src
);
153 // Allocate space for the unpacked path
155 NewPath
= AllocateZeroPool (Size
);
156 if (NewPath
!= NULL
) {
158 ASSERT (((UINTN
) NewPath
) % MIN_ALIGNMENT_SIZE
== 0);
166 Size
= DevicePathNodeLength (Src
);
167 CopyMem (Dest
, Src
, Size
);
168 Size
+= ALIGN_SIZE (Size
);
169 SetDevicePathNodeLength (Dest
, Size
);
170 Dest
->Type
|= EFI_DP_TYPE_UNPACKED
;
171 Dest
= (EFI_DEVICE_PATH_PROTOCOL
*) (((UINT8
*) Dest
) + Size
);
173 if (IsDevicePathEnd (Src
)) {
177 Src
= NextDevicePathNode (Src
);
185 Convert Device Path to a Unicode string for printing.
187 @param Str The buffer holding the output string.
188 This buffer contains the length of the
189 string and the maixmum length reserved
190 for the string buffer.
191 @param DevPath The device path.
196 IN OUT POOL_PRINT
*Str
,
200 PCI_DEVICE_PATH
*Pci
;
203 CatPrint (Str
, L
"Pci(%x|%x)", (UINTN
) Pci
->Device
, (UINTN
) Pci
->Function
);
207 Convert Device Path to a Unicode string for printing.
209 @param Str The buffer holding the output string.
210 This buffer contains the length of the
211 string and the maixmum length reserved
212 for the string buffer.
213 @param DevPath The device path.
218 IN OUT POOL_PRINT
*Str
,
222 PCCARD_DEVICE_PATH
*Pccard
;
225 CatPrint (Str
, L
"Pcmcia(Function%x)", (UINTN
) Pccard
->FunctionNumber
);
229 Convert Device Path to a Unicode string for printing.
231 @param Str The buffer holding the output string.
232 This buffer contains the length of the
233 string and the maixmum length reserved
234 for the string buffer.
235 @param DevPath The device path.
240 IN OUT POOL_PRINT
*Str
,
244 MEMMAP_DEVICE_PATH
*MemMap
;
249 L
"MemMap(%d:%lx-%lx)",
251 MemMap
->StartingAddress
,
252 MemMap
->EndingAddress
257 Convert Device Path to a Unicode string for printing.
259 @param Str The buffer holding the output string.
260 This buffer contains the length of the
261 string and the maixmum length reserved
262 for the string buffer.
263 @param DevPath The device path.
268 IN OUT POOL_PRINT
*Str
,
272 CONTROLLER_DEVICE_PATH
*Controller
;
274 Controller
= DevPath
;
275 CatPrint (Str
, L
"Ctrl(%d)", (UINTN
) Controller
->ControllerNumber
);
280 Convert Device Path to a Unicode string for printing.
282 @param Str The buffer holding the output string.
283 This buffer contains the length of the
284 string and the maixmum length reserved
285 for the string buffer.
286 @param DevPath The device path.
292 IN OUT POOL_PRINT
*Str
,
296 VENDOR_DEVICE_PATH
*Vendor
;
300 UINT32 FlowControlMap
;
306 switch (DevicePathType (&Vendor
->Header
)) {
307 case HARDWARE_DEVICE_PATH
:
311 case MESSAGING_DEVICE_PATH
:
313 if (CompareGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
)) {
314 CatPrint (Str
, L
"VenPcAnsi()");
316 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100Guid
)) {
317 CatPrint (Str
, L
"VenVt100()");
319 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
)) {
320 CatPrint (Str
, L
"VenVt100Plus()");
322 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
)) {
323 CatPrint (Str
, L
"VenUft8()");
325 } else if (CompareGuid (&Vendor
->Guid
, &gEfiUartDevicePathGuid
)) {
326 FlowControlMap
= (((UART_FLOW_CONTROL_DEVICE_PATH
*) Vendor
)->FlowControlMap
);
327 switch (FlowControlMap
& 0x00000003) {
329 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"None");
333 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"Hardware");
337 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"XonXoff");
346 } else if (CompareGuid (&Vendor
->Guid
, &gEfiSasDevicePathGuid
)) {
350 ((SAS_DEVICE_PATH
*) Vendor
)->SasAddress
,
351 ((SAS_DEVICE_PATH
*) Vendor
)->Lun
,
352 ((SAS_DEVICE_PATH
*) Vendor
)->RelativeTargetPort
354 Info
= (((SAS_DEVICE_PATH
*) Vendor
)->DeviceTopology
);
355 if ((Info
& 0x0f) == 0) {
356 CatPrint (Str
, L
"NoTopology,0,0,0,");
357 } else if (((Info
& 0x0f) == 1) || ((Info
& 0x0f) == 2)) {
361 ((Info
& (0x1 << 4)) != 0) ? L
"SATA" : L
"SAS",
362 ((Info
& (0x1 << 5)) != 0) ? L
"External" : L
"Internal",
363 ((Info
& (0x1 << 6)) != 0) ? L
"Expanded" : L
"Direct"
365 if ((Info
& 0x0f) == 1) {
366 CatPrint (Str
, L
"0,");
368 CatPrint (Str
, L
"%x,", (UINTN
) ((Info
>> 8) & 0xff));
371 CatPrint (Str
, L
"0,0,0,0,");
374 CatPrint (Str
, L
"%x)", (UINTN
) ((SAS_DEVICE_PATH
*) Vendor
)->Reserved
);
377 } else if (CompareGuid (&Vendor
->Guid
, &gEfiDebugPortProtocolGuid
)) {
378 CatPrint (Str
, L
"DebugPort()");
383 case MEDIA_DEVICE_PATH
:
392 CatPrint (Str
, L
"Ven%s(%g", Type
, &Vendor
->Guid
);
393 DataLength
= DevicePathNodeLength (&Vendor
->Header
) - sizeof (VENDOR_DEVICE_PATH
);
394 if (DataLength
> 0) {
395 CatPrint (Str
, L
",");
396 for (Index
= 0; Index
< DataLength
; Index
++) {
397 CatPrint (Str
, L
"%02x", (UINTN
) ((VENDOR_DEVICE_PATH_WITH_DATA
*) Vendor
)->VendorDefinedData
[Index
]);
400 CatPrint (Str
, L
")");
404 Convert Device Path to a Unicode string for printing.
406 @param Str The buffer holding the output string.
407 This buffer contains the length of the
408 string and the maixmum length reserved
409 for the string buffer.
410 @param DevPath The device path.
415 IN OUT POOL_PRINT
*Str
,
419 ACPI_HID_DEVICE_PATH
*Acpi
;
422 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
423 CatPrint (Str
, L
"Acpi(PNP%04x,%x)", (UINTN
) EISA_ID_TO_NUM (Acpi
->HID
), (UINTN
) Acpi
->UID
);
425 CatPrint (Str
, L
"Acpi(%08x,%x)", (UINTN
) Acpi
->HID
, (UINTN
) Acpi
->UID
);
430 Convert Device Path to a Unicode string for printing.
432 @param Str The buffer holding the output string.
433 This buffer contains the length of the
434 string and the maixmum length reserved
435 for the string buffer.
436 @param DevPath The device path.
440 DevPathExtendedAcpi (
441 IN OUT POOL_PRINT
*Str
,
445 ACPI_EXTENDED_HID_DEVICE_PATH
*ExtendedAcpi
;
448 // Index for HID, UID and CID strings, 0 for non-exist
458 ASSERT (Str
!= NULL
);
459 ASSERT (DevPath
!= NULL
);
464 ExtendedAcpi
= DevPath
;
465 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) ExtendedAcpi
);
467 ASSERT (Length
>= 19);
468 AsChar8Array
= (CHAR8
*) ExtendedAcpi
;
474 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
] != '\0'; Index
++) {
477 if (Index
> Anchor
) {
483 Anchor
= (UINT16
) (Index
+ 1);
484 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
] != '\0'; Index
++) {
487 if (Index
> Anchor
) {
493 Anchor
= (UINT16
) (Index
+ 1);
494 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
] != '\0'; Index
++) {
497 if (Index
> Anchor
) {
501 if (HIDSTRIdx
== 0 && CIDSTRIdx
== 0 && ExtendedAcpi
->UID
== 0) {
502 CatPrint (Str
, L
"AcpiExp(");
503 if ((ExtendedAcpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
504 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->HID
));
506 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->HID
);
508 if ((ExtendedAcpi
->CID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
509 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->CID
));
511 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->CID
);
513 if (UIDSTRIdx
!= 0) {
514 CatPrint (Str
, L
"%a)", AsChar8Array
+ UIDSTRIdx
);
516 CatPrint (Str
, L
"\"\")");
519 CatPrint (Str
, L
"AcpiEx(");
520 if ((ExtendedAcpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
521 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->HID
));
523 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->HID
);
525 if ((ExtendedAcpi
->CID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
526 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->CID
));
528 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->CID
);
530 CatPrint (Str
, L
"%x,", (UINTN
) ExtendedAcpi
->UID
);
532 if (HIDSTRIdx
!= 0) {
533 CatPrint (Str
, L
"%a,", AsChar8Array
+ HIDSTRIdx
);
535 CatPrint (Str
, L
"\"\",");
537 if (CIDSTRIdx
!= 0) {
538 CatPrint (Str
, L
"%a,", AsChar8Array
+ CIDSTRIdx
);
540 CatPrint (Str
, L
"\"\",");
542 if (UIDSTRIdx
!= 0) {
543 CatPrint (Str
, L
"%a)", AsChar8Array
+ UIDSTRIdx
);
545 CatPrint (Str
, L
"\"\")");
552 Convert Device Path to a Unicode string for printing.
554 @param Str The buffer holding the output string.
555 This buffer contains the length of the
556 string and the maixmum length reserved
557 for the string buffer.
558 @param DevPath The device path.
563 IN OUT POOL_PRINT
*Str
,
567 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
570 UINT16 AdditionalAdrCount
;
573 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
);
574 AdditionalAdrCount
= (UINT16
) ((Length
- 8) / 4);
576 CatPrint (Str
, L
"AcpiAdr(%x", (UINTN
) AcpiAdr
->ADR
);
577 for (Index
= 0; Index
< AdditionalAdrCount
; Index
++) {
578 CatPrint (Str
, L
",%x", (UINTN
) *(UINT32
*) ((UINT8
*) AcpiAdr
+ 8 + Index
* 4));
580 CatPrint (Str
, L
")");
584 Convert Device Path to a Unicode string for printing.
586 @param Str The buffer holding the output string.
587 This buffer contains the length of the
588 string and the maixmum length reserved
589 for the string buffer.
590 @param DevPath The device path.
595 IN OUT POOL_PRINT
*Str
,
599 ATAPI_DEVICE_PATH
*Atapi
;
605 Atapi
->PrimarySecondary
? L
"Secondary" : L
"Primary",
606 Atapi
->SlaveMaster
? L
"Slave" : L
"Master"
611 Convert Device Path to a Unicode string for printing.
613 @param Str The buffer holding the output string.
614 This buffer contains the length of the
615 string and the maixmum length reserved
616 for the string buffer.
617 @param DevPath The device path.
622 IN OUT POOL_PRINT
*Str
,
626 SCSI_DEVICE_PATH
*Scsi
;
629 CatPrint (Str
, L
"Scsi(Pun%x,Lun%x)", (UINTN
) Scsi
->Pun
, (UINTN
) Scsi
->Lun
);
633 Convert Device Path to a Unicode string for printing.
635 @param Str The buffer holding the output string.
636 This buffer contains the length of the
637 string and the maixmum length reserved
638 for the string buffer.
639 @param DevPath The device path.
644 IN OUT POOL_PRINT
*Str
,
648 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
651 CatPrint (Str
, L
"Fibre(Wwn%lx,Lun%x)", Fibre
->WWN
, Fibre
->Lun
);
655 Convert Device Path to a Unicode string for printing.
657 @param Str The buffer holding the output string.
658 This buffer contains the length of the
659 string and the maixmum length reserved
660 for the string buffer.
661 @param DevPath The device path.
666 IN OUT POOL_PRINT
*Str
,
670 F1394_DEVICE_PATH
*F1394Path
;
673 CatPrint (Str
, L
"1394(%g)", &F1394Path
->Guid
);
677 Convert Device Path to a Unicode string for printing.
679 @param Str The buffer holding the output string.
680 This buffer contains the length of the
681 string and the maixmum length reserved
682 for the string buffer.
683 @param DevPath The device path.
688 IN OUT POOL_PRINT
*Str
,
692 USB_DEVICE_PATH
*Usb
;
695 CatPrint (Str
, L
"Usb(%x,%x)", (UINTN
) Usb
->ParentPortNumber
, (UINTN
) Usb
->InterfaceNumber
);
699 Convert Device Path to a Unicode string for printing.
701 @param Str The buffer holding the output string.
702 This buffer contains the length of the
703 string and the maixmum length reserved
704 for the string buffer.
705 @param DevPath The device path.
710 IN OUT POOL_PRINT
*Str
,
714 USB_WWID_DEVICE_PATH
*UsbWWId
;
719 L
"UsbWwid(%x,%x,%x,\"WWID\")",
720 (UINTN
) UsbWWId
->VendorId
,
721 (UINTN
) UsbWWId
->ProductId
,
722 (UINTN
) UsbWWId
->InterfaceNumber
727 Convert Device Path to a Unicode string for printing.
729 @param Str The buffer holding the output string.
730 This buffer contains the length of the
731 string and the maixmum length reserved
732 for the string buffer.
733 @param DevPath The device path.
738 IN OUT POOL_PRINT
*Str
,
742 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
744 LogicalUnit
= DevPath
;
745 CatPrint (Str
, L
"Unit(%x)", (UINTN
) LogicalUnit
->Lun
);
749 Convert Device Path to a Unicode string for printing.
751 @param Str The buffer holding the output string.
752 This buffer contains the length of the
753 string and the maixmum length reserved
754 for the string buffer.
755 @param DevPath The device path.
760 IN OUT POOL_PRINT
*Str
,
764 USB_CLASS_DEVICE_PATH
*UsbClass
;
769 L
"Usb Class(%x,%x,%x,%x,%x)",
770 (UINTN
) UsbClass
->VendorId
,
771 (UINTN
) UsbClass
->ProductId
,
772 (UINTN
) UsbClass
->DeviceClass
,
773 (UINTN
) UsbClass
->DeviceSubClass
,
774 (UINTN
) UsbClass
->DeviceProtocol
779 Convert Device Path to a Unicode string for printing.
781 @param Str The buffer holding the output string.
782 This buffer contains the length of the
783 string and the maixmum length reserved
784 for the string buffer.
785 @param DevPath The device path.
790 IN OUT POOL_PRINT
*Str
,
794 SATA_DEVICE_PATH
*Sata
;
800 (UINTN
) Sata
->HBAPortNumber
,
801 (UINTN
) Sata
->PortMultiplierPortNumber
,
807 Convert Device Path to a Unicode string for printing.
809 @param Str The buffer holding the output string.
810 This buffer contains the length of the
811 string and the maixmum length reserved
812 for the string buffer.
813 @param DevPath The device path.
818 IN OUT POOL_PRINT
*Str
,
822 I2O_DEVICE_PATH
*I2OPath
;
825 CatPrint (Str
, L
"I2O(%x)", (UINTN
) I2OPath
->Tid
);
829 Convert Device Path to a Unicode string for printing.
831 @param Str The buffer holding the output string.
832 This buffer contains the length of the
833 string and the maixmum length reserved
834 for the string buffer.
835 @param DevPath The device path.
840 IN OUT POOL_PRINT
*Str
,
844 MAC_ADDR_DEVICE_PATH
*MACDevPath
;
848 MACDevPath
= DevPath
;
850 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
851 if (MACDevPath
->IfType
== 0x01 || MACDevPath
->IfType
== 0x00) {
855 CatPrint (Str
, L
"Mac(");
857 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
858 CatPrint (Str
, L
"%02x", (UINTN
) MACDevPath
->MacAddress
.Addr
[Index
]);
861 CatPrint (Str
, L
")");
865 Convert Device Path to a Unicode string for printing.
867 @param Str The buffer holding the output string.
868 This buffer contains the length of the
869 string and the maixmum length reserved
870 for the string buffer.
871 @param DevPath The device path.
876 IN OUT POOL_PRINT
*Str
,
880 IPv4_DEVICE_PATH
*IPDevPath
;
885 L
"IPv4(%d.%d.%d.%d:%d)",
886 (UINTN
) IPDevPath
->RemoteIpAddress
.Addr
[0],
887 (UINTN
) IPDevPath
->RemoteIpAddress
.Addr
[1],
888 (UINTN
) IPDevPath
->RemoteIpAddress
.Addr
[2],
889 (UINTN
) IPDevPath
->RemoteIpAddress
.Addr
[3],
890 (UINTN
) IPDevPath
->RemotePort
895 Convert Device Path to a Unicode string for printing.
897 @param Str The buffer holding the output string.
898 This buffer contains the length of the
899 string and the maixmum length reserved
900 for the string buffer.
901 @param DevPath The device path.
906 IN OUT POOL_PRINT
*Str
,
910 IPv6_DEVICE_PATH
*IPv6DevPath
;
912 IPv6DevPath
= DevPath
;
915 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
916 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[0],
917 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[1],
918 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[2],
919 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[3],
920 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[4],
921 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[5],
922 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[6],
923 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[7],
924 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[8],
925 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[9],
926 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[10],
927 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[11],
928 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[12],
929 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[13],
930 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[14],
931 (UINTN
) IPv6DevPath
->RemoteIpAddress
.Addr
[15]
936 Convert Device Path to a Unicode string for printing.
938 @param Str The buffer holding the output string.
939 This buffer contains the length of the
940 string and the maixmum length reserved
941 for the string buffer.
942 @param DevPath The device path.
947 IN OUT POOL_PRINT
*Str
,
951 INFINIBAND_DEVICE_PATH
*InfiniBand
;
953 InfiniBand
= DevPath
;
956 L
"Infiniband(%x,%g,%lx,%lx,%lx)",
957 (UINTN
) InfiniBand
->ResourceFlags
,
959 InfiniBand
->ServiceId
,
960 InfiniBand
->TargetPortId
,
966 Convert Device Path to a Unicode string for printing.
968 @param Str The buffer holding the output string.
969 This buffer contains the length of the
970 string and the maixmum length reserved
971 for the string buffer.
972 @param DevPath The device path.
977 IN OUT POOL_PRINT
*Str
,
981 UART_DEVICE_PATH
*Uart
;
985 switch (Uart
->Parity
) {
1015 if (Uart
->BaudRate
== 0) {
1016 CatPrint (Str
, L
"Uart(DEFAULT,%c,", Parity
);
1018 CatPrint (Str
, L
"Uart(%d,%c,", Uart
->BaudRate
, Parity
);
1021 if (Uart
->DataBits
== 0) {
1022 CatPrint (Str
, L
"D,");
1024 CatPrint (Str
, L
"%d,", (UINTN
) Uart
->DataBits
);
1027 switch (Uart
->StopBits
) {
1029 CatPrint (Str
, L
"D)");
1033 CatPrint (Str
, L
"1)");
1037 CatPrint (Str
, L
"1.5)");
1041 CatPrint (Str
, L
"2)");
1045 CatPrint (Str
, L
"x)");
1051 Convert Device Path to a Unicode string for printing.
1053 @param Str The buffer holding the output string.
1054 This buffer contains the length of the
1055 string and the maixmum length reserved
1056 for the string buffer.
1057 @param DevPath The device path.
1062 IN OUT POOL_PRINT
*Str
,
1066 ISCSI_DEVICE_PATH_WITH_NAME
*IScsi
;
1069 ASSERT (Str
!= NULL
);
1070 ASSERT (DevPath
!= NULL
);
1075 L
"iSCSI(%s,%x,%lx,",
1076 IScsi
->iSCSITargetName
,
1077 IScsi
->TargetPortalGroupTag
,
1081 Options
= IScsi
->LoginOption
;
1082 CatPrint (Str
, L
"%s,", (((Options
>> 1) & 0x0001) != 0) ? L
"CRC32C" : L
"None");
1083 CatPrint (Str
, L
"%s,", (((Options
>> 3) & 0x0001) != 0) ? L
"CRC32C" : L
"None");
1084 if (((Options
>> 11) & 0x0001) != 0) {
1085 CatPrint (Str
, L
"%s,", L
"None");
1086 } else if (((Options
>> 12) & 0x0001) != 0) {
1087 CatPrint (Str
, L
"%s,", L
"CHAP_UNI");
1089 CatPrint (Str
, L
"%s,", L
"CHAP_BI");
1093 CatPrint (Str
, L
"%s)", (IScsi
->NetworkProtocol
== 0) ? L
"TCP" : L
"reserved");
1097 Convert Device Path to a Unicode string for printing.
1099 @param Str The buffer holding the output string.
1100 This buffer contains the length of the
1101 string and the maixmum length reserved
1102 for the string buffer.
1103 @param DevPath The device path.
1108 IN OUT POOL_PRINT
*Str
,
1112 HARDDRIVE_DEVICE_PATH
*Hd
;
1115 switch (Hd
->SignatureType
) {
1116 case SIGNATURE_TYPE_MBR
:
1119 L
"HD(Part%d,Sig%08x)",
1120 (UINTN
) Hd
->PartitionNumber
,
1121 (UINTN
) *((UINT32
*) (&(Hd
->Signature
[0])))
1125 case SIGNATURE_TYPE_GUID
:
1128 L
"HD(Part%d,Sig%g)",
1129 (UINTN
) Hd
->PartitionNumber
,
1130 (EFI_GUID
*) &(Hd
->Signature
[0])
1137 L
"HD(Part%d,MBRType=%02x,SigType=%02x)",
1138 (UINTN
) Hd
->PartitionNumber
,
1139 (UINTN
) Hd
->MBRType
,
1140 (UINTN
) Hd
->SignatureType
1147 Convert Device Path to a Unicode string for printing.
1149 @param Str The buffer holding the output string.
1150 This buffer contains the length of the
1151 string and the maixmum length reserved
1152 for the string buffer.
1153 @param DevPath The device path.
1158 IN OUT POOL_PRINT
*Str
,
1162 CDROM_DEVICE_PATH
*Cd
;
1165 CatPrint (Str
, L
"CDROM(Entry%x)", (UINTN
) Cd
->BootEntry
);
1169 Convert Device Path to a Unicode string for printing.
1171 @param Str The buffer holding the output string.
1172 This buffer contains the length of the
1173 string and the maixmum length reserved
1174 for the string buffer.
1175 @param DevPath The device path.
1180 IN OUT POOL_PRINT
*Str
,
1184 FILEPATH_DEVICE_PATH
*Fp
;
1187 CatPrint (Str
, L
"%s", Fp
->PathName
);
1191 Convert Device Path to a Unicode string for printing.
1193 @param Str The buffer holding the output string.
1194 This buffer contains the length of the
1195 string and the maixmum length reserved
1196 for the string buffer.
1197 @param DevPath The device path.
1201 DevPathMediaProtocol (
1202 IN OUT POOL_PRINT
*Str
,
1206 MEDIA_PROTOCOL_DEVICE_PATH
*MediaProt
;
1208 MediaProt
= DevPath
;
1209 CatPrint (Str
, L
"Media(%g)", &MediaProt
->Protocol
);
1213 Convert Device Path to a Unicode string for printing.
1215 @param Str The buffer holding the output string.
1216 This buffer contains the length of the
1217 string and the maixmum length reserved
1218 for the string buffer.
1219 @param DevPath The device path.
1224 IN OUT POOL_PRINT
*Str
,
1228 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFilePath
;
1230 FvFilePath
= DevPath
;
1231 CatPrint (Str
, L
"%g", &FvFilePath
->FvFileName
);
1235 Convert Device Path to a Unicode string for printing.
1237 @param Str The buffer holding the output string.
1238 This buffer contains the length of the
1239 string and the maixmum length reserved
1240 for the string buffer.
1241 @param DevPath The device path.
1246 IN OUT POOL_PRINT
*Str
,
1250 BBS_BBS_DEVICE_PATH
*Bbs
;
1254 switch (Bbs
->DeviceType
) {
1255 case BBS_TYPE_FLOPPY
:
1259 case BBS_TYPE_HARDDRIVE
:
1260 Type
= L
"Harddrive";
1263 case BBS_TYPE_CDROM
:
1267 case BBS_TYPE_PCMCIA
:
1275 case BBS_TYPE_EMBEDDED_NETWORK
:
1287 CatPrint (Str
, L
"Legacy-%s", Type
);
1291 Convert Device Path to a Unicode string for printing.
1293 @param Str The buffer holding the output string.
1294 This buffer contains the length of the
1295 string and the maixmum length reserved
1296 for the string buffer.
1297 @param DevPath The device path.
1301 DevPathEndInstance (
1302 IN OUT POOL_PRINT
*Str
,
1306 CatPrint (Str
, L
",");
1310 Convert Device Path to a Unicode string for printing.
1312 @param Str The buffer holding the output string.
1313 This buffer contains the length of the
1314 string and the maixmum length reserved
1315 for the string buffer.
1316 @param DevPath The device path.
1320 DevPathNodeUnknown (
1321 IN OUT POOL_PRINT
*Str
,
1325 CatPrint (Str
, L
"?");
1328 DEVICE_PATH_STRING_TABLE DevPathTable
[] = {
1330 HARDWARE_DEVICE_PATH
,
1335 HARDWARE_DEVICE_PATH
,
1340 HARDWARE_DEVICE_PATH
,
1345 HARDWARE_DEVICE_PATH
,
1350 HARDWARE_DEVICE_PATH
,
1370 MESSAGING_DEVICE_PATH
,
1375 MESSAGING_DEVICE_PATH
,
1380 MESSAGING_DEVICE_PATH
,
1381 MSG_FIBRECHANNEL_DP
,
1385 MESSAGING_DEVICE_PATH
,
1390 MESSAGING_DEVICE_PATH
,
1395 MESSAGING_DEVICE_PATH
,
1400 MESSAGING_DEVICE_PATH
,
1401 MSG_DEVICE_LOGICAL_UNIT_DP
,
1405 MESSAGING_DEVICE_PATH
,
1410 MESSAGING_DEVICE_PATH
,
1415 MESSAGING_DEVICE_PATH
,
1420 MESSAGING_DEVICE_PATH
,
1425 MESSAGING_DEVICE_PATH
,
1430 MESSAGING_DEVICE_PATH
,
1435 MESSAGING_DEVICE_PATH
,
1440 MESSAGING_DEVICE_PATH
,
1445 MESSAGING_DEVICE_PATH
,
1450 MESSAGING_DEVICE_PATH
,
1477 DevPathMediaProtocol
1481 MEDIA_PIWG_FW_FILE_DP
,
1490 END_DEVICE_PATH_TYPE
,
1491 END_INSTANCE_DEVICE_PATH_SUBTYPE
,
1503 This function converts an input device structure to a Unicode string.
1505 @param DevPath A pointer to the device path structure.
1507 @return A new allocated Unicode string that represents the device path.
1513 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1517 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1518 VOID (*DumpNode
) (POOL_PRINT
*, VOID
*);
1525 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*DevPathToText
;
1527 ZeroMem (&Str
, sizeof (Str
));
1529 if (DevPath
== NULL
) {
1533 Status
= gBS
->LocateProtocol (
1534 &gEfiDevicePathToTextProtocolGuid
,
1536 (VOID
**) &DevPathToText
1538 if (!EFI_ERROR (Status
)) {
1539 ToText
= DevPathToText
->ConvertDevicePathToText (
1544 ASSERT (ToText
!= NULL
);
1549 // Unpacked the device path
1551 DevPath
= BdsLibUnpackDevicePath (DevPath
);
1555 // Process each device path node
1557 DevPathNode
= DevPath
;
1558 while (!IsDevicePathEnd (DevPathNode
)) {
1560 // Find the handler to dump this device path node
1563 for (Index
= 0; DevPathTable
[Index
].Function
; Index
+= 1) {
1565 if (DevicePathType (DevPathNode
) == DevPathTable
[Index
].Type
&&
1566 DevicePathSubType (DevPathNode
) == DevPathTable
[Index
].SubType
1568 DumpNode
= DevPathTable
[Index
].Function
;
1573 // If not found, use a generic function
1576 DumpNode
= DevPathNodeUnknown
;
1579 // Put a path seperator in if needed
1581 if (Str
.len
&& DumpNode
!= DevPathEndInstance
) {
1582 CatPrint (&Str
, L
"/");
1585 // Print this node of the device path
1587 DumpNode (&Str
, DevPathNode
);
1590 // Next device path node
1592 DevPathNode
= NextDevicePathNode (DevPathNode
);
1595 // Shrink pool used for string allocation
1600 NewSize
= (Str
.len
+ 1) * sizeof (CHAR16
);
1601 Str
.str
= ReallocatePool (Str
.str
, NewSize
, NewSize
);
1602 ASSERT (Str
.str
!= NULL
);
1603 Str
.str
[Str
.len
] = 0;
1608 Function creates a device path data structure that identically matches the
1609 device path passed in.
1611 @param DevPath A pointer to a device path data structure.
1613 @return The new copy of DevPath is created to identically match the input.
1614 @return Otherwise, NULL is returned.
1617 EFI_DEVICE_PATH_PROTOCOL
*
1618 LibDuplicateDevicePathInstance (
1619 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1622 EFI_DEVICE_PATH_PROTOCOL
*NewDevPath
;
1623 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
1624 EFI_DEVICE_PATH_PROTOCOL
*Temp
;
1628 // get the size of an instance from the input
1631 DevicePathInst
= GetNextDevicePathInstance (&Temp
, &Size
);
1638 NewDevPath
= AllocateZeroPool (Size
);
1639 ASSERT (NewDevPath
!= NULL
);
1642 if (NewDevPath
!= NULL
) {
1643 CopyMem (NewDevPath
, DevicePathInst
, Size
);