]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/hexeditor: Use CpuIo for memory access
authorRuiyu Ni <ruiyu.ni@intel.com>
Wed, 1 Nov 2017 10:12:53 +0000 (18:12 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Thu, 2 Nov 2017 00:40:33 +0000 (08:40 +0800)
The original code uses PciRootBridgeIo for memory access.
It worked before MdeModulePkg/PciHostBridgeDxe driver was checked in.
But MdeModulePkg/PciHostBridgeDxe adds checks to ensure the MMIO
access request is in the scope of the current RootBridgeIo instance.
It causes "hexeditor -m 0 2" reports error because memory address 0
surely is not in the scope of any RootBridgeIo instance.
In fact only accessing the MMIO space occupied by the RootBridgeIo
can work.

The patch changes hexeditor to use CpuIo for memory access.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditorTypes.h
ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c

index ddd6070c94846e85a51f034310c5258ae35b1403..8f0da3b6673b007520f087e664540e816d8356d2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   data types that are used by editor\r
   \r
-  Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -78,10 +78,9 @@ typedef struct {
 } HEFI_EDITOR_DISK_IMAGE;\r
 \r
 typedef struct {\r
-  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoFncs;\r
-\r
-  UINTN                           Offset;\r
-  UINTN                           Size;\r
+  EFI_CPU_IO2_PROTOCOL *IoFncs;\r
+  UINTN                Offset;\r
+  UINTN                Size;\r
 } HEFI_EDITOR_MEM_IMAGE;\r
 \r
 typedef struct {\r
index 300c67f0d4fe4ed611eaa98473c879d858e4fcce..fce9bbe0e66c4a2c4568a3c1468dd9fdef4e10b3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Functions to deal with Mem buffer\r
   \r
-  Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -27,8 +27,6 @@ extern HEFI_EDITOR_GLOBAL_EDITOR  HMainEditor;
 HEFI_EDITOR_MEM_IMAGE             HMemImage;\r
 HEFI_EDITOR_MEM_IMAGE             HMemImageBackupVar;\r
 \r
-EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL   DummyPciRootBridgeIo;\r
-\r
 //\r
 // for basic initialization of HDiskImage\r
 //\r
@@ -38,54 +36,6 @@ HEFI_EDITOR_MEM_IMAGE             HMemImageConst = {
   0\r
 };\r
 \r
-/**\r
-  Empty function.  always returns the same.\r
-\r
-  @param[in] This        Ignored.\r
-  @param[in] Width       Ignored.\r
-  @param[in] Address     Ignored.\r
-  @param[in] Count       Ignored.\r
-  @param[in, out] Buffer Ignored.\r
-\r
-  @retval EFI_UNSUPPORTED.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DummyMemRead (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              * This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH    Width,\r
-  IN     UINT64                                   Address,\r
-  IN     UINTN                                    Count,\r
-  IN OUT VOID                                     *Buffer\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
-/**\r
-  Empty function.  always returns the same.\r
-\r
-  @param[in] This        Ignored.\r
-  @param[in] Width       Ignored.\r
-  @param[in] Address     Ignored.\r
-  @param[in] Count       Ignored.\r
-  @param[in, out] Buffer Ignored.\r
-\r
-  @retval EFI_UNSUPPORTED.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-DummyMemWrite (\r
-  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL              * This,\r
-  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH    Width,\r
-  IN     UINT64                                   Address,\r
-  IN     UINTN                                    Count,\r
-  IN OUT VOID                                     *Buffer\r
-  )\r
-{\r
-  return EFI_UNSUPPORTED;\r
-}\r
-\r
 /**\r
   Initialization function for HDiskImage.\r
 \r
@@ -105,21 +55,10 @@ HMemImageInit (
   CopyMem (&HMemImage, &HMemImageConst, sizeof (HMemImage));\r
 \r
   Status = gBS->LocateProtocol (\r
-                &gEfiPciRootBridgeIoProtocolGuid,\r
+                &gEfiCpuIo2ProtocolGuid,\r
                 NULL,\r
                 (VOID**)&HMemImage.IoFncs\r
                 );\r
-  if (Status == EFI_NOT_FOUND) {\r
-    //\r
-    // For NT32, no EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL is available\r
-    // Use Dummy PciRootBridgeIo for memory access\r
-    //\r
-    ZeroMem (&DummyPciRootBridgeIo, sizeof (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL));\r
-    DummyPciRootBridgeIo.Mem.Read  = DummyMemRead;\r
-    DummyPciRootBridgeIo.Mem.Write = DummyMemWrite;\r
-    HMemImage.IoFncs = &DummyPciRootBridgeIo;\r
-    Status = EFI_SUCCESS;\r
-  }\r
   if (!EFI_ERROR (Status)) {\r
     return EFI_SUCCESS;\r
   } else {\r