ShellPkg/pci: Support interpreting specific PCIE ext cap thru "-ec"

The implementation was already there but through a private flag
"-_e". The patch removes "-_e" support and add "-ec" support.
Removing old "-_e" support makes the pci command more clean.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
This commit is contained in:
Ruiyu Ni 2017-01-23 18:49:33 +08:00
parent 0c84a69fbe
commit c831a2c3b0
2 changed files with 36 additions and 44 deletions

View File

@ -2370,7 +2370,7 @@ PCI_CONFIG_SPACE *mConfigSpace = NULL;
STATIC CONST SHELL_PARAM_ITEM ParamList[] = { STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-s", TypeValue}, {L"-s", TypeValue},
{L"-i", TypeFlag}, {L"-i", TypeFlag},
{L"-_e", TypeValue}, {L"-ec", TypeValue},
{NULL, TypeMax} {NULL, TypeMax}
}; };
@ -2516,6 +2516,11 @@ ShellCommandRunPci (
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
goto Done; goto Done;
} }
if (ShellCommandLineGetFlag(Package, L"-ec") && ShellCommandLineGetValue(Package, L"-ec") == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"pci", L"-ec");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
if (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetValue(Package, L"-s") == NULL) { if (ShellCommandLineGetFlag(Package, L"-s") && ShellCommandLineGetValue(Package, L"-s") == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"pci", L"-s"); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"pci", L"-s");
ShellStatus = SHELL_INVALID_PARAMETER; ShellStatus = SHELL_INVALID_PARAMETER;
@ -2878,14 +2883,12 @@ ShellCommandRunPci (
// If "-i" appears in command line, interpret data in configuration space // If "-i" appears in command line, interpret data in configuration space
// //
if (ExplainData) { if (ExplainData) {
EnhancedDump = 0;
if (ShellCommandLineGetFlag(Package, L"-_e")) {
EnhancedDump = 0xFFFF; EnhancedDump = 0xFFFF;
Temp = ShellCommandLineGetValue(Package, L"-_e"); if (ShellCommandLineGetFlag(Package, L"-ec")) {
if (Temp != NULL) { Temp = ShellCommandLineGetValue(Package, L"-ec");
ASSERT (Temp != NULL);
EnhancedDump = (UINT16) ShellHexStrToUintn (Temp); EnhancedDump = (UINT16) ShellHexStrToUintn (Temp);
} }
}
Status = PciExplainData (&ConfigSpace, Address, IoDev, EnhancedDump); Status = PciExplainData (&ConfigSpace, Address, IoDev, EnhancedDump);
} }
} }
@ -5829,19 +5832,6 @@ PciExplainPciExpress (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
if (EnhancedDump == 0) {
//
// Print the PciEx extend space in raw bytes ( 0xFF-0xFFF)
//
ShellPrintEx (-1, -1, L"\r\n%HStart dumping PCIex extended configuration space (0x100 - 0xFFF).%N\r\n\r\n");
DumpHex (
2,
EFI_PCIE_CAPABILITY_BASE_OFFSET,
ExtendRegSize,
(VOID *) (ExRegBuffer)
);
} else {
ExtHdr = (PCI_EXP_EXT_HDR*)ExRegBuffer; ExtHdr = (PCI_EXP_EXT_HDR*)ExRegBuffer;
while (ExtHdr->CapabilityId != 0 && ExtHdr->CapabilityVersion != 0) { while (ExtHdr->CapabilityId != 0 && ExtHdr->CapabilityVersion != 0) {
// //
@ -5863,7 +5853,6 @@ PciExplainPciExpress (
break; break;
} }
} }
}
SHELL_FREE_NON_NULL(ExRegBuffer); SHELL_FREE_NON_NULL(ExRegBuffer);
Done: Done:

View File

@ -895,17 +895,20 @@
#string STR_GET_HELP_PCI #language en-US "" #string STR_GET_HELP_PCI #language en-US ""
".TH pci 0 "Displays PCI device information."\r\n" ".TH pci 0 "Displays PCI device information."\r\n"
".SH NAME\r\n" ".SH NAME\r\n"
"Displays a PCI device list or PCI function configuration space of a device.\r\n" "Displays PCI device list or PCI function configuration space and PCIe extended\r\n"
"configuration space.\r\n"
".SH SYNOPSIS\r\n" ".SH SYNOPSIS\r\n"
" \r\n" " \r\n"
"PCI [Bus Dev [Func] [-s Seg] [-i]]\r\n" "PCI [Bus Dev [Func] [-s Seg] [-i [-ec ID]]]\r\n"
".SH OPTIONS\r\n" ".SH OPTIONS\r\n"
" \r\n" " \r\n"
" -s - Specifies optional segment number.\r\n" " -s - Specifies optional segment number (hexadecimal number).\r\n"
" -i - Displays interpreted information.\r\n" " -i - Displays interpreted information.\r\n"
" Bus - Specifies a bus number.\r\n" " -ec - Displays detailed interpretation of specified PCIe extended capability\r\n"
" Dev - Specifies a device number.\r\n" " ID (hexadecimal number).\r\n"
" Func - Specifies a function number.\r\n" " Bus - Specifies a bus number (hexadecimal number).\r\n"
" Dev - Specifies a device number (hexadecimal number).\r\n"
" Func - Specifies a function number (hexadecimal number).\r\n"
".SH DESCRIPTION\r\n" ".SH DESCRIPTION\r\n"
" \r\n" " \r\n"
"NOTES:\r\n" "NOTES:\r\n"