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>
36 } DEVICE_CONSIST_MAPPING_INFO
;
44 Serial Decode function.
46 @param DevPath The Device path info.
47 @param MapInfo The map info.
48 @param OrigDevPath The original device path protocol.
50 @retval EFI_OUT_OF_RESOURCES Out of resources.
51 @retval EFI_SUCCESS The appending was successful.
55 (*SERIAL_DECODE_FUNCTION
) (
56 EFI_DEVICE_PATH_PROTOCOL
*DevPath
,
57 DEVICE_CONSIST_MAPPING_INFO
*MapInfo
,
58 EFI_DEVICE_PATH_PROTOCOL
*OrigDevPath
64 SERIAL_DECODE_FUNCTION SerialFun
;
65 INTN (EFIAPI
*CompareFun
) (EFI_DEVICE_PATH_PROTOCOL
*DevPath
, EFI_DEVICE_PATH_PROTOCOL
*DevPath2
);
66 } DEV_PATH_CONSIST_MAPPING_TABLE
;
70 Concatenates a formatted unicode string to allocated pool.
71 The caller must free the resulting buffer.
73 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.
74 @param Fmt The format string
75 @param ... The data will be printed.
77 @retval EFI_SUCCESS The string is concatenated successfully.
78 @retval EFI_OUT_OF_RESOURCES Out of resources.
84 IN OUT POOL_PRINT
*Str
,
94 AppendStr
= AllocateZeroPool (0x1000);
95 if (AppendStr
== NULL
) {
96 return EFI_OUT_OF_RESOURCES
;
100 UnicodeVSPrint (AppendStr
, 0x1000, Fmt
, Args
);
102 if (NULL
== Str
->Str
) {
103 StringSize
= StrSize (AppendStr
);
104 NewStr
= AllocateZeroPool (StringSize
);
106 StringSize
= StrSize (AppendStr
);
107 StringSize
+= (StrSize (Str
->Str
) - sizeof (UINT16
));
109 NewStr
= ReallocatePool (
115 if (NewStr
== NULL
) {
116 FreePool (AppendStr
);
117 return EFI_OUT_OF_RESOURCES
;
121 StrCatS (Str
->Str
, StringSize
/sizeof(CHAR16
), AppendStr
);
122 Str
->Len
= StringSize
;
124 FreePool (AppendStr
);
128 MTD_NAME mMTDName
[] = {
152 Function to append a 64 bit number / 25 onto the string.
154 @param[in, out] Str The string so append onto.
155 @param[in] Num The number to divide and append.
157 @retval EFI_OUT_OF_RESOURCES Out of resources.
158 @retval EFI_SUCCESS The appending was successful.
162 IN OUT POOL_PRINT
*Str
,
170 ASSERT (Str
!= NULL
);
172 Result
= DivU64x32Remainder (Num
, 25, &Rem
);
174 Status
= AppendCSDNum2 (Str
, Result
);
175 if (EFI_ERROR (Status
)) {
180 return CatPrint (Str
, L
"%c", Rem
+ 'a');
184 Function to append a 64 bit number onto the mapping info.
186 @param[in, out] MappingItem The mapping info object to append onto.
187 @param[in] Num The info to append.
189 @retval EFI_OUT_OF_RESOURCES Out of resources.
190 @retval EFI_SUCCESS The appending was successful.
195 IN OUT DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
200 ASSERT (MappingItem
!= NULL
);
202 if (MappingItem
->Digital
) {
203 Status
= CatPrint (&MappingItem
->Csd
, L
"%ld", Num
);
205 Status
= AppendCSDNum2 (&MappingItem
->Csd
, Num
);
208 if (!EFI_ERROR (Status
)) {
209 MappingItem
->Digital
= (BOOLEAN
) !(MappingItem
->Digital
);
216 Function to append string into the mapping info.
218 @param[in, out] MappingItem The mapping info object to append onto.
219 @param[in] Str The info to append.
221 @retval EFI_OUT_OF_RESOURCES Out of resources.
222 @retval EFI_SUCCESS The appending was successful.
226 IN OUT DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
233 ASSERT (Str
!= NULL
&& MappingItem
!= NULL
);
235 Status
= EFI_SUCCESS
;
237 if (MappingItem
->Digital
) {
239 // To aVOID mult-meaning, the mapping is:
240 // 0 1 2 3 4 5 6 7 8 9 a b c d e f
241 // 0 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15
243 for (Index
= Str
; *Index
!= 0; Index
++) {
254 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
);
258 Status
= CatPrint (&MappingItem
->Csd
, L
"16");
267 Status
= CatPrint (&MappingItem
->Csd
, L
"1%c", *Index
- 'a' + '0');
276 Status
= CatPrint (&MappingItem
->Csd
, L
"1%c", *Index
- 'A' + '0');
280 if (EFI_ERROR (Status
)) {
285 for (Index
= Str
; *Index
!= 0; Index
++) {
288 // 0 1 2 3 4 5 6 7 8 9 a b c d e f
289 // a b c d e f g h i j k l m n o p
291 if (*Index
>= '0' && *Index
<= '9') {
292 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- '0' + 'a');
293 } else if (*Index
>= 'a' && *Index
<= 'f') {
294 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- 'a' + 'k');
295 } else if (*Index
>= 'A' && *Index
<= 'F') {
296 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- 'A' + 'k');
299 if (EFI_ERROR (Status
)) {
305 MappingItem
->Digital
= (BOOLEAN
)!(MappingItem
->Digital
);
307 return (EFI_SUCCESS
);
311 Function to append a Guid to the mapping item.
313 @param[in, out] MappingItem The item to append onto.
314 @param[in] Guid The guid to append.
316 @retval EFI_OUT_OF_RESOURCES Out of resources.
317 @retval EFI_SUCCESS The appending was successful.
321 DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
327 ASSERT (Guid
!= NULL
&& MappingItem
!= NULL
);
336 return AppendCSDStr (MappingItem
, Buffer
);
340 Function to compare 2 APCI device paths.
342 @param[in] DevicePath1 The first device path to compare.
343 @param[in] DevicePath2 The second device path to compare.
345 @retval 0 The device paths represent the same device.
346 @return Non zero if the devices are different, zero otherwise.
351 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
352 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
355 ACPI_HID_DEVICE_PATH
*Acpi1
;
356 ACPI_HID_DEVICE_PATH
*Acpi2
;
358 if (DevicePath1
== NULL
|| DevicePath2
== NULL
) {
362 Acpi1
= (ACPI_HID_DEVICE_PATH
*) DevicePath1
;
363 Acpi2
= (ACPI_HID_DEVICE_PATH
*) DevicePath2
;
364 if (Acpi1
->HID
> Acpi2
->HID
|| (Acpi1
->HID
== Acpi2
->HID
&& Acpi1
->UID
> Acpi2
->UID
)) {
368 if (Acpi1
->HID
== Acpi2
->HID
&& Acpi1
->UID
== Acpi2
->UID
) {
376 Function to compare 2 PCI device paths.
378 @param[in] DevicePath1 The first device path to compare.
379 @param[in] DevicePath2 The second device path to compare.
381 @retval 0 The device paths represent the same device.
382 @return Non zero if the devices are different, zero otherwise.
387 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
388 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
391 PCI_DEVICE_PATH
*Pci1
;
392 PCI_DEVICE_PATH
*Pci2
;
394 ASSERT(DevicePath1
!= NULL
);
395 ASSERT(DevicePath2
!= NULL
);
397 Pci1
= (PCI_DEVICE_PATH
*) DevicePath1
;
398 Pci2
= (PCI_DEVICE_PATH
*) DevicePath2
;
399 if (Pci1
->Device
> Pci2
->Device
|| (Pci1
->Device
== Pci2
->Device
&& Pci1
->Function
> Pci2
->Function
)) {
403 if (Pci1
->Device
== Pci2
->Device
&& Pci1
->Function
== Pci2
->Function
) {
411 Do a comparison on 2 device paths.
413 @param[in] DevicePath1 The first device path.
414 @param[in] DevicePath2 The second device path.
416 @retval 0 The 2 device paths are the same.
417 @retval <0 DevicePath2 is greater than DevicePath1.
418 @retval >0 DevicePath1 is greater than DevicePath2.
422 DevPathCompareDefault (
423 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
424 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
430 ASSERT(DevicePath1
!= NULL
);
431 ASSERT(DevicePath2
!= NULL
);
433 DevPathSize1
= DevicePathNodeLength (DevicePath1
);
434 DevPathSize2
= DevicePathNodeLength (DevicePath2
);
435 if (DevPathSize1
> DevPathSize2
) {
437 } else if (DevPathSize1
< DevPathSize2
) {
440 return CompareMem (DevicePath1
, DevicePath2
, DevPathSize1
);
445 DevicePathNode must be SerialHDD Channel type and this will populate the MappingItem.
447 @param[in] DevicePathNode The node to get info on.
448 @param[in] MappingItem The info item to populate.
449 @param[in] DevicePath Ignored.
451 @retval EFI_OUT_OF_RESOURCES Out of resources.
452 @retval EFI_SUCCESS The appending was successful.
455 DevPathSerialHardDrive (
456 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
457 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
458 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
461 HARDDRIVE_DEVICE_PATH
*Hd
;
463 ASSERT(DevicePathNode
!= NULL
);
464 ASSERT(MappingItem
!= NULL
);
466 Hd
= (HARDDRIVE_DEVICE_PATH
*) DevicePathNode
;
467 if (MappingItem
->Mtd
== MTDTypeUnknown
) {
468 MappingItem
->Mtd
= MTDTypeHardDisk
;
471 return AppendCSDNum (MappingItem
, Hd
->PartitionNumber
);
475 DevicePathNode must be SerialAtapi Channel type and this will populate the MappingItem.
477 @param[in] DevicePathNode The node to get info on.
478 @param[in] MappingItem The info item to populate.
479 @param[in] DevicePath Ignored.
481 @retval EFI_OUT_OF_RESOURCES Out of resources.
482 @retval EFI_SUCCESS The appending was successful.
486 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
487 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
488 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
491 ATAPI_DEVICE_PATH
*Atapi
;
493 ASSERT(DevicePathNode
!= NULL
);
494 ASSERT(MappingItem
!= NULL
);
496 Atapi
= (ATAPI_DEVICE_PATH
*) DevicePathNode
;
497 return AppendCSDNum (MappingItem
, (Atapi
->PrimarySecondary
* 2 + Atapi
->SlaveMaster
));
501 DevicePathNode must be SerialCDROM Channel type and this will populate the MappingItem.
503 @param[in] DevicePathNode The node to get info on.
504 @param[in] MappingItem The info item to populate.
505 @param[in] DevicePath Ignored.
507 @retval EFI_OUT_OF_RESOURCES Out of resources.
508 @retval EFI_SUCCESS The appending was successful.
512 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
513 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
514 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
517 CDROM_DEVICE_PATH
*Cd
;
519 ASSERT(DevicePathNode
!= NULL
);
520 ASSERT(MappingItem
!= NULL
);
522 Cd
= (CDROM_DEVICE_PATH
*) DevicePathNode
;
523 MappingItem
->Mtd
= MTDTypeCDRom
;
524 return AppendCSDNum (MappingItem
, Cd
->BootEntry
);
528 DevicePathNode must be SerialFibre Channel type and this will populate the MappingItem.
530 @param[in] DevicePathNode The node to get info on.
531 @param[in] MappingItem The info item to populate.
532 @param[in] DevicePath Ignored.
534 @retval EFI_OUT_OF_RESOURCES Out of resources.
535 @retval EFI_SUCCESS The appending was successful.
539 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
540 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
541 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
545 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
547 ASSERT(DevicePathNode
!= NULL
);
548 ASSERT(MappingItem
!= NULL
);
550 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) DevicePathNode
;
551 Status
= AppendCSDNum (MappingItem
, Fibre
->WWN
);
552 if (!EFI_ERROR (Status
)) {
553 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
);
586 if (!EFI_ERROR (Status
)) {
587 Status
= AppendCSDNum (MappingItem
, Uart
->Parity
);
589 if (!EFI_ERROR (Status
)) {
590 Status
= AppendCSDNum (MappingItem
, Uart
->StopBits
);
596 DevicePathNode must be SerialUSB type and this will populate the MappingItem.
598 @param[in] DevicePathNode The node to get info on.
599 @param[in] MappingItem The info item to populate.
600 @param[in] DevicePath Ignored.
602 @retval EFI_OUT_OF_RESOURCES Out of resources.
603 @retval EFI_SUCCESS The appending was successful.
607 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
608 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
609 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
612 USB_DEVICE_PATH
*Usb
;
613 EFI_USB_IO_PROTOCOL
*UsbIo
;
614 EFI_HANDLE TempHandle
;
616 USB_INTERFACE_DESCRIPTOR InterfaceDesc
;
619 ASSERT(DevicePathNode
!= NULL
);
620 ASSERT(MappingItem
!= NULL
);
622 Usb
= (USB_DEVICE_PATH
*) DevicePathNode
;
623 Status
= AppendCSDNum (MappingItem
, Usb
->ParentPortNumber
);
624 if (!EFI_ERROR (Status
)) {
625 Status
= AppendCSDNum (MappingItem
, Usb
->InterfaceNumber
);
628 if (EFI_ERROR (Status
)) {
632 if (PcdGetBool(PcdUsbExtendedDecode
)) {
633 Status
= gBS
->LocateDevicePath( &gEfiUsbIoProtocolGuid
, &DevicePath
, &TempHandle
);
635 if (!EFI_ERROR(Status
)) {
636 Status
= gBS
->OpenProtocol(TempHandle
, &gEfiUsbIoProtocolGuid
, (VOID
**)&UsbIo
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
639 if (!EFI_ERROR(Status
)) {
640 ASSERT(UsbIo
!= NULL
);
641 Status
= UsbIo
->UsbGetInterfaceDescriptor(UsbIo
, &InterfaceDesc
);
642 if (!EFI_ERROR(Status
)) {
643 if (InterfaceDesc
.InterfaceClass
== USB_MASS_STORE_CLASS
&& MappingItem
->Mtd
== MTDTypeUnknown
) {
644 switch (InterfaceDesc
.InterfaceSubClass
){
645 case USB_MASS_STORE_SCSI
:
646 MappingItem
->Mtd
= MTDTypeHardDisk
;
648 case USB_MASS_STORE_8070I
:
649 case USB_MASS_STORE_UFI
:
650 MappingItem
->Mtd
= MTDTypeFloppy
;
652 case USB_MASS_STORE_8020I
:
653 MappingItem
->Mtd
= MTDTypeCDRom
;
664 DevicePathNode must be SerialVendor type and this will populate the MappingItem.
666 @param[in] DevicePathNode The node to get info on.
667 @param[in] MappingItem The info item to populate.
668 @param[in] DevicePath Ignored.
670 @retval EFI_OUT_OF_RESOURCES Out of resources.
671 @retval EFI_SUCCESS The appending was successful.
674 DevPathSerialVendor (
675 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
676 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
677 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
681 VENDOR_DEVICE_PATH
*Vendor
;
682 SAS_DEVICE_PATH
*Sas
;
683 UINTN TargetNameLength
;
688 ASSERT(DevicePathNode
!= NULL
);
689 ASSERT(MappingItem
!= NULL
);
691 Vendor
= (VENDOR_DEVICE_PATH
*) DevicePathNode
;
692 Status
= AppendCSDGuid (MappingItem
, &Vendor
->Guid
);
693 if (EFI_ERROR (Status
)) {
697 if (CompareGuid (&gEfiSasDevicePathGuid
, &Vendor
->Guid
)) {
698 Sas
= (SAS_DEVICE_PATH
*) Vendor
;
699 Status
= AppendCSDNum (MappingItem
, Sas
->SasAddress
);
700 if (!EFI_ERROR (Status
)) {
701 Status
= AppendCSDNum (MappingItem
, Sas
->Lun
);
703 if (!EFI_ERROR (Status
)) {
704 Status
= AppendCSDNum (MappingItem
, Sas
->DeviceTopology
);
706 if (!EFI_ERROR (Status
)) {
707 Status
= AppendCSDNum (MappingItem
, Sas
->RelativeTargetPort
);
710 TargetNameLength
= MIN(DevicePathNodeLength (DevicePathNode
) - sizeof (VENDOR_DEVICE_PATH
), PcdGet32(PcdShellVendorExtendedDecode
));
711 if (TargetNameLength
!= 0) {
713 // String is 2 chars per data byte, plus NULL terminator
715 Buffer
= AllocateZeroPool (((TargetNameLength
* 2) + 1) * sizeof(CHAR16
));
716 if (Buffer
== NULL
) {
717 return EFI_OUT_OF_RESOURCES
;
721 // Build the string data
723 for (Index
= 0; Index
< TargetNameLength
; Index
++) {
724 NewBuffer
= CatSPrint (Buffer
, L
"%02x", *((UINT8
*)Vendor
+ sizeof (VENDOR_DEVICE_PATH
) + Index
));
725 if (NewBuffer
== NULL
) {
726 Status
= EFI_OUT_OF_RESOURCES
;
733 // Append the new data block
735 if (!EFI_ERROR (Status
)) {
736 Status
= AppendCSDStr (MappingItem
, Buffer
);
746 DevicePathNode must be SerialLun type and this will populate the MappingItem.
748 @param[in] DevicePathNode The node to get info on.
749 @param[in] MappingItem The info item to populate.
750 @param[in] DevicePath Ignored.
752 @retval EFI_OUT_OF_RESOURCES Out of resources.
753 @retval EFI_SUCCESS The appending was successful.
757 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
758 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
759 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
762 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*Lun
;
764 ASSERT(DevicePathNode
!= NULL
);
765 ASSERT(MappingItem
!= NULL
);
767 Lun
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) DevicePathNode
;
768 return AppendCSDNum (MappingItem
, Lun
->Lun
);
772 DevicePathNode must be SerialSata type and this will populate the MappingItem.
774 @param[in] DevicePathNode The node to get info on.
775 @param[in] MappingItem The info item to populate.
776 @param[in] DevicePath Ignored.
778 @retval EFI_OUT_OF_RESOURCES Out of resources.
779 @retval EFI_SUCCESS The appending was successful.
783 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
784 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
785 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
789 SATA_DEVICE_PATH
*Sata
;
791 ASSERT(DevicePathNode
!= NULL
);
792 ASSERT(MappingItem
!= NULL
);
794 Sata
= (SATA_DEVICE_PATH
*) DevicePathNode
;
795 Status
= AppendCSDNum (MappingItem
, Sata
->HBAPortNumber
);
796 if (!EFI_ERROR (Status
)) {
797 Status
= AppendCSDNum (MappingItem
, Sata
->PortMultiplierPortNumber
);
799 if (!EFI_ERROR (Status
)) {
800 Status
= AppendCSDNum (MappingItem
, Sata
->Lun
);
806 DevicePathNode must be SerialSCSI type and this will populate the MappingItem.
808 @param[in] DevicePathNode The node to get info on.
809 @param[in] MappingItem The info item to populate.
810 @param[in] DevicePath Ignored.
812 @retval EFI_OUT_OF_RESOURCES Out of resources.
813 @retval EFI_SUCCESS The appending was successful.
817 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
818 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
819 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
823 ISCSI_DEVICE_PATH
*IScsi
;
824 UINT8
*IScsiTargetName
;
826 UINTN TargetNameLength
;
829 ASSERT(DevicePathNode
!= NULL
);
830 ASSERT(MappingItem
!= NULL
);
832 Status
= EFI_SUCCESS
;
834 if (PcdGetBool(PcdShellDecodeIScsiMapNames
)) {
835 IScsi
= (ISCSI_DEVICE_PATH
*) DevicePathNode
;
836 Status
= AppendCSDNum (MappingItem
, IScsi
->NetworkProtocol
);
837 if (!EFI_ERROR (Status
)) {
838 Status
= AppendCSDNum (MappingItem
, IScsi
->LoginOption
);
840 if (!EFI_ERROR (Status
)) {
841 Status
= AppendCSDNum (MappingItem
, IScsi
->Lun
);
843 if (!EFI_ERROR (Status
)) {
844 Status
= AppendCSDNum (MappingItem
, IScsi
->TargetPortalGroupTag
);
846 if (EFI_ERROR (Status
)) {
849 TargetNameLength
= DevicePathNodeLength (DevicePathNode
) - sizeof (ISCSI_DEVICE_PATH
);
850 if (TargetNameLength
> 0) {
851 TargetName
= AllocateZeroPool ((TargetNameLength
+ 1) * sizeof (CHAR16
));
852 if (TargetName
== NULL
) {
853 Status
= EFI_OUT_OF_RESOURCES
;
855 IScsiTargetName
= (UINT8
*) (IScsi
+ 1);
856 for (Index
= 0; Index
< TargetNameLength
; Index
++) {
857 TargetName
[Index
] = (CHAR16
) IScsiTargetName
[Index
];
859 Status
= AppendCSDStr (MappingItem
, TargetName
);
860 FreePool (TargetName
);
868 DevicePathNode must be SerialI20 type and this will populate the MappingItem.
870 @param[in] DevicePathNode The node to get info on.
871 @param[in] MappingItem The info item to populate.
872 @param[in] DevicePath Ignored.
874 @retval EFI_OUT_OF_RESOURCES Out of resources.
875 @retval EFI_SUCCESS The appending was successful.
879 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
880 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
881 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
884 I2O_DEVICE_PATH
*DevicePath_I20
;
886 ASSERT(DevicePathNode
!= NULL
);
887 ASSERT(MappingItem
!= NULL
);
889 DevicePath_I20
= (I2O_DEVICE_PATH
*) DevicePathNode
;
890 return AppendCSDNum (MappingItem
, DevicePath_I20
->Tid
);
894 DevicePathNode must be Mac Address type and this will populate the MappingItem.
896 @param[in] DevicePathNode The node to get info on.
897 @param[in] MappingItem The info item to populate.
898 @param[in] DevicePath Ignored.
900 @retval EFI_OUT_OF_RESOURCES Out of resources.
901 @retval EFI_SUCCESS The appending was successful.
904 DevPathSerialMacAddr (
905 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
906 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
907 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
910 MAC_ADDR_DEVICE_PATH
*Mac
;
916 ASSERT(DevicePathNode
!= NULL
);
917 ASSERT(MappingItem
!= NULL
);
919 Mac
= (MAC_ADDR_DEVICE_PATH
*) DevicePathNode
;
921 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
922 if (Mac
->IfType
== 0x01 || Mac
->IfType
== 0x00) {
926 for (Index
= 0, PBuffer
= Buffer
; Index
< HwAddressSize
; Index
++, PBuffer
+= 2) {
927 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) Mac
->MacAddress
.Addr
[Index
]);
930 return AppendCSDStr (MappingItem
, Buffer
);
934 DevicePathNode must be InfiniBand type and this will populate the MappingItem.
936 @param[in] DevicePathNode The node to get info on.
937 @param[in] MappingItem The info item to populate.
938 @param[in] DevicePath Ignored.
940 @retval EFI_OUT_OF_RESOURCES Out of resources.
941 @retval EFI_SUCCESS The appending was successful.
944 DevPathSerialInfiniBand (
945 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
946 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
947 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
951 INFINIBAND_DEVICE_PATH
*InfiniBand
;
956 ASSERT(DevicePathNode
!= NULL
);
957 ASSERT(MappingItem
!= NULL
);
959 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) DevicePathNode
;
960 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
961 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) InfiniBand
->PortGid
[Index
]);
964 Status
= AppendCSDStr (MappingItem
, Buffer
);
965 if (!EFI_ERROR (Status
)) {
966 Status
= AppendCSDNum (MappingItem
, InfiniBand
->ServiceId
);
968 if (!EFI_ERROR (Status
)) {
969 Status
= AppendCSDNum (MappingItem
, InfiniBand
->TargetPortId
);
971 if (!EFI_ERROR (Status
)) {
972 Status
= AppendCSDNum (MappingItem
, InfiniBand
->DeviceId
);
978 DevicePathNode must be IPv4 type and this will populate the MappingItem.
980 @param[in] DevicePathNode The node to get info on.
981 @param[in] MappingItem The info item to populate.
982 @param[in] DevicePath Ignored.
984 @retval EFI_OUT_OF_RESOURCES Out of resources.
985 @retval EFI_SUCCESS The appending was successful.
989 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
990 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
991 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
995 IPv4_DEVICE_PATH
*Ip
;
998 ASSERT(DevicePathNode
!= NULL
);
999 ASSERT(MappingItem
!= NULL
);
1001 Ip
= (IPv4_DEVICE_PATH
*) DevicePathNode
;
1005 L
"%02x%02x%02x%02x",
1006 (UINTN
) Ip
->LocalIpAddress
.Addr
[0],
1007 (UINTN
) Ip
->LocalIpAddress
.Addr
[1],
1008 (UINTN
) Ip
->LocalIpAddress
.Addr
[2],
1009 (UINTN
) Ip
->LocalIpAddress
.Addr
[3]
1011 Status
= AppendCSDStr (MappingItem
, Buffer
);
1012 if (!EFI_ERROR (Status
)) {
1013 Status
= AppendCSDNum (MappingItem
, Ip
->LocalPort
);
1015 if (!EFI_ERROR (Status
)) {
1019 L
"%02x%02x%02x%02x",
1020 (UINTN
) Ip
->RemoteIpAddress
.Addr
[0],
1021 (UINTN
) Ip
->RemoteIpAddress
.Addr
[1],
1022 (UINTN
) Ip
->RemoteIpAddress
.Addr
[2],
1023 (UINTN
) Ip
->RemoteIpAddress
.Addr
[3]
1025 Status
= AppendCSDStr (MappingItem
, Buffer
);
1027 if (!EFI_ERROR (Status
)) {
1028 Status
= AppendCSDNum (MappingItem
, Ip
->RemotePort
);
1034 DevicePathNode must be IPv6 type and this will populate the MappingItem.
1036 @param[in] DevicePathNode The node to get info on.
1037 @param[in] MappingItem The info item to populate.
1038 @param[in] DevicePath Ignored.
1040 @retval EFI_OUT_OF_RESOURCES Out of resources.
1041 @retval EFI_SUCCESS The appending was successful.
1045 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1046 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1047 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1051 IPv6_DEVICE_PATH
*Ip
;
1056 ASSERT(DevicePathNode
!= NULL
);
1057 ASSERT(MappingItem
!= NULL
);
1059 Ip
= (IPv6_DEVICE_PATH
*) DevicePathNode
;
1060 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
1061 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) Ip
->LocalIpAddress
.Addr
[Index
]);
1064 Status
= AppendCSDStr (MappingItem
, Buffer
);
1065 if (!EFI_ERROR (Status
)) {
1066 Status
= AppendCSDNum (MappingItem
, Ip
->LocalPort
);
1068 if (!EFI_ERROR (Status
)) {
1069 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
1070 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) Ip
->RemoteIpAddress
.Addr
[Index
]);
1073 Status
= AppendCSDStr (MappingItem
, Buffer
);
1075 if (!EFI_ERROR (Status
)) {
1076 Status
= AppendCSDNum (MappingItem
, Ip
->RemotePort
);
1082 DevicePathNode must be SCSI type and this will populate the MappingItem.
1084 @param[in] DevicePathNode The node to get info on.
1085 @param[in] MappingItem The info item to populate.
1086 @param[in] DevicePath Ignored.
1088 @retval EFI_OUT_OF_RESOURCES Out of resources.
1089 @retval EFI_SUCCESS The appending was successful.
1093 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1094 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1095 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1099 SCSI_DEVICE_PATH
*Scsi
;
1101 ASSERT(DevicePathNode
!= NULL
);
1102 ASSERT(MappingItem
!= NULL
);
1104 Scsi
= (SCSI_DEVICE_PATH
*) DevicePathNode
;
1105 Status
= AppendCSDNum (MappingItem
, Scsi
->Pun
);
1106 if (!EFI_ERROR (Status
)) {
1107 Status
= AppendCSDNum (MappingItem
, Scsi
->Lun
);
1113 DevicePathNode must be 1394 type and this will populate the MappingItem.
1115 @param[in] DevicePathNode The node to get info on.
1116 @param[in] MappingItem The info item to populate.
1117 @param[in] DevicePath Ignored.
1119 @retval EFI_OUT_OF_RESOURCES Out of resources.
1120 @retval EFI_SUCCESS The appending was successful.
1124 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1125 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1126 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1129 F1394_DEVICE_PATH
*DevicePath_F1394
;
1132 ASSERT(DevicePathNode
!= NULL
);
1133 ASSERT(MappingItem
!= NULL
);
1135 DevicePath_F1394
= (F1394_DEVICE_PATH
*) DevicePathNode
;
1136 UnicodeSPrint (Buffer
, 0, L
"%lx", DevicePath_F1394
->Guid
);
1137 return AppendCSDStr (MappingItem
, Buffer
);
1141 If the node is floppy type then populate the MappingItem.
1143 @param[in] DevicePathNode The node to get info on.
1144 @param[in] MappingItem The info item to populate.
1145 @param[in] DevicePath Ignored.
1147 @retval EFI_OUT_OF_RESOURCES Out of resources.
1148 @retval EFI_SUCCESS The appending was successful.
1152 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1153 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1154 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1157 ACPI_HID_DEVICE_PATH
*Acpi
;
1159 ASSERT(DevicePathNode
!= NULL
);
1160 ASSERT(MappingItem
!= NULL
);
1162 Acpi
= (ACPI_HID_DEVICE_PATH
*) DevicePathNode
;
1163 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
1164 if (EISA_ID_TO_NUM (Acpi
->HID
) == 0x0604) {
1165 MappingItem
->Mtd
= MTDTypeFloppy
;
1166 return AppendCSDNum (MappingItem
, Acpi
->UID
);
1173 Empty function used for unknown devices.
1175 @param[in] DevicePathNode Ignored.
1176 @param[in] MappingItem Ignored.
1177 @param[in] DevicePath Ignored.
1179 @retval EFI_OUT_OF_RESOURCES Out of resources.
1180 @retval EFI_SUCCESS The appending was successful.
1183 DevPathSerialDefault (
1184 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1185 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1186 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1192 DEV_PATH_CONSIST_MAPPING_TABLE DevPathConsistMappingTable
[] = {
1194 HARDWARE_DEVICE_PATH
,
1196 DevPathSerialDefault
,
1206 MESSAGING_DEVICE_PATH
,
1209 DevPathCompareDefault
1212 MESSAGING_DEVICE_PATH
,
1215 DevPathCompareDefault
1218 MESSAGING_DEVICE_PATH
,
1219 MSG_FIBRECHANNEL_DP
,
1221 DevPathCompareDefault
1224 MESSAGING_DEVICE_PATH
,
1227 DevPathCompareDefault
1230 MESSAGING_DEVICE_PATH
,
1233 DevPathCompareDefault
1236 MESSAGING_DEVICE_PATH
,
1239 DevPathCompareDefault
1242 MESSAGING_DEVICE_PATH
,
1244 DevPathSerialMacAddr
,
1245 DevPathCompareDefault
1248 MESSAGING_DEVICE_PATH
,
1251 DevPathCompareDefault
1254 MESSAGING_DEVICE_PATH
,
1257 DevPathCompareDefault
1260 MESSAGING_DEVICE_PATH
,
1262 DevPathSerialInfiniBand
,
1263 DevPathCompareDefault
1266 MESSAGING_DEVICE_PATH
,
1269 DevPathCompareDefault
1272 MESSAGING_DEVICE_PATH
,
1274 DevPathSerialVendor
,
1275 DevPathCompareDefault
1278 MESSAGING_DEVICE_PATH
,
1279 MSG_DEVICE_LOGICAL_UNIT_DP
,
1281 DevPathCompareDefault
1284 MESSAGING_DEVICE_PATH
,
1287 DevPathCompareDefault
1290 MESSAGING_DEVICE_PATH
,
1293 DevPathCompareDefault
1298 DevPathSerialHardDrive
,
1299 DevPathCompareDefault
1305 DevPathCompareDefault
1310 DevPathSerialVendor
,
1311 DevPathCompareDefault
1322 Function to determine if a device path node is Hi or not.
1324 @param[in] DevicePathNode The node to check.
1326 @retval TRUE The node is Hi.
1327 @retval FALSE The node is not Hi.
1330 IsHIDevicePathNode (
1331 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
1334 ACPI_HID_DEVICE_PATH
*Acpi
;
1336 ASSERT(DevicePathNode
!= NULL
);
1338 if (DevicePathNode
->Type
== HARDWARE_DEVICE_PATH
) {
1342 if (DevicePathNode
->Type
== ACPI_DEVICE_PATH
) {
1343 Acpi
= (ACPI_HID_DEVICE_PATH
*) DevicePathNode
;
1344 switch (EISA_ID_TO_NUM (Acpi
->HID
)) {
1359 Function to convert a standard device path structure into a Hi version.
1361 @param[in] DevicePath The device path to convert.
1363 @return the device path portion that is Hi.
1365 EFI_DEVICE_PATH_PROTOCOL
*
1367 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1370 UINTN NonHIDevicePathNodeCount
;
1373 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1374 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
1376 ASSERT(DevicePath
!= NULL
);
1378 NonHIDevicePathNodeCount
= 0;
1380 HIDevicePath
= AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL
));
1381 SetDevicePathEndNode (HIDevicePath
);
1383 Node
.DevPath
.Type
= END_DEVICE_PATH_TYPE
;
1384 Node
.DevPath
.SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
1385 Node
.DevPath
.Length
[0] = (UINT8
)sizeof (EFI_DEVICE_PATH_PROTOCOL
);
1386 Node
.DevPath
.Length
[1] = 0;
1388 while (!IsDevicePathEnd (DevicePath
)) {
1389 if (IsHIDevicePathNode (DevicePath
)) {
1390 for (Index
= 0; Index
< NonHIDevicePathNodeCount
; Index
++) {
1391 TempDevicePath
= AppendDevicePathNode (HIDevicePath
, &Node
.DevPath
);
1392 FreePool (HIDevicePath
);
1393 HIDevicePath
= TempDevicePath
;
1396 TempDevicePath
= AppendDevicePathNode (HIDevicePath
, DevicePath
);
1397 FreePool (HIDevicePath
);
1398 HIDevicePath
= TempDevicePath
;
1400 NonHIDevicePathNodeCount
++;
1403 // Next device path node
1405 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (DevicePath
);
1408 return HIDevicePath
;
1412 Function to walk the device path looking for a dumpable node.
1414 @param[in] MappingItem The Item to fill with data.
1415 @param[in] DevicePath The path of the item to get data on.
1417 @return EFI_SUCCESS Always returns success.
1420 GetDeviceConsistMappingInfo (
1421 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1422 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1426 SERIAL_DECODE_FUNCTION SerialFun
;
1428 EFI_DEVICE_PATH_PROTOCOL
*OriginalDevicePath
;
1430 ASSERT(DevicePath
!= NULL
);
1431 ASSERT(MappingItem
!= NULL
);
1433 SetMem (&MappingItem
->Csd
, sizeof (POOL_PRINT
), 0);
1434 OriginalDevicePath
= DevicePath
;
1436 while (!IsDevicePathEnd (DevicePath
)) {
1438 // Find the handler to dump this device path node and
1439 // initialize with generic function in case nothing is found
1441 for (SerialFun
= DevPathSerialDefault
, Index
= 0; DevPathConsistMappingTable
[Index
].SerialFun
!= NULL
; Index
+= 1) {
1443 if (DevicePathType (DevicePath
) == DevPathConsistMappingTable
[Index
].Type
&&
1444 DevicePathSubType (DevicePath
) == DevPathConsistMappingTable
[Index
].SubType
1446 SerialFun
= DevPathConsistMappingTable
[Index
].SerialFun
;
1451 Status
= SerialFun (DevicePath
, MappingItem
, OriginalDevicePath
);
1452 if (EFI_ERROR (Status
)) {
1453 SHELL_FREE_NON_NULL (MappingItem
->Csd
.Str
);
1458 // Next device path node
1460 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (DevicePath
);
1467 Function to initialize the table for creating consistent map names.
1469 @param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.
1471 @retval EFI_SUCCESS The table was created successfully.
1475 ShellCommandConsistMappingInitialize (
1476 OUT EFI_DEVICE_PATH_PROTOCOL
***Table
1479 EFI_HANDLE
*HandleBuffer
;
1482 EFI_DEVICE_PATH_PROTOCOL
**TempTable
;
1483 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
1484 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1485 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
1486 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
1490 HandleBuffer
= NULL
;
1492 Status
= gBS
->LocateHandleBuffer (
1494 &gEfiDevicePathProtocolGuid
,
1499 ASSERT_EFI_ERROR(Status
);
1501 TempTable
= AllocateZeroPool ((HandleNum
+ 1) * sizeof (EFI_DEVICE_PATH_PROTOCOL
*));
1502 if (TempTable
== NULL
) {
1503 return EFI_OUT_OF_RESOURCES
;
1506 for (HandleLoop
= 0 ; HandleLoop
< HandleNum
; HandleLoop
++) {
1507 DevicePath
= DevicePathFromHandle (HandleBuffer
[HandleLoop
]);
1508 if (DevicePath
== NULL
) {
1512 HIDevicePath
= GetHIDevicePath (DevicePath
);
1513 if (HIDevicePath
== NULL
) {
1517 Status
= gBS
->HandleProtocol( HandleBuffer
[HandleLoop
],
1518 &gEfiBlockIoProtocolGuid
,
1521 if (EFI_ERROR(Status
)) {
1522 Status
= gBS
->HandleProtocol( HandleBuffer
[HandleLoop
],
1523 &gEfiSimpleFileSystemProtocolGuid
,
1524 (VOID
**)&SimpleFileSystem
1526 if (EFI_ERROR(Status
)) {
1527 FreePool (HIDevicePath
);
1532 for (Index
= 0; TempTable
[Index
] != NULL
; Index
++) {
1533 if (DevicePathCompare (&TempTable
[Index
], &HIDevicePath
) == 0) {
1534 FreePool (HIDevicePath
);
1539 if (TempTable
[Index
] == NULL
) {
1540 TempTable
[Index
] = HIDevicePath
;
1544 for (Index
= 0; TempTable
[Index
] != NULL
; Index
++);
1545 PerformQuickSort(TempTable
, Index
, sizeof(EFI_DEVICE_PATH_PROTOCOL
*), DevicePathCompare
);
1548 if (HandleBuffer
!= NULL
) {
1549 FreePool (HandleBuffer
);
1556 Function to uninitialize the table for creating consistent map names.
1558 The parameter must have been received from ShellCommandConsistMappingInitialize.
1560 @param[out] Table The pointer to pointer to DevicePathProtocol object.
1562 @retval EFI_SUCCESS The table was deleted successfully.
1566 ShellCommandConsistMappingUnInitialize (
1567 EFI_DEVICE_PATH_PROTOCOL
**Table
1572 ASSERT(Table
!= NULL
);
1574 for (Index
= 0; Table
[Index
] != NULL
; Index
++) {
1575 FreePool (Table
[Index
]);
1583 Create a consistent mapped name for the device specified by DevicePath
1586 This must be called after ShellCommandConsistMappingInitialize() and
1587 before ShellCommandConsistMappingUnInitialize() is called.
1589 @param[in] DevicePath The pointer to the dev path for the device.
1590 @param[in] Table The Table of mapping information.
1592 @retval NULL A consistent mapped name could not be created.
1593 @return A pointer to a string allocated from pool with the device name.
1597 ShellCommandConsistMappingGenMappingName (
1598 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1599 IN EFI_DEVICE_PATH_PROTOCOL
**Table
1604 DEVICE_CONSIST_MAPPING_INFO MappingInfo
;
1605 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1608 ASSERT(DevicePath
!= NULL
);
1609 ASSERT(Table
!= NULL
);
1611 HIDevicePath
= GetHIDevicePath (DevicePath
);
1612 if (HIDevicePath
== NULL
) {
1616 for (Index
= 0; Table
[Index
] != NULL
; Index
++) {
1617 if (DevicePathCompare (&Table
[Index
], &HIDevicePath
) == 0) {
1622 FreePool (HIDevicePath
);
1623 if (Table
[Index
] == NULL
) {
1627 MappingInfo
.Hi
= Index
;
1628 MappingInfo
.Mtd
= MTDTypeUnknown
;
1629 MappingInfo
.Digital
= FALSE
;
1631 Status
= GetDeviceConsistMappingInfo (&MappingInfo
, DevicePath
);
1632 if (EFI_ERROR (Status
)) {
1636 SetMem (&Str
, sizeof (Str
), 0);
1637 for (Index
= 0; mMTDName
[Index
].MTDType
!= MTDTypeEnd
; Index
++) {
1638 if (MappingInfo
.Mtd
== mMTDName
[Index
].MTDType
) {
1643 if (mMTDName
[Index
].MTDType
!= MTDTypeEnd
) {
1644 Status
= CatPrint (&Str
, L
"%s", mMTDName
[Index
].Name
);
1647 if (!EFI_ERROR (Status
)) {
1648 Status
= CatPrint (&Str
, L
"%d", (UINTN
) MappingInfo
.Hi
);
1650 if (!EFI_ERROR (Status
) && MappingInfo
.Csd
.Str
!= NULL
) {
1651 Status
= CatPrint (&Str
, L
"%s", MappingInfo
.Csd
.Str
);
1652 FreePool (MappingInfo
.Csd
.Str
);
1655 if (!EFI_ERROR (Status
) && Str
.Str
!= NULL
) {
1656 Status
= CatPrint (&Str
, L
":");
1658 if (EFI_ERROR (Status
)) {
1659 SHELL_FREE_NON_NULL (Str
.Str
);
1667 Function to search the list of mappings for the node on the list based on the key.
1669 @param[in] MapKey String Key to search for on the map
1671 @return the node on the list.
1675 ShellCommandFindMapItem (
1676 IN CONST CHAR16
*MapKey
1679 SHELL_MAP_LIST
*MapListItem
;
1681 for ( MapListItem
= (SHELL_MAP_LIST
*)GetFirstNode(&gShellMapList
.Link
)
1682 ; !IsNull(&gShellMapList
.Link
, &MapListItem
->Link
)
1683 ; MapListItem
= (SHELL_MAP_LIST
*)GetNextNode(&gShellMapList
.Link
, &MapListItem
->Link
)
1685 if (gUnicodeCollation
->StriColl(gUnicodeCollation
,MapListItem
->MapName
,(CHAR16
*)MapKey
) == 0) {
1686 return (MapListItem
);