From nobody Sat Nov 2 16:33:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zoho.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 148665845787614.725861219705962; Thu, 9 Feb 2017 08:40:57 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 67FC381F6D; Thu, 9 Feb 2017 08:40:51 -0800 (PST) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0625.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe48::625]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 00C8881FFB for ; Thu, 9 Feb 2017 08:40:50 -0800 (PST) Received: from leduran-Precision-WorkStation-T5400.amd.com (165.204.77.1) by MWHPR12MB1245.namprd12.prod.outlook.com (10.169.204.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Thu, 9 Feb 2017 16:40:47 +0000 X-Original-To: edk2-devel@ml01.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=dmtYrtQR8VupdsppDXHs+sMSfocgCH8zqsa8WSn4IKo=; b=d/OOfK7Kfl7/NiqgUIGeUiHpleivVHWzemurlMq+tiOmdv+k/N8TuBFBkJ4U3trh63sfWWHn44bN3OzjktHWM4Az74xIRpiuPRkkz+GOfYX+yyNnJb9vBfIsakwKLyRRBK8wnHuJP61JLvRWaHNUcUsMZk57K8dNEdAPrpw68cs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=leo.duran@amd.com; From: Leo Duran To: Date: Thu, 9 Feb 2017 10:40:27 -0600 Message-ID: <1486658427-6551-7-git-send-email-leo.duran@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1486658427-6551-1-git-send-email-leo.duran@amd.com> References: <1486658427-6551-1-git-send-email-leo.duran@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: YTOPR01CA0009.CANPRD01.PROD.OUTLOOK.COM (10.166.147.19) To MWHPR12MB1245.namprd12.prod.outlook.com (10.169.204.149) X-MS-Office365-Filtering-Correlation-Id: dfeeb930-08c8-417c-a6d2-08d4510a6701 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:MWHPR12MB1245; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1245; 3:CXDUpxF36Tbw38UwLW04bmirF2OxhHYJsOIEevZ+4e208ftStg6YxD61esYRpA4O4fq7HYluBj92Kevra6v56ZsppHKMFgwH63VlvGIr5qvrOMXcKvqbFxEwjJBX6idrGocIOy1/x2hqfbc7GwCfKHphweQeKWlMwa/ssaXb4AxxxqjJZ75Vgzurl8IraXNPNPlhIpSuVuQsRHKl8Ts0MgvIDENMfiaJm5MO1EOd8u7W3lTEtomZ/PGe6NMXDd7nS0fjXLkHm2SPTVGogKLa/NtYQKcACsJYHb7Lix2mYAs=; 25:ozRIJ9hkQqaVST40bA0ucCxS4ySj/tjdroU+gbAVM7oCMkcxqPZGqEV5Yvl/4n/lwDJqGW73VOxVTXW8aaYHds9cacoxncJCF+4KH9arxB9bMcSzBHWScjtGVDyFwwjQZjQ79+rfOEKzOJ3Up0B86SnD28/0/vIZp+R91R2l5vylKUiOe075dbXnOxUIdcc6mqKssXnCntiukbLBY9CMHXEa3pR6rqlXS/ux2BPOfcjnQgVY442LaInv5qC5OUnAbPuzjE3jyW1Ga8dMqxjTpapoSmL84CgNhIbYAmIxAU3Z84WEPgJkASla+R/k3gpJiBAJ43Rzb+pVN+lfcvRw4aQrljhova9iobvj4kkQlNgpEeVXCGq7CCDtZ29chM3OYYmLOexFfoNrp/fJJLHzABO/FgrlHTURy4EpoS8d2BF0emVrdjgwwSVWmG+HYR2DkSstznId3C8mTl+Xwht7wA== X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1245; 31:1nYjYsc1mRwM+VxbiIrN4ywLo1uhKc/fJqwyFVXr23lg8TWdsl26A/9fmtCXYLxlep39yL82Ex9ZFkoOf4X1HdRYH1MxathDL9h7Vf/HpHBxxYleDq5/FLDv4+lBaiInKhm12junKdyAEoVrFVPSXdDNH0jlhTKHjn7gp81vjSnNx8etWXXCKRFjOOnQMJS24METw3a3K4jEKRaVIwUs0LnWMZVh+9LUzX9N09kJEoWGMHTC8cnMLg2TF6Az497UH6htrmj1cnTqG6VcYGNBug==; 20:ydVUwYsXdYbkfj8YPUIRUpl+wcXKQk6pYDkbl5GIxDN9f8Sqv4yB8AESgGbnUxcrAwH/PA5yPyzav7XQlrpsvS3GAlLgQpsci7VyQMimOErv3giReHFQ+zoaT8OTf+XR5oSZs+NKLENDyM3Oe8T3drTcvmQb489UYZJigTU+ANLEf0CKzWd2HfA/5eMVb6Pg4tK07w2vjEeWyxjEMvLgRxeomupWKDkXKb9s1MXJE2d3sS1Om4gxaB4Qfku0vJCb4q9Z6dM7JAHdEDDTb9bl5mqnmAnp7et3WdQl2UX2bYJg1rmWrwm0d06kvesiFutcYnHdHLPQuZqyNoH9Gzoi54yAvygeP+6DlaKTt00y8BRepTlqDODJNw7Y6ok6YTHQfXpWst5+61PpBoaYYIMH7rk6F2VMGeqFMctHKxKG8Wfk8KWlDinRhPK6vD/wvmTb+vrli2xyAJDA8KJs7ztiXsdwZVvGzxe69dmbN5N98LDFC0ckOnccQrU2q6lqRWYo X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123564025)(20161123558025)(20161123555025)(20161123562025)(6072148); SRVR:MWHPR12MB1245; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1245; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1245; 4:MAdcx9/VoW3RVYfJJyJfHpQWiCC/Y+WRJeJEZ9TZbpImwGc7sRG+y/CjFzFiT7rtL8geaharvubqV9EUxjfxHIDo/29l60csxOhbpzN36Lff3Jifker49FQCXlZciH6XvXEe1HRsrlhstJN/Vkhs/2K3kyezOe7QRBjyefdmQrMhJP6AVFeQBoP9k7QDihEc+kSOSNp8OGjF4m1Ex0EffxqdERiG8NDPWM+rJzC1zWbYXZYSJWAAvwnqQ7qZ5v94Vk37jCbKqStPj2wRQJvrSOtlAWWYjORCLruRgDew7t3thlVWWhsnqcz92mlKQkBEsSKTVh8e7lQkEfNxbnPuSpESUuIt/yWLSfHwDjedRoTOnFgAMwgG5h+tVG/GJCI5tKXKL3MTp6G4FbICazB1BeHa1NUS6TOFs4XDbyqdkw4CQlHdUu8C1TYJlm+8xs0mv0+u//wH2wK3a2SVHDeyiYqPD7vcdsDkq5+OSnn8cMjznRsK4KMSsAG/EeV7M23FqTnB/FJjq9Bi+EyKe2Vgu/73fNpS7GR7vmO67f4lLAr9hhlXir5uIMWMb0ZWgtkf1EnPzGTarC5LXoPBNgBUzPYeVFg99rq5nzWJ5djfXe36AzsIklbcvMb1B9tVknQGbcORY3C+eOmFtvFqvdFI/fAFsPzq/jP9guDPMlQkOA5Kat7k9FQyXbOZv0rv2Orl/y/8wh5AOKYGuIQYY/yfRg== X-Forefront-PRVS: 02135EB356 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6029001)(6009001)(7916002)(39860400002)(39840400002)(39410400002)(39450400003)(39850400002)(189002)(199003)(101416001)(76176999)(66066001)(2906002)(47776003)(189998001)(54906002)(4326007)(305945005)(53416004)(2351001)(105586002)(106356001)(50986999)(42186005)(5003940100001)(25786008)(92566002)(68736007)(7736002)(50466002)(50226002)(3846002)(6116002)(48376002)(6486002)(97736004)(81156014)(8676002)(81166006)(36756003)(110136004)(2950100002)(38730400002)(33646002)(6916009)(6666003)(86362001)(53936002)(5660300001)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1245; H:leduran-Precision-WorkStation-T5400.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; 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: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1245; 23:7+FOXNelK0o4cA5oT8S/EtGt9OCKwNpdSg/FzQzEu?= =?us-ascii?Q?Qctj8NxANub/PRF6F+j5H9hXcDO1TG66uC49s71yxkr4hfSP9CTfUApokfxF?= =?us-ascii?Q?8Q/eifD3xuh4r0gS3k7264c0x1A6vQlGn1TJiIWe7+QwDmz7tSsD7RWybt8T?= =?us-ascii?Q?7IouqSwHDe/Bs6xOto1IKxBtt0kBhtnR8xwIKNFggeU1cgltrA5/7dfEZ7lU?= =?us-ascii?Q?AlRBbNtoVQPHS2uTO53LPrDep4fgq/3pJgmJ6GjKSJ8lIOj1XrjWiPfCeb2d?= =?us-ascii?Q?jb5uzJK9suN2QfPolVezdjNRU4L8PsMDHG/IyEkug01reOR4Nxf6htEArhDx?= =?us-ascii?Q?qvg6tXkc2ybOralB2mKktjmwhT9KFbDm9tjUS9gHW2ATnZyzMR54vWsdJaHz?= =?us-ascii?Q?m3UuTEPp0O85tI+1QtlPPrSopVwEp8kxVTdScYDqedKE2mM0VFf7xG8LSVFv?= =?us-ascii?Q?3s/XwEzy6b92qI7NyqC3Ku43gaGvp6wiRmDIWliPBIRSz+hkD75dGixiFKuP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cKL5Oo7tir29XMeecHIGgSBjlfpOA4C7iw6SD2xbXm+cI2cT6cqVaOGjg7QuLLdnWtfflq2Dprhkqj9omKMc0y3DAHTQxsqVjf9e9HVta2EftOyImaacBRyvWCx2/i8y5PCKmn9ozWKwoz0srqRUABg==; 20:MNh/iz6R+w5fcuPBTmHU7a5C4p/gCFTQn2gLPlnS25/5GpWMt9SHFR9ezggDSML0vuHZiF3bZmF3mSgYwhTvAwnJT4pskherBHimqk095r1iLxfhedCfGe0Fw7jrrbf3MSq/X5Q5u/6iDmwQbK4y2i35O9DWvUcnnIJgYczyz6rZIRTpyQ3xBgJlg6g9NX1CkNCv0yf1BUccDoKG/4n7j50hbDvkj9SxXO2yklwAqhI6BiQsJpOuJPusTBrhWUXx X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2017 16:40:47.9311 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1245 Subject: [edk2] [PATCH v3 6/6] MdeModulePkg: Modify PciHostBridgeDxe to use new BmDmaLib class library X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Feng Tian , Leo Duran , Star Zeng 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 BmDmaLib class library provides an abstraction layer for Bus-master DMA operations as currently implemented by the PciHostBridgeDxe driver. The intent is to allow override of the library as required by specific hardware implementations, such as AMD's Secure Encrypted Virtualization (SEV). Cc: Feng Tian Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 signed-off-by: Leo Duran Reviewed-by: Ruiyu Ni --- .../Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf | 1 + .../Bus/Pci/PciHostBridgeDxe/PciRootBridge.h | 13 +- .../Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 272 +++++------------= ---- MdeModulePkg/MdeModulePkg.dsc | 1 + 4 files changed, 67 insertions(+), 220 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf b/M= deModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf index d8b0439..35bb5c4 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf @@ -42,6 +42,7 @@ [LibraryClasses] BaseLib PciSegmentLib PciHostBridgeLib + BmDmaLib =20 [Protocols] gEfiMetronomeArchProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h b/MdeMod= ulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h index 13185b4..c125fcd 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h @@ -34,6 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER= EXPRESS OR IMPLIED. #include #include #include +#include #include "PciHostResource.h" =20 =20 @@ -43,17 +44,6 @@ typedef enum { PciOperation } OPERATION_TYPE; =20 -#define MAP_INFO_SIGNATURE SIGNATURE_32 ('_', 'm', 'a', 'p') -typedef struct { - UINT32 Signature; - LIST_ENTRY Link; - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation; - UINTN NumberOfBytes; - UINTN NumberOfPages; - EFI_PHYSICAL_ADDRESS HostAddress; - EFI_PHYSICAL_ADDRESS MappedHostAddress; -} MAP_INFO; -#define MAP_INFO_FROM_LINK(a) CR (a, MAP_INFO, Link, MAP_INFO_SIGNATURE) =20 #define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32 ('_', 'p', 'r', 'b') =20 @@ -79,7 +69,6 @@ typedef struct { EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL RootBridgeIo; =20 BOOLEAN ResourceSubmitted; - LIST_ENTRY Maps; } PCI_ROOT_BRIDGE_INSTANCE; =20 #define ROOT_BRIDGE_FROM_THIS(a) CR (a, PCI_ROOT_BRIDGE_INSTANCE, RootBrid= geIo, PCI_ROOT_BRIDGE_SIGNATURE) diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c b/MdeM= odulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c index 8af131b..8a74bf6 100644 --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c @@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER= EXPRESS OR IMPLIED. #include "PciRootBridge.h" #include "PciHostResource.h" =20 -#define NO_MAPPING (VOID *) (UINTN) -1 =20 // // Lookup table for increment values based on transfer widths @@ -55,6 +54,39 @@ UINT8 mOutStride[] =3D { 0 // EfiPciWidthFillUint64 }; =20 + +BM_DMA_OPERATION +ConvertDmaOperation ( + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION RbOperation + ) +{ + BM_DMA_OPERATION BmOperation; + + switch (RbOperation) { + case EfiPciOperationBusMasterRead: + case EfiPciOperationBusMasterRead64: + BmOperation =3D DmaOperationBusMasterRead; + break; + + case EfiPciOperationBusMasterWrite: + case EfiPciOperationBusMasterWrite64: + BmOperation =3D DmaOperationBusMasterWrite; + break; + + case EfiPciOperationBusMasterCommonBuffer: + case EfiPciOperationBusMasterCommonBuffer64: + BmOperation =3D DmaOperationBusMasterCommonBuffer; + break; + + default: + BmOperation =3D DmaOperationBusMasterMaximum; + break; + } + + return BmOperation; +} + + /** Construct the Pci Root Bridge instance. =20 @@ -168,7 +200,6 @@ CreateRootBridge ( TypeMax * sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof (EFI_ACP= I_END_TAG_DESCRIPTOR) ); ASSERT (RootBridge->ConfigBuffer !=3D NULL); - InitializeListHead (&RootBridge->Maps); =20 CopyMem (&RootBridge->Bus, &Bridge->Bus, sizeof (PCI_ROOT_BRIDGE_APERTUR= E)); CopyMem (&RootBridge->Io, &Bridge->Io, sizeof (PCI_ROOT_BRIDGE_APERTURE)= ); @@ -1053,118 +1084,27 @@ RootBridgeIoMap ( OUT VOID **Mapping ) { - EFI_STATUS Status; - PCI_ROOT_BRIDGE_INSTANCE *RootBridge; - EFI_PHYSICAL_ADDRESS PhysicalAddress; - MAP_INFO *MapInfo; - - if (HostAddress =3D=3D NULL || NumberOfBytes =3D=3D NULL || DeviceAddres= s =3D=3D NULL || - Mapping =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // Make sure that Operation is valid - // - if ((UINT32) Operation >=3D EfiPciOperationMaximum) { - return EFI_INVALID_PARAMETER; - } + PCI_ROOT_BRIDGE_INSTANCE *RootBridge; + BOOLEAN DmaAbove4GB; + BM_DMA_OPERATION BmOperation; =20 RootBridge =3D ROOT_BRIDGE_FROM_THIS (This); - - PhysicalAddress =3D (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress; - if ((!RootBridge->DmaAbove4G || - (Operation !=3D EfiPciOperationBusMasterRead64 && - Operation !=3D EfiPciOperationBusMasterWrite64 && - Operation !=3D EfiPciOperationBusMasterCommonBuffer64)) && - ((PhysicalAddress + *NumberOfBytes) > SIZE_4GB)) { - - // - // If the root bridge or the device cannot handle performing DMA above - // 4GB but any part of the DMA transfer being mapped is above 4GB, then - // map the DMA transfer to a buffer below 4GB. - // - - if (Operation =3D=3D EfiPciOperationBusMasterCommonBuffer || - Operation =3D=3D EfiPciOperationBusMasterCommonBuffer64) { - // - // Common Buffer operations can not be remapped. If the common buff= er - // if above 4GB, then it is not possible to generate a mapping, so r= eturn - // an error. - // - return EFI_UNSUPPORTED; - } - - // - // Allocate a MAP_INFO structure to remember the mapping when Unmap() = is - // called later. - // - MapInfo =3D AllocatePool (sizeof (MAP_INFO)); - if (MapInfo =3D=3D NULL) { - *NumberOfBytes =3D 0; - return EFI_OUT_OF_RESOURCES; - } - - // - // Initialize the MAP_INFO structure - // - MapInfo->Signature =3D MAP_INFO_SIGNATURE; - MapInfo->Operation =3D Operation; - MapInfo->NumberOfBytes =3D *NumberOfBytes; - MapInfo->NumberOfPages =3D EFI_SIZE_TO_PAGES (MapInfo->NumberOfByt= es); - MapInfo->HostAddress =3D PhysicalAddress; - MapInfo->MappedHostAddress =3D SIZE_4GB - 1; - - // - // Allocate a buffer below 4GB to map the transfer to. - // - Status =3D gBS->AllocatePages ( - AllocateMaxAddress, - EfiBootServicesData, - MapInfo->NumberOfPages, - &MapInfo->MappedHostAddress - ); - if (EFI_ERROR (Status)) { - FreePool (MapInfo); - *NumberOfBytes =3D 0; - return Status; - } - - // - // If this is a read operation from the Bus Master's point of view, - // then copy the contents of the real buffer into the mapped buffer - // so the Bus Master can read the contents of the real buffer. - // - if (Operation =3D=3D EfiPciOperationBusMasterRead || - Operation =3D=3D EfiPciOperationBusMasterRead64) { - CopyMem ( - (VOID *) (UINTN) MapInfo->MappedHostAddress, - (VOID *) (UINTN) MapInfo->HostAddress, - MapInfo->NumberOfBytes - ); - } - - InsertTailList (&RootBridge->Maps, &MapInfo->Link); - - // - // The DeviceAddress is the address of the maped buffer below 4GB - // - *DeviceAddress =3D MapInfo->MappedHostAddress; - // - // Return a pointer to the MAP_INFO structure in Mapping - // - *Mapping =3D MapInfo; - } else { - // - // If the root bridge CAN handle performing DMA above 4GB or - // the transfer is below 4GB, so the DeviceAddress is simply the - // HostAddress - // - *DeviceAddress =3D PhysicalAddress; - *Mapping =3D NO_MAPPING; - } - - return EFI_SUCCESS; + DmaAbove4GB =3D RootBridge->DmaAbove4G && ( + Operation =3D=3D EfiPciOperationBusMasterRead64 || + Operation =3D=3D EfiPciOperationBusMasterWrite64 || + Operation =3D=3D EfiPciOperationBusMasterCommonBuffer64 + ); + + BmOperation =3D ConvertDmaOperation (Operation); + + return BmDmaMap ( + DmaAbove4GB, + BmOperation, + HostAddress, + NumberOfBytes, + DeviceAddress, + Mapping + ); } =20 /** @@ -1191,58 +1131,7 @@ RootBridgeIoUnmap ( IN VOID *Mapping ) { - MAP_INFO *MapInfo; - LIST_ENTRY *Link; - PCI_ROOT_BRIDGE_INSTANCE *RootBridge; - - RootBridge =3D ROOT_BRIDGE_FROM_THIS (This); - // - // See if the Map() operation associated with this Unmap() required a ma= pping - // buffer. If a mapping buffer was not required, then this function simp= ly - // returns EFI_SUCCESS. - // - if (Mapping =3D=3D NO_MAPPING) { - return EFI_SUCCESS; - } - - MapInfo =3D NO_MAPPING; - for (Link =3D GetFirstNode (&RootBridge->Maps) - ; !IsNull (&RootBridge->Maps, Link) - ; Link =3D GetNextNode (&RootBridge->Maps, Link) - ) { - MapInfo =3D MAP_INFO_FROM_LINK (Link); - if (MapInfo =3D=3D Mapping) { - break; - } - } - // - // Mapping is not a valid value returned by Map() - // - if (MapInfo !=3D Mapping) { - return EFI_INVALID_PARAMETER; - } - RemoveEntryList (&MapInfo->Link); - - // - // If this is a write operation from the Bus Master's point of view, - // then copy the contents of the mapped buffer into the real buffer - // so the processor can read the contents of the real buffer. - // - if (MapInfo->Operation =3D=3D EfiPciOperationBusMasterWrite || - MapInfo->Operation =3D=3D EfiPciOperationBusMasterWrite64) { - CopyMem ( - (VOID *) (UINTN) MapInfo->HostAddress, - (VOID *) (UINTN) MapInfo->MappedHostAddress, - MapInfo->NumberOfBytes - ); - } - - // - // Free the mapped buffer and the MAP_INFO structure. - // - gBS->FreePages (MapInfo->MappedHostAddress, MapInfo->NumberOfPages); - FreePool (Mapping); - return EFI_SUCCESS; + return BmDmaUnmap (Mapping); } =20 /** @@ -1282,56 +1171,23 @@ RootBridgeIoAllocateBuffer ( IN UINT64 Attributes ) { - EFI_STATUS Status; - EFI_PHYSICAL_ADDRESS PhysicalAddress; - PCI_ROOT_BRIDGE_INSTANCE *RootBridge; - EFI_ALLOCATE_TYPE AllocateType; + PCI_ROOT_BRIDGE_INSTANCE *RootBridge; + BOOLEAN DmaAbove4GB; =20 - // - // Validate Attributes - // if ((Attributes & EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER) !=3D 0)= { return EFI_UNSUPPORTED; } =20 - // - // Check for invalid inputs - // - if (HostAddress =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - // - // The only valid memory types are EfiBootServicesData and - // EfiRuntimeServicesData - // - if (MemoryType !=3D EfiBootServicesData && - MemoryType !=3D EfiRuntimeServicesData) { - return EFI_INVALID_PARAMETER; - } - RootBridge =3D ROOT_BRIDGE_FROM_THIS (This); + DmaAbove4GB =3D RootBridge->DmaAbove4G && + (Attributes & EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE) !=3D= 0; =20 - AllocateType =3D AllocateAnyPages; - if (!RootBridge->DmaAbove4G || - (Attributes & EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE) =3D=3D 0) { - // - // Limit allocations to memory below 4GB - // - AllocateType =3D AllocateMaxAddress; - PhysicalAddress =3D (EFI_PHYSICAL_ADDRESS) (SIZE_4GB - 1); - } - Status =3D gBS->AllocatePages ( - AllocateType, - MemoryType, - Pages, - &PhysicalAddress - ); - if (!EFI_ERROR (Status)) { - *HostAddress =3D (VOID *) (UINTN) PhysicalAddress; - } - - return Status; + return BmDmaAllocateBuffer ( + DmaAbove4GB, + MemoryType, + Pages, + HostAddress + ); } =20 /** @@ -1356,7 +1212,7 @@ RootBridgeIoFreeBuffer ( OUT VOID *HostAddress ) { - return gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress, Pages= ); + return BmDmaFreeBuffer (Pages, HostAddress); } =20 /** diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index b343c19..47aa9b9 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -83,6 +83,7 @@ [LibraryClasses] PalLib|MdePkg/Library/BasePalLibNull/BasePalLibNull.inf CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Customize= dDisplayLib.inf FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltL= ib.inf + BmDmaLib|MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf # # Misc # --=20 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel