/** @file
Main file for support of shell consist mapping.
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
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
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>
typedef enum {
} MTD_TYPE;
typedef struct {
} POOL_PRINT;
typedef struct {
typedef struct {
} MTD_NAME;
typedef struct {
/**
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.
@return Allocated buffer with the formatted string printed in it.
The caller must free the allocated buffer.
The buffer allocation is not packed.
**/
CHAR16 *
CatPrint (
...
)
{
}
} else {
);
}
}
{
L"F"
},
{
L"FP"
},
{
L"HD"
},
{
L"CD"
},
{
}
};
/**
Function to append a 64 bit number / 25 onto the string.
@param[in, out] Str The string so append onto.
@param[in] Num The number to divide and append.
@retval EFI_INVALID_PARAMETER A parameter was NULL.
@retval EFI_SUCCESS The appending was successful.
**/
)
{
return (EFI_INVALID_PARAMETER);
}
if (Result > 0) {
}
return (EFI_SUCCESS);
}
/**
Function to append a 64 bit number onto the mapping info.
@param[in, out] MappingItem The mapping info object to append onto.
@param[in] Num The info to append.
@retval EFI_INVALID_PARAMETER A parameter was NULL.
@retval EFI_SUCCESS The appending was successful.
**/
)
{
if (MappingItem == NULL) {
return EFI_INVALID_PARAMETER;
}
if (MappingItem->Digital) {
} else {
}
return (EFI_SUCCESS);
}
/**
Function to append string into the mapping info.
@param[in, out] MappingItem The mapping info object to append onto.
@param[in] Str The info to append.
@retval EFI_INVALID_PARAMETER A parameter was NULL.
@retval EFI_SUCCESS The appending was successful.
**/
)
{
return (EFI_INVALID_PARAMETER);
}
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
//
switch (*Index) {
case '0':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
break;
case '1':
break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
break;
}
}
} else {
//
// 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
//
}
}
}
return (EFI_SUCCESS);
}
/**
Function to append a Guid to the mapping item.
@param[in, out] MappingItem The item to append onto.
@param[in] Guid The guid to append.
@retval EFI_SUCCESS The appending operation was successful.
@retval EFI_INVALID_PARAMETER A parameter was NULL.
**/
)
{
return (EFI_INVALID_PARAMETER);
}
0,
L"%g",
);
return (EFI_SUCCESS);
}
/**
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.
**/
)
{
return (-2);
}
return 1;
}
return 0;
}
return -1;
}
/**
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.
**/
)
{
if (Pci1->Device > Pci2->Device || (Pci1->Device == Pci2->Device && Pci1->Function > Pci2->Function)) {
return 1;
}
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.
**/
)
{
if (DevPathSize1 > DevPathSize2) {
return 1;
} else if (DevPathSize1 < DevPathSize2) {
return -1;
} else {
}
}
/**
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.
**/
)
{
}
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
return;
}
}
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
///@todo make this a PCD
//
// As Csd of ISCSI node is quite long, we comment
// the code below to keep the consistent mapping
// short. Uncomment if you really need it.
//
/*
ISCSI_DEVICE_PATH *IScsi;
UINT8 *IScsiTargetName;
CHAR16 *TargetName;
UINTN TargetNameLength;
UINTN Index;
ASSERT(DevicePathNode != NULL);
ASSERT(MappingItem != NULL);
IScsi = (ISCSI_DEVICE_PATH *) DevicePathNode;
AppendCSDNum (MappingItem, IScsi->NetworkProtocol);
AppendCSDNum (MappingItem, IScsi->LoginOption);
AppendCSDNum (MappingItem, IScsi->Lun);
AppendCSDNum (MappingItem, IScsi->TargetPortalGroupTag);
TargetNameLength = DevicePathNodeLength (DevicePathNode) - sizeof (ISCSI_DEVICE_PATH);
if (TargetNameLength > 0) {
TargetName = AllocateZeroPool ((TargetNameLength + 1) * sizeof (CHAR16));
if (TargetName != NULL) {
IScsiTargetName = (UINT8 *) (IScsi + 1);
for (Index = 0; Index < TargetNameLength; Index++) {
TargetName[Index] = (CHAR16) IScsiTargetName[Index];
}
AppendCSDStr (MappingItem, TargetName);
FreePool (TargetName);
}
}
*/
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
HwAddressSize = sizeof (EFI_MAC_ADDRESS);
HwAddressSize = 6;
}
}
}
/**
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.
**/
)
{
}
}
/**
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.
**/
)
{
0,
L"%02x%02x%02x%02x",
);
0,
L"%02x%02x%02x%02x",
);
}
/**
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.
**/
)
{
}
}
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
}
/**
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.
**/
)
{
}
}
}
/**
Empty function used for unknown devices.
@param[in] DevicePathNode Ignored.
@param[in] MappingItem Ignored.
Does nothing.
**/
)
{
return;
}
0,
0,
NULL,
};
/**
Function to determine if a device path node is Hi or not.
@param[in] DevicePathNode The node to check.
@retval TRUE The node is Hi.
@retval FALSE The node is not Hi.
**/
)
{
return TRUE;
}
case 0x0301:
case 0x0401:
case 0x0501:
case 0x0604:
return FALSE;
}
return TRUE;
}
return FALSE;
}
/**
Function to convert a standard device path structure into a Hi version.
@param[in] DevicePath The device path to convert.
@return the device path portion that is Hi.
**/
)
{
while (!IsDevicePathEnd (DevicePath)) {
if (IsHIDevicePathNode (DevicePath)) {
}
} else {
}
//
// Next device path node
//
}
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.
**/
)
{
while (!IsDevicePathEnd (DevicePath)) {
//
// Find the handler to dump this device path node
//
) {
break;
}
}
//
// If not found, use a generic function
//
if (!SerialFun) {
}
//
// Next device path node
//
}
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.
**/
)
{
HandleBuffer = NULL;
NULL,
NULL,
);
return EFI_OUT_OF_RESOURCES;
}
if (DevicePath == NULL) {
continue;
}
if (HIDevicePath == NULL) {
continue;
}
break;
}
}
}
}
if (HandleBuffer != NULL) {
}
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.
**/
)
{
}
return EFI_SUCCESS;
}
/**
Create a consistent mapped name for the device specified by DevicePath
based on the Table.
This must be called after ShellCommandConsistMappingInitialize() and
before ShellCommandConsistMappingUnInitialize() is called.
@param[in] DevicePath The pointer to the dev path for the device.
@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 *
)
{
if (HIDevicePath == NULL) {
return NULL;
}
break;
}
}
return NULL;
}
break;
}
}
}
}
}
return (NULL);
}
}
/**
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.
**/
)
{
){
return (MapListItem);
}
}
return (NULL);
}