TianoCore EDK2 master
Loading...
Searching...
No Matches
NonCoherentDmaLib.c File Reference

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_PROTOCOLmCpu
 
STATIC LIST_ENTRY UncachedAllocationList
 
STATIC PHYSICAL_ADDRESS mDmaHostAddressLimit
 

Detailed Description

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.

Function Documentation

◆ DmaAllocateAlignedBuffer()

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.

Parameters
MemoryTypeThe type of memory to allocate, EfiBootServicesData or EfiRuntimeServicesData.
PagesThe number of pages to allocate.
AlignmentAlignment in bytes of the base of the returned buffer (must be a power of 2)
HostAddressA pointer to store the base system memory address of the allocated range.
Return values
EFI_SUCCESSThe requested memory pages were allocated.
EFI_INVALID_PARAMETEROne or more parameters are invalid.
EFI_OUT_OF_RESOURCESThe memory pages could not be allocated.

Definition at line 494 of file NonCoherentDmaLib.c.

◆ DmaAllocateBuffer()

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.

Parameters
MemoryTypeThe type of memory to allocate, EfiBootServicesData or EfiRuntimeServicesData.
PagesThe number of pages to allocate.
HostAddressA pointer to store the base system memory address of the allocated range.
Return values
EFI_SUCCESSThe requested memory pages were allocated.
EFI_INVALID_PARAMETEROne or more parameters are invalid.
EFI_OUT_OF_RESOURCESThe memory pages could not be allocated.

Definition at line 466 of file NonCoherentDmaLib.c.

◆ DmaFreeBuffer()

EFI_STATUS EFIAPI DmaFreeBuffer ( IN UINTN  Pages,
IN VOID *  HostAddress 
)

Frees memory that was allocated with DmaAllocateBuffer().

Parameters
PagesThe number of pages to free.
HostAddressThe base system memory address of the allocated range.
Return values
EFI_SUCCESSThe requested memory pages were freed.
EFI_INVALID_PARAMETERThe memory range specified by HostAddress and Pages was not allocated with DmaAllocateBuffer().

Definition at line 632 of file NonCoherentDmaLib.c.

◆ DmaMap()

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.

Parameters
OperationIndicates if the bus master is going to read or write to system memory.
HostAddressThe system memory address to map to the DMA controller.
NumberOfBytesOn input the number of bytes to map. On output the number of bytes that were mapped.
DeviceAddressThe resulting map address for the bus master controller to use to access the host's HostAddress.
MappingA resulting value to pass to Unmap().
Return values
EFI_SUCCESSThe range was mapped for the returned NumberOfBytes.
EFI_UNSUPPORTEDThe HostAddress cannot be mapped as a common buffer.
EFI_INVALID_PARAMETEROne or more parameters are invalid.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.
EFI_DEVICE_ERRORThe system hardware could not map the requested address.

Definition at line 191 of file NonCoherentDmaLib.c.

◆ DmaUnmap()

EFI_STATUS EFIAPI DmaUnmap ( IN VOID *  Mapping)

Completes the DmaMapBusMasterRead(), DmaMapBusMasterWrite(), or DmaMapBusMasterCommonBuffer() operation and releases any corresponding resources.

Parameters
MappingThe mapping value returned from DmaMap*().
Return values
EFI_SUCCESSThe range was unmapped.
EFI_DEVICE_ERRORThe data was not committed to the target system memory.
EFI_INVALID_PARAMETERAn inconsistency was detected between the mapping type and the DoubleBuffer field

Definition at line 377 of file NonCoherentDmaLib.c.

◆ HostToDeviceAddress()

STATIC PHYSICAL_ADDRESS HostToDeviceAddress ( IN VOID *  Address)

Definition at line 46 of file NonCoherentDmaLib.c.

◆ InternalAllocateAlignedPages()

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().

Parameters
MemoryTypeThe type of memory to allocate.
PagesThe number of 4 KB pages to allocate.
AlignmentThe requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
Returns
A pointer to the allocated buffer or NULL if allocation fails.

Definition at line 76 of file NonCoherentDmaLib.c.

◆ NonCoherentDmaLibConstructor()

EFI_STATUS EFIAPI NonCoherentDmaLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Definition at line 686 of file NonCoherentDmaLib.c.

Variable Documentation

◆ mCpu

Definition at line 39 of file NonCoherentDmaLib.c.

◆ mDmaHostAddressLimit

STATIC PHYSICAL_ADDRESS mDmaHostAddressLimit

Definition at line 42 of file NonCoherentDmaLib.c.

◆ UncachedAllocationList

STATIC LIST_ENTRY UncachedAllocationList

Definition at line 40 of file NonCoherentDmaLib.c.