From nobody Fri May 3 01:43:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1509531202484591.738275972336; Wed, 1 Nov 2017 03:13:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5FD3721C913DF; Wed, 1 Nov 2017 03:09:28 -0700 (PDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D5B3621C913DE for ; Wed, 1 Nov 2017 03:09:26 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2017 03:13:18 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.7]) by fmsmga005.fm.intel.com with ESMTP; 01 Nov 2017 03:13:17 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,327,1505804400"; d="scan'208";a="169885048" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 1 Nov 2017 18:13:16 +0800 Message-Id: <20171101101316.59648-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 Subject: [edk2] [PATCH] ShellPkg/hexeditor: Use CpuIo for memory access X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jaben Carsey MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Cc: Jaben Carsey Reviewed-by: Jaben Carsey --- .../HexEdit/HexEditorTypes.h | 9 ++- .../UefiShellDebug1CommandsLib/HexEdit/MemImage.c | 65 +-----------------= ---- 2 files changed, 6 insertions(+), 68 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditorT= ypes.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditorTypes= .h index ddd6070c94..8f0da3b667 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditorTypes.h +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEditorTypes.h @@ -1,7 +1,7 @@ /** @file data types that are used by editor =20 - Copyright (c) 2005 - 2011, 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -78,10 +78,9 @@ typedef struct { } HEFI_EDITOR_DISK_IMAGE; =20 typedef struct { - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoFncs; - - UINTN Offset; - UINTN Size; + EFI_CPU_IO2_PROTOCOL *IoFncs; + UINTN Offset; + UINTN Size; } HEFI_EDITOR_MEM_IMAGE; =20 typedef struct { diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c= b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c index 300c67f0d4..fce9bbe0e6 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MemImage.c @@ -1,7 +1,7 @@ /** @file Functions to deal with Mem buffer =20 - Copyright (c) 2005 - 2011, 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -27,8 +27,6 @@ extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor; HEFI_EDITOR_MEM_IMAGE HMemImage; HEFI_EDITOR_MEM_IMAGE HMemImageBackupVar; =20 -EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL DummyPciRootBridgeIo; - // // for basic initialization of HDiskImage // @@ -39,54 +37,6 @@ HEFI_EDITOR_MEM_IMAGE HMemImageConst =3D { }; =20 /** - Empty function. always returns the same. - - @param[in] This Ignored. - @param[in] Width Ignored. - @param[in] Address Ignored. - @param[in] Count Ignored. - @param[in, out] Buffer Ignored. - - @retval EFI_UNSUPPORTED. -**/ -EFI_STATUS -EFIAPI -DummyMemRead ( - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN OUT VOID *Buffer - ) -{ - return EFI_UNSUPPORTED; -} - -/** - Empty function. always returns the same. - - @param[in] This Ignored. - @param[in] Width Ignored. - @param[in] Address Ignored. - @param[in] Count Ignored. - @param[in, out] Buffer Ignored. - - @retval EFI_UNSUPPORTED. -**/ -EFI_STATUS -EFIAPI -DummyMemWrite ( - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN OUT VOID *Buffer - ) -{ - return EFI_UNSUPPORTED; -} - -/** Initialization function for HDiskImage. =20 @retval EFI_SUCCESS The operation was successful. @@ -105,21 +55,10 @@ HMemImageInit ( CopyMem (&HMemImage, &HMemImageConst, sizeof (HMemImage)); =20 Status =3D gBS->LocateProtocol ( - &gEfiPciRootBridgeIoProtocolGuid, + &gEfiCpuIo2ProtocolGuid, NULL, (VOID**)&HMemImage.IoFncs ); - if (Status =3D=3D EFI_NOT_FOUND) { - // - // For NT32, no EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL is available - // Use Dummy PciRootBridgeIo for memory access - // - ZeroMem (&DummyPciRootBridgeIo, sizeof (EFI_PCI_ROOT_BRIDGE_IO_PROTOCO= L)); - DummyPciRootBridgeIo.Mem.Read =3D DummyMemRead; - DummyPciRootBridgeIo.Mem.Write =3D DummyMemWrite; - HMemImage.IoFncs =3D &DummyPciRootBridgeIo; - Status =3D EFI_SUCCESS; - } if (!EFI_ERROR (Status)) { return EFI_SUCCESS; } else { --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel