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
;
34 Adjusts the size of a previously allocated buffer.
38 OldPool - A pointer to the buffer whose size is being adjusted.
40 OldSize - The size of the current buffer.
42 NewSize - The size of the new buffer.
46 EFI_SUCEESS - The requested number of bytes were allocated.
48 EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
50 EFI_INVALID_PARAMETER - The buffer was invalid.
58 NewPool
= AllocateZeroPool (NewSize
);
63 CopyMem (NewPool
, OldPool
, OldSize
< NewSize
? OldSize
: NewSize
);
66 gBS
->FreePool (OldPool
);
74 Concatenates a formatted unicode string to allocated pool.
75 The caller must free the resulting buffer.
77 @param Str Tracks the allocated pool, size in use, and amount of pool
79 @param fmt The format string
81 @return Allocated buffer with the formatted string printed in it.
82 @return The caller must free the allocated buffer. The buffer
83 @return allocation is not packed.
89 IN OUT POOL_PRINT
*Str
,
98 AppendStr
= AllocateZeroPool (0x1000);
99 if (AppendStr
== NULL
) {
103 VA_START (args
, fmt
);
104 UnicodeVSPrint (AppendStr
, 0x1000, fmt
, args
);
106 if (NULL
== Str
->str
) {
107 strsize
= StrSize (AppendStr
);
108 Str
->str
= AllocateZeroPool (strsize
);
109 ASSERT (Str
->str
!= NULL
);
111 strsize
= StrSize (AppendStr
);
112 strsize
+= (StrSize (Str
->str
) - sizeof (UINT16
));
114 Str
->str
= ReallocatePool (
119 ASSERT (Str
->str
!= NULL
);
122 Str
->maxlen
= MAX_CHAR
* sizeof (UINT16
);
123 if (strsize
< Str
->maxlen
) {
124 StrCat (Str
->str
, AppendStr
);
125 Str
->len
= strsize
- sizeof (UINT16
);
128 gBS
->FreePool (AppendStr
);
134 Function unpacks a device path data structure so that all the nodes
135 of a device path are naturally aligned.
137 @param DevPath A pointer to a device path data structure
139 @return A ponter to new device If the memory for the device path is successfully allocated, then a
140 pointer to the new device path is returned. Otherwise, NULL is returned.
143 EFI_DEVICE_PATH_PROTOCOL
*
145 BdsLibUnpackDevicePath (
146 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
149 EFI_DEVICE_PATH_PROTOCOL
*Src
;
150 EFI_DEVICE_PATH_PROTOCOL
*Dest
;
151 EFI_DEVICE_PATH_PROTOCOL
*NewPath
;
155 // Walk device path and round sizes to valid boundries
160 Size
+= DevicePathNodeLength (Src
);
161 Size
+= ALIGN_SIZE (Size
);
163 if (IsDevicePathEnd (Src
)) {
167 Src
= NextDevicePathNode (Src
);
170 // Allocate space for the unpacked path
172 NewPath
= AllocateZeroPool (Size
);
175 ASSERT (((UINTN
) NewPath
) % MIN_ALIGNMENT_SIZE
== 0);
183 Size
= DevicePathNodeLength (Src
);
184 CopyMem (Dest
, Src
, Size
);
185 Size
+= ALIGN_SIZE (Size
);
186 SetDevicePathNodeLength (Dest
, Size
);
187 Dest
->Type
|= EFI_DP_TYPE_UNPACKED
;
188 Dest
= (EFI_DEVICE_PATH_PROTOCOL
*) (((UINT8
*) Dest
) + Size
);
190 if (IsDevicePathEnd (Src
)) {
194 Src
= NextDevicePathNode (Src
);
203 IN OUT POOL_PRINT
*Str
,
207 PCI_DEVICE_PATH
*Pci
;
210 CatPrint (Str
, L
"Pci(%x|%x)", (UINTN
) Pci
->Device
, (UINTN
) Pci
->Function
);
215 IN OUT POOL_PRINT
*Str
,
219 PCCARD_DEVICE_PATH
*Pccard
;
222 CatPrint (Str
, L
"Pcmcia(Function%x)", (UINTN
) Pccard
->FunctionNumber
);
227 IN OUT POOL_PRINT
*Str
,
231 MEMMAP_DEVICE_PATH
*MemMap
;
236 L
"MemMap(%d:%lx-%lx)",
238 MemMap
->StartingAddress
,
239 MemMap
->EndingAddress
245 IN OUT POOL_PRINT
*Str
,
249 CONTROLLER_DEVICE_PATH
*Controller
;
251 Controller
= DevPath
;
252 CatPrint (Str
, L
"Ctrl(%d)", (UINTN
) Controller
->ControllerNumber
);
257 Convert Vendor device path to device name
259 @param Str The buffer store device name
260 @param DevPath Pointer to vendor device path
262 @return When it return, the device name have been stored in *Str.
268 IN OUT POOL_PRINT
*Str
,
272 VENDOR_DEVICE_PATH
*Vendor
;
276 UINT32 FlowControlMap
;
282 switch (DevicePathType (&Vendor
->Header
)) {
283 case HARDWARE_DEVICE_PATH
:
285 // bugbug: nt 32 specific definition
288 // If the device is a winntbus device, we will give it a readable device name.
290 if (CompareGuid (&Vendor
->Guid
, &mEfiWinNtThunkProtocolGuid
)) {
291 CatPrint (Str
, L
"%s", L
"WinNtBus");
293 } else if (CompareGuid (&Vendor
->Guid
, &mEfiWinNtGopGuid
)) {
294 CatPrint (Str
, L
"%s", L
"GOP");
296 } else if (CompareGuid (&Vendor
->Guid
, &mEfiWinNtSerialPortGuid
)) {
297 CatPrint (Str
, L
"%s", L
"Serial");
303 case MESSAGING_DEVICE_PATH
:
305 if (CompareGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
)) {
306 CatPrint (Str
, L
"VenPcAnsi()");
308 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100Guid
)) {
309 CatPrint (Str
, L
"VenVt100()");
311 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
)) {
312 CatPrint (Str
, L
"VenVt100Plus()");
314 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
)) {
315 CatPrint (Str
, L
"VenUft8()");
317 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingUartFlowControlGuid
)) {
318 FlowControlMap
= (((UART_FLOW_CONTROL_DEVICE_PATH
*) Vendor
)->FlowControlMap
);
319 switch (FlowControlMap
& 0x00000003) {
321 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"None");
325 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"Hardware");
329 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"XonXoff");
338 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingSASGuid
)) {
342 ((SAS_DEVICE_PATH
*) Vendor
)->SasAddress
,
343 ((SAS_DEVICE_PATH
*) Vendor
)->Lun
,
344 ((SAS_DEVICE_PATH
*) Vendor
)->RelativeTargetPort
346 Info
= (((SAS_DEVICE_PATH
*) Vendor
)->DeviceTopology
);
347 if ((Info
& 0x0f) == 0) {
348 CatPrint (Str
, L
"NoTopology,0,0,0,");
349 } else if (((Info
& 0x0f) == 1) || ((Info
& 0x0f) == 2)) {
353 (Info
& (0x1 << 4)) ? L
"SATA" : L
"SAS",
354 (Info
& (0x1 << 5)) ? L
"External" : L
"Internal",
355 (Info
& (0x1 << 6)) ? L
"Expanded" : L
"Direct"
357 if ((Info
& 0x0f) == 1) {
358 CatPrint (Str
, L
"0,");
360 CatPrint (Str
, L
"%x,", (UINTN
) ((Info
>> 8) & 0xff));
363 CatPrint (Str
, L
"0,0,0,0,");
366 CatPrint (Str
, L
"%x)", (UINTN
) ((SAS_DEVICE_PATH
*) Vendor
)->Reserved
);
369 } else if (CompareGuid (&Vendor
->Guid
, &gEfiDebugPortProtocolGuid
)) {
370 CatPrint (Str
, L
"DebugPort()");
375 case MEDIA_DEVICE_PATH
:
384 CatPrint (Str
, L
"Ven%s(%g", Type
, &Vendor
->Guid
);
385 DataLength
= DevicePathNodeLength (&Vendor
->Header
) - sizeof (VENDOR_DEVICE_PATH
);
386 if (DataLength
> 0) {
387 CatPrint (Str
, L
",");
388 for (Index
= 0; Index
< DataLength
; Index
++) {
389 CatPrint (Str
, L
"%02x", (UINTN
) ((VENDOR_DEVICE_PATH_WITH_DATA
*) Vendor
)->VendorDefinedData
[Index
]);
392 CatPrint (Str
, L
")");
398 IN OUT POOL_PRINT
*Str
,
402 ACPI_HID_DEVICE_PATH
*Acpi
;
405 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
406 CatPrint (Str
, L
"Acpi(PNP%04x,%x)", (UINTN
) EISA_ID_TO_NUM (Acpi
->HID
), (UINTN
) Acpi
->UID
);
408 CatPrint (Str
, L
"Acpi(%08x,%x)", (UINTN
) Acpi
->HID
, (UINTN
) Acpi
->UID
);
413 DevPathExtendedAcpi (
414 IN OUT POOL_PRINT
*Str
,
418 ACPI_EXTENDED_HID_DEVICE_PATH
*ExtendedAcpi
;
420 // Index for HID, UID and CID strings, 0 for non-exist
430 ASSERT (Str
!= NULL
);
431 ASSERT (DevPath
!= NULL
);
436 ExtendedAcpi
= DevPath
;
437 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) ExtendedAcpi
);
439 ASSERT (Length
>= 19);
440 AsChar8Array
= (CHAR8
*) ExtendedAcpi
;
446 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
]; Index
++) {
449 if (Index
> Anchor
) {
455 Anchor
= (UINT16
) (Index
+ 1);
456 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
]; Index
++) {
459 if (Index
> Anchor
) {
465 Anchor
= (UINT16
) (Index
+ 1);
466 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
]; Index
++) {
469 if (Index
> Anchor
) {
473 if (HIDSTRIdx
== 0 && CIDSTRIdx
== 0 && ExtendedAcpi
->UID
== 0) {
474 CatPrint (Str
, L
"AcpiExp(");
475 if ((ExtendedAcpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
476 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->HID
));
478 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->HID
);
480 if ((ExtendedAcpi
->CID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
481 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->CID
));
483 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->CID
);
485 if (UIDSTRIdx
!= 0) {
486 CatPrint (Str
, L
"%a)", AsChar8Array
+ UIDSTRIdx
);
488 CatPrint (Str
, L
"\"\")");
491 CatPrint (Str
, L
"AcpiEx(");
492 if ((ExtendedAcpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
493 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->HID
));
495 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->HID
);
497 if ((ExtendedAcpi
->CID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
498 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->CID
));
500 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->CID
);
502 CatPrint (Str
, L
"%x,", (UINTN
) ExtendedAcpi
->UID
);
504 if (HIDSTRIdx
!= 0) {
505 CatPrint (Str
, L
"%a,", AsChar8Array
+ HIDSTRIdx
);
507 CatPrint (Str
, L
"\"\",");
509 if (CIDSTRIdx
!= 0) {
510 CatPrint (Str
, L
"%a,", AsChar8Array
+ CIDSTRIdx
);
512 CatPrint (Str
, L
"\"\",");
514 if (UIDSTRIdx
!= 0) {
515 CatPrint (Str
, L
"%a)", AsChar8Array
+ UIDSTRIdx
);
517 CatPrint (Str
, L
"\"\")");
525 IN OUT POOL_PRINT
*Str
,
529 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
532 UINT16 AdditionalAdrCount
;
535 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
);
536 AdditionalAdrCount
= (UINT16
) ((Length
- 8) / 4);
538 CatPrint (Str
, L
"AcpiAdr(%x", (UINTN
) AcpiAdr
->ADR
);
539 for (Index
= 0; Index
< AdditionalAdrCount
; Index
++) {
540 CatPrint (Str
, L
",%x", (UINTN
) *(UINT32
*) ((UINT8
*) AcpiAdr
+ 8 + Index
* 4));
542 CatPrint (Str
, L
")");
547 IN OUT POOL_PRINT
*Str
,
551 ATAPI_DEVICE_PATH
*Atapi
;
557 Atapi
->PrimarySecondary
? L
"Secondary" : L
"Primary",
558 Atapi
->SlaveMaster
? L
"Slave" : L
"Master"
564 IN OUT POOL_PRINT
*Str
,
568 SCSI_DEVICE_PATH
*Scsi
;
571 CatPrint (Str
, L
"Scsi(Pun%x,Lun%x)", (UINTN
) Scsi
->Pun
, (UINTN
) Scsi
->Lun
);
576 IN OUT POOL_PRINT
*Str
,
580 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
583 CatPrint (Str
, L
"Fibre(Wwn%lx,Lun%x)", Fibre
->WWN
, Fibre
->Lun
);
588 IN OUT POOL_PRINT
*Str
,
592 F1394_DEVICE_PATH
*F1394
;
595 CatPrint (Str
, L
"1394(%g)", &F1394
->Guid
);
600 IN OUT POOL_PRINT
*Str
,
604 USB_DEVICE_PATH
*Usb
;
607 CatPrint (Str
, L
"Usb(%x,%x)", (UINTN
) Usb
->ParentPortNumber
, (UINTN
) Usb
->InterfaceNumber
);
612 IN OUT POOL_PRINT
*Str
,
616 USB_WWID_DEVICE_PATH
*UsbWWId
;
621 L
"UsbWwid(%x,%x,%x,\"WWID\")",
622 (UINTN
) UsbWWId
->VendorId
,
623 (UINTN
) UsbWWId
->ProductId
,
624 (UINTN
) UsbWWId
->InterfaceNumber
630 IN OUT POOL_PRINT
*Str
,
634 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
636 LogicalUnit
= DevPath
;
637 CatPrint (Str
, L
"Unit(%x)", (UINTN
) LogicalUnit
->Lun
);
642 IN OUT POOL_PRINT
*Str
,
646 USB_CLASS_DEVICE_PATH
*UsbClass
;
651 L
"Usb Class(%x,%x,%x,%x,%x)",
652 (UINTN
) UsbClass
->VendorId
,
653 (UINTN
) UsbClass
->ProductId
,
654 (UINTN
) UsbClass
->DeviceClass
,
655 (UINTN
) UsbClass
->DeviceSubClass
,
656 (UINTN
) UsbClass
->DeviceProtocol
662 IN OUT POOL_PRINT
*Str
,
666 SATA_DEVICE_PATH
*Sata
;
672 (UINTN
) Sata
->HBAPortNumber
,
673 (UINTN
) Sata
->PortMultiplierPortNumber
,
680 IN OUT POOL_PRINT
*Str
,
684 I2O_DEVICE_PATH
*I2O
;
687 CatPrint (Str
, L
"I2O(%x)", (UINTN
) I2O
->Tid
);
692 IN OUT POOL_PRINT
*Str
,
696 MAC_ADDR_DEVICE_PATH
*MAC
;
702 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
703 if (MAC
->IfType
== 0x01 || MAC
->IfType
== 0x00) {
707 CatPrint (Str
, L
"Mac(");
709 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
710 CatPrint (Str
, L
"%02x", (UINTN
) MAC
->MacAddress
.Addr
[Index
]);
713 CatPrint (Str
, L
")");
718 IN OUT POOL_PRINT
*Str
,
722 IPv4_DEVICE_PATH
*IP
;
727 L
"IPv4(%d.%d.%d.%d:%d)",
728 (UINTN
) IP
->RemoteIpAddress
.Addr
[0],
729 (UINTN
) IP
->RemoteIpAddress
.Addr
[1],
730 (UINTN
) IP
->RemoteIpAddress
.Addr
[2],
731 (UINTN
) IP
->RemoteIpAddress
.Addr
[3],
732 (UINTN
) IP
->RemotePort
738 IN OUT POOL_PRINT
*Str
,
742 IPv6_DEVICE_PATH
*IP
;
747 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
748 (UINTN
) IP
->RemoteIpAddress
.Addr
[0],
749 (UINTN
) IP
->RemoteIpAddress
.Addr
[1],
750 (UINTN
) IP
->RemoteIpAddress
.Addr
[2],
751 (UINTN
) IP
->RemoteIpAddress
.Addr
[3],
752 (UINTN
) IP
->RemoteIpAddress
.Addr
[4],
753 (UINTN
) IP
->RemoteIpAddress
.Addr
[5],
754 (UINTN
) IP
->RemoteIpAddress
.Addr
[6],
755 (UINTN
) IP
->RemoteIpAddress
.Addr
[7],
756 (UINTN
) IP
->RemoteIpAddress
.Addr
[8],
757 (UINTN
) IP
->RemoteIpAddress
.Addr
[9],
758 (UINTN
) IP
->RemoteIpAddress
.Addr
[10],
759 (UINTN
) IP
->RemoteIpAddress
.Addr
[11],
760 (UINTN
) IP
->RemoteIpAddress
.Addr
[12],
761 (UINTN
) IP
->RemoteIpAddress
.Addr
[13],
762 (UINTN
) IP
->RemoteIpAddress
.Addr
[14],
763 (UINTN
) IP
->RemoteIpAddress
.Addr
[15]
769 IN OUT POOL_PRINT
*Str
,
773 INFINIBAND_DEVICE_PATH
*InfiniBand
;
775 InfiniBand
= DevPath
;
778 L
"Infiniband(%x,%g,%lx,%lx,%lx)",
779 (UINTN
) InfiniBand
->ResourceFlags
,
781 InfiniBand
->ServiceId
,
782 InfiniBand
->TargetPortId
,
789 IN OUT POOL_PRINT
*Str
,
793 UART_DEVICE_PATH
*Uart
;
797 switch (Uart
->Parity
) {
827 if (Uart
->BaudRate
== 0) {
828 CatPrint (Str
, L
"Uart(DEFAULT,%c,", Parity
);
830 CatPrint (Str
, L
"Uart(%d,%c,", Uart
->BaudRate
, Parity
);
833 if (Uart
->DataBits
== 0) {
834 CatPrint (Str
, L
"D,");
836 CatPrint (Str
, L
"%d,", (UINTN
) Uart
->DataBits
);
839 switch (Uart
->StopBits
) {
841 CatPrint (Str
, L
"D)");
845 CatPrint (Str
, L
"1)");
849 CatPrint (Str
, L
"1.5)");
853 CatPrint (Str
, L
"2)");
857 CatPrint (Str
, L
"x)");
864 IN OUT POOL_PRINT
*Str
,
868 ISCSI_DEVICE_PATH_WITH_NAME
*iSCSI
;
871 ASSERT (Str
!= NULL
);
872 ASSERT (DevPath
!= NULL
);
878 iSCSI
->iSCSITargetName
,
879 iSCSI
->TargetPortalGroupTag
,
883 Options
= iSCSI
->LoginOption
;
884 CatPrint (Str
, L
"%s,", ((Options
>> 1) & 0x0001) ? L
"CRC32C" : L
"None");
885 CatPrint (Str
, L
"%s,", ((Options
>> 3) & 0x0001) ? L
"CRC32C" : L
"None");
886 if ((Options
>> 11) & 0x0001) {
887 CatPrint (Str
, L
"%s,", L
"None");
888 } else if ((Options
>> 12) & 0x0001) {
889 CatPrint (Str
, L
"%s,", L
"CHAP_UNI");
891 CatPrint (Str
, L
"%s,", L
"CHAP_BI");
895 CatPrint (Str
, L
"%s)", (iSCSI
->NetworkProtocol
== 0) ? L
"TCP" : L
"reserved");
900 IN OUT POOL_PRINT
*Str
,
904 HARDDRIVE_DEVICE_PATH
*Hd
;
907 switch (Hd
->SignatureType
) {
908 case SIGNATURE_TYPE_MBR
:
911 L
"HD(Part%d,Sig%08x)",
912 (UINTN
) Hd
->PartitionNumber
,
913 (UINTN
) *((UINT32
*) (&(Hd
->Signature
[0])))
917 case SIGNATURE_TYPE_GUID
:
921 (UINTN
) Hd
->PartitionNumber
,
922 (EFI_GUID
*) &(Hd
->Signature
[0])
929 L
"HD(Part%d,MBRType=%02x,SigType=%02x)",
930 (UINTN
) Hd
->PartitionNumber
,
932 (UINTN
) Hd
->SignatureType
940 IN OUT POOL_PRINT
*Str
,
944 CDROM_DEVICE_PATH
*Cd
;
947 CatPrint (Str
, L
"CDROM(Entry%x)", (UINTN
) Cd
->BootEntry
);
952 IN OUT POOL_PRINT
*Str
,
956 FILEPATH_DEVICE_PATH
*Fp
;
959 CatPrint (Str
, L
"%s", Fp
->PathName
);
963 DevPathMediaProtocol (
964 IN OUT POOL_PRINT
*Str
,
968 MEDIA_PROTOCOL_DEVICE_PATH
*MediaProt
;
971 CatPrint (Str
, L
"Media(%g)", &MediaProt
->Protocol
);
976 IN OUT POOL_PRINT
*Str
,
980 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFilePath
;
982 FvFilePath
= DevPath
;
983 CatPrint (Str
, L
"%g", &FvFilePath
->FvFileName
);
988 IN OUT POOL_PRINT
*Str
,
992 BBS_BBS_DEVICE_PATH
*Bbs
;
996 switch (Bbs
->DeviceType
) {
997 case BBS_TYPE_FLOPPY
:
1001 case BBS_TYPE_HARDDRIVE
:
1002 Type
= L
"Harddrive";
1005 case BBS_TYPE_CDROM
:
1009 case BBS_TYPE_PCMCIA
:
1017 case BBS_TYPE_EMBEDDED_NETWORK
:
1029 CatPrint (Str
, L
"Legacy-%s", Type
);
1033 DevPathEndInstance (
1034 IN OUT POOL_PRINT
*Str
,
1038 CatPrint (Str
, L
",");
1042 DevPathNodeUnknown (
1043 IN OUT POOL_PRINT
*Str
,
1047 CatPrint (Str
, L
"?");
1050 DEVICE_PATH_STRING_TABLE DevPathTable
[] = {
1051 HARDWARE_DEVICE_PATH
,
1054 HARDWARE_DEVICE_PATH
,
1057 HARDWARE_DEVICE_PATH
,
1060 HARDWARE_DEVICE_PATH
,
1063 HARDWARE_DEVICE_PATH
,
1071 DevPathExtendedAcpi
,
1075 MESSAGING_DEVICE_PATH
,
1078 MESSAGING_DEVICE_PATH
,
1081 MESSAGING_DEVICE_PATH
,
1082 MSG_FIBRECHANNEL_DP
,
1084 MESSAGING_DEVICE_PATH
,
1087 MESSAGING_DEVICE_PATH
,
1090 MESSAGING_DEVICE_PATH
,
1093 MESSAGING_DEVICE_PATH
,
1094 MSG_DEVICE_LOGICAL_UNIT_DP
,
1096 MESSAGING_DEVICE_PATH
,
1099 MESSAGING_DEVICE_PATH
,
1102 MESSAGING_DEVICE_PATH
,
1105 MESSAGING_DEVICE_PATH
,
1108 MESSAGING_DEVICE_PATH
,
1111 MESSAGING_DEVICE_PATH
,
1114 MESSAGING_DEVICE_PATH
,
1117 MESSAGING_DEVICE_PATH
,
1120 MESSAGING_DEVICE_PATH
,
1123 MESSAGING_DEVICE_PATH
,
1140 DevPathMediaProtocol
,
1142 MEDIA_PIWG_FW_FILE_DP
,
1147 END_DEVICE_PATH_TYPE
,
1148 END_INSTANCE_DEVICE_PATH_SUBTYPE
,
1157 This function converts an input device structure to a Unicode string.
1159 @param DevPath A pointer to the device path structure.
1161 @return A new allocated Unicode string that represents the device path.
1167 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1171 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1172 VOID (*DumpNode
) (POOL_PRINT
*, VOID
*);
1179 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*DevPathToText
;
1181 ZeroMem (&Str
, sizeof (Str
));
1183 if (DevPath
== NULL
) {
1187 Status
= gBS
->LocateProtocol (
1188 &gEfiDevicePathToTextProtocolGuid
,
1190 (VOID
**) &DevPathToText
1192 if (!EFI_ERROR (Status
)) {
1193 ToText
= DevPathToText
->ConvertDevicePathToText (
1198 ASSERT (ToText
!= NULL
);
1203 // Unpacked the device path
1205 DevPath
= BdsLibUnpackDevicePath (DevPath
);
1209 // Process each device path node
1211 DevPathNode
= DevPath
;
1212 while (!IsDevicePathEnd (DevPathNode
)) {
1214 // Find the handler to dump this device path node
1217 for (Index
= 0; DevPathTable
[Index
].Function
; Index
+= 1) {
1219 if (DevicePathType (DevPathNode
) == DevPathTable
[Index
].Type
&&
1220 DevicePathSubType (DevPathNode
) == DevPathTable
[Index
].SubType
1222 DumpNode
= DevPathTable
[Index
].Function
;
1227 // If not found, use a generic function
1230 DumpNode
= DevPathNodeUnknown
;
1233 // Put a path seperator in if needed
1235 if (Str
.len
&& DumpNode
!= DevPathEndInstance
) {
1236 CatPrint (&Str
, L
"/");
1239 // Print this node of the device path
1241 DumpNode (&Str
, DevPathNode
);
1244 // Next device path node
1246 DevPathNode
= NextDevicePathNode (DevPathNode
);
1249 // Shrink pool used for string allocation
1251 gBS
->FreePool (DevPath
);
1254 NewSize
= (Str
.len
+ 1) * sizeof (CHAR16
);
1255 Str
.str
= ReallocatePool (Str
.str
, NewSize
, NewSize
);
1256 ASSERT (Str
.str
!= NULL
);
1257 Str
.str
[Str
.len
] = 0;
1263 Function creates a device path data structure that identically matches the
1264 device path passed in.
1266 @param DevPath A pointer to a device path data structure.
1268 @return The new copy of DevPath is created to identically match the input.
1269 @return Otherwise, NULL is returned.
1272 EFI_DEVICE_PATH_PROTOCOL
*
1273 LibDuplicateDevicePathInstance (
1274 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1277 EFI_DEVICE_PATH_PROTOCOL
*NewDevPath
;
1278 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
1279 EFI_DEVICE_PATH_PROTOCOL
*Temp
;
1283 // get the size of an instance from the input
1286 DevicePathInst
= GetNextDevicePathInstance (&Temp
, &Size
);
1293 NewDevPath
= AllocateZeroPool (Size
);
1294 ASSERT (NewDevPath
!= NULL
);
1298 CopyMem (NewDevPath
, DevicePathInst
, Size
);