L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
L4Re::Dma_space_mgr Class Reference

A privileged interface to manage Dma_space associations for the clients. More...

#include <dma_space>

Collaboration diagram for L4Re::Dma_space_mgr:

Public Types

enum  Space_attrib : unsigned { Identity_map = 1U << 0 }
 Attributes assigned to the DMA space when associated with a specific device. More...
enum  Block_flag : unsigned { Search_addr = 1U << 0 }
 Attributes used when blocking an area. More...
using Space_attribs = L4::Types::Flags_t<Space_attrib, unsigned>
 Attributes used when associating the DMA space.
using Block_flags = L4::Types::Flags_t<Block_flag, unsigned>
 Attributes used when blocking an area.

Public Member Functions

l4_ret_t associate (L4::Ipc::Cap< Dma_space > dma_space, L4::Ipc::Cap< L4::Task > dma_task, Space_attribs attr)
 Associate a (kernel) DMA space for a device to a Dma_space.
l4_ret_t associate_phys (L4::Ipc::Cap< Dma_space > dma_space, Space_attribs attr)
 Register a Dma_space to use for DMA.
l4_ret_t disassociate (L4::Ipc::Cap< Dma_space > dma_space)
 Disassociate the (kernel) DMA space from this Dma_space.
l4_ret_t block_area (L4::Ipc::Cap< Dma_space > dma_space, L4::Ipc::In_out< Dma_addr * > addr, Dma_size size, Dma_addr max_addr=-1, Block_flags flags=Block_flags(), unsigned char align=L4_SUPERPAGESHIFT)
 Block an area in a Dma_space.
l4_ret_t set_limits (L4::Ipc::Cap< Dma_space > dma_space, Dma_addr min_addr, Dma_addr max_addr)
 Set lower and upper bound of DMA addresses.

Detailed Description

A privileged interface to manage Dma_space associations for the clients.

This interface is provided as a singleton by Moe.

Definition at line 375 of file dma_space.

Member Enumeration Documentation

◆ Block_flag

Attributes used when blocking an area.

See also
Block_flags
Enumerator
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 408 of file dma_space.

◆ Space_attrib

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

See also
Space_attribs
Enumerator
Identity_map 

Request identity mappings.

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

Definition at line 388 of file dma_space.

Member Function Documentation

◆ associate()

l4_ret_t L4Re::Dma_space_mgr::associate ( L4::Ipc::Cap< Dma_space > dma_space,
L4::Ipc::Cap< L4::Task > dma_task,
Space_attribs attr )

Associate a (kernel) DMA space for a device to a Dma_space.

Parameters
[in]dma_spaceThe Dma_space to associate the (kernel) DMA space with.
[in]dma_taskThe (kernel) DMA space used for the device that shall be associated with this DMA space.
[in]attrAttributes for this DMA space. See L4Re::Dma_space::Space_attrib.
Return values
L4_EOKOperation successful.
-L4_EBUSYThe Dma_space is already associated.
-L4_EINVALInvalid arguments, e.g. no dma_task capability passed. In particular, when Space_attrib::Identity_map is requested, the Dma_space must not have any pre-existing blockings (see Dma_space_mgr::block_area()) and must not have custom address limits set (see Dma_space_mgr::set_limits()).
-L4_ENOENTInvalid dma_space was passed.
-L4_ENOMEMNot enough memory to allocate internal datastructures.
-L4_EPERMInsufficient permissions; see precondition.
Precondition
The dma_space and dma_task capabilities must have the permission L4_CAP_FPAGE_W.

References associate_phys().

Here is the call graph for this function:

◆ associate_phys()

l4_ret_t L4Re::Dma_space_mgr::associate_phys ( L4::Ipc::Cap< Dma_space > dma_space,
Space_attribs attr )

Register a Dma_space to use for DMA.

This function should be used, in case no IOMMU is present or configured. The CPU's physical memory is used as DMA address space.

Parameters
[in]dma_spaceThe Dma_space to register.
[in]attrAttributes for the provided DMA space. Currently not used; must be the default-constructed Space_attribs() value.
Return values
L4_EOKOperation successful.
-L4_EBUSYThe Dma_space is already associated.
-L4_EINVALInvalid arguments, for example a non-zero attr, pre-existing blockings on dma_space (see Dma_space_mgr::block_area()), or custom address limits set on dma_space (see Dma_space_mgr::set_limits()).
-L4_ENOENTInvalid dma_space was passed.
-L4_ENOMEMNot enough memory to allocate internal datastructures.
-L4_EPERMInsufficient permissions; see precondition.
Precondition
The dma_space capability must have the permission L4_CAP_FPAGE_W.

