TianoCore EDK2 master
|
#include <PiDxe.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/DmaLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/IoLib.h>
#include <Library/BaseMemoryLib.h>
#include <Protocol/Cpu.h>
Go to the source code of this file.
Data Structures | |
struct | MAP_INFO_INSTANCE |
struct | UNCACHED_ALLOCATION |
Functions | |
STATIC PHYSICAL_ADDRESS | HostToDeviceAddress (IN VOID *Address) |
STATIC VOID * | InternalAllocateAlignedPages (IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, IN UINTN Alignment) |
EFI_STATUS EFIAPI | DmaMap (IN DMA_MAP_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping) |
EFI_STATUS EFIAPI | DmaUnmap (IN VOID *Mapping) |
EFI_STATUS EFIAPI | DmaAllocateBuffer (IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, OUT VOID **HostAddress) |
EFI_STATUS EFIAPI | DmaAllocateAlignedBuffer (IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, IN UINTN Alignment, OUT VOID **HostAddress) |
EFI_STATUS EFIAPI | DmaFreeBuffer (IN UINTN Pages, IN VOID *HostAddress) |
EFI_STATUS EFIAPI | NonCoherentDmaLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable) |
Variables | |
STATIC EFI_CPU_ARCH_PROTOCOL * | mCpu |
STATIC LIST_ENTRY | UncachedAllocationList |
STATIC PHYSICAL_ADDRESS | mDmaHostAddressLimit |
Generic non-coherent implementation of DmaLib.h
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
Copyright (c) 2015 - 2017, Linaro, Ltd. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file NonCoherentDmaLib.c.
EFI_STATUS EFIAPI DmaAllocateAlignedBuffer | ( | IN EFI_MEMORY_TYPE | MemoryType, |
IN UINTN | Pages, | ||
IN UINTN | Alignment, | ||
OUT VOID ** | HostAddress | ||
) |
Allocates pages that are suitable for an DmaMap() of type MapOperationBusMasterCommonBuffer mapping, at the requested alignment.
MemoryType | The type of memory to allocate, EfiBootServicesData or EfiRuntimeServicesData. |
Pages | The number of pages to allocate. |
Alignment | Alignment in bytes of the base of the returned buffer (must be a power of 2) |
HostAddress | A pointer to store the base system memory address of the allocated range. |
EFI_SUCCESS | The requested memory pages were allocated. |
EFI_INVALID_PARAMETER | One or more parameters are invalid. |
EFI_OUT_OF_RESOURCES | The memory pages could not be allocated. |
Definition at line 494 of file NonCoherentDmaLib.c.
EFI_STATUS EFIAPI DmaAllocateBuffer | ( | IN EFI_MEMORY_TYPE | MemoryType, |
IN UINTN | Pages, | ||
OUT VOID ** | HostAddress | ||
) |
Allocates pages that are suitable for an DmaMap() of type MapOperationBusMasterCommonBuffer mapping.
MemoryType | The type of memory to allocate, EfiBootServicesData or EfiRuntimeServicesData. |
Pages | The number of pages to allocate. |
HostAddress | A pointer to store the base system memory address of the allocated range. |
EFI_SUCCESS | The requested memory pages were allocated. |
EFI_INVALID_PARAMETER | One or more parameters are invalid. |
EFI_OUT_OF_RESOURCES | The memory pages could not be allocated. |
Definition at line 466 of file NonCoherentDmaLib.c.
EFI_STATUS EFIAPI DmaFreeBuffer | ( | IN UINTN | Pages, |
IN VOID * | HostAddress | ||
) |
Frees memory that was allocated with DmaAllocateBuffer().
Pages | The number of pages to free. |
HostAddress | The base system memory address of the allocated range. |
EFI_SUCCESS | The requested memory pages were freed. |
EFI_INVALID_PARAMETER | The memory range specified by HostAddress and Pages was not allocated with DmaAllocateBuffer(). |
Definition at line 632 of file NonCoherentDmaLib.c.
EFI_STATUS EFIAPI DmaMap | ( | IN DMA_MAP_OPERATION | Operation, |
IN VOID * | HostAddress, | ||
IN OUT UINTN * | NumberOfBytes, | ||
OUT PHYSICAL_ADDRESS * | DeviceAddress, | ||
OUT VOID ** | Mapping | ||
) |
Provides the DMA controller-specific addresses needed to access system memory.
Operation is relative to the DMA bus master.
Operation | Indicates if the bus master is going to read or write to system memory. |
HostAddress | The system memory address to map to the DMA controller. |
NumberOfBytes | On input the number of bytes to map. On output the number of bytes that were mapped. |
DeviceAddress | The resulting map address for the bus master controller to use to access the host's HostAddress. |
Mapping | A resulting value to pass to Unmap(). |
EFI_SUCCESS | The range was mapped for the returned NumberOfBytes. |
EFI_UNSUPPORTED | The HostAddress cannot be mapped as a common buffer. |
EFI_INVALID_PARAMETER | One or more parameters are invalid. |
EFI_OUT_OF_RESOURCES | The request could not be completed due to a lack of resources. |
EFI_DEVICE_ERROR | The system hardware could not map the requested address. |
Definition at line 191 of file NonCoherentDmaLib.c.
EFI_STATUS EFIAPI DmaUnmap | ( | IN VOID * | Mapping | ) |
Completes the DmaMapBusMasterRead(), DmaMapBusMasterWrite(), or DmaMapBusMasterCommonBuffer() operation and releases any corresponding resources.
Mapping | The mapping value returned from DmaMap*(). |
EFI_SUCCESS | The range was unmapped. |
EFI_DEVICE_ERROR | The data was not committed to the target system memory. |
EFI_INVALID_PARAMETER | An inconsistency was detected between the mapping type and the DoubleBuffer field |
Definition at line 377 of file NonCoherentDmaLib.c.
Definition at line 46 of file NonCoherentDmaLib.c.
STATIC VOID * InternalAllocateAlignedPages | ( | IN EFI_MEMORY_TYPE | MemoryType, |
IN UINTN | Pages, | ||
IN UINTN | Alignment | ||
) |
Allocates one or more 4KB pages of a certain memory type at a specified alignment.
Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned. If there is not enough memory at the specified alignment remaining to satisfy the request, then NULL is returned. If Alignment is not a power of two and Alignment is not zero, then ASSERT(). If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
MemoryType | The type of memory to allocate. |
Pages | The number of 4 KB pages to allocate. |
Alignment | The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used. |
Definition at line 76 of file NonCoherentDmaLib.c.
EFI_STATUS EFIAPI NonCoherentDmaLibConstructor | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
Definition at line 686 of file NonCoherentDmaLib.c.
STATIC EFI_CPU_ARCH_PROTOCOL* mCpu |
Definition at line 39 of file NonCoherentDmaLib.c.
STATIC PHYSICAL_ADDRESS mDmaHostAddressLimit |
Definition at line 42 of file NonCoherentDmaLib.c.
STATIC LIST_ENTRY UncachedAllocationList |
Definition at line 40 of file NonCoherentDmaLib.c.