3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 BDS internal function define the default device path string, it can be
19 replaced by platform device path.
24 #include "InternalBdsLib.h"
27 // Platform Code should implement the Vendor specific Device Path display routine.
32 IN OUT POOL_PRINT
*Str
,
37 EFI_GUID mEfiDevicePathMessagingUartFlowControlGuid
= DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL
;
39 EFI_GUID mEfiDevicePathMessagingSASGuid
= DEVICE_PATH_MESSAGING_SAS
;
52 Adjusts the size of a previously allocated buffer.
56 OldPool - A pointer to the buffer whose size is being adjusted.
58 OldSize - The size of the current buffer.
60 NewSize - The size of the new buffer.
64 EFI_SUCEESS - The requested number of bytes were allocated.
66 EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
68 EFI_INVALID_PARAMETER - The buffer was invalid.
76 NewPool
= AllocateZeroPool (NewSize
);
81 CopyMem (NewPool
, OldPool
, OldSize
< NewSize
? OldSize
: NewSize
);
84 gBS
->FreePool (OldPool
);
92 Concatenates a formatted unicode string to allocated pool.
93 The caller must free the resulting buffer.
95 @param Str Tracks the allocated pool, size in use, and amount of pool
97 @param fmt The format string
99 @return Allocated buffer with the formatted string printed in it.
100 @return The caller must free the allocated buffer. The buffer
101 @return allocation is not packed.
106 IN OUT POOL_PRINT
*Str
,
115 AppendStr
= AllocateZeroPool (0x1000);
116 if (AppendStr
== NULL
) {
120 VA_START (args
, fmt
);
121 UnicodeVSPrint (AppendStr
, 0x1000, fmt
, args
);
123 if (NULL
== Str
->str
) {
124 strsize
= StrSize (AppendStr
);
125 Str
->str
= AllocateZeroPool (strsize
);
126 ASSERT (Str
->str
!= NULL
);
128 strsize
= StrSize (AppendStr
);
129 strsize
+= (StrSize (Str
->str
) - sizeof (UINT16
));
131 Str
->str
= ReallocatePool (
136 ASSERT (Str
->str
!= NULL
);
139 Str
->maxlen
= MAX_CHAR
* sizeof (UINT16
);
140 if (strsize
< Str
->maxlen
) {
141 StrCat (Str
->str
, AppendStr
);
142 Str
->len
= strsize
- sizeof (UINT16
);
145 gBS
->FreePool (AppendStr
);
151 Function unpacks a device path data structure so that all the nodes
152 of a device path are naturally aligned.
154 @param DevPath A pointer to a device path data structure
156 @return If the memory for the device path is successfully allocated, then a
157 @return pointer to the new device path is returned. Otherwise, NULL is returned.
160 EFI_DEVICE_PATH_PROTOCOL
*
161 BdsLibUnpackDevicePath (
162 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
165 EFI_DEVICE_PATH_PROTOCOL
*Src
;
166 EFI_DEVICE_PATH_PROTOCOL
*Dest
;
167 EFI_DEVICE_PATH_PROTOCOL
*NewPath
;
171 // Walk device path and round sizes to valid boundries
176 Size
+= DevicePathNodeLength (Src
);
177 Size
+= ALIGN_SIZE (Size
);
179 if (IsDevicePathEnd (Src
)) {
183 Src
= NextDevicePathNode (Src
);
186 // Allocate space for the unpacked path
188 NewPath
= AllocateZeroPool (Size
);
191 ASSERT (((UINTN
) NewPath
) % MIN_ALIGNMENT_SIZE
== 0);
199 Size
= DevicePathNodeLength (Src
);
200 CopyMem (Dest
, Src
, Size
);
201 Size
+= ALIGN_SIZE (Size
);
202 SetDevicePathNodeLength (Dest
, Size
);
203 Dest
->Type
|= EFI_DP_TYPE_UNPACKED
;
204 Dest
= (EFI_DEVICE_PATH_PROTOCOL
*) (((UINT8
*) Dest
) + Size
);
206 if (IsDevicePathEnd (Src
)) {
210 Src
= NextDevicePathNode (Src
);
219 IN OUT POOL_PRINT
*Str
,
223 PCI_DEVICE_PATH
*Pci
;
226 CatPrint (Str
, L
"Pci(%x|%x)", (UINTN
) Pci
->Device
, (UINTN
) Pci
->Function
);
231 IN OUT POOL_PRINT
*Str
,
235 PCCARD_DEVICE_PATH
*Pccard
;
238 CatPrint (Str
, L
"Pcmcia(Function%x)", (UINTN
) Pccard
->FunctionNumber
);
243 IN OUT POOL_PRINT
*Str
,
247 MEMMAP_DEVICE_PATH
*MemMap
;
252 L
"MemMap(%d:%lx-%lx)",
254 MemMap
->StartingAddress
,
255 MemMap
->EndingAddress
261 IN OUT POOL_PRINT
*Str
,
265 CONTROLLER_DEVICE_PATH
*Controller
;
267 Controller
= DevPath
;
268 CatPrint (Str
, L
"Ctrl(%d)", (UINTN
) Controller
->ControllerNumber
);
273 Convert Vendor device path to device name
275 @param Str The buffer store device name
276 @param DevPath Pointer to vendor device path
278 @return When it return, the device name have been stored in *Str.
283 IN OUT POOL_PRINT
*Str
,
287 VENDOR_DEVICE_PATH
*Vendor
;
291 UINT32 FlowControlMap
;
297 switch (DevicePathType (&Vendor
->Header
)) {
298 case HARDWARE_DEVICE_PATH
:
300 // bugbug: nt 32 specific definition
303 // If the device is a winntbus device, we will give it a readable device name.
305 if (CompareGuid (&Vendor
->Guid
, &mEfiWinNtThunkProtocolGuid
)) {
306 CatPrint (Str
, L
"%s", L
"WinNtBus");
308 } else if (CompareGuid (&Vendor
->Guid
, &mEfiWinNtGopGuid
)) {
309 CatPrint (Str
, L
"%s", L
"GOP");
311 } else if (CompareGuid (&Vendor
->Guid
, &mEfiWinNtSerialPortGuid
)) {
312 CatPrint (Str
, L
"%s", L
"Serial");
318 case MESSAGING_DEVICE_PATH
:
320 if (CompareGuid (&Vendor
->Guid
, &gEfiPcAnsiGuid
)) {
321 CatPrint (Str
, L
"VenPcAnsi()");
323 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100Guid
)) {
324 CatPrint (Str
, L
"VenVt100()");
326 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVT100PlusGuid
)) {
327 CatPrint (Str
, L
"VenVt100Plus()");
329 } else if (CompareGuid (&Vendor
->Guid
, &gEfiVTUTF8Guid
)) {
330 CatPrint (Str
, L
"VenUft8()");
332 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingUartFlowControlGuid
)) {
333 FlowControlMap
= (((UART_FLOW_CONTROL_DEVICE_PATH
*) Vendor
)->FlowControlMap
);
334 switch (FlowControlMap
& 0x00000003) {
336 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"None");
340 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"Hardware");
344 CatPrint (Str
, L
"UartFlowCtrl(%s)", L
"XonXoff");
353 } else if (CompareGuid (&Vendor
->Guid
, &mEfiDevicePathMessagingSASGuid
)) {
357 ((SAS_DEVICE_PATH
*) Vendor
)->SasAddress
,
358 ((SAS_DEVICE_PATH
*) Vendor
)->Lun
,
359 ((SAS_DEVICE_PATH
*) Vendor
)->RelativeTargetPort
361 Info
= (((SAS_DEVICE_PATH
*) Vendor
)->DeviceTopology
);
362 if ((Info
& 0x0f) == 0) {
363 CatPrint (Str
, L
"NoTopology,0,0,0,");
364 } else if (((Info
& 0x0f) == 1) || ((Info
& 0x0f) == 2)) {
368 (Info
& (0x1 << 4)) ? L
"SATA" : L
"SAS",
369 (Info
& (0x1 << 5)) ? L
"External" : L
"Internal",
370 (Info
& (0x1 << 6)) ? L
"Expanded" : L
"Direct"
372 if ((Info
& 0x0f) == 1) {
373 CatPrint (Str
, L
"0,");
375 CatPrint (Str
, L
"%x,", (UINTN
) ((Info
>> 8) & 0xff));
378 CatPrint (Str
, L
"0,0,0,0,");
381 CatPrint (Str
, L
"%x)", (UINTN
) ((SAS_DEVICE_PATH
*) Vendor
)->Reserved
);
384 } else if (CompareGuid (&Vendor
->Guid
, &gEfiDebugPortProtocolGuid
)) {
385 CatPrint (Str
, L
"DebugPort()");
390 case MEDIA_DEVICE_PATH
:
399 CatPrint (Str
, L
"Ven%s(%g", Type
, &Vendor
->Guid
);
400 DataLength
= DevicePathNodeLength (&Vendor
->Header
) - sizeof (VENDOR_DEVICE_PATH
);
401 if (DataLength
> 0) {
402 CatPrint (Str
, L
",");
403 for (Index
= 0; Index
< DataLength
; Index
++) {
404 CatPrint (Str
, L
"%02x", (UINTN
) ((VENDOR_DEVICE_PATH_WITH_DATA
*) Vendor
)->VendorDefinedData
[Index
]);
407 CatPrint (Str
, L
")");
413 IN OUT POOL_PRINT
*Str
,
417 ACPI_HID_DEVICE_PATH
*Acpi
;
420 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
421 CatPrint (Str
, L
"Acpi(PNP%04x,%x)", (UINTN
) EISA_ID_TO_NUM (Acpi
->HID
), (UINTN
) Acpi
->UID
);
423 CatPrint (Str
, L
"Acpi(%08x,%x)", (UINTN
) Acpi
->HID
, (UINTN
) Acpi
->UID
);
428 DevPathExtendedAcpi (
429 IN OUT POOL_PRINT
*Str
,
433 ACPI_EXTENDED_HID_DEVICE_PATH
*ExtendedAcpi
;
435 // Index for HID, UID and CID strings, 0 for non-exist
445 ASSERT (Str
!= NULL
);
446 ASSERT (DevPath
!= NULL
);
451 ExtendedAcpi
= DevPath
;
452 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) ExtendedAcpi
);
454 ASSERT (Length
>= 19);
455 AsChar8Array
= (CHAR8
*) ExtendedAcpi
;
461 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
]; Index
++) {
464 if (Index
> Anchor
) {
470 Anchor
= (UINT16
) (Index
+ 1);
471 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
]; Index
++) {
474 if (Index
> Anchor
) {
480 Anchor
= (UINT16
) (Index
+ 1);
481 for (Index
= Anchor
; Index
< Length
&& AsChar8Array
[Index
]; Index
++) {
484 if (Index
> Anchor
) {
488 if (HIDSTRIdx
== 0 && CIDSTRIdx
== 0 && ExtendedAcpi
->UID
== 0) {
489 CatPrint (Str
, L
"AcpiExp(");
490 if ((ExtendedAcpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
491 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->HID
));
493 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->HID
);
495 if ((ExtendedAcpi
->CID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
496 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->CID
));
498 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->CID
);
500 if (UIDSTRIdx
!= 0) {
501 CatPrint (Str
, L
"%a)", AsChar8Array
+ UIDSTRIdx
);
503 CatPrint (Str
, L
"\"\")");
506 CatPrint (Str
, L
"AcpiEx(");
507 if ((ExtendedAcpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
508 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->HID
));
510 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->HID
);
512 if ((ExtendedAcpi
->CID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
513 CatPrint (Str
, L
"PNP%04x,", (UINTN
) EISA_ID_TO_NUM (ExtendedAcpi
->CID
));
515 CatPrint (Str
, L
"%08x,", (UINTN
) ExtendedAcpi
->CID
);
517 CatPrint (Str
, L
"%x,", (UINTN
) ExtendedAcpi
->UID
);
519 if (HIDSTRIdx
!= 0) {
520 CatPrint (Str
, L
"%a,", AsChar8Array
+ HIDSTRIdx
);
522 CatPrint (Str
, L
"\"\",");
524 if (CIDSTRIdx
!= 0) {
525 CatPrint (Str
, L
"%a,", AsChar8Array
+ CIDSTRIdx
);
527 CatPrint (Str
, L
"\"\",");
529 if (UIDSTRIdx
!= 0) {
530 CatPrint (Str
, L
"%a)", AsChar8Array
+ UIDSTRIdx
);
532 CatPrint (Str
, L
"\"\")");
540 IN OUT POOL_PRINT
*Str
,
544 ACPI_ADR_DEVICE_PATH
*AcpiAdr
;
547 UINT16 AdditionalAdrCount
;
550 Length
= (UINT16
) DevicePathNodeLength ((EFI_DEVICE_PATH_PROTOCOL
*) AcpiAdr
);
551 AdditionalAdrCount
= (UINT16
) ((Length
- 8) / 4);
553 CatPrint (Str
, L
"AcpiAdr(%x", (UINTN
) AcpiAdr
->ADR
);
554 for (Index
= 0; Index
< AdditionalAdrCount
; Index
++) {
555 CatPrint (Str
, L
",%x", (UINTN
) *(UINT32
*) ((UINT8
*) AcpiAdr
+ 8 + Index
* 4));
557 CatPrint (Str
, L
")");
562 IN OUT POOL_PRINT
*Str
,
566 ATAPI_DEVICE_PATH
*Atapi
;
572 Atapi
->PrimarySecondary
? L
"Secondary" : L
"Primary",
573 Atapi
->SlaveMaster
? L
"Slave" : L
"Master"
579 IN OUT POOL_PRINT
*Str
,
583 SCSI_DEVICE_PATH
*Scsi
;
586 CatPrint (Str
, L
"Scsi(Pun%x,Lun%x)", (UINTN
) Scsi
->Pun
, (UINTN
) Scsi
->Lun
);
591 IN OUT POOL_PRINT
*Str
,
595 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
598 CatPrint (Str
, L
"Fibre(Wwn%lx,Lun%x)", Fibre
->WWN
, Fibre
->Lun
);
603 IN OUT POOL_PRINT
*Str
,
607 F1394_DEVICE_PATH
*F1394
;
610 CatPrint (Str
, L
"1394(%g)", &F1394
->Guid
);
615 IN OUT POOL_PRINT
*Str
,
619 USB_DEVICE_PATH
*Usb
;
622 CatPrint (Str
, L
"Usb(%x,%x)", (UINTN
) Usb
->ParentPortNumber
, (UINTN
) Usb
->InterfaceNumber
);
625 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
628 IN OUT POOL_PRINT
*Str
,
632 USB_WWID_DEVICE_PATH
*UsbWWId
;
637 L
"UsbWwid(%x,%x,%x,\"WWID\")",
638 (UINTN
) UsbWWId
->VendorId
,
639 (UINTN
) UsbWWId
->ProductId
,
640 (UINTN
) UsbWWId
->InterfaceNumber
646 IN OUT POOL_PRINT
*Str
,
650 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*LogicalUnit
;
652 LogicalUnit
= DevPath
;
653 CatPrint (Str
, L
"Unit(%x)", (UINTN
) LogicalUnit
->Lun
);
659 IN OUT POOL_PRINT
*Str
,
663 USB_CLASS_DEVICE_PATH
*UsbClass
;
668 L
"Usb Class(%x,%x,%x,%x,%x)",
669 (UINTN
) UsbClass
->VendorId
,
670 (UINTN
) UsbClass
->ProductId
,
671 (UINTN
) UsbClass
->DeviceClass
,
672 (UINTN
) UsbClass
->DeviceSubClass
,
673 (UINTN
) UsbClass
->DeviceProtocol
679 IN OUT POOL_PRINT
*Str
,
683 SATA_DEVICE_PATH
*Sata
;
689 (UINTN
) Sata
->HBAPortNumber
,
690 (UINTN
) Sata
->PortMultiplierPortNumber
,
697 IN OUT POOL_PRINT
*Str
,
701 I2O_DEVICE_PATH
*I2O
;
704 CatPrint (Str
, L
"I2O(%x)", (UINTN
) I2O
->Tid
);
709 IN OUT POOL_PRINT
*Str
,
713 MAC_ADDR_DEVICE_PATH
*MAC
;
719 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
720 if (MAC
->IfType
== 0x01 || MAC
->IfType
== 0x00) {
724 CatPrint (Str
, L
"Mac(");
726 for (Index
= 0; Index
< HwAddressSize
; Index
++) {
727 CatPrint (Str
, L
"%02x", (UINTN
) MAC
->MacAddress
.Addr
[Index
]);
730 CatPrint (Str
, L
")");
735 IN OUT POOL_PRINT
*Str
,
739 IPv4_DEVICE_PATH
*IP
;
744 L
"IPv4(%d.%d.%d.%d:%d)",
745 (UINTN
) IP
->RemoteIpAddress
.Addr
[0],
746 (UINTN
) IP
->RemoteIpAddress
.Addr
[1],
747 (UINTN
) IP
->RemoteIpAddress
.Addr
[2],
748 (UINTN
) IP
->RemoteIpAddress
.Addr
[3],
749 (UINTN
) IP
->RemotePort
755 IN OUT POOL_PRINT
*Str
,
759 IPv6_DEVICE_PATH
*IP
;
764 L
"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",
765 (UINTN
) IP
->RemoteIpAddress
.Addr
[0],
766 (UINTN
) IP
->RemoteIpAddress
.Addr
[1],
767 (UINTN
) IP
->RemoteIpAddress
.Addr
[2],
768 (UINTN
) IP
->RemoteIpAddress
.Addr
[3],
769 (UINTN
) IP
->RemoteIpAddress
.Addr
[4],
770 (UINTN
) IP
->RemoteIpAddress
.Addr
[5],
771 (UINTN
) IP
->RemoteIpAddress
.Addr
[6],
772 (UINTN
) IP
->RemoteIpAddress
.Addr
[7],
773 (UINTN
) IP
->RemoteIpAddress
.Addr
[8],
774 (UINTN
) IP
->RemoteIpAddress
.Addr
[9],
775 (UINTN
) IP
->RemoteIpAddress
.Addr
[10],
776 (UINTN
) IP
->RemoteIpAddress
.Addr
[11],
777 (UINTN
) IP
->RemoteIpAddress
.Addr
[12],
778 (UINTN
) IP
->RemoteIpAddress
.Addr
[13],
779 (UINTN
) IP
->RemoteIpAddress
.Addr
[14],
780 (UINTN
) IP
->RemoteIpAddress
.Addr
[15]
786 IN OUT POOL_PRINT
*Str
,
790 INFINIBAND_DEVICE_PATH
*InfiniBand
;
792 InfiniBand
= DevPath
;
795 L
"Infiniband(%x,%g,%lx,%lx,%lx)",
796 (UINTN
) InfiniBand
->ResourceFlags
,
798 InfiniBand
->ServiceId
,
799 InfiniBand
->TargetPortId
,
806 IN OUT POOL_PRINT
*Str
,
810 UART_DEVICE_PATH
*Uart
;
814 switch (Uart
->Parity
) {
844 if (Uart
->BaudRate
== 0) {
845 CatPrint (Str
, L
"Uart(DEFAULT,%c,", Parity
);
847 CatPrint (Str
, L
"Uart(%d,%c,", Uart
->BaudRate
, Parity
);
850 if (Uart
->DataBits
== 0) {
851 CatPrint (Str
, L
"D,");
853 CatPrint (Str
, L
"%d,", (UINTN
) Uart
->DataBits
);
856 switch (Uart
->StopBits
) {
858 CatPrint (Str
, L
"D)");
862 CatPrint (Str
, L
"1)");
866 CatPrint (Str
, L
"1.5)");
870 CatPrint (Str
, L
"2)");
874 CatPrint (Str
, L
"x)");
879 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
882 IN OUT POOL_PRINT
*Str
,
886 ISCSI_DEVICE_PATH_WITH_NAME
*iSCSI
;
889 ASSERT (Str
!= NULL
);
890 ASSERT (DevPath
!= NULL
);
896 iSCSI
->iSCSITargetName
,
897 iSCSI
->TargetPortalGroupTag
,
901 Options
= iSCSI
->LoginOption
;
902 CatPrint (Str
, L
"%s,", ((Options
>> 1) & 0x0001) ? L
"CRC32C" : L
"None");
903 CatPrint (Str
, L
"%s,", ((Options
>> 3) & 0x0001) ? L
"CRC32C" : L
"None");
904 if ((Options
>> 11) & 0x0001) {
905 CatPrint (Str
, L
"%s,", L
"None");
906 } else if ((Options
>> 12) & 0x0001) {
907 CatPrint (Str
, L
"%s,", L
"CHAP_UNI");
909 CatPrint (Str
, L
"%s,", L
"CHAP_BI");
913 CatPrint (Str
, L
"%s)", (iSCSI
->NetworkProtocol
== 0) ? L
"TCP" : L
"reserved");
919 IN OUT POOL_PRINT
*Str
,
923 HARDDRIVE_DEVICE_PATH
*Hd
;
926 switch (Hd
->SignatureType
) {
927 case SIGNATURE_TYPE_MBR
:
930 L
"HD(Part%d,Sig%08x)",
931 (UINTN
) Hd
->PartitionNumber
,
932 (UINTN
) *((UINT32
*) (&(Hd
->Signature
[0])))
936 case SIGNATURE_TYPE_GUID
:
940 (UINTN
) Hd
->PartitionNumber
,
941 (EFI_GUID
*) &(Hd
->Signature
[0])
948 L
"HD(Part%d,MBRType=%02x,SigType=%02x)",
949 (UINTN
) Hd
->PartitionNumber
,
951 (UINTN
) Hd
->SignatureType
959 IN OUT POOL_PRINT
*Str
,
963 CDROM_DEVICE_PATH
*Cd
;
966 CatPrint (Str
, L
"CDROM(Entry%x)", (UINTN
) Cd
->BootEntry
);
971 IN OUT POOL_PRINT
*Str
,
975 FILEPATH_DEVICE_PATH
*Fp
;
978 CatPrint (Str
, L
"%s", Fp
->PathName
);
982 DevPathMediaProtocol (
983 IN OUT POOL_PRINT
*Str
,
987 MEDIA_PROTOCOL_DEVICE_PATH
*MediaProt
;
990 CatPrint (Str
, L
"Media(%g)", &MediaProt
->Protocol
);
995 IN OUT POOL_PRINT
*Str
,
999 MEDIA_FW_VOL_FILEPATH_DEVICE_PATH
*FvFilePath
;
1001 FvFilePath
= DevPath
;
1002 CatPrint (Str
, L
"%g", &FvFilePath
->FvFileName
);
1007 IN OUT POOL_PRINT
*Str
,
1011 BBS_BBS_DEVICE_PATH
*Bbs
;
1015 switch (Bbs
->DeviceType
) {
1016 case BBS_TYPE_FLOPPY
:
1020 case BBS_TYPE_HARDDRIVE
:
1021 Type
= L
"Harddrive";
1024 case BBS_TYPE_CDROM
:
1028 case BBS_TYPE_PCMCIA
:
1036 case BBS_TYPE_EMBEDDED_NETWORK
:
1048 CatPrint (Str
, L
"Legacy-%s", Type
);
1052 DevPathEndInstance (
1053 IN OUT POOL_PRINT
*Str
,
1057 CatPrint (Str
, L
",");
1061 DevPathNodeUnknown (
1062 IN OUT POOL_PRINT
*Str
,
1066 CatPrint (Str
, L
"?");
1069 DEVICE_PATH_STRING_TABLE DevPathTable
[] = {
1070 HARDWARE_DEVICE_PATH
,
1073 HARDWARE_DEVICE_PATH
,
1076 HARDWARE_DEVICE_PATH
,
1079 HARDWARE_DEVICE_PATH
,
1082 HARDWARE_DEVICE_PATH
,
1090 DevPathExtendedAcpi
,
1094 MESSAGING_DEVICE_PATH
,
1097 MESSAGING_DEVICE_PATH
,
1100 MESSAGING_DEVICE_PATH
,
1101 MSG_FIBRECHANNEL_DP
,
1103 MESSAGING_DEVICE_PATH
,
1106 MESSAGING_DEVICE_PATH
,
1109 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
1110 MESSAGING_DEVICE_PATH
,
1113 MESSAGING_DEVICE_PATH
,
1114 MSG_DEVICE_LOGICAL_UNIT_DP
,
1117 MESSAGING_DEVICE_PATH
,
1120 MESSAGING_DEVICE_PATH
,
1123 MESSAGING_DEVICE_PATH
,
1126 MESSAGING_DEVICE_PATH
,
1129 MESSAGING_DEVICE_PATH
,
1132 MESSAGING_DEVICE_PATH
,
1135 MESSAGING_DEVICE_PATH
,
1138 MESSAGING_DEVICE_PATH
,
1141 MESSAGING_DEVICE_PATH
,
1144 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
1145 MESSAGING_DEVICE_PATH
,
1163 DevPathMediaProtocol
,
1164 #if (EFI_SPECIFICATION_VERSION != 0x00020000)
1166 MEDIA_PIWG_FW_FILE_DP
,
1172 END_DEVICE_PATH_TYPE
,
1173 END_INSTANCE_DEVICE_PATH_SUBTYPE
,
1186 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1190 EFI_DEVICE_PATH_PROTOCOL
*DevPathNode
;
1191 VOID (*DumpNode
) (POOL_PRINT
*, VOID
*);
1198 EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
*DevPathToText
;
1200 ZeroMem (&Str
, sizeof (Str
));
1202 if (DevPath
== NULL
) {
1206 Status
= gBS
->LocateProtocol (
1207 &gEfiDevicePathToTextProtocolGuid
,
1209 (VOID
**) &DevPathToText
1211 if (!EFI_ERROR (Status
)) {
1212 ToText
= DevPathToText
->ConvertDevicePathToText (
1217 ASSERT (ToText
!= NULL
);
1222 // Unpacked the device path
1224 DevPath
= BdsLibUnpackDevicePath (DevPath
);
1228 // Process each device path node
1230 DevPathNode
= DevPath
;
1231 while (!IsDevicePathEnd (DevPathNode
)) {
1233 // Find the handler to dump this device path node
1236 for (Index
= 0; DevPathTable
[Index
].Function
; Index
+= 1) {
1238 if (DevicePathType (DevPathNode
) == DevPathTable
[Index
].Type
&&
1239 DevicePathSubType (DevPathNode
) == DevPathTable
[Index
].SubType
1241 DumpNode
= DevPathTable
[Index
].Function
;
1246 // If not found, use a generic function
1249 DumpNode
= DevPathNodeUnknown
;
1252 // Put a path seperator in if needed
1254 if (Str
.len
&& DumpNode
!= DevPathEndInstance
) {
1255 CatPrint (&Str
, L
"/");
1258 // Print this node of the device path
1260 DumpNode (&Str
, DevPathNode
);
1263 // Next device path node
1265 DevPathNode
= NextDevicePathNode (DevPathNode
);
1268 // Shrink pool used for string allocation
1270 gBS
->FreePool (DevPath
);
1273 NewSize
= (Str
.len
+ 1) * sizeof (CHAR16
);
1274 Str
.str
= ReallocatePool (Str
.str
, NewSize
, NewSize
);
1275 ASSERT (Str
.str
!= NULL
);
1276 Str
.str
[Str
.len
] = 0;
1282 Function creates a device path data structure that identically matches the
1283 device path passed in.
1285 @param DevPath A pointer to a device path data structure.
1287 @return The new copy of DevPath is created to identically match the input.
1288 @return Otherwise, NULL is returned.
1291 EFI_DEVICE_PATH_PROTOCOL
*
1292 LibDuplicateDevicePathInstance (
1293 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
1296 EFI_DEVICE_PATH_PROTOCOL
*NewDevPath
;
1297 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
1298 EFI_DEVICE_PATH_PROTOCOL
*Temp
;
1302 // get the size of an instance from the input
1305 DevicePathInst
= GetNextDevicePathInstance (&Temp
, &Size
);
1312 NewDevPath
= AllocateZeroPool (Size
);
1313 ASSERT (NewDevPath
!= NULL
);
1317 CopyMem (NewDevPath
, DevicePathInst
, Size
);