2 Main file for support of shell consist mapping.
4 Copyright (c) 2005 - 2016, 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.
89 IN OUT POOL_PRINT
*Str
,
99 AppendStr
= AllocateZeroPool (0x1000);
100 if (AppendStr
== NULL
) {
101 return EFI_OUT_OF_RESOURCES
;
104 VA_START (Args
, Fmt
);
105 UnicodeVSPrint (AppendStr
, 0x1000, Fmt
, Args
);
107 if (NULL
== Str
->Str
) {
108 StringSize
= StrSize (AppendStr
);
109 NewStr
= AllocateZeroPool (StringSize
);
111 StringSize
= StrSize (AppendStr
);
112 StringSize
+= (StrSize (Str
->Str
) - sizeof (UINT16
));
114 NewStr
= ReallocatePool (
120 if (NewStr
== NULL
) {
121 FreePool (AppendStr
);
122 return EFI_OUT_OF_RESOURCES
;
126 StrCatS (Str
->Str
, StringSize
/sizeof(CHAR16
), AppendStr
);
127 Str
->Len
= StringSize
;
129 FreePool (AppendStr
);
133 MTD_NAME mMTDName
[] = {
157 Function to append a 64 bit number / 25 onto the string.
159 @param[in, out] Str The string so append onto.
160 @param[in] Num The number to divide and append.
162 @retval EFI_OUT_OF_RESOURCES Out of resources.
163 @retval EFI_SUCCESS The appending was successful.
167 IN OUT POOL_PRINT
*Str
,
175 ASSERT (Str
!= NULL
);
177 Result
= DivU64x32Remainder (Num
, 25, &Rem
);
179 Status
= AppendCSDNum2 (Str
, Result
);
180 if (EFI_ERROR (Status
)) {
185 return CatPrint (Str
, L
"%c", Rem
+ 'a');
189 Function to append a 64 bit number onto the mapping info.
191 @param[in, out] MappingItem The mapping info object to append onto.
192 @param[in] Num The info to append.
194 @retval EFI_OUT_OF_RESOURCES Out of resources.
195 @retval EFI_SUCCESS The appending was successful.
200 IN OUT DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
205 ASSERT (MappingItem
!= NULL
);
207 if (MappingItem
->Digital
) {
208 Status
= CatPrint (&MappingItem
->Csd
, L
"%ld", Num
);
210 Status
= AppendCSDNum2 (&MappingItem
->Csd
, Num
);
213 if (!EFI_ERROR (Status
)) {
214 MappingItem
->Digital
= (BOOLEAN
) !(MappingItem
->Digital
);
221 Function to append string into the mapping info.
223 @param[in, out] MappingItem The mapping info object to append onto.
224 @param[in] Str The info to append.
226 @retval EFI_OUT_OF_RESOURCES Out of resources.
227 @retval EFI_SUCCESS The appending was successful.
231 IN OUT DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
238 ASSERT (Str
!= NULL
&& MappingItem
!= NULL
);
240 Status
= EFI_SUCCESS
;
242 if (MappingItem
->Digital
) {
244 // To aVOID mult-meaning, the mapping is:
245 // 0 1 2 3 4 5 6 7 8 9 a b c d e f
246 // 0 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15
248 for (Index
= Str
; *Index
!= 0; Index
++) {
259 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
);
263 Status
= CatPrint (&MappingItem
->Csd
, L
"16");
272 Status
= CatPrint (&MappingItem
->Csd
, L
"1%c", *Index
- 'a' + '0');
281 Status
= CatPrint (&MappingItem
->Csd
, L
"1%c", *Index
- 'A' + '0');
285 if (EFI_ERROR (Status
)) {
290 for (Index
= Str
; *Index
!= 0; Index
++) {
293 // 0 1 2 3 4 5 6 7 8 9 a b c d e f
294 // a b c d e f g h i j k l m n o p
296 if (*Index
>= '0' && *Index
<= '9') {
297 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- '0' + 'a');
298 } else if (*Index
>= 'a' && *Index
<= 'f') {
299 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- 'a' + 'k');
300 } else if (*Index
>= 'A' && *Index
<= 'F') {
301 Status
= CatPrint (&MappingItem
->Csd
, L
"%c", *Index
- 'A' + 'k');
304 if (EFI_ERROR (Status
)) {
310 MappingItem
->Digital
= (BOOLEAN
)!(MappingItem
->Digital
);
312 return (EFI_SUCCESS
);
316 Function to append a Guid to the mapping item.
318 @param[in, out] MappingItem The item to append onto.
319 @param[in] Guid The guid to append.
321 @retval EFI_OUT_OF_RESOURCES Out of resources.
322 @retval EFI_SUCCESS The appending was successful.
326 DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
332 ASSERT (Guid
!= NULL
&& MappingItem
!= NULL
);
341 return AppendCSDStr (MappingItem
, Buffer
);
345 Function to compare 2 APCI device paths.
347 @param[in] DevicePath1 The first device path to compare.
348 @param[in] DevicePath2 The second device path to compare.
350 @retval 0 The device paths represent the same device.
351 @return Non zero if the devices are different, zero otherwise.
356 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
357 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
360 ACPI_HID_DEVICE_PATH
*Acpi1
;
361 ACPI_HID_DEVICE_PATH
*Acpi2
;
363 if (DevicePath1
== NULL
|| DevicePath2
== NULL
) {
367 Acpi1
= (ACPI_HID_DEVICE_PATH
*) DevicePath1
;
368 Acpi2
= (ACPI_HID_DEVICE_PATH
*) DevicePath2
;
369 if (Acpi1
->HID
> Acpi2
->HID
|| (Acpi1
->HID
== Acpi2
->HID
&& Acpi1
->UID
> Acpi2
->UID
)) {
373 if (Acpi1
->HID
== Acpi2
->HID
&& Acpi1
->UID
== Acpi2
->UID
) {
381 Function to compare 2 PCI device paths.
383 @param[in] DevicePath1 The first device path to compare.
384 @param[in] DevicePath2 The second device path to compare.
386 @retval 0 The device paths represent the same device.
387 @return Non zero if the devices are different, zero otherwise.
392 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
393 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
396 PCI_DEVICE_PATH
*Pci1
;
397 PCI_DEVICE_PATH
*Pci2
;
399 ASSERT(DevicePath1
!= NULL
);
400 ASSERT(DevicePath2
!= NULL
);
402 Pci1
= (PCI_DEVICE_PATH
*) DevicePath1
;
403 Pci2
= (PCI_DEVICE_PATH
*) DevicePath2
;
404 if (Pci1
->Device
> Pci2
->Device
|| (Pci1
->Device
== Pci2
->Device
&& Pci1
->Function
> Pci2
->Function
)) {
408 if (Pci1
->Device
== Pci2
->Device
&& Pci1
->Function
== Pci2
->Function
) {
416 Do a comparison on 2 device paths.
418 @param[in] DevicePath1 The first device path.
419 @param[in] DevicePath2 The second device path.
421 @retval 0 The 2 device paths are the same.
422 @retval <0 DevicePath2 is greater than DevicePath1.
423 @retval >0 DevicePath1 is greater than DevicePath2.
427 DevPathCompareDefault (
428 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath1
,
429 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath2
435 ASSERT(DevicePath1
!= NULL
);
436 ASSERT(DevicePath2
!= NULL
);
438 DevPathSize1
= DevicePathNodeLength (DevicePath1
);
439 DevPathSize2
= DevicePathNodeLength (DevicePath2
);
440 if (DevPathSize1
> DevPathSize2
) {
442 } else if (DevPathSize1
< DevPathSize2
) {
445 return CompareMem (DevicePath1
, DevicePath2
, DevPathSize1
);
450 DevicePathNode must be SerialHDD Channel type and this will populate the MappingItem.
452 @param[in] DevicePathNode The node to get info on.
453 @param[in] MappingItem The info item to populate.
454 @param[in] DevicePath Ignored.
456 @retval EFI_OUT_OF_RESOURCES Out of resources.
457 @retval EFI_SUCCESS The appending was successful.
460 DevPathSerialHardDrive (
461 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
462 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
463 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
466 HARDDRIVE_DEVICE_PATH
*Hd
;
468 ASSERT(DevicePathNode
!= NULL
);
469 ASSERT(MappingItem
!= NULL
);
471 Hd
= (HARDDRIVE_DEVICE_PATH
*) DevicePathNode
;
472 if (MappingItem
->Mtd
== MTDTypeUnknown
) {
473 MappingItem
->Mtd
= MTDTypeHardDisk
;
476 return AppendCSDNum (MappingItem
, Hd
->PartitionNumber
);
480 DevicePathNode must be SerialAtapi Channel type and this will populate the MappingItem.
482 @param[in] DevicePathNode The node to get info on.
483 @param[in] MappingItem The info item to populate.
484 @param[in] DevicePath Ignored.
486 @retval EFI_OUT_OF_RESOURCES Out of resources.
487 @retval EFI_SUCCESS The appending was successful.
491 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
492 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
493 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
496 ATAPI_DEVICE_PATH
*Atapi
;
498 ASSERT(DevicePathNode
!= NULL
);
499 ASSERT(MappingItem
!= NULL
);
501 Atapi
= (ATAPI_DEVICE_PATH
*) DevicePathNode
;
502 return AppendCSDNum (MappingItem
, (Atapi
->PrimarySecondary
* 2 + Atapi
->SlaveMaster
));
506 DevicePathNode must be SerialCDROM Channel type and this will populate the MappingItem.
508 @param[in] DevicePathNode The node to get info on.
509 @param[in] MappingItem The info item to populate.
510 @param[in] DevicePath Ignored.
512 @retval EFI_OUT_OF_RESOURCES Out of resources.
513 @retval EFI_SUCCESS The appending was successful.
517 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
518 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
519 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
522 CDROM_DEVICE_PATH
*Cd
;
524 ASSERT(DevicePathNode
!= NULL
);
525 ASSERT(MappingItem
!= NULL
);
527 Cd
= (CDROM_DEVICE_PATH
*) DevicePathNode
;
528 MappingItem
->Mtd
= MTDTypeCDRom
;
529 return AppendCSDNum (MappingItem
, Cd
->BootEntry
);
533 DevicePathNode must be SerialFibre Channel type and this will populate the MappingItem.
535 @param[in] DevicePathNode The node to get info on.
536 @param[in] MappingItem The info item to populate.
537 @param[in] DevicePath Ignored.
539 @retval EFI_OUT_OF_RESOURCES Out of resources.
540 @retval EFI_SUCCESS The appending was successful.
544 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
545 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
546 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
550 FIBRECHANNEL_DEVICE_PATH
*Fibre
;
552 ASSERT(DevicePathNode
!= NULL
);
553 ASSERT(MappingItem
!= NULL
);
555 Fibre
= (FIBRECHANNEL_DEVICE_PATH
*) DevicePathNode
;
556 Status
= AppendCSDNum (MappingItem
, Fibre
->WWN
);
557 if (!EFI_ERROR (Status
)) {
558 Status
= AppendCSDNum (MappingItem
, Fibre
->Lun
);
564 DevicePathNode must be SerialUart type and this will populate the MappingItem.
566 @param[in] DevicePathNode The node to get info on.
567 @param[in] MappingItem The info item to populate.
568 @param[in] DevicePath Ignored.
570 @retval EFI_OUT_OF_RESOURCES Out of resources.
571 @retval EFI_SUCCESS The appending was successful.
575 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
576 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
577 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
581 UART_DEVICE_PATH
*Uart
;
583 ASSERT(DevicePathNode
!= NULL
);
584 ASSERT(MappingItem
!= NULL
);
586 Uart
= (UART_DEVICE_PATH
*) DevicePathNode
;
587 Status
= AppendCSDNum (MappingItem
, Uart
->BaudRate
);
588 if (!EFI_ERROR (Status
)) {
589 Status
= AppendCSDNum (MappingItem
, Uart
->DataBits
);
591 if (!EFI_ERROR (Status
)) {
592 Status
= AppendCSDNum (MappingItem
, Uart
->Parity
);
594 if (!EFI_ERROR (Status
)) {
595 Status
= AppendCSDNum (MappingItem
, Uart
->StopBits
);
601 DevicePathNode must be SerialUSB type and this will populate the MappingItem.
603 @param[in] DevicePathNode The node to get info on.
604 @param[in] MappingItem The info item to populate.
605 @param[in] DevicePath Ignored.
607 @retval EFI_OUT_OF_RESOURCES Out of resources.
608 @retval EFI_SUCCESS The appending was successful.
612 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
613 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
614 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
617 USB_DEVICE_PATH
*Usb
;
618 EFI_USB_IO_PROTOCOL
*UsbIo
;
619 EFI_HANDLE TempHandle
;
621 USB_INTERFACE_DESCRIPTOR InterfaceDesc
;
624 ASSERT(DevicePathNode
!= NULL
);
625 ASSERT(MappingItem
!= NULL
);
627 Usb
= (USB_DEVICE_PATH
*) DevicePathNode
;
628 Status
= AppendCSDNum (MappingItem
, Usb
->ParentPortNumber
);
629 if (!EFI_ERROR (Status
)) {
630 Status
= AppendCSDNum (MappingItem
, Usb
->InterfaceNumber
);
633 if (EFI_ERROR (Status
)) {
637 if (PcdGetBool(PcdUsbExtendedDecode
)) {
638 Status
= gBS
->LocateDevicePath( &gEfiUsbIoProtocolGuid
, &DevicePath
, &TempHandle
);
640 if (!EFI_ERROR(Status
)) {
641 Status
= gBS
->OpenProtocol(TempHandle
, &gEfiUsbIoProtocolGuid
, (VOID
**)&UsbIo
, gImageHandle
, NULL
, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
644 if (!EFI_ERROR(Status
)) {
645 ASSERT(UsbIo
!= NULL
);
646 Status
= UsbIo
->UsbGetInterfaceDescriptor(UsbIo
, &InterfaceDesc
);
647 if (!EFI_ERROR(Status
)) {
648 if (InterfaceDesc
.InterfaceClass
== USB_MASS_STORE_CLASS
&& MappingItem
->Mtd
== MTDTypeUnknown
) {
649 switch (InterfaceDesc
.InterfaceSubClass
){
650 case USB_MASS_STORE_SCSI
:
651 MappingItem
->Mtd
= MTDTypeHardDisk
;
653 case USB_MASS_STORE_8070I
:
654 case USB_MASS_STORE_UFI
:
655 MappingItem
->Mtd
= MTDTypeFloppy
;
657 case USB_MASS_STORE_8020I
:
658 MappingItem
->Mtd
= MTDTypeCDRom
;
669 DevicePathNode must be SerialVendor type and this will populate the MappingItem.
671 @param[in] DevicePathNode The node to get info on.
672 @param[in] MappingItem The info item to populate.
673 @param[in] DevicePath Ignored.
675 @retval EFI_OUT_OF_RESOURCES Out of resources.
676 @retval EFI_SUCCESS The appending was successful.
679 DevPathSerialVendor (
680 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
681 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
682 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
686 VENDOR_DEVICE_PATH
*Vendor
;
687 SAS_DEVICE_PATH
*Sas
;
688 UINTN TargetNameLength
;
693 ASSERT(DevicePathNode
!= NULL
);
694 ASSERT(MappingItem
!= NULL
);
696 Vendor
= (VENDOR_DEVICE_PATH
*) DevicePathNode
;
697 Status
= AppendCSDGuid (MappingItem
, &Vendor
->Guid
);
698 if (EFI_ERROR (Status
)) {
702 if (CompareGuid (&gEfiSasDevicePathGuid
, &Vendor
->Guid
)) {
703 Sas
= (SAS_DEVICE_PATH
*) Vendor
;
704 Status
= AppendCSDNum (MappingItem
, Sas
->SasAddress
);
705 if (!EFI_ERROR (Status
)) {
706 Status
= AppendCSDNum (MappingItem
, Sas
->Lun
);
708 if (!EFI_ERROR (Status
)) {
709 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
;
738 // Append the new data block
740 if (!EFI_ERROR (Status
)) {
741 Status
= AppendCSDStr (MappingItem
, Buffer
);
751 DevicePathNode must be SerialLun type and this will populate the MappingItem.
753 @param[in] DevicePathNode The node to get info on.
754 @param[in] MappingItem The info item to populate.
755 @param[in] DevicePath Ignored.
757 @retval EFI_OUT_OF_RESOURCES Out of resources.
758 @retval EFI_SUCCESS The appending was successful.
762 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
763 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
764 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
767 DEVICE_LOGICAL_UNIT_DEVICE_PATH
*Lun
;
769 ASSERT(DevicePathNode
!= NULL
);
770 ASSERT(MappingItem
!= NULL
);
772 Lun
= (DEVICE_LOGICAL_UNIT_DEVICE_PATH
*) DevicePathNode
;
773 return AppendCSDNum (MappingItem
, Lun
->Lun
);
777 DevicePathNode must be SerialSata type and this will populate the MappingItem.
779 @param[in] DevicePathNode The node to get info on.
780 @param[in] MappingItem The info item to populate.
781 @param[in] DevicePath Ignored.
783 @retval EFI_OUT_OF_RESOURCES Out of resources.
784 @retval EFI_SUCCESS The appending was successful.
788 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
789 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
790 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
794 SATA_DEVICE_PATH
*Sata
;
796 ASSERT(DevicePathNode
!= NULL
);
797 ASSERT(MappingItem
!= NULL
);
799 Sata
= (SATA_DEVICE_PATH
*) DevicePathNode
;
800 Status
= AppendCSDNum (MappingItem
, Sata
->HBAPortNumber
);
801 if (!EFI_ERROR (Status
)) {
802 Status
= AppendCSDNum (MappingItem
, Sata
->PortMultiplierPortNumber
);
804 if (!EFI_ERROR (Status
)) {
805 Status
= AppendCSDNum (MappingItem
, Sata
->Lun
);
811 DevicePathNode must be SerialSCSI type and this will populate the MappingItem.
813 @param[in] DevicePathNode The node to get info on.
814 @param[in] MappingItem The info item to populate.
815 @param[in] DevicePath Ignored.
817 @retval EFI_OUT_OF_RESOURCES Out of resources.
818 @retval EFI_SUCCESS The appending was successful.
822 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
823 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
824 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
828 ISCSI_DEVICE_PATH
*IScsi
;
829 UINT8
*IScsiTargetName
;
831 UINTN TargetNameLength
;
834 ASSERT(DevicePathNode
!= NULL
);
835 ASSERT(MappingItem
!= NULL
);
837 Status
= EFI_SUCCESS
;
839 if (PcdGetBool(PcdShellDecodeIScsiMapNames
)) {
840 IScsi
= (ISCSI_DEVICE_PATH
*) DevicePathNode
;
841 Status
= AppendCSDNum (MappingItem
, IScsi
->NetworkProtocol
);
842 if (!EFI_ERROR (Status
)) {
843 Status
= AppendCSDNum (MappingItem
, IScsi
->LoginOption
);
845 if (!EFI_ERROR (Status
)) {
846 Status
= AppendCSDNum (MappingItem
, IScsi
->Lun
);
848 if (!EFI_ERROR (Status
)) {
849 Status
= AppendCSDNum (MappingItem
, IScsi
->TargetPortalGroupTag
);
851 if (EFI_ERROR (Status
)) {
854 TargetNameLength
= DevicePathNodeLength (DevicePathNode
) - sizeof (ISCSI_DEVICE_PATH
);
855 if (TargetNameLength
> 0) {
856 TargetName
= AllocateZeroPool ((TargetNameLength
+ 1) * sizeof (CHAR16
));
857 if (TargetName
== NULL
) {
858 Status
= EFI_OUT_OF_RESOURCES
;
860 IScsiTargetName
= (UINT8
*) (IScsi
+ 1);
861 for (Index
= 0; Index
< TargetNameLength
; Index
++) {
862 TargetName
[Index
] = (CHAR16
) IScsiTargetName
[Index
];
864 Status
= AppendCSDStr (MappingItem
, TargetName
);
865 FreePool (TargetName
);
873 DevicePathNode must be SerialI20 type and this will populate the MappingItem.
875 @param[in] DevicePathNode The node to get info on.
876 @param[in] MappingItem The info item to populate.
877 @param[in] DevicePath Ignored.
879 @retval EFI_OUT_OF_RESOURCES Out of resources.
880 @retval EFI_SUCCESS The appending was successful.
884 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
885 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
886 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
889 I2O_DEVICE_PATH
*DevicePath_I20
;
891 ASSERT(DevicePathNode
!= NULL
);
892 ASSERT(MappingItem
!= NULL
);
894 DevicePath_I20
= (I2O_DEVICE_PATH
*) DevicePathNode
;
895 return AppendCSDNum (MappingItem
, DevicePath_I20
->Tid
);
899 DevicePathNode must be Mac Address type and this will populate the MappingItem.
901 @param[in] DevicePathNode The node to get info on.
902 @param[in] MappingItem The info item to populate.
903 @param[in] DevicePath Ignored.
905 @retval EFI_OUT_OF_RESOURCES Out of resources.
906 @retval EFI_SUCCESS The appending was successful.
909 DevPathSerialMacAddr (
910 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
911 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
912 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
915 MAC_ADDR_DEVICE_PATH
*Mac
;
921 ASSERT(DevicePathNode
!= NULL
);
922 ASSERT(MappingItem
!= NULL
);
924 Mac
= (MAC_ADDR_DEVICE_PATH
*) DevicePathNode
;
926 HwAddressSize
= sizeof (EFI_MAC_ADDRESS
);
927 if (Mac
->IfType
== 0x01 || Mac
->IfType
== 0x00) {
931 for (Index
= 0, PBuffer
= Buffer
; Index
< HwAddressSize
; Index
++, PBuffer
+= 2) {
932 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) Mac
->MacAddress
.Addr
[Index
]);
935 return AppendCSDStr (MappingItem
, Buffer
);
939 DevicePathNode must be InfiniBand type and this will populate the MappingItem.
941 @param[in] DevicePathNode The node to get info on.
942 @param[in] MappingItem The info item to populate.
943 @param[in] DevicePath Ignored.
945 @retval EFI_OUT_OF_RESOURCES Out of resources.
946 @retval EFI_SUCCESS The appending was successful.
949 DevPathSerialInfiniBand (
950 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
951 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
952 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
956 INFINIBAND_DEVICE_PATH
*InfiniBand
;
961 ASSERT(DevicePathNode
!= NULL
);
962 ASSERT(MappingItem
!= NULL
);
964 InfiniBand
= (INFINIBAND_DEVICE_PATH
*) DevicePathNode
;
965 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
966 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) InfiniBand
->PortGid
[Index
]);
969 Status
= AppendCSDStr (MappingItem
, Buffer
);
970 if (!EFI_ERROR (Status
)) {
971 Status
= AppendCSDNum (MappingItem
, InfiniBand
->ServiceId
);
973 if (!EFI_ERROR (Status
)) {
974 Status
= AppendCSDNum (MappingItem
, InfiniBand
->TargetPortId
);
976 if (!EFI_ERROR (Status
)) {
977 Status
= AppendCSDNum (MappingItem
, InfiniBand
->DeviceId
);
983 DevicePathNode must be IPv4 type and this will populate the MappingItem.
985 @param[in] DevicePathNode The node to get info on.
986 @param[in] MappingItem The info item to populate.
987 @param[in] DevicePath Ignored.
989 @retval EFI_OUT_OF_RESOURCES Out of resources.
990 @retval EFI_SUCCESS The appending was successful.
994 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
995 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
996 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1000 IPv4_DEVICE_PATH
*Ip
;
1003 ASSERT(DevicePathNode
!= NULL
);
1004 ASSERT(MappingItem
!= NULL
);
1006 Ip
= (IPv4_DEVICE_PATH
*) DevicePathNode
;
1010 L
"%02x%02x%02x%02x",
1011 (UINTN
) Ip
->LocalIpAddress
.Addr
[0],
1012 (UINTN
) Ip
->LocalIpAddress
.Addr
[1],
1013 (UINTN
) Ip
->LocalIpAddress
.Addr
[2],
1014 (UINTN
) Ip
->LocalIpAddress
.Addr
[3]
1016 Status
= AppendCSDStr (MappingItem
, Buffer
);
1017 if (!EFI_ERROR (Status
)) {
1018 Status
= AppendCSDNum (MappingItem
, Ip
->LocalPort
);
1020 if (!EFI_ERROR (Status
)) {
1024 L
"%02x%02x%02x%02x",
1025 (UINTN
) Ip
->RemoteIpAddress
.Addr
[0],
1026 (UINTN
) Ip
->RemoteIpAddress
.Addr
[1],
1027 (UINTN
) Ip
->RemoteIpAddress
.Addr
[2],
1028 (UINTN
) Ip
->RemoteIpAddress
.Addr
[3]
1030 Status
= AppendCSDStr (MappingItem
, Buffer
);
1032 if (!EFI_ERROR (Status
)) {
1033 Status
= AppendCSDNum (MappingItem
, Ip
->RemotePort
);
1039 DevicePathNode must be IPv6 type and this will populate the MappingItem.
1041 @param[in] DevicePathNode The node to get info on.
1042 @param[in] MappingItem The info item to populate.
1043 @param[in] DevicePath Ignored.
1045 @retval EFI_OUT_OF_RESOURCES Out of resources.
1046 @retval EFI_SUCCESS The appending was successful.
1050 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1051 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1052 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1056 IPv6_DEVICE_PATH
*Ip
;
1061 ASSERT(DevicePathNode
!= NULL
);
1062 ASSERT(MappingItem
!= NULL
);
1064 Ip
= (IPv6_DEVICE_PATH
*) DevicePathNode
;
1065 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
1066 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) Ip
->LocalIpAddress
.Addr
[Index
]);
1069 Status
= AppendCSDStr (MappingItem
, Buffer
);
1070 if (!EFI_ERROR (Status
)) {
1071 Status
= AppendCSDNum (MappingItem
, Ip
->LocalPort
);
1073 if (!EFI_ERROR (Status
)) {
1074 for (Index
= 0, PBuffer
= Buffer
; Index
< 16; Index
++, PBuffer
+= 2) {
1075 UnicodeSPrint (PBuffer
, 0, L
"%02x", (UINTN
) Ip
->RemoteIpAddress
.Addr
[Index
]);
1078 Status
= AppendCSDStr (MappingItem
, Buffer
);
1080 if (!EFI_ERROR (Status
)) {
1081 Status
= AppendCSDNum (MappingItem
, Ip
->RemotePort
);
1087 DevicePathNode must be SCSI type and this will populate the MappingItem.
1089 @param[in] DevicePathNode The node to get info on.
1090 @param[in] MappingItem The info item to populate.
1091 @param[in] DevicePath Ignored.
1093 @retval EFI_OUT_OF_RESOURCES Out of resources.
1094 @retval EFI_SUCCESS The appending was successful.
1098 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1099 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1100 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1104 SCSI_DEVICE_PATH
*Scsi
;
1106 ASSERT(DevicePathNode
!= NULL
);
1107 ASSERT(MappingItem
!= NULL
);
1109 Scsi
= (SCSI_DEVICE_PATH
*) DevicePathNode
;
1110 Status
= AppendCSDNum (MappingItem
, Scsi
->Pun
);
1111 if (!EFI_ERROR (Status
)) {
1112 Status
= AppendCSDNum (MappingItem
, Scsi
->Lun
);
1118 DevicePathNode must be 1394 type and this will populate the MappingItem.
1120 @param[in] DevicePathNode The node to get info on.
1121 @param[in] MappingItem The info item to populate.
1122 @param[in] DevicePath Ignored.
1124 @retval EFI_OUT_OF_RESOURCES Out of resources.
1125 @retval EFI_SUCCESS The appending was successful.
1129 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1130 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1131 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1134 F1394_DEVICE_PATH
*DevicePath_F1394
;
1137 ASSERT(DevicePathNode
!= NULL
);
1138 ASSERT(MappingItem
!= NULL
);
1140 DevicePath_F1394
= (F1394_DEVICE_PATH
*) DevicePathNode
;
1141 UnicodeSPrint (Buffer
, 0, L
"%lx", DevicePath_F1394
->Guid
);
1142 return AppendCSDStr (MappingItem
, Buffer
);
1146 If the node is floppy type then populate the MappingItem.
1148 @param[in] DevicePathNode The node to get info on.
1149 @param[in] MappingItem The info item to populate.
1150 @param[in] DevicePath Ignored.
1152 @retval EFI_OUT_OF_RESOURCES Out of resources.
1153 @retval EFI_SUCCESS The appending was successful.
1157 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1158 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1159 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1162 ACPI_HID_DEVICE_PATH
*Acpi
;
1164 ASSERT(DevicePathNode
!= NULL
);
1165 ASSERT(MappingItem
!= NULL
);
1167 Acpi
= (ACPI_HID_DEVICE_PATH
*) DevicePathNode
;
1168 if ((Acpi
->HID
& PNP_EISA_ID_MASK
) == PNP_EISA_ID_CONST
) {
1169 if (EISA_ID_TO_NUM (Acpi
->HID
) == 0x0604) {
1170 MappingItem
->Mtd
= MTDTypeFloppy
;
1171 return AppendCSDNum (MappingItem
, Acpi
->UID
);
1178 Empty function used for unknown devices.
1180 @param[in] DevicePathNode Ignored.
1181 @param[in] MappingItem Ignored.
1182 @param[in] DevicePath Ignored.
1184 @retval EFI_OUT_OF_RESOURCES Out of resources.
1185 @retval EFI_SUCCESS The appending was successful.
1188 DevPathSerialDefault (
1189 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePathNode
,
1190 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1191 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1197 DEV_PATH_CONSIST_MAPPING_TABLE DevPathConsistMappingTable
[] = {
1199 HARDWARE_DEVICE_PATH
,
1201 DevPathSerialDefault
,
1211 MESSAGING_DEVICE_PATH
,
1214 DevPathCompareDefault
1217 MESSAGING_DEVICE_PATH
,
1220 DevPathCompareDefault
1223 MESSAGING_DEVICE_PATH
,
1224 MSG_FIBRECHANNEL_DP
,
1226 DevPathCompareDefault
1229 MESSAGING_DEVICE_PATH
,
1232 DevPathCompareDefault
1235 MESSAGING_DEVICE_PATH
,
1238 DevPathCompareDefault
1241 MESSAGING_DEVICE_PATH
,
1244 DevPathCompareDefault
1247 MESSAGING_DEVICE_PATH
,
1249 DevPathSerialMacAddr
,
1250 DevPathCompareDefault
1253 MESSAGING_DEVICE_PATH
,
1256 DevPathCompareDefault
1259 MESSAGING_DEVICE_PATH
,
1262 DevPathCompareDefault
1265 MESSAGING_DEVICE_PATH
,
1267 DevPathSerialInfiniBand
,
1268 DevPathCompareDefault
1271 MESSAGING_DEVICE_PATH
,
1274 DevPathCompareDefault
1277 MESSAGING_DEVICE_PATH
,
1279 DevPathSerialVendor
,
1280 DevPathCompareDefault
1283 MESSAGING_DEVICE_PATH
,
1284 MSG_DEVICE_LOGICAL_UNIT_DP
,
1286 DevPathCompareDefault
1289 MESSAGING_DEVICE_PATH
,
1292 DevPathCompareDefault
1295 MESSAGING_DEVICE_PATH
,
1298 DevPathCompareDefault
1303 DevPathSerialHardDrive
,
1304 DevPathCompareDefault
1310 DevPathCompareDefault
1315 DevPathSerialVendor
,
1316 DevPathCompareDefault
1327 Function to determine if a device path node is Hi or not.
1329 @param[in] DevicePathNode The node to check.
1331 @retval TRUE The node is Hi.
1332 @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
*
1374 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1377 UINTN NonHIDevicePathNodeCount
;
1380 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1381 EFI_DEVICE_PATH_PROTOCOL
*TempDevicePath
;
1383 ASSERT(DevicePath
!= NULL
);
1385 NonHIDevicePathNodeCount
= 0;
1387 HIDevicePath
= AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL
));
1388 SetDevicePathEndNode (HIDevicePath
);
1390 Node
.DevPath
.Type
= END_DEVICE_PATH_TYPE
;
1391 Node
.DevPath
.SubType
= END_INSTANCE_DEVICE_PATH_SUBTYPE
;
1392 Node
.DevPath
.Length
[0] = (UINT8
)sizeof (EFI_DEVICE_PATH_PROTOCOL
);
1393 Node
.DevPath
.Length
[1] = 0;
1395 while (!IsDevicePathEnd (DevicePath
)) {
1396 if (IsHIDevicePathNode (DevicePath
)) {
1397 for (Index
= 0; Index
< NonHIDevicePathNodeCount
; Index
++) {
1398 TempDevicePath
= AppendDevicePathNode (HIDevicePath
, &Node
.DevPath
);
1399 FreePool (HIDevicePath
);
1400 HIDevicePath
= TempDevicePath
;
1403 TempDevicePath
= AppendDevicePathNode (HIDevicePath
, DevicePath
);
1404 FreePool (HIDevicePath
);
1405 HIDevicePath
= TempDevicePath
;
1407 NonHIDevicePathNodeCount
++;
1410 // Next device path node
1412 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (DevicePath
);
1415 return HIDevicePath
;
1419 Function to walk the device path looking for a dumpable node.
1421 @param[in] MappingItem The Item to fill with data.
1422 @param[in] DevicePath The path of the item to get data on.
1424 @return EFI_SUCCESS Always returns success.
1428 GetDeviceConsistMappingInfo (
1429 IN DEVICE_CONSIST_MAPPING_INFO
*MappingItem
,
1430 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
1434 SERIAL_DECODE_FUNCTION SerialFun
;
1436 EFI_DEVICE_PATH_PROTOCOL
*OriginalDevicePath
;
1438 ASSERT(DevicePath
!= NULL
);
1439 ASSERT(MappingItem
!= NULL
);
1441 SetMem (&MappingItem
->Csd
, sizeof (POOL_PRINT
), 0);
1442 OriginalDevicePath
= DevicePath
;
1444 while (!IsDevicePathEnd (DevicePath
)) {
1446 // Find the handler to dump this device path node and
1447 // initialize with generic function in case nothing is found
1449 for (SerialFun
= DevPathSerialDefault
, Index
= 0; DevPathConsistMappingTable
[Index
].SerialFun
!= NULL
; Index
+= 1) {
1451 if (DevicePathType (DevicePath
) == DevPathConsistMappingTable
[Index
].Type
&&
1452 DevicePathSubType (DevicePath
) == DevPathConsistMappingTable
[Index
].SubType
1454 SerialFun
= DevPathConsistMappingTable
[Index
].SerialFun
;
1459 Status
= SerialFun (DevicePath
, MappingItem
, OriginalDevicePath
);
1460 if (EFI_ERROR (Status
)) {
1461 SHELL_FREE_NON_NULL (MappingItem
->Csd
.Str
);
1466 // Next device path node
1468 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) NextDevicePathNode (DevicePath
);
1475 Function to initialize the table for creating consistent map names.
1477 @param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.
1479 @retval EFI_SUCCESS The table was created successfully.
1483 ShellCommandConsistMappingInitialize (
1484 OUT EFI_DEVICE_PATH_PROTOCOL
***Table
1487 EFI_HANDLE
*HandleBuffer
;
1490 EFI_DEVICE_PATH_PROTOCOL
**TempTable
;
1491 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
1492 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1493 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
1494 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFileSystem
;
1498 HandleBuffer
= NULL
;
1500 Status
= gBS
->LocateHandleBuffer (
1502 &gEfiDevicePathProtocolGuid
,
1507 ASSERT_EFI_ERROR(Status
);
1509 TempTable
= AllocateZeroPool ((HandleNum
+ 1) * sizeof (EFI_DEVICE_PATH_PROTOCOL
*));
1510 if (TempTable
== NULL
) {
1511 return EFI_OUT_OF_RESOURCES
;
1514 for (HandleLoop
= 0 ; HandleLoop
< HandleNum
; HandleLoop
++) {
1515 DevicePath
= DevicePathFromHandle (HandleBuffer
[HandleLoop
]);
1516 if (DevicePath
== NULL
) {
1520 HIDevicePath
= GetHIDevicePath (DevicePath
);
1521 if (HIDevicePath
== NULL
) {
1525 Status
= gBS
->HandleProtocol( HandleBuffer
[HandleLoop
],
1526 &gEfiBlockIoProtocolGuid
,
1529 if (EFI_ERROR(Status
)) {
1530 Status
= gBS
->HandleProtocol( HandleBuffer
[HandleLoop
],
1531 &gEfiSimpleFileSystemProtocolGuid
,
1532 (VOID
**)&SimpleFileSystem
1534 if (EFI_ERROR(Status
)) {
1535 FreePool (HIDevicePath
);
1540 for (Index
= 0; TempTable
[Index
] != NULL
; Index
++) {
1541 if (DevicePathCompare (&TempTable
[Index
], &HIDevicePath
) == 0) {
1542 FreePool (HIDevicePath
);
1547 if (TempTable
[Index
] == NULL
) {
1548 TempTable
[Index
] = HIDevicePath
;
1552 for (Index
= 0; TempTable
[Index
] != NULL
; Index
++);
1553 PerformQuickSort(TempTable
, Index
, sizeof(EFI_DEVICE_PATH_PROTOCOL
*), DevicePathCompare
);
1556 if (HandleBuffer
!= NULL
) {
1557 FreePool (HandleBuffer
);
1564 Function to uninitialize the table for creating consistent map names.
1566 The parameter must have been received from ShellCommandConsistMappingInitialize.
1568 @param[out] Table The pointer to pointer to DevicePathProtocol object.
1570 @retval EFI_SUCCESS The table was deleted successfully.
1574 ShellCommandConsistMappingUnInitialize (
1575 EFI_DEVICE_PATH_PROTOCOL
**Table
1580 ASSERT(Table
!= NULL
);
1582 for (Index
= 0; Table
[Index
] != NULL
; Index
++) {
1583 FreePool (Table
[Index
]);
1591 Create a consistent mapped name for the device specified by DevicePath
1594 This must be called after ShellCommandConsistMappingInitialize() and
1595 before ShellCommandConsistMappingUnInitialize() is called.
1597 @param[in] DevicePath The pointer to the dev path for the device.
1598 @param[in] Table The Table of mapping information.
1600 @retval NULL A consistent mapped name could not be created.
1601 @return A pointer to a string allocated from pool with the device name.
1605 ShellCommandConsistMappingGenMappingName (
1606 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1607 IN EFI_DEVICE_PATH_PROTOCOL
**Table
1612 DEVICE_CONSIST_MAPPING_INFO MappingInfo
;
1613 EFI_DEVICE_PATH_PROTOCOL
*HIDevicePath
;
1617 ASSERT(DevicePath
!= NULL
);
1618 ASSERT(Table
!= NULL
);
1620 HIDevicePath
= GetHIDevicePath (DevicePath
);
1621 if (HIDevicePath
== NULL
) {
1625 for (Index
= 0; Table
[Index
] != NULL
; Index
++) {
1626 if (DevicePathCompare (&Table
[Index
], &HIDevicePath
) == 0) {
1631 FreePool (HIDevicePath
);
1632 if (Table
[Index
] == NULL
) {
1636 MappingInfo
.Hi
= Index
;
1637 MappingInfo
.Mtd
= MTDTypeUnknown
;
1638 MappingInfo
.Digital
= FALSE
;
1640 Status
= GetDeviceConsistMappingInfo (&MappingInfo
, DevicePath
);
1641 if (EFI_ERROR (Status
)) {
1645 SetMem (&Str
, sizeof (Str
), 0);
1646 for (Index
= 0; mMTDName
[Index
].MTDType
!= MTDTypeEnd
; Index
++) {
1647 if (MappingInfo
.Mtd
== mMTDName
[Index
].MTDType
) {
1652 if (mMTDName
[Index
].MTDType
!= MTDTypeEnd
) {
1653 Status
= CatPrint (&Str
, L
"%s", mMTDName
[Index
].Name
);
1656 if (!EFI_ERROR (Status
)) {
1657 Status
= CatPrint (&Str
, L
"%d", (UINTN
) MappingInfo
.Hi
);
1659 if (!EFI_ERROR (Status
) && MappingInfo
.Csd
.Str
!= NULL
) {
1660 Status
= CatPrint (&Str
, L
"%s", MappingInfo
.Csd
.Str
);
1661 FreePool (MappingInfo
.Csd
.Str
);
1664 if (!EFI_ERROR (Status
) && Str
.Str
!= NULL
) {
1665 Status
= CatPrint (&Str
, L
":");
1667 if (EFI_ERROR (Status
)) {
1668 SHELL_FREE_NON_NULL (Str
.Str
);
1672 NewStr
= ReallocatePool (Str
.Len
* sizeof (CHAR16
), (Str
.Len
+ 1) * sizeof (CHAR16
), Str
.Str
);
1673 if (NewStr
== NULL
) {
1674 SHELL_FREE_NON_NULL (Str
.Str
);
1677 NewStr
[Str
.Len
] = CHAR_NULL
;
1682 Function to search the list of mappings for the node on the list based on the key.
1684 @param[in] MapKey String Key to search for on the map
1686 @return the node on the list.
1690 ShellCommandFindMapItem (
1691 IN CONST CHAR16
*MapKey
1694 SHELL_MAP_LIST
*MapListItem
;
1696 for ( MapListItem
= (SHELL_MAP_LIST
*)GetFirstNode(&gShellMapList
.Link
)
1697 ; !IsNull(&gShellMapList
.Link
, &MapListItem
->Link
)
1698 ; MapListItem
= (SHELL_MAP_LIST
*)GetNextNode(&gShellMapList
.Link
, &MapListItem
->Link
)
1700 if (gUnicodeCollation
->StriColl(gUnicodeCollation
,MapListItem
->MapName
,(CHAR16
*)MapKey
) == 0) {
1701 return (MapListItem
);