From nobody Thu Dec 26 13:23:11 2024 Delivered-To: importer@patchew.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; 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 1504170692420215.98277306707257; Thu, 31 Aug 2017 02:11:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4DCDF21EB5292; Thu, 31 Aug 2017 02:08:47 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 E485821EB528D for ; Thu, 31 Aug 2017 02:08:45 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Aug 2017 02:11:27 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.31]) by orsmga001.jf.intel.com with ESMTP; 31 Aug 2017 02:11:26 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,451,1498546800"; d="scan'208";a="1167869449" From: Star Zeng To: edk2-devel@lists.01.org Date: Thu, 31 Aug 2017 17:11:19 +0800 Message-Id: <1504170679-7412-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [edk2] [PATCH] SourceLevelDebugPkg/DebugCommLibUsb3Pei: Make sure alloc physical mem 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: Ruiyu Ni , Hao Wu , Star Zeng 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" PI 1.6 has supported pre permanent memory page allocation, to make sure the allocated memory is physical memory for DMA, the patch is to check memory discovered PPI installed or not first before calling AllocatePages. Cc: Ruiyu Ni Cc: Hao Wu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng Reviewed-by: Hao Wu Reviewed-by: Ruiyu Ni --- .../DebugCommunicationLibUsb3Pei.c | 28 +++++++++++++++---= ---- .../DebugCommunicationLibUsb3Pei.inf | 5 +++- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom= municationLibUsb3Pei.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibU= sb3/DebugCommunicationLibUsb3Pei.c index be3174e75fd6..902a3b626acc 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicat= ionLibUsb3Pei.c +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicat= ionLibUsb3Pei.c @@ -1,7 +1,7 @@ /** @file Debug Port Library implementation based on usb3 debug port. =20 - Copyright (c) 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 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 @@ -14,6 +14,7 @@ =20 #include #include +#include #include "DebugCommunicationLibUsb3Internal.h" =20 /** @@ -32,13 +33,24 @@ AllocateAlignBuffer ( VOID *Buf; EFI_PHYSICAL_ADDRESS Address; EFI_STATUS Status; - =20 - Buf =3D NULL; =20 - Status =3D PeiServicesAllocatePages (EfiACPIMemoryNVS, EFI_SIZE_TO_PAGES= (BufferSize), &Address); - if (EFI_ERROR (Status)) { - Buf =3D NULL; - } else { - Buf =3D (VOID *)(UINTN) Address; + VOID *MemoryDiscoveredPpi; + + Buf =3D NULL; + + // + // Make sure the allocated memory is physical memory. + // + Status =3D PeiServicesLocatePpi ( + &gEfiPeiMemoryDiscoveredPpiGuid, + 0, + NULL, + (VOID **) &MemoryDiscoveredPpi + ); + if (!EFI_ERROR (Status)) { + Status =3D PeiServicesAllocatePages (EfiACPIMemoryNVS, EFI_SIZE_TO_PAG= ES (BufferSize), &Address); + if (!EFI_ERROR (Status)) { + Buf =3D (VOID *)(UINTN) Address; + } } return Buf; } diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCom= municationLibUsb3Pei.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLi= bUsb3/DebugCommunicationLibUsb3Pei.inf index 74dcdd124b47..6cd5e1068333 100644 --- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicat= ionLibUsb3Pei.inf +++ b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb3/DebugCommunicat= ionLibUsb3Pei.inf @@ -1,7 +1,7 @@ ## @file # Debug Communication Library instance based on usb3 debug port. # -# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -40,6 +40,9 @@ [Packages] IntelFrameworkPkg/IntelFrameworkPkg.dec SourceLevelDebugPkg/SourceLevelDebugPkg.dec =20 +[Ppis] + gEfiPeiMemoryDiscoveredPpiGuid ## CONSUMES + [Pcd] # The memory BAR of ehci host controller, in which usb debug feature is = enabled. # Note that the memory BAR address is only used before Pci bus resource = allocation. --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel