2 Main file for support of shell consist mapping.
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #include "UefiShellCommandLib.h"
15 #include <Library/DevicePathLib.h>
16 #include <Library/SortLib.h>
17 #include <Library/UefiLib.h>
18 #include <Protocol/UsbIo.h>
19 #include <Protocol/BlockIo.h>
20 #include <Protocol/SimpleFileSystem.h>
42 } DEVICE_CONSIST_MAPPING_INFO
;
50 Serial Decode function.
52 @param DevPath The Device path info.
53 @param MapInfo The map info.
54 @param OrigDevPath The original device path protocol.
56 @retval EFI_OUT_OF_RESOURCES Out of resources.
57 @retval EFI_SUCCESS The appending was successful.
61 (*SERIAL_DECODE_FUNCTION
) (
62 EFI_DEVICE_PATH_PROTOCOL
*DevPath
,
63 DEVICE_CONSIST_MAPPING_INFO
*MapInfo
,
64 EFI_DEVICE_PATH_PROTOCOL
*OrigDevPath
70 SERIAL_DECODE_FUNCTION SerialFun
;
71 INTN (EFIAPI
*CompareFun
) (EFI_DEVICE_PATH_PROTOCOL
*DevPath
, EFI_DEVICE_PATH_PROTOCOL
*DevPath2
);
72 } DEV_PATH_CONSIST_MAPPING_TABLE
;
76 Concatenates a formatted unicode string to allocated pool.
77 The caller must free the resulting buffer.
79 @param Str Tracks the allocated pool, size in use, and amount of pool allocated.
80 @param Fmt The format string
81 @param ... The data will be printed.
83 @retval EFI_SUCCESS The string is concatenated successfully.
84 @retval EFI_OUT_OF_RESOURCES Out of resources.
90 IN OUT POOL_PRINT
*Str
,
100 AppendStr
= AllocateZeroPool (0x1000);
101 if (AppendStr
== NULL
) {
102 return EFI_OUT_OF_RESOURCES
;
105 VA_START (Args
, Fmt
);
106 UnicodeVSPrint (AppendStr
, 0x1000, Fmt
, Args
);
108 if (NULL
== Str
->Str
) {
109 StringSize
= StrSize (AppendStr
);
110 NewStr
= AllocateZeroPool (StringSize
);
112 StringSize
= StrSize (AppendStr
);
113 StringSize
+= (StrSize (Str
->Str
) - sizeof (UINT16
));
115 NewStr
= ReallocatePool (
121 if (NewStr
== NULL
) {
122 FreePool (AppendStr
);
123 return EFI_OUT_OF_RESOURCES
;
127 StrCatS (Str
->Str
, StringSize
/sizeof(CHAR16
), AppendStr
);
128 Str
->Len
= StringSize
;
130 FreePool (AppendStr
);
134 MTD_NAME mMTDName
[] = {
158 Function to append a 64 bit number / 25 onto the string.
160 @param[in, out] Str The string so append onto.
161 @param[in] Num The number to divide and append.
163 @retval EFI_OUT_OF_RESOURCES Out of resources.
164 @retval EFI_SUCCESS The appending was successful.
168 IN OUT POOL_PRINT
*Str
,
176 ASSERT (Str
!= NULL
);
178 Result
= DivU64x32Remainder (Num
, 25, &Rem
);
180 Status
= AppendCSDNum2 (Str
, Result
);
181 if (EFI_ERROR (Status
)) {
186 return CatPrint (Str
, L
"%c", Rem
+ 'a');
190 Function to append a 64 bit number onto the mapping info.
192 @param[in, out] MappingItem The mapping info object to append onto.
193 @param[in] Num The info to append.
195 @retval EFI_OUT_OF_RESOURCES Out of resources.
196 @retval EFI_SUCCESS The appending was successful.
201 IN OUT DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
206 ASSERT (MappingItem
!= NULL
);
208 if (MappingItem
->Digital
) {
209 Status
= CatPrint (&MappingItem
->Csd
, L
"%ld", Num
);
211 Status
= AppendCSDNum2 (&MappingItem
->Csd
, Num
);
214 if (!EFI_ERROR (Status
)) {
215 MappingItem
->Digital
= (BOOLEAN
) !(MappingItem
->Digital
);
222 Function to append string into the mapping info.
224 @param[in, out] MappingItem The mapping info object to append onto.
225 @param[in] Str The info to append.
227 @retval EFI_OUT_OF_RESOURCES Out of resources.
228 @retval EFI_SUCCESS The appending was successful.
232 IN OUT DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
239 ASSERT (Str
!= NULL
&& MappingItem
!= NULL
);
241 Status
= EFI_SUCCESS
;
243 if (MappingItem
->Digital
) {
245 // To aVOID mult-meaning, the mapping is:
246 // 0 1 2 3 4 5 6 7 8 9 a b c d e f
247 // 0 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15
249 for (Index
= Str
; *Index
!= 0; Index
++) {
260 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
);
264 Status
= CatPrint (&MappingItem
->Csd
, L
"16");
273 Status
= CatPrint (&MappingItem
->Csd
, L
"1%c", *Index
- 'a' + '0');
282 Status
= CatPrint (&MappingItem
->Csd
, L
"1%c", *Index
- 'A' + '0');
286 if (EFI_ERROR (Status
)) {
291 for (Index
= Str
; *Index
!= 0; Index
++) {
294 // 0 1 2 3 4 5 6 7 8 9 a b c d e f
295 // a b c d e f g h i j k l m n o p
297 if (*Index
>= '0' && *Index
<= '9') {
298 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- '0' + 'a');
299 } else if (*Index
>= 'a' && *Index
<= 'f') {
300 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- 'a' + 'k');
301 } else if (*Index
>= 'A' && *Index
<= 'F') {
302 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- 'A' + 'k');
305 if (EFI_ERROR (Status
)) {
311 MappingItem
->Digital
= (BOOLEAN
)!(MappingItem
->Digital
);
313 return (EFI_SUCCESS
);
317 Function to append a Guid to the mapping item.
319 @param[in, out] MappingItem The item to append onto.
320 @param[in] Guid The guid to append.
322 @retval EFI_OUT_OF_RESOURCES Out of resources.
323 @retval EFI_SUCCESS The appending was successful.
327 DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
333 ASSERT (Guid
!= NULL
&& MappingItem
!= NULL
);
342 return AppendCSDStr (MappingItem
, Buffer
);
346 Function to compare 2 APCI device paths.
348 @param[in] DevicePath1 The first device path to compare.
349 @param[in] DevicePath2 The second device path to compare.
351 @retval 0 The device paths represent the same device.
352 @return Non zero if the devices are different, zero otherwise.
357 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
358 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
361 ACPI_HID_DEVICE_PATH
*Acpi1
;
362 ACPI_HID_DEVICE_PATH
*Acpi2
;
364 if (DevicePath1
== NULL
|| DevicePath2
== NULL
) {
368 Acpi1
= (ACPI_HID_DEVICE_PATH
*) DevicePath1
;
369 Acpi2
= (ACPI_HID_DEVICE_PATH
*) DevicePath2
;
370 if (Acpi1
->HID
> Acpi2
->HID
|| (Acpi1
->HID
== Acpi2
->HID
&& Acpi1
->UID
> Acpi2
->UID
)) {
374 if (Acpi1
->HID
== Acpi2
->HID
&& Acpi1
->UID
== Acpi2
->UID
) {
382 Function to compare 2 PCI device paths.
384 @param[in] DevicePath1 The first device path to compare.
385 @param[in] DevicePath2 The second device path to compare.
387 @retval 0 The device paths represent the same device.
388 @return Non zero if the devices are different, zero otherwise.
393 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
394 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
397 PCI_DEVICE_PATH
*Pci1
;
398 PCI_DEVICE_PATH
*Pci2
;
400 ASSERT(DevicePath1
!= NULL
);
401 ASSERT(DevicePath2
!= NULL
);
403 Pci1
= (PCI_DEVICE_PATH
*) DevicePath1
;
404 Pci2
= (PCI_DEVICE_PATH
*) DevicePath2
;
405 if (Pci1
->Device
> Pci2
->Device
|| (Pci1
->Device
== Pci2
->Device
&& Pci1
->Function
> Pci2
->Function
)) {
409 if (Pci1
->Device
== Pci2
->Device
&& Pci1
->Function
== Pci2
->Function
) {
417 Do a comparison on 2 device paths.
419 @param[in] DevicePath1 The first device path.
420 @param[in] DevicePath2 The second device path.
422 @retval 0 The 2 device paths are the same.
423 @retval <0 DevicePath2 is greater than DevicePath1.
424 @retval >0 DevicePath1 is greater than DevicePath2.
428 DevPathCompareDefault (
429 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
430 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
436 ASSERT(DevicePath1
!= NULL
);
437 ASSERT(DevicePath2
!= NULL
);
439 DevPathSize1
= DevicePathNodeLength (DevicePath1
);
440 DevPathSize2
= DevicePathNodeLength (DevicePath2
);
441 if (DevPathSize1
> DevPathSize2
) {
443 } else if (DevPathSize1
< DevPathSize2
) {
446 return CompareMem (DevicePath1
, DevicePath2
, DevPathSize1
);
451 DevicePathNode must be SerialHDD Channel type and this will populate the MappingItem.
453 @param[in] DevicePathNode The node to get info on.
454 @param[in] MappingItem The info item to populate.
455 @param[in] DevicePath Ignored.
457 @retval EFI_OUT_OF_RESOURCES Out of resources.
458 @retval EFI_SUCCESS The appending was successful.
461 DevPathSerialHardDrive (
462 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
463 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
464 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
467 HARDDRIVE_DEVICE_PATH
*Hd
;
469 ASSERT(DevicePathNode
!= NULL
);
470 ASSERT(MappingItem
!= NULL
);
472 Hd
= (HARDDRIVE_DEVICE_PATH
*) DevicePathNode
;
473 if (MappingItem
->Mtd
== MTDTypeUnknown
) {
474 MappingItem
->Mtd
= MTDTypeHardDisk
;
477 return AppendCSDNum (MappingItem
, Hd
->PartitionNumber
);
481 DevicePathNode must be SerialAtapi Channel type and this will populate the MappingItem.
483 @param[in] DevicePathNode The node to get info on.
484 @param[in] MappingItem The info item to populate.
485 @param[in] DevicePath Ignored.
487 @retval EFI_OUT_OF_RESOURCES Out of resources.
488 @retval EFI_SUCCESS The appending was successful.
492 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
493 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
494 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
497 ATAPI_DEVICE_PATH
*Atapi
;
499 ASSERT(DevicePathNode
!= NULL
);
500 ASSERT(MappingItem
!= NULL
);
502 Atapi
= (ATAPI_DEVICE_PATH
*) DevicePathNode
;
503 return AppendCSDNum (MappingItem
, (Atapi
->PrimarySecondary
* 2 + Atapi
->SlaveMaster
));
507 DevicePathNode must be SerialCDROM Channel type and this will populate the MappingItem.
509 @param[in] DevicePathNode The node to get info on.
510 @param[in] MappingItem The info item to populate.
511 @param[in] DevicePath Ignored.
513 @retval EFI_OUT_OF_RESOURCES Out of resources.
514 @retval EFI_SUCCESS The appending was successful.
518 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
519 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
520 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
523 CDROM_DEVICE_PATH
*Cd
;
525 ASSERT(DevicePathNode
!= NULL
);
526 ASSERT(MappingItem
!= NULL
);
528 Cd
= (CDROM_DEVICE_PATH
*) DevicePathNode
;
529 MappingItem
->Mtd
= MTDTypeCDRom
;
530 return AppendCSDNum (MappingItem
, Cd
->BootEntry
);
534 DevicePathNode must be SerialFibre Channel type and this will populate the MappingItem.
536 @param[in] DevicePathNode The node to get info on.
537 @param[in] MappingItem The info item to populate.
538 @param[in] DevicePath Ignored.
540 @retval EFI_OUT_OF_RESOURCES Out of resources.
541 @retval EFI_SUCCESS The appending was successful.
545 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
546 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
547 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
551 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
553 ASSERT(DevicePathNode
!= NULL
);
554 ASSERT(MappingItem
!= NULL
);
556 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) DevicePathNode
;
557 Status
= AppendCSDNum (MappingItem
, Fibre
->WWN
);
558 if (!EFI_ERROR (Status
)) {
559 Status
= AppendCSDNum (MappingItem
, Fibre
->Lun
);
565 DevicePathNode must be SerialUart type and this will populate the MappingItem.
567 @param[in] DevicePathNode The node to get info on.
568 @param[in] MappingItem The info item to populate.
569 @param[in] DevicePath Ignored.
571 @retval EFI_OUT_OF_RESOURCES Out of resources.
572 @retval EFI_SUCCESS The appending was successful.
576 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
577 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
578 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
582 UART_DEVICE_PATH
*Uart
;
584 ASSERT(DevicePathNode
!= NULL
);
585 ASSERT(MappingItem
!= NULL
);
587 Uart
= (UART_DEVICE_PATH
*) DevicePathNode
;
588 Status
= AppendCSDNum (MappingItem
, Uart
->BaudRate
);
589 if (!EFI_ERROR (Status
)) {
590 Status
= AppendCSDNum (MappingItem
, Uart
->DataBits
);
592 if (!EFI_ERROR (Status
)) {
593 Status
= AppendCSDNum (MappingItem
, Uart
->Parity
);
595 if (!EFI_ERROR (Status
)) {
596 Status
= AppendCSDNum (MappingItem
, Uart
->StopBits
);
602 DevicePathNode must be SerialUSB type and this will populate the MappingItem.
604 @param[in] DevicePathNode The node to get info on.
605 @param[in] MappingItem The info item to populate.
606 @param[in] DevicePath Ignored.
608 @retval EFI_OUT_OF_RESOURCES Out of resources.
609 @retval EFI_SUCCESS The appending was successful.
613 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
614 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
615 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
618 USB_DEVICE_PATH
*Usb
;
619 EFI_USB_IO_PROTOCOL
*UsbIo
;
620 EFI_HANDLE TempHandle
;
622 USB_INTERFACE_DESCRIPTOR InterfaceDesc
;
625 ASSERT(DevicePathNode
!= NULL
);
626 ASSERT(MappingItem
!= NULL
);
628 Usb
= (USB_DEVICE_PATH
*) DevicePathNode
;
629 Status
= AppendCSDNum (MappingItem
, Usb
->ParentPortNumber
);
630 if (!EFI_ERROR (Status
)) {
631 Status
= AppendCSDNum (MappingItem
, Usb
->InterfaceNumber
);
634 if (EFI_ERROR (Status
)) {
638 if (PcdGetBool(PcdUsbExtendedDecode
)) {
639 Status
= gBS
->LocateDevicePath( &gEfiUsbIoProtocolGuid
, &DevicePath
, &TempHandle
);
641 if (!EFI_ERROR(Status
)) {
642 Status
= gBS
->OpenProtocol(TempHandle
, &gEfiUsbIoProtocolGuid
, (VOID
**)&UsbIo
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
645 if (!EFI_ERROR(Status
)) {
646 ASSERT(UsbIo
!= NULL
);
647 Status
= UsbIo
->UsbGetInterfaceDescriptor(UsbIo
, &InterfaceDesc
);
648 if (!EFI_ERROR(Status
)) {
649 if (InterfaceDesc
.InterfaceClass
== USB_MASS_STORE_CLASS
&& MappingItem
->Mtd
== MTDTypeUnknown
) {
650 switch (InterfaceDesc
.InterfaceSubClass
){
651 case USB_MASS_STORE_SCSI
:
652 MappingItem
->Mtd
= MTDTypeHardDisk
;
654 case USB_MASS_STORE_8070I
:
655 case USB_MASS_STORE_UFI
:
656 MappingItem
->Mtd
= MTDTypeFloppy
;
658 case USB_MASS_STORE_8020I
:
659 MappingItem
->Mtd
= MTDTypeCDRom
;
670 DevicePathNode must be SerialVendor type and this will populate the MappingItem.
672 @param[in] DevicePathNode The node to get info on.
673 @param[in] MappingItem The info item to populate.
674 @param[in] DevicePath Ignored.
676 @retval EFI_OUT_OF_RESOURCES Out of resources.
677 @retval EFI_SUCCESS The appending was successful.
680 DevPathSerialVendor (
681 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
682 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
683 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
687 VENDOR_DEVICE_PATH
*Vendor
;
688 SAS_DEVICE_PATH
*Sas
;
689 UINTN TargetNameLength
;
694 ASSERT(DevicePathNode
!= NULL
);
695 ASSERT(MappingItem
!= NULL
);
697 Vendor
= (VENDOR_DEVICE_PATH
*) DevicePathNode
;
698 Status
= AppendCSDGuid (MappingItem
, &Vendor
->Guid
);
699 if (EFI_ERROR (Status
)) {
703 if (CompareGuid (&gEfiSasDevicePathGuid
, &Vendor
->Guid
)) {
704 Sas
= (SAS_DEVICE_PATH
*) Vendor
;
705 Status
= AppendCSDNum (MappingItem
, Sas
->SasAddress
);
706 if (!EFI_ERROR (Status
)) {
707 Status
= AppendCSDNum (MappingItem
, Sas
->Lun
);
709 if (!EFI_ERROR (Status
)) {
710 Status
= AppendCSDNum (MappingItem
, Sas
->DeviceTopology
);
712 if (!EFI_ERROR (Status
)) {
713 Status
= AppendCSDNum (MappingItem
, Sas
->RelativeTargetPort
);
716 TargetNameLength
= MIN(DevicePathNodeLength (DevicePathNode
) - sizeof (VENDOR_DEVICE_PATH
), PcdGet32(PcdShellVendorExtendedDecode
));
717 if (TargetNameLength
!= 0) {
719 // String is 2 chars per data byte, plus NULL terminator
721 Buffer
= AllocateZeroPool (((TargetNameLength
* 2) + 1) * sizeof(CHAR16
));
722 if (Buffer
== NULL
) {
723 return EFI_OUT_OF_RESOURCES
;
727 // Build the string data
729 for (Index
= 0; Index
< TargetNameLength
; Index
++) {
730 NewBuffer
= CatSPrint (Buffer
, L
"%02x", *((UINT8
*)Vendor
+ sizeof (VENDOR_DEVICE_PATH
) + Index
));
731 if (NewBuffer
== NULL
) {
732 Status
= EFI_OUT_OF_RESOURCES
;
739 // Append the new data block
741 if (!EFI_ERROR (Status
)) {
742 Status
= AppendCSDStr (MappingItem
, Buffer
);
752 DevicePathNode must be SerialLun type and this will populate the MappingItem.
754 @param[in] DevicePathNode The node to get info on.
755 @param[in] MappingItem The info item to populate.
756 @param[in] DevicePath Ignored.
758 @retval EFI_OUT_OF_RESOURCES Out of resources.
759 @retval EFI_SUCCESS The appending was successful.
763 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
764 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
765 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
768 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*Lun
;
770 ASSERT(DevicePathNode
!= NULL
);
771 ASSERT(MappingItem
!= NULL
);
773 Lun
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) DevicePathNode
;
774 return AppendCSDNum (MappingItem
, Lun
->Lun
);
778 DevicePathNode must be SerialSata type and this will populate the MappingItem.
780 @param[in] DevicePathNode The node to get info on.
781 @param[in] MappingItem The info item to populate.
782 @param[in] DevicePath Ignored.
784 @retval EFI_OUT_OF_RESOURCES Out of resources.
785 @retval EFI_SUCCESS The appending was successful.
789 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
790 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
791 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
795 SATA_DEVICE_PATH
*Sata
;
797 ASSERT(DevicePathNode
!= NULL
);
798 ASSERT(MappingItem
!= NULL
);
800 Sata
= (SATA_DEVICE_PATH
*) DevicePathNode
;
801 Status
= AppendCSDNum (MappingItem
, Sata
->HBAPortNumber
);
802 if (!EFI_ERROR (Status
)) {
803 Status
= AppendCSDNum (MappingItem
, Sata
->PortMultiplierPortNumber
);
805 if (!EFI_ERROR (Status
)) {
806 Status
= AppendCSDNum (MappingItem
, Sata
->Lun
);
812 DevicePathNode must be SerialSCSI type and this will populate the MappingItem.
814 @param[in] DevicePathNode The node to get info on.
815 @param[in] MappingItem The info item to populate.
816 @param[in] DevicePath Ignored.
818 @retval EFI_OUT_OF_RESOURCES Out of resources.
819 @retval EFI_SUCCESS The appending was successful.
823 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
824 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
825 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
829 ISCSI_DEVICE_PATH
*IScsi
;
830 UINT8
*IScsiTargetName
;
832 UINTN TargetNameLength
;
835 ASSERT(DevicePathNode
!= NULL
);
836 ASSERT(MappingItem
!= NULL
);
838 Status
= EFI_SUCCESS
;
840 if (PcdGetBool(PcdShellDecodeIScsiMapNames
)) {
841 IScsi
= (ISCSI_DEVICE_PATH
*) DevicePathNode
;
842 Status
= AppendCSDNum (MappingItem
, IScsi
->NetworkProtocol
);
843 if (!EFI_ERROR (Status
)) {
844 Status
= AppendCSDNum (MappingItem
, IScsi
->LoginOption
);
846 if (!EFI_ERROR (Status
)) {
847 Status
= AppendCSDNum (MappingItem
, IScsi
->Lun
);
849 if (!EFI_ERROR (Status
)) {
850 Status
= AppendCSDNum (MappingItem
, IScsi
->TargetPortalGroupTag
);
852 if (EFI_ERROR (Status
)) {
855 TargetNameLength
= DevicePathNodeLength (DevicePathNode
) - sizeof (ISCSI_DEVICE_PATH
);
856 if (TargetNameLength
> 0) {
857 TargetName
= AllocateZeroPool ((TargetNameLength
+ 1) * sizeof (CHAR16
));
858 if (TargetName
== NULL
) {
859 Status
= EFI_OUT_OF_RESOURCES
;
861 IScsiTargetName
= (UINT8
*) (IScsi
+ 1);
862 for (Index
= 0; Index
< TargetNameLength
; Index
++) {
863 TargetName
[Index
] = (CHAR16
) IScsiTargetName
[Index
];
865 Status
= AppendCSDStr (MappingItem
, TargetName
);
866 FreePool (TargetName
);
874 DevicePathNode must be SerialI20 type and this will populate the MappingItem.
876 @param[in] DevicePathNode The node to get info on.
877 @param[in] MappingItem The info item to populate.
878 @param[in] DevicePath Ignored.
880 @retval EFI_OUT_OF_RESOURCES Out of resources.
881 @retval EFI_SUCCESS The appending was successful.
885 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
886 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
887 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
890 I2O_DEVICE_PATH
*DevicePath_I20
;
892 ASSERT(DevicePathNode
!= NULL
);
893 ASSERT(MappingItem
!= NULL
);
895 DevicePath_I20
= (I2O_DEVICE_PATH
*) DevicePathNode
;
896 return AppendCSDNum (MappingItem
, DevicePath_I20
->Tid
);
900 DevicePathNode must be Mac Address type and this will populate the MappingItem.
902 @param[in] DevicePathNode The node to get info on.
903 @param[in] MappingItem The info item to populate.
904 @param[in] DevicePath Ignored.
906 @retval EFI_OUT_OF_RESOURCES Out of resources.
907 @retval EFI_SUCCESS The appending was successful.
910 DevPathSerialMacAddr (
911 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
912 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
913 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
916 MAC_ADDR_DEVICE_PATH
*Mac
;
922 ASSERT(DevicePathNode
!= NULL
);
923 ASSERT(MappingItem
!= NULL
);
925 Mac
= (MAC_ADDR_DEVICE_PATH
*) DevicePathNode
;
927 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
928 if (Mac
->IfType
== 0x01 || Mac
->IfType
== 0x00) {
932 for (Index
= 0, PBuffer
= Buffer
; Index
< HwAddressSize
; Index
++, PBuffer
+= 2) {
933 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) Mac
->MacAddress
.Addr
[Index
]);
936 return AppendCSDStr (MappingItem
, Buffer
);
940 DevicePathNode must be InfiniBand type and this will populate the MappingItem.
942 @param[in] DevicePathNode The node to get info on.
943 @param[in] MappingItem The info item to populate.
944 @param[in] DevicePath Ignored.
946 @retval EFI_OUT_OF_RESOURCES Out of resources.
947 @retval EFI_SUCCESS The appending was successful.
950 DevPathSerialInfiniBand (
951 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
952 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
953 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
957 INFINIBAND_DEVICE_PATH
*InfiniBand
;
962 ASSERT(DevicePathNode
!= NULL
);
963 ASSERT(MappingItem
!= NULL
);
965 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) DevicePathNode
;
966 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
967 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) InfiniBand
->PortGid
[Index
]);
970 Status
= AppendCSDStr (MappingItem
, Buffer
);
971 if (!EFI_ERROR (Status
)) {
972 Status
= AppendCSDNum (MappingItem
, InfiniBand
->ServiceId
);
974 if (!EFI_ERROR (Status
)) {
975 Status
= AppendCSDNum (MappingItem
, InfiniBand
->TargetPortId
);
977 if (!EFI_ERROR (Status
)) {
978 Status
= AppendCSDNum (MappingItem
, InfiniBand
->DeviceId
);
984 DevicePathNode must be IPv4 type and this will populate the MappingItem.
986 @param[in] DevicePathNode The node to get info on.
987 @param[in] MappingItem The info item to populate.
988 @param[in] DevicePath Ignored.
990 @retval EFI_OUT_OF_RESOURCES Out of resources.
991 @retval EFI_SUCCESS The appending was successful.
995 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
996 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
997 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1001 IPv4_DEVICE_PATH
*Ip
;
1004 ASSERT(DevicePathNode
!= NULL
);
1005 ASSERT(MappingItem
!= NULL
);
1007 Ip
= (IPv4_DEVICE_PATH
*) DevicePathNode
;
1011 L
"%02x%02x%02x%02x",
1012 (UINTN
) Ip
->LocalIpAddress
.Addr
[0],
1013 (UINTN
) Ip
->LocalIpAddress
.Addr
[1],
1014 (UINTN
) Ip
->LocalIpAddress
.Addr
[2],
1015 (UINTN
) Ip
->LocalIpAddress
.Addr
[3]
1017 Status
= AppendCSDStr (MappingItem
, Buffer
);
1018 if (!EFI_ERROR (Status
)) {
1019 Status
= AppendCSDNum (MappingItem
, Ip
->LocalPort
);
1021 if (!EFI_ERROR (Status
)) {
1025 L
"%02x%02x%02x%02x",
1026 (UINTN
) Ip
->RemoteIpAddress
.Addr
[0],
1027 (UINTN
) Ip
->RemoteIpAddress
.Addr
[1],
1028 (UINTN
) Ip
->RemoteIpAddress
.Addr
[2],
1029 (UINTN
) Ip
->RemoteIpAddress
.Addr
[3]
1031 Status
= AppendCSDStr (MappingItem
, Buffer
);
1033 if (!EFI_ERROR (Status
)) {
1034 Status
= AppendCSDNum (MappingItem
, Ip
->RemotePort
);
1040 DevicePathNode must be IPv6 type and this will populate the MappingItem.
1042 @param[in] DevicePathNode The node to get info on.
1043 @param[in] MappingItem The info item to populate.
1044 @param[in] DevicePath Ignored.
1046 @retval EFI_OUT_OF_RESOURCES Out of resources.
1047 @retval EFI_SUCCESS The appending was successful.
1051 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1052 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1053 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1057 IPv6_DEVICE_PATH
*Ip
;
1062 ASSERT(DevicePathNode
!= NULL
);
1063 ASSERT(MappingItem
!= NULL
);
1065 Ip
= (IPv6_DEVICE_PATH
*) DevicePathNode
;
1066 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
1067 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) Ip
->LocalIpAddress
.Addr
[Index
]);
1070 Status
= AppendCSDStr (MappingItem
, Buffer
);
1071 if (!EFI_ERROR (Status
)) {
1072 Status
= AppendCSDNum (MappingItem
, Ip
->LocalPort
);
1074 if (!EFI_ERROR (Status
)) {
1075 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
1076 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) Ip
->RemoteIpAddress
.Addr
[Index
]);
1079 Status
= AppendCSDStr (MappingItem
, Buffer
);
1081 if (!EFI_ERROR (Status
)) {
1082 Status
= AppendCSDNum (MappingItem
, Ip
->RemotePort
);
1088 DevicePathNode must be SCSI type and this will populate the MappingItem.
1090 @param[in] DevicePathNode The node to get info on.
1091 @param[in] MappingItem The info item to populate.
1092 @param[in] DevicePath Ignored.
1094 @retval EFI_OUT_OF_RESOURCES Out of resources.
1095 @retval EFI_SUCCESS The appending was successful.
1099 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1100 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1101 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1105 SCSI_DEVICE_PATH
*Scsi
;
1107 ASSERT(DevicePathNode
!= NULL
);
1108 ASSERT(MappingItem
!= NULL
);
1110 Scsi
= (SCSI_DEVICE_PATH
*) DevicePathNode
;
1111 Status
= AppendCSDNum (MappingItem
, Scsi
->Pun
);
1112 if (!EFI_ERROR (Status
)) {
1113 Status
= AppendCSDNum (MappingItem
, Scsi
->Lun
);
1119 DevicePathNode must be 1394 type and this will populate the MappingItem.
1121 @param[in] DevicePathNode The node to get info on.
1122 @param[in] MappingItem The info item to populate.
1123 @param[in] DevicePath Ignored.
1125 @retval EFI_OUT_OF_RESOURCES Out of resources.
1126 @retval EFI_SUCCESS The appending was successful.
1130 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1131 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1132 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1135 F1394_DEVICE_PATH
*DevicePath_F1394
;
1138 ASSERT(DevicePathNode
!= NULL
);
1139 ASSERT(MappingItem
!= NULL
);
1141 DevicePath_F1394
= (F1394_DEVICE_PATH
*) DevicePathNode
;
1142 UnicodeSPrint (Buffer
, 0, L
"%lx", DevicePath_F1394
->Guid
);
1143 return AppendCSDStr (MappingItem
, Buffer
);
1147 If the node is floppy type then populate the MappingItem.
1149 @param[in] DevicePathNode The node to get info on.
1150 @param[in] MappingItem The info item to populate.
1151 @param[in] DevicePath Ignored.
1153 @retval EFI_OUT_OF_RESOURCES Out of resources.
1154 @retval EFI_SUCCESS The appending was successful.
1158 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1159 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1160 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1163 ACPI_HID_DEVICE_PATH
*Acpi
;
1165 ASSERT(DevicePathNode
!= NULL
);
1166 ASSERT(MappingItem
!= NULL
);
1168 Acpi
= (ACPI_HID_DEVICE_PATH
*) DevicePathNode
;
1169 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
1170 if (EISA_ID_TO_NUM (Acpi
->HID
) == 0x0604) {
1171 MappingItem
->Mtd
= MTDTypeFloppy
;
1172 return AppendCSDNum (MappingItem
, Acpi
->UID
);
1179 Empty function used for unknown devices.
1181 @param[in] DevicePathNode Ignored.
1182 @param[in] MappingItem Ignored.
1183 @param[in] DevicePath Ignored.
1185 @retval EFI_OUT_OF_RESOURCES Out of resources.
1186 @retval EFI_SUCCESS The appending was successful.
1189 DevPathSerialDefault (
1190 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1191 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1192 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1198 DEV_PATH_CONSIST_MAPPING_TABLE DevPathConsistMappingTable
[] = {
1200 HARDWARE_DEVICE_PATH
,
1202 DevPathSerialDefault
,
1212 MESSAGING_DEVICE_PATH
,
1215 DevPathCompareDefault
1218 MESSAGING_DEVICE_PATH
,
1221 DevPathCompareDefault
1224 MESSAGING_DEVICE_PATH
,
1225 MSG_FIBRECHANNEL_DP
,
1227 DevPathCompareDefault
1230 MESSAGING_DEVICE_PATH
,
1233 DevPathCompareDefault
1236 MESSAGING_DEVICE_PATH
,
1239 DevPathCompareDefault
1242 MESSAGING_DEVICE_PATH
,
1245 DevPathCompareDefault
1248 MESSAGING_DEVICE_PATH
,
1250 DevPathSerialMacAddr
,
1251 DevPathCompareDefault
1254 MESSAGING_DEVICE_PATH
,
1257 DevPathCompareDefault
1260 MESSAGING_DEVICE_PATH
,
1263 DevPathCompareDefault
1266 MESSAGING_DEVICE_PATH
,
1268 DevPathSerialInfiniBand
,
1269 DevPathCompareDefault
1272 MESSAGING_DEVICE_PATH
,
1275 DevPathCompareDefault
1278 MESSAGING_DEVICE_PATH
,
1280 DevPathSerialVendor
,
1281 DevPathCompareDefault
1284 MESSAGING_DEVICE_PATH
,
1285 MSG_DEVICE_LOGICAL_UNIT_DP
,
1287 DevPathCompareDefault
1290 MESSAGING_DEVICE_PATH
,
1293 DevPathCompareDefault
1296 MESSAGING_DEVICE_PATH
,
1299 DevPathCompareDefault
1304 DevPathSerialHardDrive
,
1305 DevPathCompareDefault
1311 DevPathCompareDefault
1316 DevPathSerialVendor
,
1317 DevPathCompareDefault
1328 Function to determine if a device path node is Hi or not.
1330 @param[in] DevicePathNode The node to check.
1332 @retval TRUE The node is Hi.
1333 @retval FALSE The node is not Hi.
1336 IsHIDevicePathNode (
1337 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
1340 ACPI_HID_DEVICE_PATH
*Acpi
;
1342 ASSERT(DevicePathNode
!= NULL
);
1344 if (DevicePathNode
->Type
== HARDWARE_DEVICE_PATH
) {
1348 if (DevicePathNode
->Type
== ACPI_DEVICE_PATH
) {
1349 Acpi
= (ACPI_HID_DEVICE_PATH
*) DevicePathNode
;
1350 switch (EISA_ID_TO_NUM (Acpi
->HID
)) {
1365 Function to convert a standard device path structure into a Hi version.
1367 @param[in] DevicePath The device path to convert.
1369 @return the device path portion that is Hi.
1371 EFI_DEVICE_PATH_PROTOCOL
*
1373 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1376 UINTN NonHIDevicePathNodeCount
;
1379 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1380 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
1382 ASSERT(DevicePath
!= NULL
);
1384 NonHIDevicePathNodeCount
= 0;
1386 HIDevicePath
= AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL
));
1387 SetDevicePathEndNode (HIDevicePath
);
1389 Node
.DevPath
.Type
= END_DEVICE_PATH_TYPE
;
1390 Node
.DevPath
.SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
1391 Node
.DevPath
.Length
[0] = (UINT8
)sizeof (EFI_DEVICE_PATH_PROTOCOL
);
1392 Node
.DevPath
.Length
[1] = 0;
1394 while (!IsDevicePathEnd (DevicePath
)) {
1395 if (IsHIDevicePathNode (DevicePath
)) {
1396 for (Index
= 0; Index
< NonHIDevicePathNodeCount
; Index
++) {
1397 TempDevicePath
= AppendDevicePathNode (HIDevicePath
, &Node
.DevPath
);
1398 FreePool (HIDevicePath
);
1399 HIDevicePath
= TempDevicePath
;
1402 TempDevicePath
= AppendDevicePathNode (HIDevicePath
, DevicePath
);
1403 FreePool (HIDevicePath
);
1404 HIDevicePath
= TempDevicePath
;
1406 NonHIDevicePathNodeCount
++;
1409 // Next device path node
1411 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (DevicePath
);
1414 return HIDevicePath
;
1418 Function to walk the device path looking for a dumpable node.
1420 @param[in] MappingItem The Item to fill with data.
1421 @param[in] DevicePath The path of the item to get data on.
1423 @return EFI_SUCCESS Always returns success.
1426 GetDeviceConsistMappingInfo (
1427 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1428 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1432 SERIAL_DECODE_FUNCTION SerialFun
;
1434 EFI_DEVICE_PATH_PROTOCOL
*OriginalDevicePath
;
1436 ASSERT(DevicePath
!= NULL
);
1437 ASSERT(MappingItem
!= NULL
);
1439 SetMem (&MappingItem
->Csd
, sizeof (POOL_PRINT
), 0);
1440 OriginalDevicePath
= DevicePath
;
1442 while (!IsDevicePathEnd (DevicePath
)) {
1444 // Find the handler to dump this device path node and
1445 // initialize with generic function in case nothing is found
1447 for (SerialFun
= DevPathSerialDefault
, Index
= 0; DevPathConsistMappingTable
[Index
].SerialFun
!= NULL
; Index
+= 1) {
1449 if (DevicePathType (DevicePath
) == DevPathConsistMappingTable
[Index
].Type
&&
1450 DevicePathSubType (DevicePath
) == DevPathConsistMappingTable
[Index
].SubType
1452 SerialFun
= DevPathConsistMappingTable
[Index
].SerialFun
;
1457 Status
= SerialFun (DevicePath
, MappingItem
, OriginalDevicePath
);
1458 if (EFI_ERROR (Status
)) {
1459 SHELL_FREE_NON_NULL (MappingItem
->Csd
.Str
);
1464 // Next device path node
1466 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (DevicePath
);
1473 Function to initialize the table for creating consistent map names.
1475 @param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.
1477 @retval EFI_SUCCESS The table was created successfully.
1481 ShellCommandConsistMappingInitialize (
1482 OUT EFI_DEVICE_PATH_PROTOCOL
***Table
1485 EFI_HANDLE
*HandleBuffer
;
1488 EFI_DEVICE_PATH_PROTOCOL
**TempTable
;
1489 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
1490 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1491 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
1492 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
1496 HandleBuffer
= NULL
;
1498 Status
= gBS
->LocateHandleBuffer (
1500 &gEfiDevicePathProtocolGuid
,
1505 ASSERT_EFI_ERROR(Status
);
1507 TempTable
= AllocateZeroPool ((HandleNum
+ 1) * sizeof (EFI_DEVICE_PATH_PROTOCOL
*));
1508 if (TempTable
== NULL
) {
1509 return EFI_OUT_OF_RESOURCES
;
1512 for (HandleLoop
= 0 ; HandleLoop
< HandleNum
; HandleLoop
++) {
1513 DevicePath
= DevicePathFromHandle (HandleBuffer
[HandleLoop
]);
1514 if (DevicePath
== NULL
) {
1518 HIDevicePath
= GetHIDevicePath (DevicePath
);
1519 if (HIDevicePath
== NULL
) {
1523 Status
= gBS
->HandleProtocol( HandleBuffer
[HandleLoop
],
1524 &gEfiBlockIoProtocolGuid
,
1527 if (EFI_ERROR(Status
)) {
1528 Status
= gBS
->HandleProtocol( HandleBuffer
[HandleLoop
],
1529 &gEfiSimpleFileSystemProtocolGuid
,
1530 (VOID
**)&SimpleFileSystem
1532 if (EFI_ERROR(Status
)) {
1533 FreePool (HIDevicePath
);
1538 for (Index
= 0; TempTable
[Index
] != NULL
; Index
++) {
1539 if (DevicePathCompare (&TempTable
[Index
], &HIDevicePath
) == 0) {
1540 FreePool (HIDevicePath
);
1545 if (TempTable
[Index
] == NULL
) {
1546 TempTable
[Index
] = HIDevicePath
;
1550 for (Index
= 0; TempTable
[Index
] != NULL
; Index
++);
1551 PerformQuickSort(TempTable
, Index
, sizeof(EFI_DEVICE_PATH_PROTOCOL
*), DevicePathCompare
);
1554 if (HandleBuffer
!= NULL
) {
1555 FreePool (HandleBuffer
);
1562 Function to uninitialize the table for creating consistent map names.
1564 The parameter must have been received from ShellCommandConsistMappingInitialize.
1566 @param[out] Table The pointer to pointer to DevicePathProtocol object.
1568 @retval EFI_SUCCESS The table was deleted successfully.
1572 ShellCommandConsistMappingUnInitialize (
1573 EFI_DEVICE_PATH_PROTOCOL
**Table
1578 ASSERT(Table
!= NULL
);
1580 for (Index
= 0; Table
[Index
] != NULL
; Index
++) {
1581 FreePool (Table
[Index
]);
1589 Create a consistent mapped name for the device specified by DevicePath
1592 This must be called after ShellCommandConsistMappingInitialize() and
1593 before ShellCommandConsistMappingUnInitialize() is called.
1595 @param[in] DevicePath The pointer to the dev path for the device.
1596 @param[in] Table The Table of mapping information.
1598 @retval NULL A consistent mapped name could not be created.
1599 @return A pointer to a string allocated from pool with the device name.
1603 ShellCommandConsistMappingGenMappingName (
1604 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1605 IN EFI_DEVICE_PATH_PROTOCOL
**Table
1610 DEVICE_CONSIST_MAPPING_INFO MappingInfo
;
1611 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1614 ASSERT(DevicePath
!= NULL
);
1615 ASSERT(Table
!= NULL
);
1617 HIDevicePath
= GetHIDevicePath (DevicePath
);
1618 if (HIDevicePath
== NULL
) {
1622 for (Index
= 0; Table
[Index
] != NULL
; Index
++) {
1623 if (DevicePathCompare (&Table
[Index
], &HIDevicePath
) == 0) {
1628 FreePool (HIDevicePath
);
1629 if (Table
[Index
] == NULL
) {
1633 MappingInfo
.Hi
= Index
;
1634 MappingInfo
.Mtd
= MTDTypeUnknown
;
1635 MappingInfo
.Digital
= FALSE
;
1637 Status
= GetDeviceConsistMappingInfo (&MappingInfo
, DevicePath
);
1638 if (EFI_ERROR (Status
)) {
1642 SetMem (&Str
, sizeof (Str
), 0);
1643 for (Index
= 0; mMTDName
[Index
].MTDType
!= MTDTypeEnd
; Index
++) {
1644 if (MappingInfo
.Mtd
== mMTDName
[Index
].MTDType
) {
1649 if (mMTDName
[Index
].MTDType
!= MTDTypeEnd
) {
1650 Status
= CatPrint (&Str
, L
"%s", mMTDName
[Index
].Name
);
1653 if (!EFI_ERROR (Status
)) {
1654 Status
= CatPrint (&Str
, L
"%d", (UINTN
) MappingInfo
.Hi
);
1656 if (!EFI_ERROR (Status
) && MappingInfo
.Csd
.Str
!= NULL
) {
1657 Status
= CatPrint (&Str
, L
"%s", MappingInfo
.Csd
.Str
);
1658 FreePool (MappingInfo
.Csd
.Str
);
1661 if (!EFI_ERROR (Status
) && Str
.Str
!= NULL
) {
1662 Status
= CatPrint (&Str
, L
":");
1664 if (EFI_ERROR (Status
)) {
1665 SHELL_FREE_NON_NULL (Str
.Str
);
1673 Function to search the list of mappings for the node on the list based on the key.
1675 @param[in] MapKey String Key to search for on the map
1677 @return the node on the list.
1681 ShellCommandFindMapItem (
1682 IN CONST CHAR16
*MapKey
1685 SHELL_MAP_LIST
*MapListItem
;
1687 for ( MapListItem
= (SHELL_MAP_LIST
*)GetFirstNode(&gShellMapList
.Link
)
1688 ; !IsNull(&gShellMapList
.Link
, &MapListItem
->Link
)
1689 ; MapListItem
= (SHELL_MAP_LIST
*)GetNextNode(&gShellMapList
.Link
, &MapListItem
->Link
)
1691 if (gUnicodeCollation
->StriColl(gUnicodeCollation
,MapListItem
->MapName
,(CHAR16
*)MapKey
) == 0) {
1692 return (MapListItem
);