2010-09-14 07:18:09 +02:00
|
|
|
/** @file
|
|
|
|
Main file for support of shell consist mapping.
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
|
2010-09-14 07:18:09 +02:00
|
|
|
This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "UefiShellCommandLib.h"
|
|
|
|
#include <Library/DevicePathLib.h>
|
|
|
|
#include <Library/SortLib.h>
|
2014-11-24 15:50:14 +01:00
|
|
|
#include <Library/UefiLib.h>
|
2014-11-24 15:58:33 +01:00
|
|
|
#include <Protocol/UsbIo.h>
|
2015-12-08 03:00:16 +01:00
|
|
|
#include <Protocol/BlockIo.h>
|
|
|
|
#include <Protocol/SimpleFileSystem.h>
|
|
|
|
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
MTDTypeUnknown,
|
|
|
|
MTDTypeFloppy,
|
|
|
|
MTDTypeHardDisk,
|
|
|
|
MTDTypeCDRom,
|
|
|
|
MTDTypeEnd
|
|
|
|
} MTD_TYPE;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
CHAR16 *Str;
|
|
|
|
UINTN Len;
|
|
|
|
} POOL_PRINT;
|
|
|
|
|
|
|
|
typedef struct {
|
2011-03-25 22:09:21 +01:00
|
|
|
UINTN Hi;
|
|
|
|
MTD_TYPE Mtd;
|
|
|
|
POOL_PRINT Csd;
|
2010-09-14 07:18:09 +02:00
|
|
|
BOOLEAN Digital;
|
|
|
|
} DEVICE_CONSIST_MAPPING_INFO;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
MTD_TYPE MTDType;
|
|
|
|
CHAR16 *Name;
|
|
|
|
} MTD_NAME;
|
|
|
|
|
2014-12-12 01:45:05 +01:00
|
|
|
/**
|
|
|
|
Serial Decode function.
|
|
|
|
|
|
|
|
@param DevPath The Device path info.
|
|
|
|
@param MapInfo The map info.
|
|
|
|
@param OrigDevPath The original device path protocol.
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2014-12-12 01:45:05 +01:00
|
|
|
**/
|
|
|
|
typedef
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
|
|
|
(*SERIAL_DECODE_FUNCTION) (
|
2014-12-12 01:45:05 +01:00
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevPath,
|
|
|
|
DEVICE_CONSIST_MAPPING_INFO *MapInfo,
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *OrigDevPath
|
|
|
|
);
|
2014-11-24 15:58:33 +01:00
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
typedef struct {
|
|
|
|
UINT8 Type;
|
|
|
|
UINT8 SubType;
|
2014-12-12 01:45:05 +01:00
|
|
|
SERIAL_DECODE_FUNCTION SerialFun;
|
2011-03-25 22:09:21 +01:00
|
|
|
INTN (EFIAPI *CompareFun) (EFI_DEVICE_PATH_PROTOCOL *DevPath, EFI_DEVICE_PATH_PROTOCOL *DevPath2);
|
2010-09-14 07:18:09 +02:00
|
|
|
} DEV_PATH_CONSIST_MAPPING_TABLE;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Concatenates a formatted unicode string to allocated pool.
|
|
|
|
The caller must free the resulting buffer.
|
|
|
|
|
|
|
|
@param Str Tracks the allocated pool, size in use, and amount of pool allocated.
|
|
|
|
@param Fmt The format string
|
|
|
|
@param ... The data will be printed.
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_SUCCESS The string is concatenated successfully.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2016-08-03 11:43:06 +02:00
|
|
|
EFIAPI
|
2010-09-14 07:18:09 +02:00
|
|
|
CatPrint (
|
|
|
|
IN OUT POOL_PRINT *Str,
|
|
|
|
IN CHAR16 *Fmt,
|
|
|
|
...
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT16 *AppendStr;
|
|
|
|
VA_LIST Args;
|
|
|
|
UINTN StringSize;
|
2016-07-12 09:01:17 +02:00
|
|
|
CHAR16 *NewStr;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
AppendStr = AllocateZeroPool (0x1000);
|
|
|
|
if (AppendStr == NULL) {
|
2016-07-12 09:01:17 +02:00
|
|
|
return EFI_OUT_OF_RESOURCES;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VA_START (Args, Fmt);
|
|
|
|
UnicodeVSPrint (AppendStr, 0x1000, Fmt, Args);
|
|
|
|
VA_END (Args);
|
|
|
|
if (NULL == Str->Str) {
|
2016-07-12 09:01:17 +02:00
|
|
|
StringSize = StrSize (AppendStr);
|
|
|
|
NewStr = AllocateZeroPool (StringSize);
|
2010-09-14 07:18:09 +02:00
|
|
|
} else {
|
|
|
|
StringSize = StrSize (AppendStr);
|
|
|
|
StringSize += (StrSize (Str->Str) - sizeof (UINT16));
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
NewStr = ReallocatePool (
|
|
|
|
StrSize (Str->Str),
|
|
|
|
StringSize,
|
|
|
|
Str->Str
|
2010-09-14 07:18:09 +02:00
|
|
|
);
|
2016-07-12 09:01:17 +02:00
|
|
|
}
|
|
|
|
if (NewStr == NULL) {
|
|
|
|
FreePool (AppendStr);
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
Str->Str = NewStr;
|
2015-06-30 05:18:31 +02:00
|
|
|
StrCatS (Str->Str, StringSize/sizeof(CHAR16), AppendStr);
|
2010-09-14 07:18:09 +02:00
|
|
|
Str->Len = StringSize;
|
|
|
|
|
|
|
|
FreePool (AppendStr);
|
2016-07-12 09:01:17 +02:00
|
|
|
return EFI_SUCCESS;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MTD_NAME mMTDName[] = {
|
|
|
|
{
|
|
|
|
MTDTypeUnknown,
|
|
|
|
L"F"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MTDTypeFloppy,
|
|
|
|
L"FP"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MTDTypeHardDisk,
|
|
|
|
L"HD"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MTDTypeCDRom,
|
|
|
|
L"CD"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MTDTypeEnd,
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
/**
|
|
|
|
Function to append a 64 bit number / 25 onto the string.
|
|
|
|
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] Str The string so append onto.
|
|
|
|
@param[in] Num The number to divide and append.
|
2011-03-25 22:09:21 +01:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
2011-03-25 22:09:21 +01:00
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
AppendCSDNum2 (
|
|
|
|
IN OUT POOL_PRINT *Str,
|
|
|
|
IN UINT64 Num
|
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
UINT64 Result;
|
|
|
|
UINT32 Rem;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
ASSERT (Str != NULL);
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
Result = DivU64x32Remainder (Num, 25, &Rem);
|
|
|
|
if (Result > 0) {
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDNum2 (Str, Result);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
return CatPrint (Str, L"%c", Rem + 'a');
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
/**
|
|
|
|
Function to append a 64 bit number onto the mapping info.
|
|
|
|
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] MappingItem The mapping info object to append onto.
|
|
|
|
@param[in] Num The info to append.
|
2011-03-25 22:09:21 +01:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
2011-03-25 22:09:21 +01:00
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
AppendCSDNum (
|
2011-03-25 22:09:21 +01:00
|
|
|
IN OUT DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN UINT64 Num
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
ASSERT (MappingItem != NULL);
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
if (MappingItem->Digital) {
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = CatPrint (&MappingItem->Csd, L"%ld", Num);
|
2010-09-14 07:18:09 +02:00
|
|
|
} else {
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDNum2 (&MappingItem->Csd, Num);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
MappingItem->Digital = (BOOLEAN) !(MappingItem->Digital);
|
|
|
|
}
|
2011-03-25 22:09:21 +01:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
/**
|
|
|
|
Function to append string into the mapping info.
|
|
|
|
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] MappingItem The mapping info object to append onto.
|
|
|
|
@param[in] Str The info to append.
|
2011-03-25 22:09:21 +01:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
2011-03-25 22:09:21 +01:00
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
AppendCSDStr (
|
2011-03-25 22:09:21 +01:00
|
|
|
IN OUT DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN CHAR16 *Str
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
CHAR16 *Index;
|
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
ASSERT (Str != NULL && MappingItem != NULL);
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
if (MappingItem->Digital) {
|
|
|
|
//
|
|
|
|
// To aVOID mult-meaning, the mapping is:
|
|
|
|
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
|
|
|
// 0 16 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
|
|
//
|
|
|
|
for (Index = Str; *Index != 0; Index++) {
|
|
|
|
switch (*Index) {
|
|
|
|
case '0':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
case '8':
|
|
|
|
case '9':
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = CatPrint (&MappingItem->Csd, L"%c", *Index);
|
2010-09-14 07:18:09 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case '1':
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = CatPrint (&MappingItem->Csd, L"16");
|
2010-09-14 07:18:09 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'a':
|
|
|
|
case 'b':
|
|
|
|
case 'c':
|
|
|
|
case 'd':
|
|
|
|
case 'e':
|
|
|
|
case 'f':
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = CatPrint (&MappingItem->Csd, L"1%c", *Index - 'a' + '0');
|
2010-09-14 07:18:09 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'A':
|
|
|
|
case 'B':
|
|
|
|
case 'C':
|
|
|
|
case 'D':
|
|
|
|
case 'E':
|
|
|
|
case 'F':
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = CatPrint (&MappingItem->Csd, L"1%c", *Index - 'A' + '0');
|
2010-09-14 07:18:09 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (Index = Str; *Index != 0; Index++) {
|
|
|
|
//
|
|
|
|
// The mapping is:
|
|
|
|
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
|
|
|
// a b c d e f g h i j k l m n o p
|
|
|
|
//
|
|
|
|
if (*Index >= '0' && *Index <= '9') {
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = CatPrint (&MappingItem->Csd, L"%c", *Index - '0' + 'a');
|
2010-09-14 07:18:09 +02:00
|
|
|
} else if (*Index >= 'a' && *Index <= 'f') {
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = CatPrint (&MappingItem->Csd, L"%c", *Index - 'a' + 'k');
|
2010-09-14 07:18:09 +02:00
|
|
|
} else if (*Index >= 'A' && *Index <= 'F') {
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = CatPrint (&MappingItem->Csd, L"%c", *Index - 'A' + 'k');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MappingItem->Digital = (BOOLEAN)!(MappingItem->Digital);
|
2011-03-25 22:09:21 +01:00
|
|
|
|
|
|
|
return (EFI_SUCCESS);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
/**
|
|
|
|
Function to append a Guid to the mapping item.
|
|
|
|
|
2011-09-02 10:05:34 +02:00
|
|
|
@param[in, out] MappingItem The item to append onto.
|
|
|
|
@param[in] Guid The guid to append.
|
2011-03-25 22:09:21 +01:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2011-03-25 22:09:21 +01:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
AppendCSDGuid (
|
|
|
|
DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
EFI_GUID *Guid
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CHAR16 Buffer[64];
|
2011-03-25 22:09:21 +01:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
ASSERT (Guid != NULL && MappingItem != NULL);
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
UnicodeSPrint (
|
|
|
|
Buffer,
|
|
|
|
0,
|
|
|
|
L"%g",
|
|
|
|
Guid
|
|
|
|
);
|
2011-03-25 22:09:21 +01:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
return AppendCSDStr (MappingItem, Buffer);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
/**
|
|
|
|
Function to compare 2 APCI device paths.
|
|
|
|
|
|
|
|
@param[in] DevicePath1 The first device path to compare.
|
|
|
|
@param[in] DevicePath2 The second device path to compare.
|
|
|
|
|
|
|
|
@retval 0 The device paths represent the same device.
|
|
|
|
@return Non zero if the devices are different, zero otherwise.
|
|
|
|
**/
|
2010-09-14 07:18:09 +02:00
|
|
|
INTN
|
2010-09-17 22:08:57 +02:00
|
|
|
EFIAPI
|
2011-03-25 22:09:21 +01:00
|
|
|
DevPathCompareAcpi (
|
2010-09-14 07:18:09 +02:00
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ACPI_HID_DEVICE_PATH *Acpi1;
|
|
|
|
ACPI_HID_DEVICE_PATH *Acpi2;
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
if (DevicePath1 == NULL || DevicePath2 == NULL) {
|
|
|
|
return (-2);
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
Acpi1 = (ACPI_HID_DEVICE_PATH *) DevicePath1;
|
|
|
|
Acpi2 = (ACPI_HID_DEVICE_PATH *) DevicePath2;
|
|
|
|
if (Acpi1->HID > Acpi2->HID || (Acpi1->HID == Acpi2->HID && Acpi1->UID > Acpi2->UID)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Acpi1->HID == Acpi2->HID && Acpi1->UID == Acpi2->UID) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
/**
|
|
|
|
Function to compare 2 PCI device paths.
|
|
|
|
|
|
|
|
@param[in] DevicePath1 The first device path to compare.
|
|
|
|
@param[in] DevicePath2 The second device path to compare.
|
|
|
|
|
|
|
|
@retval 0 The device paths represent the same device.
|
|
|
|
@return Non zero if the devices are different, zero otherwise.
|
|
|
|
**/
|
2010-09-14 07:18:09 +02:00
|
|
|
INTN
|
2010-09-17 22:08:57 +02:00
|
|
|
EFIAPI
|
2011-03-25 22:09:21 +01:00
|
|
|
DevPathComparePci (
|
2010-09-14 07:18:09 +02:00
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2
|
|
|
|
)
|
|
|
|
{
|
|
|
|
PCI_DEVICE_PATH *Pci1;
|
|
|
|
PCI_DEVICE_PATH *Pci2;
|
|
|
|
|
|
|
|
ASSERT(DevicePath1 != NULL);
|
|
|
|
ASSERT(DevicePath2 != NULL);
|
|
|
|
|
|
|
|
Pci1 = (PCI_DEVICE_PATH *) DevicePath1;
|
|
|
|
Pci2 = (PCI_DEVICE_PATH *) DevicePath2;
|
|
|
|
if (Pci1->Device > Pci2->Device || (Pci1->Device == Pci2->Device && Pci1->Function > Pci2->Function)) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Pci1->Device == Pci2->Device && Pci1->Function == Pci2->Function) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Do a comparison on 2 device paths.
|
|
|
|
|
|
|
|
@param[in] DevicePath1 The first device path.
|
|
|
|
@param[in] DevicePath2 The second device path.
|
|
|
|
|
|
|
|
@retval 0 The 2 device paths are the same.
|
|
|
|
@retval <0 DevicePath2 is greater than DevicePath1.
|
|
|
|
@retval >0 DevicePath1 is greater than DevicePath2.
|
|
|
|
**/
|
|
|
|
INTN
|
|
|
|
EFIAPI
|
|
|
|
DevPathCompareDefault (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath1,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath2
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN DevPathSize1;
|
|
|
|
UINTN DevPathSize2;
|
|
|
|
|
|
|
|
ASSERT(DevicePath1 != NULL);
|
|
|
|
ASSERT(DevicePath2 != NULL);
|
|
|
|
|
|
|
|
DevPathSize1 = DevicePathNodeLength (DevicePath1);
|
|
|
|
DevPathSize2 = DevicePathNodeLength (DevicePath2);
|
|
|
|
if (DevPathSize1 > DevPathSize2) {
|
|
|
|
return 1;
|
|
|
|
} else if (DevPathSize1 < DevPathSize2) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return CompareMem (DevicePath1, DevicePath2, DevPathSize1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialHDD Channel type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialHardDrive (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
HARDDRIVE_DEVICE_PATH *Hd;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Hd = (HARDDRIVE_DEVICE_PATH *) DevicePathNode;
|
2011-03-25 22:09:21 +01:00
|
|
|
if (MappingItem->Mtd == MTDTypeUnknown) {
|
|
|
|
MappingItem->Mtd = MTDTypeHardDisk;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
return AppendCSDNum (MappingItem, Hd->PartitionNumber);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialAtapi Channel type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialAtapi (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ATAPI_DEVICE_PATH *Atapi;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Atapi = (ATAPI_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
return AppendCSDNum (MappingItem, (Atapi->PrimarySecondary * 2 + Atapi->SlaveMaster));
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialCDROM Channel type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialCdRom (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
CDROM_DEVICE_PATH *Cd;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Cd = (CDROM_DEVICE_PATH *) DevicePathNode;
|
2011-03-25 22:09:21 +01:00
|
|
|
MappingItem->Mtd = MTDTypeCDRom;
|
2016-07-12 09:01:17 +02:00
|
|
|
return AppendCSDNum (MappingItem, Cd->BootEntry);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialFibre Channel type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialFibre (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
FIBRECHANNEL_DEVICE_PATH *Fibre;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Fibre = (FIBRECHANNEL_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDNum (MappingItem, Fibre->WWN);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Fibre->Lun);
|
|
|
|
}
|
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialUart type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialUart (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
|
|
|
UART_DEVICE_PATH *Uart;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Uart = (UART_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDNum (MappingItem, Uart->BaudRate);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Uart->DataBits);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Uart->Parity);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Uart->StopBits);
|
|
|
|
}
|
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialUSB type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialUsb (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2014-11-24 15:58:33 +01:00
|
|
|
USB_DEVICE_PATH *Usb;
|
|
|
|
EFI_USB_IO_PROTOCOL *UsbIo;
|
|
|
|
EFI_HANDLE TempHandle;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
USB_INTERFACE_DESCRIPTOR InterfaceDesc;
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Usb = (USB_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDNum (MappingItem, Usb->ParentPortNumber);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Usb->InterfaceNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2014-11-24 15:58:33 +01:00
|
|
|
|
|
|
|
if (PcdGetBool(PcdUsbExtendedDecode)) {
|
|
|
|
Status = gBS->LocateDevicePath( &gEfiUsbIoProtocolGuid, &DevicePath, &TempHandle );
|
|
|
|
UsbIo = NULL;
|
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
Status = gBS->OpenProtocol(TempHandle, &gEfiUsbIoProtocolGuid, (VOID**)&UsbIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
ASSERT(UsbIo != NULL);
|
|
|
|
Status = UsbIo->UsbGetInterfaceDescriptor(UsbIo, &InterfaceDesc);
|
|
|
|
if (!EFI_ERROR(Status)) {
|
|
|
|
if (InterfaceDesc.InterfaceClass == USB_MASS_STORE_CLASS && MappingItem->Mtd == MTDTypeUnknown) {
|
|
|
|
switch (InterfaceDesc.InterfaceSubClass){
|
|
|
|
case USB_MASS_STORE_SCSI:
|
|
|
|
MappingItem->Mtd = MTDTypeHardDisk;
|
|
|
|
break;
|
|
|
|
case USB_MASS_STORE_8070I:
|
|
|
|
case USB_MASS_STORE_UFI:
|
|
|
|
MappingItem->Mtd = MTDTypeFloppy;
|
|
|
|
break;
|
|
|
|
case USB_MASS_STORE_8020I:
|
|
|
|
MappingItem->Mtd = MTDTypeCDRom;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-12 09:01:17 +02:00
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialVendor type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2011-03-25 22:09:21 +01:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialVendor (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
VENDOR_DEVICE_PATH *Vendor;
|
|
|
|
SAS_DEVICE_PATH *Sas;
|
2014-11-24 15:50:14 +01:00
|
|
|
UINTN TargetNameLength;
|
|
|
|
UINTN Index;
|
|
|
|
CHAR16 *Buffer;
|
2016-07-12 09:01:17 +02:00
|
|
|
CHAR16 *NewBuffer;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
Vendor = (VENDOR_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDGuid (MappingItem, &Vendor->Guid);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
if (CompareGuid (&gEfiSasDevicePathGuid, &Vendor->Guid)) {
|
2010-09-14 07:18:09 +02:00
|
|
|
Sas = (SAS_DEVICE_PATH *) Vendor;
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDNum (MappingItem, Sas->SasAddress);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Sas->Lun);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Sas->DeviceTopology);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Sas->RelativeTargetPort);
|
|
|
|
}
|
2014-11-24 15:50:14 +01:00
|
|
|
} else {
|
|
|
|
TargetNameLength = MIN(DevicePathNodeLength (DevicePathNode) - sizeof (VENDOR_DEVICE_PATH), PcdGet32(PcdShellVendorExtendedDecode));
|
|
|
|
if (TargetNameLength != 0) {
|
|
|
|
//
|
|
|
|
// String is 2 chars per data byte, plus NULL terminator
|
|
|
|
//
|
|
|
|
Buffer = AllocateZeroPool (((TargetNameLength * 2) + 1) * sizeof(CHAR16));
|
|
|
|
if (Buffer == NULL) {
|
2016-07-12 09:01:17 +02:00
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
2014-11-24 15:50:14 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Build the string data
|
|
|
|
//
|
|
|
|
for (Index = 0; Index < TargetNameLength; Index++) {
|
2016-07-12 09:01:17 +02:00
|
|
|
NewBuffer = CatSPrint (Buffer, L"%02x", *((UINT8*)Vendor + sizeof (VENDOR_DEVICE_PATH) + Index));
|
|
|
|
if (NewBuffer == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Buffer = NewBuffer;
|
|
|
|
}
|
2014-11-24 15:50:14 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Append the new data block
|
|
|
|
//
|
2016-07-12 09:01:17 +02:00
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDStr (MappingItem, Buffer);
|
|
|
|
}
|
2014-11-24 15:50:14 +01:00
|
|
|
|
|
|
|
FreePool(Buffer);
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
2016-07-12 09:01:17 +02:00
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialLun type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialLun (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
DEVICE_LOGICAL_UNIT_DEVICE_PATH *Lun;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Lun = (DEVICE_LOGICAL_UNIT_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
return AppendCSDNum (MappingItem, Lun->Lun);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialSata type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialSata (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
SATA_DEVICE_PATH *Sata;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Sata = (SATA_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDNum (MappingItem, Sata->HBAPortNumber);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Sata->PortMultiplierPortNumber);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Sata->Lun);
|
|
|
|
}
|
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialSCSI type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialIScsi (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
ISCSI_DEVICE_PATH *IScsi;
|
|
|
|
UINT8 *IScsiTargetName;
|
|
|
|
CHAR16 *TargetName;
|
|
|
|
UINTN TargetNameLength;
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
|
2014-11-12 22:28:51 +01:00
|
|
|
if (PcdGetBool(PcdShellDecodeIScsiMapNames)) {
|
|
|
|
IScsi = (ISCSI_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDNum (MappingItem, IScsi->NetworkProtocol);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, IScsi->LoginOption);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, IScsi->Lun);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag);
|
|
|
|
}
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return Status;
|
|
|
|
}
|
2014-11-12 22:28:51 +01:00
|
|
|
TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH);
|
|
|
|
if (TargetNameLength > 0) {
|
|
|
|
TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16));
|
2016-07-12 09:01:17 +02:00
|
|
|
if (TargetName == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
} else {
|
2014-11-12 22:28:51 +01:00
|
|
|
IScsiTargetName = (UINT8 *) (IScsi + 1);
|
|
|
|
for (Index = 0; Index < TargetNameLength; Index++) {
|
|
|
|
TargetName[Index] = (CHAR16) IScsiTargetName[Index];
|
|
|
|
}
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDStr (MappingItem, TargetName);
|
2014-11-12 22:28:51 +01:00
|
|
|
FreePool (TargetName);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-12 09:01:17 +02:00
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SerialI20 type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialI2O (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2011-03-25 22:09:21 +01:00
|
|
|
I2O_DEVICE_PATH *DevicePath_I20;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
DevicePath_I20 = (I2O_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
return AppendCSDNum (MappingItem, DevicePath_I20->Tid);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be Mac Address type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialMacAddr (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
MAC_ADDR_DEVICE_PATH *Mac;
|
|
|
|
UINTN HwAddressSize;
|
|
|
|
UINTN Index;
|
|
|
|
CHAR16 Buffer[64];
|
|
|
|
CHAR16 *PBuffer;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Mac = (MAC_ADDR_DEVICE_PATH *) DevicePathNode;
|
|
|
|
|
|
|
|
HwAddressSize = sizeof (EFI_MAC_ADDRESS);
|
|
|
|
if (Mac->IfType == 0x01 || Mac->IfType == 0x00) {
|
|
|
|
HwAddressSize = 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Index = 0, PBuffer = Buffer; Index < HwAddressSize; Index++, PBuffer += 2) {
|
|
|
|
UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) Mac->MacAddress.Addr[Index]);
|
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
return AppendCSDStr (MappingItem, Buffer);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be InfiniBand type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialInfiniBand (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
INFINIBAND_DEVICE_PATH *InfiniBand;
|
|
|
|
UINTN Index;
|
|
|
|
CHAR16 Buffer[64];
|
|
|
|
CHAR16 *PBuffer;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
InfiniBand = (INFINIBAND_DEVICE_PATH *) DevicePathNode;
|
|
|
|
for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
|
|
|
|
UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) InfiniBand->PortGid[Index]);
|
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDStr (MappingItem, Buffer);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, InfiniBand->ServiceId);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, InfiniBand->TargetPortId);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, InfiniBand->DeviceId);
|
|
|
|
}
|
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be IPv4 type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialIPv4 (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
IPv4_DEVICE_PATH *Ip;
|
|
|
|
CHAR16 Buffer[10];
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Ip = (IPv4_DEVICE_PATH *) DevicePathNode;
|
|
|
|
UnicodeSPrint (
|
|
|
|
Buffer,
|
|
|
|
0,
|
|
|
|
L"%02x%02x%02x%02x",
|
|
|
|
(UINTN) Ip->LocalIpAddress.Addr[0],
|
|
|
|
(UINTN) Ip->LocalIpAddress.Addr[1],
|
|
|
|
(UINTN) Ip->LocalIpAddress.Addr[2],
|
|
|
|
(UINTN) Ip->LocalIpAddress.Addr[3]
|
|
|
|
);
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDStr (MappingItem, Buffer);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Ip->LocalPort);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
UnicodeSPrint (
|
|
|
|
Buffer,
|
|
|
|
0,
|
|
|
|
L"%02x%02x%02x%02x",
|
|
|
|
(UINTN) Ip->RemoteIpAddress.Addr[0],
|
|
|
|
(UINTN) Ip->RemoteIpAddress.Addr[1],
|
|
|
|
(UINTN) Ip->RemoteIpAddress.Addr[2],
|
|
|
|
(UINTN) Ip->RemoteIpAddress.Addr[3]
|
|
|
|
);
|
|
|
|
Status = AppendCSDStr (MappingItem, Buffer);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Ip->RemotePort);
|
|
|
|
}
|
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be IPv6 type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialIPv6 (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
IPv6_DEVICE_PATH *Ip;
|
|
|
|
UINTN Index;
|
|
|
|
CHAR16 Buffer[64];
|
|
|
|
CHAR16 *PBuffer;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Ip = (IPv6_DEVICE_PATH *) DevicePathNode;
|
|
|
|
for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
|
|
|
|
UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) Ip->LocalIpAddress.Addr[Index]);
|
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDStr (MappingItem, Buffer);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Ip->LocalPort);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
2016-07-12 09:01:17 +02:00
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
for (Index = 0, PBuffer = Buffer; Index < 16; Index++, PBuffer += 2) {
|
|
|
|
UnicodeSPrint (PBuffer, 0, L"%02x", (UINTN) Ip->RemoteIpAddress.Addr[Index]);
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDStr (MappingItem, Buffer);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Ip->RemotePort);
|
|
|
|
}
|
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be SCSI type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialScsi (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
SCSI_DEVICE_PATH *Scsi;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Scsi = (SCSI_DEVICE_PATH *) DevicePathNode;
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = AppendCSDNum (MappingItem, Scsi->Pun);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = AppendCSDNum (MappingItem, Scsi->Lun);
|
|
|
|
}
|
|
|
|
return Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
DevicePathNode must be 1394 type and this will populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerial1394 (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2011-03-25 22:09:21 +01:00
|
|
|
F1394_DEVICE_PATH *DevicePath_F1394;
|
2010-09-14 07:18:09 +02:00
|
|
|
CHAR16 Buffer[20];
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
DevicePath_F1394 = (F1394_DEVICE_PATH *) DevicePathNode;
|
|
|
|
UnicodeSPrint (Buffer, 0, L"%lx", DevicePath_F1394->Guid);
|
2016-07-12 09:01:17 +02:00
|
|
|
return AppendCSDStr (MappingItem, Buffer);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
If the node is floppy type then populate the MappingItem.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to get info on.
|
|
|
|
@param[in] MappingItem The info item to populate.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2016-07-12 09:01:17 +02:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialAcpi (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ACPI_HID_DEVICE_PATH *Acpi;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
|
|
|
Acpi = (ACPI_HID_DEVICE_PATH *) DevicePathNode;
|
|
|
|
if ((Acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) {
|
|
|
|
if (EISA_ID_TO_NUM (Acpi->HID) == 0x0604) {
|
2011-03-25 22:09:21 +01:00
|
|
|
MappingItem->Mtd = MTDTypeFloppy;
|
2016-07-12 09:01:17 +02:00
|
|
|
return AppendCSDNum (MappingItem, Acpi->UID);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-12 09:01:17 +02:00
|
|
|
return EFI_SUCCESS;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Empty function used for unknown devices.
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
@param[in] DevicePathNode Ignored.
|
|
|
|
@param[in] MappingItem Ignored.
|
2014-12-12 01:45:05 +01:00
|
|
|
@param[in] DevicePath Ignored.
|
2011-03-25 22:09:21 +01:00
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES Out of resources.
|
|
|
|
@retval EFI_SUCCESS The appending was successful.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS
|
2010-09-14 07:18:09 +02:00
|
|
|
DevPathSerialDefault (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode,
|
2014-11-24 15:58:33 +01:00
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
return EFI_SUCCESS;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DEV_PATH_CONSIST_MAPPING_TABLE DevPathConsistMappingTable[] = {
|
2012-10-11 04:15:23 +02:00
|
|
|
{
|
|
|
|
HARDWARE_DEVICE_PATH,
|
|
|
|
HW_PCI_DP,
|
|
|
|
DevPathSerialDefault,
|
|
|
|
DevPathComparePci
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ACPI_DEVICE_PATH,
|
|
|
|
ACPI_DP,
|
|
|
|
DevPathSerialAcpi,
|
|
|
|
DevPathCompareAcpi
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_ATAPI_DP,
|
|
|
|
DevPathSerialAtapi,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_SCSI_DP,
|
|
|
|
DevPathSerialScsi,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_FIBRECHANNEL_DP,
|
|
|
|
DevPathSerialFibre,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_1394_DP,
|
|
|
|
DevPathSerial1394,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_USB_DP,
|
|
|
|
DevPathSerialUsb,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_I2O_DP,
|
|
|
|
DevPathSerialI2O,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_MAC_ADDR_DP,
|
|
|
|
DevPathSerialMacAddr,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_IPv4_DP,
|
|
|
|
DevPathSerialIPv4,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_IPv6_DP,
|
|
|
|
DevPathSerialIPv6,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_INFINIBAND_DP,
|
|
|
|
DevPathSerialInfiniBand,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_UART_DP,
|
|
|
|
DevPathSerialUart,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_VENDOR_DP,
|
|
|
|
DevPathSerialVendor,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_DEVICE_LOGICAL_UNIT_DP,
|
|
|
|
DevPathSerialLun,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_SATA_DP,
|
|
|
|
DevPathSerialSata,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MESSAGING_DEVICE_PATH,
|
|
|
|
MSG_ISCSI_DP,
|
|
|
|
DevPathSerialIScsi,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MEDIA_DEVICE_PATH,
|
|
|
|
MEDIA_HARDDRIVE_DP,
|
|
|
|
DevPathSerialHardDrive,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MEDIA_DEVICE_PATH,
|
|
|
|
MEDIA_CDROM_DP,
|
|
|
|
DevPathSerialCdRom,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
MEDIA_DEVICE_PATH,
|
|
|
|
MEDIA_VENDOR_DP,
|
|
|
|
DevPathSerialVendor,
|
|
|
|
DevPathCompareDefault
|
|
|
|
},
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function to determine if a device path node is Hi or not.
|
|
|
|
|
|
|
|
@param[in] DevicePathNode The node to check.
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
@retval TRUE The node is Hi.
|
|
|
|
@retval FALSE The node is not Hi.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
|
|
|
BOOLEAN
|
|
|
|
EFIAPI
|
|
|
|
IsHIDevicePathNode (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePathNode
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ACPI_HID_DEVICE_PATH *Acpi;
|
|
|
|
|
|
|
|
ASSERT(DevicePathNode != NULL);
|
|
|
|
|
|
|
|
if (DevicePathNode->Type == HARDWARE_DEVICE_PATH) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DevicePathNode->Type == ACPI_DEVICE_PATH) {
|
|
|
|
Acpi = (ACPI_HID_DEVICE_PATH *) DevicePathNode;
|
|
|
|
switch (EISA_ID_TO_NUM (Acpi->HID)) {
|
|
|
|
case 0x0301:
|
|
|
|
case 0x0401:
|
|
|
|
case 0x0501:
|
|
|
|
case 0x0604:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-03-25 22:09:21 +01:00
|
|
|
Function to convert a standard device path structure into a Hi version.
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
@param[in] DevicePath The device path to convert.
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
@return the device path portion that is Hi.
|
2010-09-14 07:18:09 +02:00
|
|
|
**/
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *
|
|
|
|
EFIAPI
|
|
|
|
GetHIDevicePath (
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN NonHIDevicePathNodeCount;
|
|
|
|
UINTN Index;
|
|
|
|
EFI_DEV_PATH Node;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
|
|
|
|
|
|
|
|
ASSERT(DevicePath != NULL);
|
|
|
|
|
|
|
|
NonHIDevicePathNodeCount = 0;
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
HIDevicePath = AllocateZeroPool (sizeof (EFI_DEVICE_PATH_PROTOCOL));
|
2010-09-14 07:18:09 +02:00
|
|
|
SetDevicePathEndNode (HIDevicePath);
|
|
|
|
|
|
|
|
Node.DevPath.Type = END_DEVICE_PATH_TYPE;
|
|
|
|
Node.DevPath.SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
|
|
|
|
Node.DevPath.Length[0] = (UINT8)sizeof (EFI_DEVICE_PATH_PROTOCOL);
|
|
|
|
Node.DevPath.Length[1] = 0;
|
|
|
|
|
|
|
|
while (!IsDevicePathEnd (DevicePath)) {
|
|
|
|
if (IsHIDevicePathNode (DevicePath)) {
|
|
|
|
for (Index = 0; Index < NonHIDevicePathNodeCount; Index++) {
|
|
|
|
TempDevicePath = AppendDevicePathNode (HIDevicePath, &Node.DevPath);
|
|
|
|
FreePool (HIDevicePath);
|
|
|
|
HIDevicePath = TempDevicePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
TempDevicePath = AppendDevicePathNode (HIDevicePath, DevicePath);
|
|
|
|
FreePool (HIDevicePath);
|
|
|
|
HIDevicePath = TempDevicePath;
|
|
|
|
} else {
|
|
|
|
NonHIDevicePathNodeCount++;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Next device path node
|
|
|
|
//
|
|
|
|
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (DevicePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
return HIDevicePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function to walk the device path looking for a dumpable node.
|
|
|
|
|
|
|
|
@param[in] MappingItem The Item to fill with data.
|
|
|
|
@param[in] DevicePath The path of the item to get data on.
|
|
|
|
|
|
|
|
@return EFI_SUCCESS Always returns success.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
GetDeviceConsistMappingInfo (
|
|
|
|
IN DEVICE_CONSIST_MAPPING_INFO *MappingItem,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2014-12-12 01:45:05 +01:00
|
|
|
SERIAL_DECODE_FUNCTION SerialFun;
|
2014-11-24 15:58:33 +01:00
|
|
|
UINTN Index;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *OriginalDevicePath;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
ASSERT(DevicePath != NULL);
|
|
|
|
ASSERT(MappingItem != NULL);
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
SetMem (&MappingItem->Csd, sizeof (POOL_PRINT), 0);
|
2014-11-24 15:58:33 +01:00
|
|
|
OriginalDevicePath = DevicePath;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
while (!IsDevicePathEnd (DevicePath)) {
|
|
|
|
//
|
2014-11-24 15:58:33 +01:00
|
|
|
// Find the handler to dump this device path node and
|
|
|
|
// initialize with generic function in case nothing is found
|
2010-09-14 07:18:09 +02:00
|
|
|
//
|
2014-11-24 15:58:33 +01:00
|
|
|
for (SerialFun = DevPathSerialDefault, Index = 0; DevPathConsistMappingTable[Index].SerialFun != NULL; Index += 1) {
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
if (DevicePathType (DevicePath) == DevPathConsistMappingTable[Index].Type &&
|
|
|
|
DevicePathSubType (DevicePath) == DevPathConsistMappingTable[Index].SubType
|
|
|
|
) {
|
|
|
|
SerialFun = DevPathConsistMappingTable[Index].SerialFun;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = SerialFun (DevicePath, MappingItem, OriginalDevicePath);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
SHELL_FREE_NON_NULL (MappingItem->Csd.Str);
|
|
|
|
return Status;
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Next device path node
|
|
|
|
//
|
|
|
|
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) NextDevicePathNode (DevicePath);
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function to initialize the table for creating consistent map names.
|
|
|
|
|
|
|
|
@param[out] Table The pointer to pointer to pointer to DevicePathProtocol object.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The table was created successfully.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandConsistMappingInitialize (
|
|
|
|
OUT EFI_DEVICE_PATH_PROTOCOL ***Table
|
|
|
|
)
|
|
|
|
{
|
2015-12-08 03:00:16 +01:00
|
|
|
EFI_HANDLE *HandleBuffer;
|
|
|
|
UINTN HandleNum;
|
|
|
|
UINTN HandleLoop;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL **TempTable;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
|
|
|
|
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
|
|
|
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
|
|
|
|
UINTN Index;
|
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
HandleBuffer = NULL;
|
|
|
|
|
|
|
|
Status = gBS->LocateHandleBuffer (
|
2015-12-08 03:00:16 +01:00
|
|
|
ByProtocol,
|
|
|
|
&gEfiDevicePathProtocolGuid,
|
2010-09-14 07:18:09 +02:00
|
|
|
NULL,
|
|
|
|
&HandleNum,
|
|
|
|
&HandleBuffer
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR(Status);
|
|
|
|
|
|
|
|
TempTable = AllocateZeroPool ((HandleNum + 1) * sizeof (EFI_DEVICE_PATH_PROTOCOL *));
|
|
|
|
if (TempTable == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (HandleLoop = 0 ; HandleLoop < HandleNum ; HandleLoop++) {
|
|
|
|
DevicePath = DevicePathFromHandle (HandleBuffer[HandleLoop]);
|
|
|
|
if (DevicePath == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
HIDevicePath = GetHIDevicePath (DevicePath);
|
|
|
|
if (HIDevicePath == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-12-08 03:00:16 +01:00
|
|
|
Status = gBS->HandleProtocol( HandleBuffer[HandleLoop],
|
|
|
|
&gEfiBlockIoProtocolGuid,
|
|
|
|
(VOID **)&BlockIo
|
|
|
|
);
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
Status = gBS->HandleProtocol( HandleBuffer[HandleLoop],
|
|
|
|
&gEfiSimpleFileSystemProtocolGuid,
|
|
|
|
(VOID **)&SimpleFileSystem
|
|
|
|
);
|
|
|
|
if (EFI_ERROR(Status)) {
|
2015-12-25 02:46:02 +01:00
|
|
|
FreePool (HIDevicePath);
|
2015-12-08 03:00:16 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-14 07:18:09 +02:00
|
|
|
for (Index = 0; TempTable[Index] != NULL; Index++) {
|
|
|
|
if (DevicePathCompare (&TempTable[Index], &HIDevicePath) == 0) {
|
|
|
|
FreePool (HIDevicePath);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TempTable[Index] == NULL) {
|
|
|
|
TempTable[Index] = HIDevicePath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Index = 0; TempTable[Index] != NULL; Index++);
|
|
|
|
PerformQuickSort(TempTable, Index, sizeof(EFI_DEVICE_PATH_PROTOCOL*), DevicePathCompare);
|
|
|
|
*Table = TempTable;
|
|
|
|
|
|
|
|
if (HandleBuffer != NULL) {
|
|
|
|
FreePool (HandleBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function to uninitialize the table for creating consistent map names.
|
|
|
|
|
|
|
|
The parameter must have been received from ShellCommandConsistMappingInitialize.
|
|
|
|
|
|
|
|
@param[out] Table The pointer to pointer to DevicePathProtocol object.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The table was deleted successfully.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandConsistMappingUnInitialize (
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL **Table
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
ASSERT(Table != NULL);
|
|
|
|
|
|
|
|
for (Index = 0; Table[Index] != NULL; Index++) {
|
|
|
|
FreePool (Table[Index]);
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (Table);
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-09-17 22:08:57 +02:00
|
|
|
Create a consistent mapped name for the device specified by DevicePath
|
2010-09-14 07:18:09 +02:00
|
|
|
based on the Table.
|
|
|
|
|
2010-09-17 22:08:57 +02:00
|
|
|
This must be called after ShellCommandConsistMappingInitialize() and
|
2010-09-14 07:18:09 +02:00
|
|
|
before ShellCommandConsistMappingUnInitialize() is called.
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
@param[in] DevicePath The pointer to the dev path for the device.
|
2010-09-14 07:18:09 +02:00
|
|
|
@param[in] Table The Table of mapping information.
|
|
|
|
|
|
|
|
@retval NULL A consistent mapped name could not be created.
|
|
|
|
@return A pointer to a string allocated from pool with the device name.
|
|
|
|
**/
|
|
|
|
CHAR16 *
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandConsistMappingGenMappingName (
|
2011-03-25 22:09:21 +01:00
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL **Table
|
2010-09-14 07:18:09 +02:00
|
|
|
)
|
|
|
|
{
|
2016-07-12 09:01:17 +02:00
|
|
|
EFI_STATUS Status;
|
2010-09-14 07:18:09 +02:00
|
|
|
POOL_PRINT Str;
|
|
|
|
DEVICE_CONSIST_MAPPING_INFO MappingInfo;
|
|
|
|
EFI_DEVICE_PATH_PROTOCOL *HIDevicePath;
|
|
|
|
UINTN Index;
|
2016-07-12 09:01:17 +02:00
|
|
|
CHAR16 *NewStr;
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
ASSERT(DevicePath != NULL);
|
|
|
|
ASSERT(Table != NULL);
|
|
|
|
|
|
|
|
HIDevicePath = GetHIDevicePath (DevicePath);
|
|
|
|
if (HIDevicePath == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Index = 0; Table[Index] != NULL; Index++) {
|
|
|
|
if (DevicePathCompare (&Table[Index], &HIDevicePath) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (HIDevicePath);
|
|
|
|
if (Table[Index] == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-25 22:09:21 +01:00
|
|
|
MappingInfo.Hi = Index;
|
|
|
|
MappingInfo.Mtd = MTDTypeUnknown;
|
2010-09-14 07:18:09 +02:00
|
|
|
MappingInfo.Digital = FALSE;
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = GetDeviceConsistMappingInfo (&MappingInfo, DevicePath);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-09-14 07:18:09 +02:00
|
|
|
|
|
|
|
SetMem (&Str, sizeof (Str), 0);
|
|
|
|
for (Index = 0; mMTDName[Index].MTDType != MTDTypeEnd; Index++) {
|
2011-03-25 22:09:21 +01:00
|
|
|
if (MappingInfo.Mtd == mMTDName[Index].MTDType) {
|
2010-09-14 07:18:09 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mMTDName[Index].MTDType != MTDTypeEnd) {
|
2016-07-12 09:01:17 +02:00
|
|
|
Status = CatPrint (&Str, L"%s", mMTDName[Index].Name);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Status = CatPrint (&Str, L"%d", (UINTN) MappingInfo.Hi);
|
|
|
|
}
|
|
|
|
if (!EFI_ERROR (Status) && MappingInfo.Csd.Str != NULL) {
|
|
|
|
Status = CatPrint (&Str, L"%s", MappingInfo.Csd.Str);
|
2011-03-25 22:09:21 +01:00
|
|
|
FreePool (MappingInfo.Csd.Str);
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
if (!EFI_ERROR (Status) && Str.Str != NULL) {
|
|
|
|
Status = CatPrint (&Str, L":");
|
|
|
|
}
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
SHELL_FREE_NON_NULL (Str.Str);
|
|
|
|
return NULL;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
2016-07-12 09:01:17 +02:00
|
|
|
NewStr = ReallocatePool (Str.Len * sizeof (CHAR16), (Str.Len + 1) * sizeof (CHAR16), Str.Str);
|
|
|
|
if (NewStr == NULL) {
|
|
|
|
SHELL_FREE_NON_NULL (Str.Str);
|
2010-10-04 18:28:35 +02:00
|
|
|
return (NULL);
|
|
|
|
}
|
2016-07-12 09:01:17 +02:00
|
|
|
NewStr[Str.Len] = CHAR_NULL;
|
|
|
|
return NewStr;
|
2010-09-14 07:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Function to search the list of mappings for the node on the list based on the key.
|
|
|
|
|
|
|
|
@param[in] MapKey String Key to search for on the map
|
|
|
|
|
|
|
|
@return the node on the list.
|
|
|
|
**/
|
|
|
|
SHELL_MAP_LIST *
|
|
|
|
EFIAPI
|
|
|
|
ShellCommandFindMapItem (
|
|
|
|
IN CONST CHAR16 *MapKey
|
|
|
|
)
|
|
|
|
{
|
|
|
|
SHELL_MAP_LIST *MapListItem;
|
|
|
|
|
|
|
|
for ( MapListItem = (SHELL_MAP_LIST *)GetFirstNode(&gShellMapList.Link)
|
|
|
|
; !IsNull(&gShellMapList.Link, &MapListItem->Link)
|
|
|
|
; MapListItem = (SHELL_MAP_LIST *)GetNextNode(&gShellMapList.Link, &MapListItem->Link)
|
|
|
|
){
|
|
|
|
if (gUnicodeCollation->StriColl(gUnicodeCollation,MapListItem->MapName,(CHAR16*)MapKey) == 0) {
|
|
|
|
return (MapListItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|