L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
dma_space.h File Reference

DMA space C interface. More...

#include <l4/sys/compiler.h>
#include <l4/sys/types.h>
#include <l4/re/c/dataspace.h>
Include dependency graph for dma_space.h:

Go to the source code of this file.

Typedefs

typedef l4_cap_idx_t l4re_dma_space_t
 DMA space capability type.
typedef l4_cap_idx_t l4re_dma_space_mgr_t
 DMA space manager capability type.
typedef l4_uint64_t l4re_dma_space_dma_addr_t
 Data type for DMA addresses.
typedef l4_uint64_t l4re_dma_space_dma_size_t
 Data type for DMA sizes.

Enumerations

enum  l4re_dma_space_direction { L4RE_DMA_SPACE_BIDIRECTIONAL , L4RE_DMA_SPACE_TO_DEVICE , L4RE_DMA_SPACE_FROM_DEVICE , L4RE_DMA_SPACE_NONE }
 Direction of the DMA transfers. More...
enum  l4re_dma_space_attributes { L4RE_DMA_SPACE_SEARCH_ADDR = 1U << 0 , L4RE_DMA_SPACE_PARTIAL_MAP = 1U << 1 , L4RE_DMA_SPACE_RESERVE = 1U << 2 , L4RE_DMA_SPACE_REPLACE = 1U << 3 }
 Attributes used for the memory region. More...
enum  l4re_dma_space_mgr_space_attribs { L4RE_DMA_SPACE_MGR_IDENTITY_MAP = 1U << 0 }
 Attributes assigned to the DMA space when associated with a specific device. More...
enum  l4re_dma_space_mgr_block_flags { L4RE_DMA_SPACE_MGR_SEARCH_ADDR = 1U << 0 }
 Attributes used when blocking an area. More...

Functions

l4_ret_t l4re_dma_space_map (l4re_dma_space_t dma, l4re_ds_t src, l4re_ds_offset_t offset, l4_size_t *size, unsigned long attrs, enum l4re_dma_space_direction dir, l4re_dma_space_dma_addr_t *dma_addr) L4_NOTHROW
 Map the given part of this data space into the DMA address space.
l4_ret_t l4re_dma_space_unmap (l4re_dma_space_t dma, l4re_dma_space_dma_addr_t dma_addr, l4_size_t size, unsigned long attrs, enum l4re_dma_space_direction dir) L4_NOTHROW
 Unmap the given part of this data space from the DMA address space.
l4_ret_t l4re_dma_space_mgr_associate (l4re_dma_space_mgr_t dma_mgr, l4re_dma_space_t dma_space, l4_cap_idx_t dma_task, enum l4re_dma_space_mgr_space_attribs attr) L4_NOTHROW
 Associate a (kernel) DMA space for a device to a Dma_space.
l4_ret_t l4re_dma_space_mgr_associate_phys (l4re_dma_space_mgr_t dma_mgr, l4re_dma_space_t dma_space, enum l4re_dma_space_mgr_space_attribs attr) L4_NOTHROW
 Register a Dma_space to use for DMA.
l4_ret_t l4re_dma_space_mgr_disassociate (l4re_dma_space_mgr_t dma_mgr, l4re_dma_space_t dma_space) L4_NOTHROW
l4_ret_t l4re_dma_space_mgr_block_area (l4re_dma_space_mgr_t dma_mgr, l4re_dma_space_t dma_space, l4re_dma_space_dma_addr_t *addr, l4re_dma_space_dma_size_t size, l4re_dma_space_dma_addr_t max_addr, enum l4re_dma_space_mgr_block_flags flags, unsigned char align) L4_NOTHROW
l4_ret_t l4re_dma_space_mgr_set_limits (l4re_dma_space_mgr_t dma_mgr, l4re_dma_space_t dma_space, l4re_dma_space_dma_addr_t min_addr, l4re_dma_space_dma_addr_t max_addr) L4_NOTHROW

Detailed Description

DMA space C interface.

Definition in file dma_space.h.

Enumeration Type Documentation

◆ l4re_dma_space_attributes

Attributes used for the memory region.

See also
Attributes
Enumerator
L4RE_DMA_SPACE_SEARCH_ADDR 

Search for suitable address.

A spot for the whole mapping is searched, starting from the passed start address. Without this flag, the start address is taken literally. Can be combined with Attribute::Partial_map.

If no address remapping is possible (i.e., the Dma_space was associated by Dma_space_mgr::associate_phys()), the flag has no effect. The Dma_space::map() call will always return the physical address.

L4RE_DMA_SPACE_PARTIAL_MAP 

Truncate mapping if it does not fit.

If there is not enough room after the chosen start address, truncate the mapping instead of failing.

L4RE_DMA_SPACE_RESERVE 

Reserve a region instead of mapping pages.

If set, the dataspace argument of Dma_space::map() is ignored. Use the Attribute::Replace flag to place dataspace mappings in a reserved region later. The reservation is released with Dma_space::unmap() carrying Unmap_flag::Cancel_reservation.

If no address remapping is possible (i.e., the Dma_space was associated by Dma_space_mgr::associate_phys()), Dma_space::map() will always fail with -L4_EPERM if this flag is present.

L4RE_DMA_SPACE_REPLACE 

Replace mappings.

The pages in the map region are replaced with mappings from the dataspace. Without this flag, existing mappings cause Dma_space::map() to fail. Areas previously claimed by Dma_space_mgr::block_area() are never replaced and still cause Dma_space::map() to fail.

If combined with Attribute::Reserve, no dataspace mapping is established. Instead, the reservation reference count is increased. Only after the matching number of Dma_space::unmap(Cancel_reservation) calls, the reservation is released.

If no address remapping is possible (i.e., the Dma_space was associated by Dma_space_mgr::associate_phys()), the flag has no effect. The Dma_space::map() call will always return the physical address.

Cannot be combined with Attribute::Search_addr or Attribute::Partial_map.

Definition at line 38 of file dma_space.h.

◆ l4re_dma_space_direction

Direction of the DMA transfers.

Deprecated
Ignored by the API. Use function overloads without the direction parameter instead.
Enumerator
L4RE_DMA_SPACE_BIDIRECTIONAL 

device reads and writes to the memory

L4RE_DMA_SPACE_TO_DEVICE 

device reads the memory

L4RE_DMA_SPACE_FROM_DEVICE 

device writes to the memory

L4RE_DMA_SPACE_NONE 

device is coherently connected

Definition at line 27 of file dma_space.h.

◆ l4re_dma_space_mgr_block_flags

Attributes used when blocking an area.

See also
Block_flags
Enumerator
L4RE_DMA_SPACE_MGR_SEARCH_ADDR 

Search suitable address.

With this flag, the start address is taken as a lower bound. Without the flag, start and size are taken literally.

Definition at line 58 of file dma_space.h.

◆ l4re_dma_space_mgr_space_attribs

Attributes assigned to the DMA space when associated with a specific device.

See also
Space_attribs
Enumerator
L4RE_DMA_SPACE_MGR_IDENTITY_MAP 

Request identity mappings.

This is needed if some devices are not connected to an IOMMU and need physical addresses.

Definition at line 49 of file dma_space.h.