X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellDebug1CommandsLib%2FMm.c;h=9f97f1d345f7e6df2609e434599970c86e132115;hp=7b26e4d27f6e3eb3250a91c029b88302eb4a8c52;hb=5563281fa2b31093a1cbd415553b9264c5136e89;hpb=02d3482574ed2b0b5435563c234563bea2167634 diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c index 7b26e4d27f..9f97f1d345 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Mm.c @@ -2,7 +2,7 @@ Main file for Mm shell Debug1 function. (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
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 @@ -58,10 +58,10 @@ CONST EFI_CPU_IO_PROTOCOL_WIDTH mShellMmCpuIoWidth[] = { /** Extract the PCI segment, bus, device, function, register from - from a SHELL_MM_PCI or SHELL_MM_PCIE format of address.. + from a PCI or PCIE format of address.. @param[in] PciFormat Whether the address is of PCI format of PCIE format. - @param[in] Address SHELL_MM_PCI or SHELL_MM_PCIE address. + @param[in] Address PCI or PCIE address. @param[out] Segment PCI segment number. @param[out] Bus PCI bus number. @param[out] Device PCI device number. @@ -69,7 +69,6 @@ CONST EFI_CPU_IO_PROTOCOL_WIDTH mShellMmCpuIoWidth[] = { @param[out] Register PCI register offset. **/ VOID -EFIAPI ShellMmDecodePciAddress ( IN BOOLEAN PciFormat, IN UINT64 Address, @@ -82,10 +81,10 @@ ShellMmDecodePciAddress ( { if (PciFormat) { // - // PCI Configuration Space.The address will have the format 0x000000ssbbddffrr, - // where ss = Segment, bb = Bus, dd = Device, ff = Function and rr = Register. + // PCI Configuration Space.The address will have the format ssssbbddffrr, + // where ssss = Segment, bb = Bus, dd = Device, ff = Function and rr = Register. // - *Segment = (UINT32) (RShiftU64 (Address, 32) & 0xFF); + *Segment = (UINT32) (RShiftU64 (Address, 32) & 0xFFFF); *Bus = (UINT8) (((UINT32) Address) >> 24); if (Device != NULL) { @@ -99,10 +98,10 @@ ShellMmDecodePciAddress ( } } else { // - // PCI Express Configuration Space.The address will have the format 0x0000000ssbbddffrrr, - // where ss = Segment, bb = Bus, dd = Device, ff = Function and rrr = Register. + // PCI Express Configuration Space.The address will have the format ssssssbbddffrrr, + // where ssss = Segment, bb = Bus, dd = Device, ff = Function and rrr = Register. // - *Segment = (UINT32) (RShiftU64 (Address, 36) & 0xFF); + *Segment = (UINT32) (RShiftU64 (Address, 36) & 0xFFFF); *Bus = (UINT8) RShiftU64 (Address, 28); if (Device != NULL) { *Device = (UINT8) (((UINT32) Address) >> 20); @@ -329,6 +328,8 @@ ShellMmLocateIoProtocol ( return FALSE; } + Segment = 0; + Bus = 0; if ((AccessType == ShellMmPci) || (AccessType == ShellMmPciExpress)) { ShellMmDecodePciAddress ((BOOLEAN) (AccessType == ShellMmPci), Address, &Segment, &Bus, NULL, NULL, NULL); } @@ -615,18 +616,18 @@ ShellCommandRunMm ( // skip space characters // for (Index = 0; InputStr[Index] == ' '; Index++); - } - if ((InputStr != NULL) && (InputStr[Index] != CHAR_NULL)) { - if ((InputStr[Index] == '.') || (InputStr[Index] == 'q') || (InputStr[Index] == 'Q')) { - Complete = TRUE; - } else if (!EFI_ERROR (ShellConvertStringToUint64 (InputStr + Index, &Buffer, TRUE, TRUE)) && - (Buffer <= mShellMmMaxNumber[Size]) - ) { - ShellMmAccess (AccessType, PciRootBridgeIo, CpuIo, FALSE, Address, Size, &Buffer); - } else { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_ERROR), gShellDebug1HiiHandle, L"mm"); - continue; + if (InputStr[Index] != CHAR_NULL) { + if ((InputStr[Index] == '.') || (InputStr[Index] == 'q') || (InputStr[Index] == 'Q')) { + Complete = TRUE; + } else if (!EFI_ERROR (ShellConvertStringToUint64 (InputStr + Index, &Buffer, TRUE, TRUE)) && + (Buffer <= mShellMmMaxNumber[Size]) + ) { + ShellMmAccess (AccessType, PciRootBridgeIo, CpuIo, FALSE, Address, Size, &Buffer); + } else { + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MM_ERROR), gShellDebug1HiiHandle, L"mm"); + continue; + } } }