2 Main file for support of shell consist mapping.
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 #include "UefiShellCommandLib.h"
9 #include <Library/DevicePathLib.h>
10 #include <Library/SortLib.h>
11 #include <Library/UefiLib.h>
12 #include <Protocol/UsbIo.h>
13 #include <Protocol/BlockIo.h>
14 #include <Protocol/SimpleFileSystem.h>
34 } DEVICE_CONSIST_MAPPING_INFO
;
42 Serial Decode function.
44 @param DevPath The Device path info.
45 @param MapInfo The map info.
46 @param OrigDevPath The original device path protocol.
48 @retval EFI_OUT_OF_RESOURCES Out of resources.
49 @retval EFI_SUCCESS The appending was successful.
53 (*SERIAL_DECODE_FUNCTION
) (
54 EFI_DEVICE_PATH_PROTOCOL
*DevPath
,
55 DEVICE_CONSIST_MAPPING_INFO
*MapInfo
,
56 EFI_DEVICE_PATH_PROTOCOL
*OrigDevPath
62 SERIAL_DECODE_FUNCTION SerialFun
;
63 INTN (EFIAPI
*CompareFun
)(EFI_DEVICE_PATH_PROTOCOL
*DevPath
, EFI_DEVICE_PATH_PROTOCOL
*DevPath2
);
64 } DEV_PATH_CONSIST_MAPPING_TABLE
;
67 Concatenates a formatted unicode string to allocated pool.
68 The caller must free the resulting buffer.
70 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.
71 @param Fmt The format string
72 @param ... The data will be printed.
74 @retval EFI_SUCCESS The string is concatenated successfully.
75 @retval EFI_OUT_OF_RESOURCES Out of resources.
81 IN OUT POOL_PRINT
*Str
,
91 AppendStr
= AllocateZeroPool (0x1000);
92 if (AppendStr
== NULL
) {
93 return EFI_OUT_OF_RESOURCES
;
97 UnicodeVSPrint (AppendStr
, 0x1000, Fmt
, Args
);
99 if (NULL
== Str
->Str
) {
100 StringSize
= StrSize (AppendStr
);
101 NewStr
= AllocateZeroPool (StringSize
);
103 StringSize
= StrSize (AppendStr
);
104 StringSize
+= (StrSize (Str
->Str
) - sizeof (UINT16
));
106 NewStr
= ReallocatePool (
113 if (NewStr
== NULL
) {
114 FreePool (AppendStr
);
115 return EFI_OUT_OF_RESOURCES
;
119 StrCatS (Str
->Str
, StringSize
/sizeof (CHAR16
), AppendStr
);
120 Str
->Len
= StringSize
;
122 FreePool (AppendStr
);
126 MTD_NAME mMTDName
[] = {
150 Function to append a 64 bit number / 25 onto the string.
152 @param[in, out] Str The string so append onto.
153 @param[in] Num The number to divide and append.
155 @retval EFI_OUT_OF_RESOURCES Out of resources.
156 @retval EFI_SUCCESS The appending was successful.
160 IN OUT POOL_PRINT
*Str
,
168 ASSERT (Str
!= NULL
);
170 Result
= DivU64x32Remainder (Num
, 25, &Rem
);
172 Status
= AppendCSDNum2 (Str
, Result
);
173 if (EFI_ERROR (Status
)) {
178 return CatPrint (Str
, L
"%c", Rem
+ 'a');
182 Function to append a 64 bit number onto the mapping info.
184 @param[in, out] MappingItem The mapping info object to append onto.
185 @param[in] Num The info to append.
187 @retval EFI_OUT_OF_RESOURCES Out of resources.
188 @retval EFI_SUCCESS The appending was successful.
193 IN OUT DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
199 ASSERT (MappingItem
!= NULL
);
201 if (MappingItem
->Digital
) {
202 Status
= CatPrint (&MappingItem
->Csd
, L
"%ld", Num
);
204 Status
= AppendCSDNum2 (&MappingItem
->Csd
, Num
);
207 if (!EFI_ERROR (Status
)) {
208 MappingItem
->Digital
= (BOOLEAN
) !(MappingItem
->Digital
);
215 Function to append string into the mapping info.
217 @param[in, out] MappingItem The mapping info object to append onto.
218 @param[in] Str The info to append.
220 @retval EFI_OUT_OF_RESOURCES Out of resources.
221 @retval EFI_SUCCESS The appending was successful.
225 IN OUT DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
232 ASSERT (Str
!= NULL
&& MappingItem
!= NULL
);
234 Status
= EFI_SUCCESS
;
236 if (MappingItem
->Digital
) {
238 // To aVOID mult-meaning, the mapping is:
239 // 0 1 2 3 4 5 6 7 8 9 a b c d e f
240 // 0 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15
242 for (Index
= Str
; *Index
!= 0; Index
++) {
253 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
);
257 Status
= CatPrint (&MappingItem
->Csd
, L
"16");
266 Status
= CatPrint (&MappingItem
->Csd
, L
"1%c", *Index
- 'a' + '0');
275 Status
= CatPrint (&MappingItem
->Csd
, L
"1%c", *Index
- 'A' + '0');
279 if (EFI_ERROR (Status
)) {
284 for (Index
= Str
; *Index
!= 0; Index
++) {
287 // 0 1 2 3 4 5 6 7 8 9 a b c d e f
288 // a b c d e f g h i j k l m n o p
290 if ((*Index
>= '0') && (*Index
<= '9')) {
291 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- '0' + 'a');
292 } else if ((*Index
>= 'a') && (*Index
<= 'f')) {
293 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- 'a' + 'k');
294 } else if ((*Index
>= 'A') && (*Index
<= 'F')) {
295 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- 'A' + 'k');
298 if (EFI_ERROR (Status
)) {
304 MappingItem
->Digital
= (BOOLEAN
) !(MappingItem
->Digital
);
306 return (EFI_SUCCESS
);
310 Function to append a Guid to the mapping item.
312 @param[in, out] MappingItem The item to append onto.
313 @param[in] Guid The guid to append.
315 @retval EFI_OUT_OF_RESOURCES Out of resources.
316 @retval EFI_SUCCESS The appending was successful.
320 DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
326 ASSERT (Guid
!= NULL
&& MappingItem
!= NULL
);
335 return AppendCSDStr (MappingItem
, Buffer
);
339 Function to compare 2 APCI device paths.
341 @param[in] DevicePath1 The first device path to compare.
342 @param[in] DevicePath2 The second device path to compare.
344 @retval 0 The device paths represent the same device.
345 @return Non zero if the devices are different, zero otherwise.
350 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
351 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
354 ACPI_HID_DEVICE_PATH
*Acpi1
;
355 ACPI_HID_DEVICE_PATH
*Acpi2
;
357 if ((DevicePath1
== NULL
) || (DevicePath2
== NULL
)) {
361 Acpi1
= (ACPI_HID_DEVICE_PATH
*)DevicePath1
;
362 Acpi2
= (ACPI_HID_DEVICE_PATH
*)DevicePath2
;
363 if ((Acpi1
->HID
> Acpi2
->HID
) || ((Acpi1
->HID
== Acpi2
->HID
) && (Acpi1
->UID
> Acpi2
->UID
))) {
367 if ((Acpi1
->HID
== Acpi2
->HID
) && (Acpi1
->UID
== Acpi2
->UID
)) {
375 Function to compare 2 PCI device paths.
377 @param[in] DevicePath1 The first device path to compare.
378 @param[in] DevicePath2 The second device path to compare.
380 @retval 0 The device paths represent the same device.
381 @return Non zero if the devices are different, zero otherwise.
386 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
387 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
390 PCI_DEVICE_PATH
*Pci1
;
391 PCI_DEVICE_PATH
*Pci2
;
393 ASSERT (DevicePath1
!= NULL
);
394 ASSERT (DevicePath2
!= NULL
);
396 Pci1
= (PCI_DEVICE_PATH
*)DevicePath1
;
397 Pci2
= (PCI_DEVICE_PATH
*)DevicePath2
;
398 if ((Pci1
->Device
> Pci2
->Device
) || ((Pci1
->Device
== Pci2
->Device
) && (Pci1
->Function
> Pci2
->Function
))) {
402 if ((Pci1
->Device
== Pci2
->Device
) && (Pci1
->Function
== Pci2
->Function
)) {
410 Do a comparison on 2 device paths.
412 @param[in] DevicePath1 The first device path.
413 @param[in] DevicePath2 The second device path.
415 @retval 0 The 2 device paths are the same.
416 @retval <0 DevicePath2 is greater than DevicePath1.
417 @retval >0 DevicePath1 is greater than DevicePath2.
421 DevPathCompareDefault (
422 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
423 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
429 ASSERT (DevicePath1
!= NULL
);
430 ASSERT (DevicePath2
!= NULL
);
432 DevPathSize1
= DevicePathNodeLength (DevicePath1
);
433 DevPathSize2
= DevicePathNodeLength (DevicePath2
);
434 if (DevPathSize1
> DevPathSize2
) {
436 } else if (DevPathSize1
< DevPathSize2
) {
439 return CompareMem (DevicePath1
, DevicePath2
, DevPathSize1
);
444 DevicePathNode must be SerialHDD Channel type and this will populate the MappingItem.
446 @param[in] DevicePathNode The node to get info on.
447 @param[in] MappingItem The info item to populate.
448 @param[in] DevicePath Ignored.
450 @retval EFI_OUT_OF_RESOURCES Out of resources.
451 @retval EFI_SUCCESS The appending was successful.
454 DevPathSerialHardDrive (
455 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
456 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
457 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
460 HARDDRIVE_DEVICE_PATH
*Hd
;
462 ASSERT (DevicePathNode
!= NULL
);
463 ASSERT (MappingItem
!= NULL
);
465 Hd
= (HARDDRIVE_DEVICE_PATH
*)DevicePathNode
;
466 if (MappingItem
->Mtd
== MTDTypeUnknown
) {
467 MappingItem
->Mtd
= MTDTypeHardDisk
;
470 return AppendCSDNum (MappingItem
, Hd
->PartitionNumber
);
474 DevicePathNode must be SerialAtapi Channel type and this will populate the MappingItem.
476 @param[in] DevicePathNode The node to get info on.
477 @param[in] MappingItem The info item to populate.
478 @param[in] DevicePath Ignored.
480 @retval EFI_OUT_OF_RESOURCES Out of resources.
481 @retval EFI_SUCCESS The appending was successful.
485 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
486 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
487 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
490 ATAPI_DEVICE_PATH
*Atapi
;
492 ASSERT (DevicePathNode
!= NULL
);
493 ASSERT (MappingItem
!= NULL
);
495 Atapi
= (ATAPI_DEVICE_PATH
*)DevicePathNode
;
496 return AppendCSDNum (MappingItem
, (Atapi
->PrimarySecondary
* 2 + Atapi
->SlaveMaster
));
500 DevicePathNode must be SerialCDROM Channel type and this will populate the MappingItem.
502 @param[in] DevicePathNode The node to get info on.
503 @param[in] MappingItem The info item to populate.
504 @param[in] DevicePath Ignored.
506 @retval EFI_OUT_OF_RESOURCES Out of resources.
507 @retval EFI_SUCCESS The appending was successful.
511 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
512 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
513 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
516 CDROM_DEVICE_PATH
*Cd
;
518 ASSERT (DevicePathNode
!= NULL
);
519 ASSERT (MappingItem
!= NULL
);
521 Cd
= (CDROM_DEVICE_PATH
*)DevicePathNode
;
522 MappingItem
->Mtd
= MTDTypeCDRom
;
523 return AppendCSDNum (MappingItem
, Cd
->BootEntry
);
527 DevicePathNode must be SerialFibre Channel type and this will populate the MappingItem.
529 @param[in] DevicePathNode The node to get info on.
530 @param[in] MappingItem The info item to populate.
531 @param[in] DevicePath Ignored.
533 @retval EFI_OUT_OF_RESOURCES Out of resources.
534 @retval EFI_SUCCESS The appending was successful.
538 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
539 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
540 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
544 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
546 ASSERT (DevicePathNode
!= NULL
);
547 ASSERT (MappingItem
!= NULL
);
549 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*)DevicePathNode
;
550 Status
= AppendCSDNum (MappingItem
, Fibre
->WWN
);
551 if (!EFI_ERROR (Status
)) {
552 Status
= AppendCSDNum (MappingItem
, Fibre
->Lun
);
559 DevicePathNode must be SerialUart type and this will populate the MappingItem.
561 @param[in] DevicePathNode The node to get info on.
562 @param[in] MappingItem The info item to populate.
563 @param[in] DevicePath Ignored.
565 @retval EFI_OUT_OF_RESOURCES Out of resources.
566 @retval EFI_SUCCESS The appending was successful.
570 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
571 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
572 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
576 UART_DEVICE_PATH
*Uart
;
578 ASSERT (DevicePathNode
!= NULL
);
579 ASSERT (MappingItem
!= NULL
);
581 Uart
= (UART_DEVICE_PATH
*)DevicePathNode
;
582 Status
= AppendCSDNum (MappingItem
, Uart
->BaudRate
);
583 if (!EFI_ERROR (Status
)) {
584 Status
= AppendCSDNum (MappingItem
, Uart
->DataBits
);
587 if (!EFI_ERROR (Status
)) {
588 Status
= AppendCSDNum (MappingItem
, Uart
->Parity
);
591 if (!EFI_ERROR (Status
)) {
592 Status
= AppendCSDNum (MappingItem
, Uart
->StopBits
);
599 DevicePathNode must be SerialUSB type and this will populate the MappingItem.
601 @param[in] DevicePathNode The node to get info on.
602 @param[in] MappingItem The info item to populate.
603 @param[in] DevicePath Ignored.
605 @retval EFI_OUT_OF_RESOURCES Out of resources.
606 @retval EFI_SUCCESS The appending was successful.
610 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
611 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
612 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
615 USB_DEVICE_PATH
*Usb
;
616 EFI_USB_IO_PROTOCOL
*UsbIo
;
617 EFI_HANDLE TempHandle
;
619 USB_INTERFACE_DESCRIPTOR InterfaceDesc
;
621 ASSERT (DevicePathNode
!= NULL
);
622 ASSERT (MappingItem
!= NULL
);
624 Usb
= (USB_DEVICE_PATH
*)DevicePathNode
;
625 Status
= AppendCSDNum (MappingItem
, Usb
->ParentPortNumber
);
626 if (!EFI_ERROR (Status
)) {
627 Status
= AppendCSDNum (MappingItem
, Usb
->InterfaceNumber
);
630 if (EFI_ERROR (Status
)) {
634 if (PcdGetBool (PcdUsbExtendedDecode
)) {
635 Status
= gBS
->LocateDevicePath (&gEfiUsbIoProtocolGuid
, &DevicePath
, &TempHandle
);
637 if (!EFI_ERROR (Status
)) {
638 Status
= gBS
->OpenProtocol (TempHandle
, &gEfiUsbIoProtocolGuid
, (VOID
**)&UsbIo
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
641 if (!EFI_ERROR (Status
)) {
642 ASSERT (UsbIo
!= NULL
);
643 Status
= UsbIo
->UsbGetInterfaceDescriptor (UsbIo
, &InterfaceDesc
);
644 if (!EFI_ERROR (Status
)) {
645 if ((InterfaceDesc
.InterfaceClass
== USB_MASS_STORE_CLASS
) && (MappingItem
->Mtd
== MTDTypeUnknown
)) {
646 switch (InterfaceDesc
.InterfaceSubClass
) {
647 case USB_MASS_STORE_SCSI
:
648 MappingItem
->Mtd
= MTDTypeHardDisk
;
650 case USB_MASS_STORE_8070I
:
651 case USB_MASS_STORE_UFI
:
652 MappingItem
->Mtd
= MTDTypeFloppy
;
654 case USB_MASS_STORE_8020I
:
655 MappingItem
->Mtd
= MTDTypeCDRom
;
667 DevicePathNode must be SerialVendor type and this will populate the MappingItem.
669 @param[in] DevicePathNode The node to get info on.
670 @param[in] MappingItem The info item to populate.
671 @param[in] DevicePath Ignored.
673 @retval EFI_OUT_OF_RESOURCES Out of resources.
674 @retval EFI_SUCCESS The appending was successful.
677 DevPathSerialVendor (
678 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
679 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
680 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
684 VENDOR_DEVICE_PATH
*Vendor
;
685 SAS_DEVICE_PATH
*Sas
;
686 UINTN TargetNameLength
;
691 ASSERT (DevicePathNode
!= NULL
);
692 ASSERT (MappingItem
!= NULL
);
694 Vendor
= (VENDOR_DEVICE_PATH
*)DevicePathNode
;
695 Status
= AppendCSDGuid (MappingItem
, &Vendor
->Guid
);
696 if (EFI_ERROR (Status
)) {
700 if (CompareGuid (&gEfiSasDevicePathGuid
, &Vendor
->Guid
)) {
701 Sas
= (SAS_DEVICE_PATH
*)Vendor
;
702 Status
= AppendCSDNum (MappingItem
, Sas
->SasAddress
);
703 if (!EFI_ERROR (Status
)) {
704 Status
= AppendCSDNum (MappingItem
, Sas
->Lun
);
707 if (!EFI_ERROR (Status
)) {
708 Status
= AppendCSDNum (MappingItem
, Sas
->DeviceTopology
);
711 if (!EFI_ERROR (Status
)) {
712 Status
= AppendCSDNum (MappingItem
, Sas
->RelativeTargetPort
);
715 TargetNameLength
= MIN (DevicePathNodeLength (DevicePathNode
) - sizeof (VENDOR_DEVICE_PATH
), PcdGet32 (PcdShellVendorExtendedDecode
));
716 if (TargetNameLength
!= 0) {
718 // String is 2 chars per data byte, plus NULL terminator
720 Buffer
= AllocateZeroPool (((TargetNameLength
* 2) + 1) * sizeof (CHAR16
));
721 if (Buffer
== NULL
) {
722 return EFI_OUT_OF_RESOURCES
;
726 // Build the string data
728 for (Index
= 0; Index
< TargetNameLength
; Index
++) {
729 NewBuffer
= CatSPrint (Buffer
, L
"%02x", *((UINT8
*)Vendor
+ sizeof (VENDOR_DEVICE_PATH
) + Index
));
730 if (NewBuffer
== NULL
) {
731 Status
= EFI_OUT_OF_RESOURCES
;
739 // Append the new data block
741 if (!EFI_ERROR (Status
)) {
742 Status
= AppendCSDStr (MappingItem
, Buffer
);
753 DevicePathNode must be SerialLun type and this will populate the MappingItem.
755 @param[in] DevicePathNode The node to get info on.
756 @param[in] MappingItem The info item to populate.
757 @param[in] DevicePath Ignored.
759 @retval EFI_OUT_OF_RESOURCES Out of resources.
760 @retval EFI_SUCCESS The appending was successful.
764 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
765 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
766 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
769 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*Lun
;
771 ASSERT (DevicePathNode
!= NULL
);
772 ASSERT (MappingItem
!= NULL
);
774 Lun
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*)DevicePathNode
;
775 return AppendCSDNum (MappingItem
, Lun
->Lun
);
779 DevicePathNode must be SerialSata type and this will populate the MappingItem.
781 @param[in] DevicePathNode The node to get info on.
782 @param[in] MappingItem The info item to populate.
783 @param[in] DevicePath Ignored.
785 @retval EFI_OUT_OF_RESOURCES Out of resources.
786 @retval EFI_SUCCESS The appending was successful.
790 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
791 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
792 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
796 SATA_DEVICE_PATH
*Sata
;
798 ASSERT (DevicePathNode
!= NULL
);
799 ASSERT (MappingItem
!= NULL
);
801 Sata
= (SATA_DEVICE_PATH
*)DevicePathNode
;
802 Status
= AppendCSDNum (MappingItem
, Sata
->HBAPortNumber
);
803 if (!EFI_ERROR (Status
)) {
804 Status
= AppendCSDNum (MappingItem
, Sata
->PortMultiplierPortNumber
);
807 if (!EFI_ERROR (Status
)) {
808 Status
= AppendCSDNum (MappingItem
, Sata
->Lun
);
815 DevicePathNode must be SerialSCSI type and this will populate the MappingItem.
817 @param[in] DevicePathNode The node to get info on.
818 @param[in] MappingItem The info item to populate.
819 @param[in] DevicePath Ignored.
821 @retval EFI_OUT_OF_RESOURCES Out of resources.
822 @retval EFI_SUCCESS The appending was successful.
826 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
827 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
828 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
832 ISCSI_DEVICE_PATH
*IScsi
;
833 UINT8
*IScsiTargetName
;
835 UINTN TargetNameLength
;
838 ASSERT (DevicePathNode
!= NULL
);
839 ASSERT (MappingItem
!= NULL
);
841 Status
= EFI_SUCCESS
;
843 if (PcdGetBool (PcdShellDecodeIScsiMapNames
)) {
844 IScsi
= (ISCSI_DEVICE_PATH
*)DevicePathNode
;
845 Status
= AppendCSDNum (MappingItem
, IScsi
->NetworkProtocol
);
846 if (!EFI_ERROR (Status
)) {
847 Status
= AppendCSDNum (MappingItem
, IScsi
->LoginOption
);
850 if (!EFI_ERROR (Status
)) {
851 Status
= AppendCSDNum (MappingItem
, IScsi
->Lun
);
854 if (!EFI_ERROR (Status
)) {
855 Status
= AppendCSDNum (MappingItem
, IScsi
->TargetPortalGroupTag
);
858 if (EFI_ERROR (Status
)) {
862 TargetNameLength
= DevicePathNodeLength (DevicePathNode
) - sizeof (ISCSI_DEVICE_PATH
);
863 if (TargetNameLength
> 0) {
864 TargetName
= AllocateZeroPool ((TargetNameLength
+ 1) * sizeof (CHAR16
));
865 if (TargetName
== NULL
) {
866 Status
= EFI_OUT_OF_RESOURCES
;
868 IScsiTargetName
= (UINT8
*)(IScsi
+ 1);
869 for (Index
= 0; Index
< TargetNameLength
; Index
++) {
870 TargetName
[Index
] = (CHAR16
)IScsiTargetName
[Index
];
873 Status
= AppendCSDStr (MappingItem
, TargetName
);
874 FreePool (TargetName
);
883 DevicePathNode must be SerialI20 type and this will populate the MappingItem.
885 @param[in] DevicePathNode The node to get info on.
886 @param[in] MappingItem The info item to populate.
887 @param[in] DevicePath Ignored.
889 @retval EFI_OUT_OF_RESOURCES Out of resources.
890 @retval EFI_SUCCESS The appending was successful.
894 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
895 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
896 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
899 I2O_DEVICE_PATH
*DevicePath_I20
;
901 ASSERT (DevicePathNode
!= NULL
);
902 ASSERT (MappingItem
!= NULL
);
904 DevicePath_I20
= (I2O_DEVICE_PATH
*)DevicePathNode
;
905 return AppendCSDNum (MappingItem
, DevicePath_I20
->Tid
);
909 DevicePathNode must be Mac Address type and this will populate the MappingItem.
911 @param[in] DevicePathNode The node to get info on.
912 @param[in] MappingItem The info item to populate.
913 @param[in] DevicePath Ignored.
915 @retval EFI_OUT_OF_RESOURCES Out of resources.
916 @retval EFI_SUCCESS The appending was successful.
919 DevPathSerialMacAddr (
920 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
921 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
922 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
925 MAC_ADDR_DEVICE_PATH
*Mac
;
931 ASSERT (DevicePathNode
!= NULL
);
932 ASSERT (MappingItem
!= NULL
);
934 Mac
= (MAC_ADDR_DEVICE_PATH
*)DevicePathNode
;
936 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
937 if ((Mac
->IfType
== 0x01) || (Mac
->IfType
== 0x00)) {
941 for (Index
= 0, PBuffer
= Buffer
; Index
< HwAddressSize
; Index
++, PBuffer
+= 2) {
942 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
)Mac
->MacAddress
.Addr
[Index
]);
945 return AppendCSDStr (MappingItem
, Buffer
);
949 DevicePathNode must be InfiniBand type and this will populate the MappingItem.
951 @param[in] DevicePathNode The node to get info on.
952 @param[in] MappingItem The info item to populate.
953 @param[in] DevicePath Ignored.
955 @retval EFI_OUT_OF_RESOURCES Out of resources.
956 @retval EFI_SUCCESS The appending was successful.
959 DevPathSerialInfiniBand (
960 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
961 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
962 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
966 INFINIBAND_DEVICE_PATH
*InfiniBand
;
971 ASSERT (DevicePathNode
!= NULL
);
972 ASSERT (MappingItem
!= NULL
);
974 InfiniBand
= (INFINIBAND_DEVICE_PATH
*)DevicePathNode
;
975 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
976 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
)InfiniBand
->PortGid
[Index
]);
979 Status
= AppendCSDStr (MappingItem
, Buffer
);
980 if (!EFI_ERROR (Status
)) {
981 Status
= AppendCSDNum (MappingItem
, InfiniBand
->ServiceId
);
984 if (!EFI_ERROR (Status
)) {
985 Status
= AppendCSDNum (MappingItem
, InfiniBand
->TargetPortId
);
988 if (!EFI_ERROR (Status
)) {
989 Status
= AppendCSDNum (MappingItem
, InfiniBand
->DeviceId
);
996 DevicePathNode must be IPv4 type and this will populate the MappingItem.
998 @param[in] DevicePathNode The node to get info on.
999 @param[in] MappingItem The info item to populate.
1000 @param[in] DevicePath Ignored.
1002 @retval EFI_OUT_OF_RESOURCES Out of resources.
1003 @retval EFI_SUCCESS The appending was successful.
1007 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1008 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1009 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1013 IPv4_DEVICE_PATH
*Ip
;
1016 ASSERT (DevicePathNode
!= NULL
);
1017 ASSERT (MappingItem
!= NULL
);
1019 Ip
= (IPv4_DEVICE_PATH
*)DevicePathNode
;
1023 L
"%02x%02x%02x%02x",
1024 (UINTN
)Ip
->LocalIpAddress
.Addr
[0],
1025 (UINTN
)Ip
->LocalIpAddress
.Addr
[1],
1026 (UINTN
)Ip
->LocalIpAddress
.Addr
[2],
1027 (UINTN
)Ip
->LocalIpAddress
.Addr
[3]
1029 Status
= AppendCSDStr (MappingItem
, Buffer
);
1030 if (!EFI_ERROR (Status
)) {
1031 Status
= AppendCSDNum (MappingItem
, Ip
->LocalPort
);
1034 if (!EFI_ERROR (Status
)) {
1038 L
"%02x%02x%02x%02x",
1039 (UINTN
)Ip
->RemoteIpAddress
.Addr
[0],
1040 (UINTN
)Ip
->RemoteIpAddress
.Addr
[1],
1041 (UINTN
)Ip
->RemoteIpAddress
.Addr
[2],
1042 (UINTN
)Ip
->RemoteIpAddress
.Addr
[3]
1044 Status
= AppendCSDStr (MappingItem
, Buffer
);
1047 if (!EFI_ERROR (Status
)) {
1048 Status
= AppendCSDNum (MappingItem
, Ip
->RemotePort
);
1055 DevicePathNode must be IPv6 type and this will populate the MappingItem.
1057 @param[in] DevicePathNode The node to get info on.
1058 @param[in] MappingItem The info item to populate.
1059 @param[in] DevicePath Ignored.
1061 @retval EFI_OUT_OF_RESOURCES Out of resources.
1062 @retval EFI_SUCCESS The appending was successful.
1066 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1067 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1068 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1072 IPv6_DEVICE_PATH
*Ip
;
1077 ASSERT (DevicePathNode
!= NULL
);
1078 ASSERT (MappingItem
!= NULL
);
1080 Ip
= (IPv6_DEVICE_PATH
*)DevicePathNode
;
1081 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
1082 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
)Ip
->LocalIpAddress
.Addr
[Index
]);
1085 Status
= AppendCSDStr (MappingItem
, Buffer
);
1086 if (!EFI_ERROR (Status
)) {
1087 Status
= AppendCSDNum (MappingItem
, Ip
->LocalPort
);
1090 if (!EFI_ERROR (Status
)) {
1091 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
1092 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
)Ip
->RemoteIpAddress
.Addr
[Index
]);
1095 Status
= AppendCSDStr (MappingItem
, Buffer
);
1098 if (!EFI_ERROR (Status
)) {
1099 Status
= AppendCSDNum (MappingItem
, Ip
->RemotePort
);
1106 DevicePathNode must be SCSI type and this will populate the MappingItem.
1108 @param[in] DevicePathNode The node to get info on.
1109 @param[in] MappingItem The info item to populate.
1110 @param[in] DevicePath Ignored.
1112 @retval EFI_OUT_OF_RESOURCES Out of resources.
1113 @retval EFI_SUCCESS The appending was successful.
1117 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1118 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1119 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1123 SCSI_DEVICE_PATH
*Scsi
;
1125 ASSERT (DevicePathNode
!= NULL
);
1126 ASSERT (MappingItem
!= NULL
);
1128 Scsi
= (SCSI_DEVICE_PATH
*)DevicePathNode
;
1129 Status
= AppendCSDNum (MappingItem
, Scsi
->Pun
);
1130 if (!EFI_ERROR (Status
)) {
1131 Status
= AppendCSDNum (MappingItem
, Scsi
->Lun
);
1138 DevicePathNode must be 1394 type and this will populate the MappingItem.
1140 @param[in] DevicePathNode The node to get info on.
1141 @param[in] MappingItem The info item to populate.
1142 @param[in] DevicePath Ignored.
1144 @retval EFI_OUT_OF_RESOURCES Out of resources.
1145 @retval EFI_SUCCESS The appending was successful.
1149 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1150 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1151 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1154 F1394_DEVICE_PATH
*DevicePath_F1394
;
1157 ASSERT (DevicePathNode
!= NULL
);
1158 ASSERT (MappingItem
!= NULL
);
1160 DevicePath_F1394
= (F1394_DEVICE_PATH
*)DevicePathNode
;
1161 UnicodeSPrint (Buffer
, 0, L
"%lx", DevicePath_F1394
->Guid
);
1162 return AppendCSDStr (MappingItem
, Buffer
);
1166 If the node is floppy type then populate the MappingItem.
1168 @param[in] DevicePathNode The node to get info on.
1169 @param[in] MappingItem The info item to populate.
1170 @param[in] DevicePath Ignored.
1172 @retval EFI_OUT_OF_RESOURCES Out of resources.
1173 @retval EFI_SUCCESS The appending was successful.
1177 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1178 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1179 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1182 ACPI_HID_DEVICE_PATH
*Acpi
;
1184 ASSERT (DevicePathNode
!= NULL
);
1185 ASSERT (MappingItem
!= NULL
);
1187 Acpi
= (ACPI_HID_DEVICE_PATH
*)DevicePathNode
;
1188 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
1189 if (EISA_ID_TO_NUM (Acpi
->HID
) == 0x0604) {
1190 MappingItem
->Mtd
= MTDTypeFloppy
;
1191 return AppendCSDNum (MappingItem
, Acpi
->UID
);
1199 Empty function used for unknown devices.
1201 @param[in] DevicePathNode Ignored.
1202 @param[in] MappingItem Ignored.
1203 @param[in] DevicePath Ignored.
1205 @retval EFI_OUT_OF_RESOURCES Out of resources.
1206 @retval EFI_SUCCESS The appending was successful.
1209 DevPathSerialDefault (
1210 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1211 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1212 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1218 DEV_PATH_CONSIST_MAPPING_TABLE DevPathConsistMappingTable
[] = {
1220 HARDWARE_DEVICE_PATH
,
1222 DevPathSerialDefault
,
1232 MESSAGING_DEVICE_PATH
,
1235 DevPathCompareDefault
1238 MESSAGING_DEVICE_PATH
,
1241 DevPathCompareDefault
1244 MESSAGING_DEVICE_PATH
,
1245 MSG_FIBRECHANNEL_DP
,
1247 DevPathCompareDefault
1250 MESSAGING_DEVICE_PATH
,
1253 DevPathCompareDefault
1256 MESSAGING_DEVICE_PATH
,
1259 DevPathCompareDefault
1262 MESSAGING_DEVICE_PATH
,
1265 DevPathCompareDefault
1268 MESSAGING_DEVICE_PATH
,
1270 DevPathSerialMacAddr
,
1271 DevPathCompareDefault
1274 MESSAGING_DEVICE_PATH
,
1277 DevPathCompareDefault
1280 MESSAGING_DEVICE_PATH
,
1283 DevPathCompareDefault
1286 MESSAGING_DEVICE_PATH
,
1288 DevPathSerialInfiniBand
,
1289 DevPathCompareDefault
1292 MESSAGING_DEVICE_PATH
,
1295 DevPathCompareDefault
1298 MESSAGING_DEVICE_PATH
,
1300 DevPathSerialVendor
,
1301 DevPathCompareDefault
1304 MESSAGING_DEVICE_PATH
,
1305 MSG_DEVICE_LOGICAL_UNIT_DP
,
1307 DevPathCompareDefault
1310 MESSAGING_DEVICE_PATH
,
1313 DevPathCompareDefault
1316 MESSAGING_DEVICE_PATH
,
1319 DevPathCompareDefault
1324 DevPathSerialHardDrive
,
1325 DevPathCompareDefault
1331 DevPathCompareDefault
1336 DevPathSerialVendor
,
1337 DevPathCompareDefault
1348 Function to determine if a device path node is Hi or not.
1350 @param[in] DevicePathNode The node to check.
1352 @retval TRUE The node is Hi.
1353 @retval FALSE The node is not Hi.
1356 IsHIDevicePathNode (
1357 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
1360 ACPI_HID_DEVICE_PATH
*Acpi
;
1362 ASSERT (DevicePathNode
!= NULL
);
1364 if (DevicePathNode
->Type
== HARDWARE_DEVICE_PATH
) {
1368 if (DevicePathNode
->Type
== ACPI_DEVICE_PATH
) {
1369 Acpi
= (ACPI_HID_DEVICE_PATH
*)DevicePathNode
;
1370 switch (EISA_ID_TO_NUM (Acpi
->HID
)) {
1385 Function to convert a standard device path structure into a Hi version.
1387 @param[in] DevicePath The device path to convert.
1389 @return the device path portion that is Hi.
1391 EFI_DEVICE_PATH_PROTOCOL
*
1393 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1396 UINTN NonHIDevicePathNodeCount
;
1399 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1400 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
1402 ASSERT (DevicePath
!= NULL
);
1404 NonHIDevicePathNodeCount
= 0;
1406 HIDevicePath
= AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL
));
1407 SetDevicePathEndNode (HIDevicePath
);
1409 Node
.DevPath
.Type
= END_DEVICE_PATH_TYPE
;
1410 Node
.DevPath
.SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
1411 Node
.DevPath
.Length
[0] = (UINT8
)sizeof (EFI_DEVICE_PATH_PROTOCOL
);
1412 Node
.DevPath
.Length
[1] = 0;
1414 while (!IsDevicePathEnd (DevicePath
)) {
1415 if (IsHIDevicePathNode (DevicePath
)) {
1416 for (Index
= 0; Index
< NonHIDevicePathNodeCount
; Index
++) {
1417 TempDevicePath
= AppendDevicePathNode (HIDevicePath
, &Node
.DevPath
);
1418 FreePool (HIDevicePath
);
1419 HIDevicePath
= TempDevicePath
;
1422 TempDevicePath
= AppendDevicePathNode (HIDevicePath
, DevicePath
);
1423 FreePool (HIDevicePath
);
1424 HIDevicePath
= TempDevicePath
;
1426 NonHIDevicePathNodeCount
++;
1430 // Next device path node
1432 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*)NextDevicePathNode (DevicePath
);
1435 return HIDevicePath
;
1439 Function to walk the device path looking for a dumpable node.
1441 @param[in] MappingItem The Item to fill with data.
1442 @param[in] DevicePath The path of the item to get data on.
1444 @return EFI_SUCCESS Always returns success.
1447 GetDeviceConsistMappingInfo (
1448 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1449 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1453 SERIAL_DECODE_FUNCTION SerialFun
;
1455 EFI_DEVICE_PATH_PROTOCOL
*OriginalDevicePath
;
1457 ASSERT (DevicePath
!= NULL
);
1458 ASSERT (MappingItem
!= NULL
);
1460 SetMem (&MappingItem
->Csd
, sizeof (POOL_PRINT
), 0);
1461 OriginalDevicePath
= DevicePath
;
1463 while (!IsDevicePathEnd (DevicePath
)) {
1465 // Find the handler to dump this device path node and
1466 // initialize with generic function in case nothing is found
1468 for (SerialFun
= DevPathSerialDefault
, Index
= 0; DevPathConsistMappingTable
[Index
].SerialFun
!= NULL
; Index
+= 1) {
1469 if ((DevicePathType (DevicePath
) == DevPathConsistMappingTable
[Index
].Type
) &&
1470 (DevicePathSubType (DevicePath
) == DevPathConsistMappingTable
[Index
].SubType
)
1473 SerialFun
= DevPathConsistMappingTable
[Index
].SerialFun
;
1478 Status
= SerialFun (DevicePath
, MappingItem
, OriginalDevicePath
);
1479 if (EFI_ERROR (Status
)) {
1480 SHELL_FREE_NON_NULL (MappingItem
->Csd
.Str
);
1485 // Next device path node
1487 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*)NextDevicePathNode (DevicePath
);
1494 Function to initialize the table for creating consistent map names.
1496 @param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.
1498 @retval EFI_SUCCESS The table was created successfully.
1502 ShellCommandConsistMappingInitialize (
1503 OUT EFI_DEVICE_PATH_PROTOCOL
***Table
1506 EFI_HANDLE
*HandleBuffer
;
1509 EFI_DEVICE_PATH_PROTOCOL
**TempTable
;
1510 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
1511 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1512 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
1513 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
1517 HandleBuffer
= NULL
;
1519 Status
= gBS
->LocateHandleBuffer (
1521 &gEfiDevicePathProtocolGuid
,
1526 ASSERT_EFI_ERROR (Status
);
1528 TempTable
= AllocateZeroPool ((HandleNum
+ 1) * sizeof (EFI_DEVICE_PATH_PROTOCOL
*));
1529 if (TempTable
== NULL
) {
1530 return EFI_OUT_OF_RESOURCES
;
1533 for (HandleLoop
= 0; HandleLoop
< HandleNum
; HandleLoop
++) {
1534 DevicePath
= DevicePathFromHandle (HandleBuffer
[HandleLoop
]);
1535 if (DevicePath
== NULL
) {
1539 HIDevicePath
= GetHIDevicePath (DevicePath
);
1540 if (HIDevicePath
== NULL
) {
1544 Status
= gBS
->HandleProtocol (
1545 HandleBuffer
[HandleLoop
],
1546 &gEfiBlockIoProtocolGuid
,
1549 if (EFI_ERROR (Status
)) {
1550 Status
= gBS
->HandleProtocol (
1551 HandleBuffer
[HandleLoop
],
1552 &gEfiSimpleFileSystemProtocolGuid
,
1553 (VOID
**)&SimpleFileSystem
1555 if (EFI_ERROR (Status
)) {
1556 FreePool (HIDevicePath
);
1561 for (Index
= 0; TempTable
[Index
] != NULL
; Index
++) {
1562 if (DevicePathCompare (&TempTable
[Index
], &HIDevicePath
) == 0) {
1563 FreePool (HIDevicePath
);
1568 if (TempTable
[Index
] == NULL
) {
1569 TempTable
[Index
] = HIDevicePath
;
1573 for (Index
= 0; TempTable
[Index
] != NULL
; Index
++) {
1576 PerformQuickSort (TempTable
, Index
, sizeof (EFI_DEVICE_PATH_PROTOCOL
*), DevicePathCompare
);
1579 if (HandleBuffer
!= NULL
) {
1580 FreePool (HandleBuffer
);
1587 Function to uninitialize the table for creating consistent map names.
1589 The parameter must have been received from ShellCommandConsistMappingInitialize.
1591 @param[out] Table The pointer to pointer to DevicePathProtocol object.
1593 @retval EFI_SUCCESS The table was deleted successfully.
1597 ShellCommandConsistMappingUnInitialize (
1598 EFI_DEVICE_PATH_PROTOCOL
**Table
1603 ASSERT (Table
!= NULL
);
1605 for (Index
= 0; Table
[Index
] != NULL
; Index
++) {
1606 FreePool (Table
[Index
]);
1614 Create a consistent mapped name for the device specified by DevicePath
1617 This must be called after ShellCommandConsistMappingInitialize() and
1618 before ShellCommandConsistMappingUnInitialize() is called.
1620 @param[in] DevicePath The pointer to the dev path for the device.
1621 @param[in] Table The Table of mapping information.
1623 @retval NULL A consistent mapped name could not be created.
1624 @return A pointer to a string allocated from pool with the device name.
1628 ShellCommandConsistMappingGenMappingName (
1629 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1630 IN EFI_DEVICE_PATH_PROTOCOL
**Table
1635 DEVICE_CONSIST_MAPPING_INFO MappingInfo
;
1636 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1639 ASSERT (DevicePath
!= NULL
);
1640 ASSERT (Table
!= NULL
);
1642 HIDevicePath
= GetHIDevicePath (DevicePath
);
1643 if (HIDevicePath
== NULL
) {
1647 for (Index
= 0; Table
[Index
] != NULL
; Index
++) {
1648 if (DevicePathCompare (&Table
[Index
], &HIDevicePath
) == 0) {
1653 FreePool (HIDevicePath
);
1654 if (Table
[Index
] == NULL
) {
1658 MappingInfo
.Hi
= Index
;
1659 MappingInfo
.Mtd
= MTDTypeUnknown
;
1660 MappingInfo
.Digital
= FALSE
;
1662 Status
= GetDeviceConsistMappingInfo (&MappingInfo
, DevicePath
);
1663 if (EFI_ERROR (Status
)) {
1667 SetMem (&Str
, sizeof (Str
), 0);
1668 for (Index
= 0; mMTDName
[Index
].MTDType
!= MTDTypeEnd
; Index
++) {
1669 if (MappingInfo
.Mtd
== mMTDName
[Index
].MTDType
) {
1674 if (mMTDName
[Index
].MTDType
!= MTDTypeEnd
) {
1675 Status
= CatPrint (&Str
, L
"%s", mMTDName
[Index
].Name
);
1678 if (!EFI_ERROR (Status
)) {
1679 Status
= CatPrint (&Str
, L
"%d", (UINTN
)MappingInfo
.Hi
);
1682 if (!EFI_ERROR (Status
) && (MappingInfo
.Csd
.Str
!= NULL
)) {
1683 Status
= CatPrint (&Str
, L
"%s", MappingInfo
.Csd
.Str
);
1684 FreePool (MappingInfo
.Csd
.Str
);
1687 if (!EFI_ERROR (Status
) && (Str
.Str
!= NULL
)) {
1688 Status
= CatPrint (&Str
, L
":");
1691 if (EFI_ERROR (Status
)) {
1692 SHELL_FREE_NON_NULL (Str
.Str
);
1700 Function to search the list of mappings for the node on the list based on the key.
1702 @param[in] MapKey String Key to search for on the map
1704 @return the node on the list.
1708 ShellCommandFindMapItem (
1709 IN CONST CHAR16
*MapKey
1712 SHELL_MAP_LIST
*MapListItem
;
1714 for ( MapListItem
= (SHELL_MAP_LIST
*)GetFirstNode (&gShellMapList
.Link
)
1715 ; !IsNull (&gShellMapList
.Link
, &MapListItem
->Link
)
1716 ; MapListItem
= (SHELL_MAP_LIST
*)GetNextNode (&gShellMapList
.Link
, &MapListItem
->Link
)
1719 if (gUnicodeCollation
->StriColl (gUnicodeCollation
, MapListItem
->MapName
, (CHAR16
*)MapKey
) == 0) {
1720 return (MapListItem
);