From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 05662821CB for ; Tue, 28 Feb 2017 18:48:12 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2017 18:48:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,223,1484035200"; d="scan'208";a="1103412805" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 28 Feb 2017 18:48:12 -0800 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 28 Feb 2017 18:48:12 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 28 Feb 2017 18:48:11 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.177]) by shsmsx102.ccr.corp.intel.com ([169.254.2.88]) with mapi id 14.03.0248.002; Wed, 1 Mar 2017 10:48:07 +0800 From: "Tian, Feng" To: "Ni, Ruiyu" , Leo Duran , "edk2-devel@ml01.01.org" CC: "Zeng, Star" , "Tian, Feng" Thread-Topic: [edk2] [PATCH v3 1/6] MdeModulePkg: Add DxeBmDmaLib (BmDmaLib class) library Thread-Index: AQHSgvNHe/zxIny6aUy+HtjTcMFkmqF+3f6AgACHoxA= Date: Wed, 1 Mar 2017 02:48:06 +0000 Message-ID: <7F1BAD85ADEA444D97065A60D2E97EE5699B6391@SHSMSX101.ccr.corp.intel.com> References: <1486658427-6551-1-git-send-email-leo.duran@amd.com> <1486658427-6551-2-git-send-email-leo.duran@amd.com> <734D49CCEBEEF84792F5B80ED585239D5B8BB133@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5B8BB133@SHSMSX104.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v3 1/6] MdeModulePkg: Add DxeBmDmaLib (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: , X-List-Received-Date: Wed, 01 Mar 2017 02:48:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable A minor comment: > + LIBRARY_CLASS =3D BmDmaLib|DXE_DRIVER Shouldn't this lib support UEFI driver? Thanks Feng -----Original Message----- From: Ni, Ruiyu=20 Sent: Wednesday, March 1, 2017 10:39 AM To: Leo Duran ; edk2-devel@ml01.01.org Cc: Tian, Feng ; Zeng, Star Subject: RE: [edk2] [PATCH v3 1/6] MdeModulePkg: Add DxeBmDmaLib (BmDmaLib = class) library I suggest to align to BS->FreePages() prototype. Other parts of this patch = are good to me. BmDmaFreeBuffer (, IN VOID *HostAddress IN UINTN Pages Thanks/Ray > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of=20 > Leo Duran > Sent: Friday, February 10, 2017 12:40 AM > To: edk2-devel@ml01.01.org > Cc: Tian, Feng ; Leo Duran ;=20 > Zeng, Star > Subject: [edk2] [PATCH v3 1/6] MdeModulePkg: Add DxeBmDmaLib (BmDmaLib=20 > class) library >=20 > This patch provides an abstraction layer for Bus-master DMA operations=20 > as currently implemented by the PciHostBridgeDxe driver. The intent is=20 > to then allow override of this library as may be required by specific=20 > hardware implementations, such as AMD's Secure Encrypted Virtualization (= SEV). >=20 > This new BmDmaLib class library is cloned from the existing DmaLib=20 > with an additional DmaAbove4GB (BOOLEAN) parameter for the Map and=20 > Allocate interfaces, so that decisions can be made about the need to=20 > allocate DMA buffers below the 4GB boundary. >=20 > Cc: Feng Tian > Cc: Star Zeng > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Leo Duran > --- > MdeModulePkg/Include/Library/BmDmaLib.h | 161 +++++++++++ > MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.c | 351 > +++++++++++++++++++++++ > MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf | 41 +++ > MdeModulePkg/MdeModulePkg.dsc | 1 + > 4 files changed, 554 insertions(+) > create mode 100644 MdeModulePkg/Include/Library/BmDmaLib.h > create mode 100644 > MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.c > create mode 100644 > MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf >=20 > diff --git a/MdeModulePkg/Include/Library/BmDmaLib.h > b/MdeModulePkg/Include/Library/BmDmaLib.h > new file mode 100644 > index 0000000..2c0e50f > --- /dev/null > +++ b/MdeModulePkg/Include/Library/BmDmaLib.h > @@ -0,0 +1,161 @@ > +/** @file > + DMA abstraction library APIs. Based on PCI IO protocol DMA abstraction= s. > + > + Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
=20 > + Copyright (c) 2017, AMD Inc. All rights reserved.
> + > + DMA Bus Master Read Operation: > + Call BmDmaMap() for DmaOperationBusMasterRead. > + Program the DMA Bus Master with the DeviceAddress returned by > BmDmaMap(). > + Start the DMA Bus Master. > + Wait for DMA Bus Master to complete the read operation. > + Call BmDmaUnmap(). > + > + DMA Bus Master Write Operation: > + Call BmDmaMap() for DmaOperationBusMasterWrite. > + Program the DMA Bus Master with the DeviceAddress returned by > BmDmaMap(). > + Start the DMA Bus Master. > + Wait for DMA Bus Master to complete the write operation. > + Call BmDmaUnmap(). > + > + DMA Bus Master Common Buffer Operation: > + Call BmDmaAllocateBuffer() to allocate a common buffer. > + Call BmDmaMap() for DmaOperationBusMasterCommonBuffer. > + Program the DMA Bus Master with the DeviceAddress returned by > BmDmaMap(). > + The common buffer can now be accessed equally by the processor=20 > + and > the DMA bus master. > + Call BmDmaUnmap(). > + Call BmDmaFreeBuffer(). > + > + This program and the accompanying materials are licensed and made=20 > + available under the terms and conditions of the BSD License which=20 > + accompanies this distribution. The full text of the license may be=20 > + found at http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > + Derived from: > + EmbeddedPkg/Include/Library/DmaLib.h > + > +**/ > + > +#ifndef __BM_DMA_LIB_H__ > +#define __BM_DMA_LIB_H__ > + > + > +typedef enum { > + /// > + /// A read operation from system memory by a bus master. > + /// > + DmaOperationBusMasterRead, > + /// > + /// A write operation from system memory by a bus master. > + /// > + DmaOperationBusMasterWrite, > + /// > + /// Provides both read and write access to system memory by both=20 > +the processor and a > + /// bus master. The buffer is coherent from both the processor's=20 > +and the > bus master's point of view. > + /// > + DmaOperationBusMasterCommonBuffer, > + DmaOperationBusMasterMaximum > +} BM_DMA_OPERATION; > + > + > +/** > + Provides the DMA controller-specific addresses needed to access=20 > +system > memory. > + > + Operation is relative to the DMA bus master. > + > + @param DmaAbove4GB Indicates capability of DMA operations > above 4GB. > + @param Operation Indicates if the bus master is going to = read or > write to system memory. > + @param HostAddress The system memory address to map to the > DMA controller. > + @param NumberOfBytes On input the number of bytes to map. On > output the number of bytes > + that were mapped. > + @param DeviceAddress The resulting map address for the bus ma= ster > controller to use to > + access the hosts HostAddress. > + @param Mapping A resulting value to pass to BmDmaUnmap(= ). > + > + @retval EFI_SUCCESS The range was mapped for the returned > NumberOfBytes. > + @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a > common buffer. > + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. > + @retval EFI_OUT_OF_RESOURCES The request could not be completed > due to a lack of resources. > + @retval EFI_DEVICE_ERROR The system hardware could not map the > requested address. > + > +**/ > +EFI_STATUS > +EFIAPI > +BmDmaMap ( > + IN BOOLEAN DmaAbove4GB, > + IN BM_DMA_OPERATION Operation, > + IN VOID *HostAddress, > + IN OUT UINTN *NumberOfBytes, > + OUT PHYSICAL_ADDRESS *DeviceAddress, > + OUT VOID **Mapping > + ); > + > + > +/** > + Completes the DmaOperationBusMasterRead/Write/CommonBuffer > operation > + and releases any corresponding resources. > + > + @param Mapping The mapping value returned from BmDmaMap= (). > + > + @retval EFI_SUCCESS The range was unmapped. > + @retval EFI_DEVICE_ERROR The data was not committed to the target > system memory. > + > +**/ > +EFI_STATUS > +EFIAPI > +BmDmaUnmap ( > + IN VOID *Mapping > + ); > + > + > +/** > + Allocates pages that are suitable for a BmDmaMap() of type > DmaOperationBusMasterCommonBuffer. > + > + @param DmaAbove4GB Indicates capability of DMA operations > above 4GB. > + @param MemoryType The type of memory to allocate: > EfiBootServicesData or > + EfiRuntimeServicesData. > + @param Pages The number of pages to allocate. > + @param HostAddress A pointer to store the base system memor= y > address of the > + allocated range. > + > + @retval EFI_SUCCESS The requested memory pages were allocate= d. > + @retval EFI_UNSUPPORTED Attributes is unsupported. The only lega= l > attribute bits are > + MEMORY_WRITE_COMBINE and MEMORY_CACHED. > + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. > + @retval EFI_OUT_OF_RESOURCES The memory pages could not be > allocated. > + > +**/ > +EFI_STATUS > +EFIAPI > +BmDmaAllocateBuffer ( > + IN BOOLEAN DmaAbove4GB, > + IN EFI_MEMORY_TYPE MemoryType, > + IN UINTN Pages, > + OUT VOID **HostAddress > + ); > + > + > +/** > + Frees memory that was allocated with BmDmaAllocateBuffer(). > + > + @param Pages The number of pages to free. > + @param HostAddress The base system memory address of the > allocated range. > + > + @retval EFI_SUCCESS The requested memory pages were freed. > + @retval EFI_INVALID_PARAMETER The memory range specified by > HostAddress and Pages > + was not allocated with BmDmaAllocateBuff= er(). > + > +**/ > +EFI_STATUS > +EFIAPI > +BmDmaFreeBuffer ( > + IN UINTN Pages, > + IN VOID *HostAddress > + ); > + > + > +#endif > + > diff --git a/MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.c > b/MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.c > new file mode 100644 > index 0000000..824b51f > --- /dev/null > +++ b/MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.c > @@ -0,0 +1,351 @@ > +/** @file > + DMA abstraction library APIs. Based on PCI IO protocol DMA abstraction= s. > + > + Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
=20 > + Copyright (c) 2017, AMD Inc. All rights reserved.
> + > + This program and the accompanying materials are licensed and made=20 > + available under the terms and conditions of the BSD License which=20 > + accompanies this distribution. The full text of the license may be=20 > + found at http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > + Derived from: > + MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c > + > +**/ > + > +#include > +#include > +#include > +#include > +#include #include=20 > + #include=20 > + > +#include > + > + > +#define FORCE_BELOW_4GB_TRUE TRUE > +#define FORCE_BELOW_4GB_FALSE FALSE > +#define NO_MAPPING (VOID *) (UINTN) -1 > + > + > +typedef struct { > + BM_DMA_OPERATION Operation; > + UINTN NumberOfBytes; > + UINTN NumberOfPages; > + EFI_PHYSICAL_ADDRESS HostAddress; > + EFI_PHYSICAL_ADDRESS MappedHostAddress; } MAP_INFO; > + > + > +EFI_STATUS > +AllocateBounceBuffer ( > + IN BOOLEAN ForceBelow4GB, > + IN BM_DMA_OPERATION Operation, > + IN EFI_PHYSICAL_ADDRESS HostAddress, > + IN OUT UINTN *NumberOfBytes, > + OUT PHYSICAL_ADDRESS *DeviceAddress, > + OUT VOID **Mapping > + ) > +{ > + EFI_STATUS Status; > + MAP_INFO *MapInfo; > + EFI_ALLOCATE_TYPE AllocateType; > + > + // > + // 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->Operation =3D Operation; > + MapInfo->NumberOfBytes =3D *NumberOfBytes; MapInfo- > >NumberOfPages =3D > + EFI_SIZE_TO_PAGES (MapInfo->NumberOfBytes); > + MapInfo->HostAddress =3D HostAddress; > + > + if (ForceBelow4GB) { > + // > + // Limit allocations to memory below 4GB > + // > + AllocateType =3D AllocateMaxAddress; > + MapInfo->MappedHostAddress =3D SIZE_4GB - 1; } else { > + AllocateType =3D AllocateAnyPages; > + } > + > + // > + // Allocate DMA bounce buffer > + // > + Status =3D gBS->AllocatePages ( > + AllocateType, > + 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,=20 > + // then copy the contents of the real buffer into the mapped buffer=20 > + // so the Bus Master can read the contents of the real buffer. > + // > + if (Operation =3D=3D DmaOperationBusMasterRead) { > + CopyMem ( > + (VOID *) (UINTN) MapInfo->MappedHostAddress, > + (VOID *) (UINTN) MapInfo->HostAddress, > + MapInfo->NumberOfBytes > + ); > + } > + > + // > + // The DeviceAddress is the address of the mapped buffer //=20 > + *DeviceAddress =3D MapInfo->MappedHostAddress; > + > + // > + // Return a pointer to the MAP_INFO structure in Mapping //=20 > + *Mapping =3D MapInfo; > + > + return EFI_SUCCESS; > +} > + > + > +/** > + Provides the DMA controller-specific addresses needed to access=20 > +system > memory. > + > + Operation is relative to the DMA bus master. > + > + @param DmaAbove4GB Indicates capability of DMA operations > above 4GB. > + @param Operation Indicates if the bus master is going to = read or > write to system memory. > + @param HostAddress The system memory address to map to the > DMA controller. > + @param NumberOfBytes On input the number of bytes to map. On > output the number of bytes > + that were mapped. > + @param DeviceAddress The resulting map address for the bus ma= ster > controller to use to > + access the hosts HostAddress. > + @param Mapping A resulting value to pass to BmDmaUnmap(= ). > + > + @retval EFI_SUCCESS The range was mapped for the returned > NumberOfBytes. > + @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a > common buffer. > + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. > + @retval EFI_OUT_OF_RESOURCES The request could not be completed > due to a lack of resources. > + @retval EFI_DEVICE_ERROR The system hardware could not map the > requested address. > + > +**/ > +EFI_STATUS > +EFIAPI > +BmDmaMap ( > + IN BOOLEAN DmaAbove4GB, > + IN BM_DMA_OPERATION Operation, > + IN VOID *HostAddress, > + IN OUT UINTN *NumberOfBytes, > + OUT PHYSICAL_ADDRESS *DeviceAddress, > + OUT VOID **Mapping > + ) > +{ > + EFI_PHYSICAL_ADDRESS PhysicalAddress; > + > + // > + // Check for invalid inputs > + // > + if (HostAddress =3D=3D NULL || NumberOfBytes =3D=3D NULL || DeviceAddr= ess=20 > + =3D=3D > NULL || > + Mapping =3D=3D NULL || (UINT32) Operation >=3D > DmaOperationBusMasterMaximum) { > + return EFI_INVALID_PARAMETER; > + } > + > + PhysicalAddress =3D (EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress; if=20 > + (DmaAbove4GB || (PhysicalAddress + *NumberOfBytes) <=3D SIZE_4GB) { > + // > + // If we CAN handle DMA above 4GB or the transfer is below 4GB, > + // the DeviceAddress is simply the HostAddress > + // > + *DeviceAddress =3D PhysicalAddress; > + *Mapping =3D NO_MAPPING; > + > + return EFI_SUCCESS; > + } > + > + // > + // If we cannot handle DMA above 4GB and any part of the DMA=20 > + transfer // being is above 4GB, then map the DMA transfer to a buffer b= elow 4GB. > + // > + if (Operation =3D=3D DmaOperationBusMasterCommonBuffer) { > + // > + // Common Buffer operations cannot be remapped, so return an error. > + // > + return EFI_UNSUPPORTED; > + } > + > + return AllocateBounceBuffer ( > + Operation, > + FORCE_BELOW_4GB_TRUE, > + PhysicalAddress, > + NumberOfBytes, > + DeviceAddress, > + Mapping > + ); > +} > + > + > +/** > + Completes the DmaOperationBusMasterRead/Write/CommonBuffer > operation > + and releases any corresponding resources. > + > + @param Mapping The mapping value returned from BmDmaMap= (). > + > + @retval EFI_SUCCESS The range was unmapped. > + @retval EFI_DEVICE_ERROR The data was not committed to the target > system memory. > + > +**/ > +EFI_STATUS > +EFIAPI > +BmDmaUnmap ( > + IN VOID *Mapping > + ) > +{ > + MAP_INFO *MapInfo; > + > + // > + // Check for invalid inputs > + // > + if (Mapping =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // See if the Map() operation associated with this Unmap() required=20 > + a mapping // buffer. If a mapping buffer was not required, then=20 > + this function simply // returns EFI_SUCCESS. > + // > + if (Mapping =3D=3D NO_MAPPING) { > + return EFI_SUCCESS; > + } > + > + // > + // If this is a write operation from the Bus Master's point of=20 > + view, // then copy the contents of the mapped buffer into the real=20 > + buffer // so the processor can read the contents of the real buffer. > + // > + MapInfo =3D (MAP_INFO *)Mapping; > + if (MapInfo->Operation =3D=3D DmaOperationBusMasterWrite) { > + 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; > +} > + > + > +/** > + Allocates pages that are suitable for a BmDmaMap() of type > DmaOperationBusMasterCommonBuffer. > + > + @param DmaAbove4GB Indicates capability of DMA operations > above 4GB. > + @param MemoryType The type of memory to allocate: > EfiBootServicesData or > + EfiRuntimeServicesData. > + @param Pages The number of pages to allocate. > + @param HostAddress A pointer to store the base system memor= y > address of the > + allocated range. > + > + @retval EFI_SUCCESS The requested memory pages were allocate= d. > + @retval EFI_UNSUPPORTED Attributes is unsupported. The only lega= l > attribute bits are > + MEMORY_WRITE_COMBINE and MEMORY_CACHED. > + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. > + @retval EFI_OUT_OF_RESOURCES The memory pages could not be > allocated. > + > +**/ > +EFI_STATUS > +EFIAPI > +BmDmaAllocateBuffer ( > + IN BOOLEAN DmaAbove4GB, > + IN EFI_MEMORY_TYPE MemoryType, > + IN UINTN Pages, > + OUT VOID **HostAddress > + ) > +{ > + EFI_STATUS Status; > + EFI_PHYSICAL_ADDRESS PhysicalAddress; > + EFI_ALLOCATE_TYPE AllocateType; > + > + // > + // Check for invalid inputs > + // > + if (HostAddress =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // The only valid memory types are EfiBootServicesData and //=20 > + EfiRuntimeServicesData // if (MemoryType !=3D EfiBootServicesData && > + MemoryType !=3D EfiRuntimeServicesData) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (DmaAbove4GB) { > + AllocateType =3D AllocateAnyPages; > + } else { > + // > + // Limit allocations to memory below 4GB > + // > + AllocateType =3D AllocateMaxAddress; > + PhysicalAddress =3D (EFI_PHYSICAL_ADDRESS) (SIZE_4GB - 1); } =20 > + Status =3D gBS->AllocatePages ( > + AllocateType, > + MemoryType, > + Pages, > + &PhysicalAddress > + ); > + if (!EFI_ERROR (Status)) { > + *HostAddress =3D (VOID *) (UINTN) PhysicalAddress; } > + > + return Status; > +} > + > + > +/** > + Frees memory that was allocated with BmDmaAllocateBuffer(). > + > + @param Pages The number of pages to free. > + @param HostAddress The base system memory address of the > allocated range. > + > + @retval EFI_SUCCESS The requested memory pages were freed. > + @retval EFI_INVALID_PARAMETER The memory range specified by > HostAddress and Pages > + was not allocated with BmDmaAllocateBuff= er(). > + > +**/ > +EFI_STATUS > +EFIAPI > +BmDmaFreeBuffer ( > + IN UINTN Pages, > + IN VOID *HostAddress > + ) > +{ > + return gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) HostAddress,=20 > +Pages); } > + > diff --git a/MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf > b/MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf > new file mode 100644 > index 0000000..4ddb27d > --- /dev/null > +++ b/MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf > @@ -0,0 +1,41 @@ > +## @file > +# > +# DMA abstraction library APIs. Based on PCI IO protocol DMA abstraction= s. > +# > +# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
#=20 > +Copyright (c) 2017, AMD Inc. All rights reserved.
# # This=20 > +program and the accompanying materials # are licensed and made=20 > +available under the terms and conditions of the BSD License # which=20 > +accompanies this distribution. The full text of the license may be=20 > +found at # http://opensource.org/licenses/bsd-license.php > +# > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > +BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, > EITHER EXPRESS OR IMPLIED. > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D DxeBmDmaLib > + FILE_GUID =3D daa403e0-071d-44ef-95cf-7f2472e4a4d= 5 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D BmDmaLib|DXE_DRIVER > + > +[Sources.common] > + DxeBmDmaLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + DebugLib > + DxeServicesTableLib > + MemoryAllocationLib > + UefiBootServicesTableLib > + > + > diff --git a/MdeModulePkg/MdeModulePkg.dsc=20 > b/MdeModulePkg/MdeModulePkg.dsc index 5996fe5..311922e 100644 > --- a/MdeModulePkg/MdeModulePkg.dsc > +++ b/MdeModulePkg/MdeModulePkg.dsc > @@ -275,6 +275,7 @@ [Components] > MdeModulePkg/Core/Pei/PeiMain.inf > MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf >=20 > + MdeModulePkg/Library/DxeBmDmaLib/DxeBmDmaLib.inf > MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf >=20 > MdeModulePkg/Library/UefiMemoryAllocationProfileLib/UefiMemoryAlloca > tionProfileLib.inf >=20 > MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllo > cationLib.inf > -- > 1.9.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel