TianoCore EDK2 master
Loading...
Searching...
No Matches
IoMmuInternal.h File Reference
#include <Base.h>
#include <Protocol/IoMmu.h>
#include <Uefi/UefiBaseType.h>
#include <Uefi/UefiSpec.h>

Go to the source code of this file.

Data Structures

struct  MAP_INFO
 
struct  COMMON_BUFFER_HEADER
 
struct  IOMMU_RESERVED_MEM_RANGE
 

Macros

#define MAP_INFO_SIG   SIGNATURE_64 ('M', 'A', 'P', '_', 'I', 'N', 'F', 'O')
 
#define COMMON_BUFFER_SIG   SIGNATURE_64 ('C', 'M', 'N', 'B', 'U', 'F', 'F', 'R')
 

Functions

EFI_STATUS IoMmuInitReservedSharedMem (VOID)
 
EFI_STATUS IoMmuReleaseReservedSharedMem (BOOLEAN MemoryMapLocked)
 
EFI_STATUS IoMmuAllocateBounceBuffer (IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN OUT MAP_INFO *MapInfo)
 
EFI_STATUS IoMmuFreeBounceBuffer (IN OUT MAP_INFO *MapInfo)
 
EFI_STATUS IoMmuAllocateCommonBuffer (IN EFI_MEMORY_TYPE MemoryType, IN UINTN CommonBufferPages, OUT EFI_PHYSICAL_ADDRESS *PhysicalAddress, OUT UINT32 *ReservedMemBitmap)
 
EFI_STATUS IoMmuFreeCommonBuffer (IN COMMON_BUFFER_HEADER *CommonBufferHeader, IN UINTN CommonBufferPages)
 

Detailed Description

Copyright (c) 2022, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file IoMmuInternal.h.

Macro Definition Documentation

◆ COMMON_BUFFER_SIG

#define COMMON_BUFFER_SIG   SIGNATURE_64 ('C', 'M', 'N', 'B', 'U', 'F', 'F', 'R')

Definition at line 30 of file IoMmuInternal.h.

◆ MAP_INFO_SIG

#define MAP_INFO_SIG   SIGNATURE_64 ('M', 'A', 'P', '_', 'I', 'N', 'F', 'O')

Definition at line 17 of file IoMmuInternal.h.

Function Documentation

◆ IoMmuAllocateBounceBuffer()

EFI_STATUS IoMmuAllocateBounceBuffer ( IN EFI_ALLOCATE_TYPE  Type,
IN EFI_MEMORY_TYPE  MemoryType,
IN OUT MAP_INFO MapInfo 
)

Allocate reserved shared memory for bounce buffer.

Parameters
TypeAllocate type
MemoryTypeThe memory type to be allocated
MapInfoPointer to the MAP_INFO
Return values
EFI_SUCCESSSuccessfully allocate the bounce buffer
OtherAs the error code indicates

Definition at line 372 of file IoMmuBuffer.c.

◆ IoMmuAllocateCommonBuffer()

EFI_STATUS IoMmuAllocateCommonBuffer ( IN EFI_MEMORY_TYPE  MemoryType,
IN UINTN  CommonBufferPages,
OUT EFI_PHYSICAL_ADDRESS PhysicalAddress,
OUT UINT32 *  ReservedMemBitmap 
)

Allocate CommonBuffer from pre-allocated shared memory.

Parameters
MemoryTypeMemory type
CommonBufferPagesPages of CommonBuffer
PhysicalAddressAllocated physical address
ReservedMemBitmapBitmap which indicates the allocation of reserved memory
Return values
EFI_SUCCESSSuccessfully allocate the common buffer
OtherAs the error code indicates

Definition at line 457 of file IoMmuBuffer.c.

◆ IoMmuFreeBounceBuffer()

EFI_STATUS IoMmuFreeBounceBuffer ( IN OUT MAP_INFO MapInfo)

Free the bounce buffer allocated in IoMmuAllocateBounceBuffer.

Parameters
MapInfoPointer to the MAP_INFO
Returns
EFI_SUCCESS Successfully free the bounce buffer.

Definition at line 421 of file IoMmuBuffer.c.

◆ IoMmuFreeCommonBuffer()

EFI_STATUS IoMmuFreeCommonBuffer ( IN COMMON_BUFFER_HEADER CommonBufferHeader,
IN UINTN  CommonBufferPages 
)

Free CommonBuffer which is allocated by IoMmuAllocateCommonBuffer().

Parameters
CommonBufferHeaderPointer to the CommonBufferHeader
CommonBufferPagesPages of CommonBuffer
Return values
EFI_SUCCESSSuccessfully free the common buffer
OtherAs the error code indicates

Definition at line 492 of file IoMmuBuffer.c.

◆ IoMmuInitReservedSharedMem()

EFI_STATUS IoMmuInitReservedSharedMem ( VOID  )

Allocate a memory region and convert it to be shared. This memory region will be used in the DMA operation.

The pre-alloc memory contains pieces of memory regions with different size. The allocation of the shared memory regions are indicated by a 32-bit bitmap (mReservedMemBitmap).

The memory regions are consumed by IoMmuAllocateBuffer (in which CommonBuffer is allocated) and IoMmuMap (in which bounce buffer is allocated).

The CommonBuffer contains 2 parts, one page for CommonBufferHeader which is private memory, the other part is shared memory. So the layout of a piece of memory region after initialization looks like:

|------------|----------------------------|
| Header     |    Data                    |  <-- a piece of pre-alloc memory region
| 4k, private| 4k/32k/128k/etc, shared    |
|-----------------------------------------|
Return values
EFI_SUCCESSSuccessfully initialize the reserved memory.
EFI_UNSUPPORTEDThis feature is not supported.

Definition at line 136 of file IoMmuBuffer.c.

◆ IoMmuReleaseReservedSharedMem()

EFI_STATUS IoMmuReleaseReservedSharedMem ( BOOLEAN  MemoryMapLocked)

Release the pre-alloc shared memory.

Return values
EFI_SUCCESSSuccessfully release the shared memory

Definition at line 203 of file IoMmuBuffer.c.