Referenced by associate().

Here is the caller graph for this function:

◆ block_area()

l4_ret_t L4Re::Dma_space_mgr::block_area ( L4::Ipc::Cap< Dma_space > dma_space,
L4::Ipc::In_out< Dma_addr * > addr,
Dma_size size,
Dma_addr max_addr = -1,
Block_flags flags = Block_flags(),
unsigned char align = L4_SUPERPAGESHIFT )
inline

Block an area in a Dma_space.

The blocked area cannot be used for mappings in the given dma_space after the call. The call will fail if there are already mappings in the requested range. It is allowed to add block areas before associate() or associate_phys() has been called.

Blocked areas are allowed to overlap.

Parameters
[in]dma_spaceThe Dma_space to add blocked areas.
[in,out]addrThe DMA address of the blocked area. Either taken literally (in which case it must be page aligned) or as start address if Block_flag::Search_addr is passed.
[in]sizeSize of the blocked region. Must be page aligned.
[in]max_addrHighest allowed DMA address of the region (inclusive).
[in]flagsThe attributes used for this blocking (a combination of Dma_space_mgr::Block_flag values).
[in]alignThe log2 alignment of the blocked area. Only used if Block_flag::Search_addr is passed.
Return values
L4_EOKOperation successful.
-L4_EADDRNOTAVAILThe specified region overlaps an existing mapping or no space left for the blocking.
-L4_EINVALInvalid address, alignment or flag passed. Block_flag::Search_addr passed but dma_space is not associated yet.
-L4_EPERMDma_space is associated with physical DMA domain or insufficient permissions; see precondition.
-L4_ENOMEMThere is not enough memory to allocate internal data structures.
Precondition
The dma_space capability must have the permission L4_CAP_FPAGE_W.

Definition at line 542 of file dma_space.

References L4::Kobject_t< Derived, L4::Kobject, L4::PROTO_ANY, Type_info::Demand_t<> >::c(), and L4_SUPERPAGESHIFT.

Here is the call graph for this function:

◆ disassociate()

l4_ret_t L4Re::Dma_space_mgr::disassociate ( L4::Ipc::Cap< Dma_space > dma_space)

Disassociate the (kernel) DMA space from this Dma_space.

Parameters
[in]dma_spaceThe Dma_space to de-register.
Return values
L4_EOKOperation successful.
-L4_ENOENTInvalid dma_space was passed or disassociate() called without prior calling associate()/associate_phys().
-L4_EPERMInsufficient permissions; see precondition.
Attention
This will remove all mappings, reservations and blockings from dma_space.
Precondition
The dma_space capability must have the permission L4_CAP_FPAGE_W.

References disassociate().

Referenced by disassociate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_limits()

l4_ret_t L4Re::Dma_space_mgr::set_limits ( L4::Ipc::Cap< Dma_space > dma_space,
Dma_addr min_addr,
Dma_addr max_addr )

Set lower and upper bound of DMA addresses.

Mappings and blockings are only allowed in the given range.

If multiple Dma_spaces share the same kernel DMA space (i.e., were associated by passing the same dma_task to associate()), all DMA address allocations, reservations and blockings performed through any of these Dma_spaces use the intersection of all their individual limits. Tightening the limits on one Dma_space therefore also constrains all other Dma_spaces sharing the same DMA task; loosening the limits on one Dma_space has no effect beyond what the most-restrictive peer Dma_space allows.

Parameters
[in]dma_spaceThe Dma_space whose limits shall be changed.
[in]min_addrThe lowest usable address in the Dma_space.
[in]max_addrThe highest usable address in the Dma_space (inclusive).
Return values
L4_EOKOperation successful.
-L4_EADDRNOTAVAILThere are existing mappings or blocking outside the bounds.
-L4_EPERMDma_space is associated with physical DMA domain or insufficient permissions; see precondition.
-L4_EINVALInvalid address passed.
Precondition
The dma_space capability must have the permission L4_CAP_FPAGE_W.

The documentation for this class was generated from the following file: