L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
dma_space
Go to the documentation of this file.
1// -*- Mode: C++ -*-
2// vim:ft=cpp
6/*
7 * (c) 2014 Alexander Warg <alexander.warg@kernkonzept.com>
8 *
9 * License: see LICENSE.spdx (in this directory or the directories above)
10 */
11
12#pragma once
13
14#include <l4/sys/types.h>
15#include <l4/sys/l4int.h>
16#include <l4/sys/capability>
17#include <l4/re/dataspace>
18#include <l4/re/protocols.h>
19#include <l4/sys/cxx/types>
20#include <l4/sys/cxx/ipc_types>
21#include <l4/sys/cxx/ipc_iface>
22
23namespace L4Re
24{
25
26
50class Dma_space :
51 public L4::Kobject_0t< Dma_space,
52 L4RE_PROTO_DMA_SPACE,
53 L4::Type_info::Demand_t<1> >
54{
55public:
58 typedef l4_uint64_t Dma_size;
59
73
78 enum Attribute : unsigned
79 {
91 Search_addr = 1U << 0,
92
99 Partial_map = 1U << 1,
100
113 Reserve = 1U << 2,
114
134 Replace = 1U << 3,
135 };
136
137 friend void enum_bitops_enable(Attribute);
138
145
191 L4Re::Dataspace::Offset offset,
192 l4_size_t * size,
193 Attributes attrs, Direction dir,
194 Dma_addr *dma_addr)
195 {
196 static_cast<void>(dir);
197
198 Dma_addr a = 0;
199 Dma_size sz = *size;
200
201 l4_ret_t ret = map(src, offset, &sz, &a, -1, attrs | Search_addr);
202 if (ret >= 0)
203 {
204 *dma_addr = a;
205 *size = sz;
206 }
207
208 return ret;
209 }
210
261 L4Re::Dataspace::Offset offset,
262 Dma_size *size,
263 Dma_addr *dma_addr,
264 Dma_addr dma_max = -1,
265 Attributes attrs = Search_addr,
266 unsigned char align = L4_SUPERPAGESHIFT)
267 {
268 return map_t::call(c(), src, offset, size, align, attrs, dma_addr, dma_max);
269 }
270
271 L4_RPC_NF(
273 L4Re::Dataspace::Offset offset,
274 L4::Ipc::In_out<Dma_size *> size, unsigned char align,
276 Dma_addr dma_max));
277
282 enum Unmap_flag : unsigned
283 {
294 };
295
296 friend void enum_bitops_enable(Unmap_flag);
297
304
326 l4_ret_t unmap(Dma_addr dma_addr, Dma_size size, Attributes attrs,
327 Direction dir)
328 {
329 static_cast<void>(attrs);
330 static_cast<void>(dir);
331 return unmap(dma_addr, size);
332 }
333
358 l4_ret_t unmap(Dma_addr dma_addr, Dma_size size,
359 Unmap_flags flags = Unmap_flags())
360 {
361 return unmap_t::call(c(), dma_addr, size, flags);
362 }
363
364 L4_RPC_NF(l4_ret_t, unmap, (Dma_addr dma_addr, Dma_size size,
365 Unmap_flags flags));
366
368};
369
376 public L4::Kobject_0t< Dma_space_mgr, L4::PROTO_ANY,
377 L4::Type_info::Demand_t<2> >
378{
379public:
380 using Dma_addr = Dma_space::Dma_addr;
381 using Dma_size = Dma_space::Dma_size;
382
388 enum Space_attrib : unsigned
389 {
396 Identity_map = 1U << 0,
397 };
398
399 friend void enum_bitops_enable(Space_attrib);
400
403
408 enum Block_flag : unsigned
409 {
416 Search_addr = 1U << 0,
417 };
418
419 friend void enum_bitops_enable(Block_flag);
420
423
453 L4::Ipc::Cap<L4::Task> dma_task,
455
483
503
544 Dma_size size,
545 Dma_addr max_addr = -1,
546 Block_flags flags = Block_flags(),
547 unsigned char align = L4_SUPERPAGESHIFT)
548 {
549 return block_area_t::call(c(), dma_space, addr, size, max_addr, flags,
550 align);
551 }
552
553 L4_RPC_NF(
556 Dma_size size,
557 Dma_addr max_addr,
558 Block_flags flags,
559 unsigned char align));
560
592 Dma_addr min_addr,
593 Dma_addr max_addr));
594
595
596 typedef L4::Typeid::Rpcs<associate_t, associate_phys_t, disassociate_t,
597 block_area_t, set_limits_t> Rpcs;
598};
599
600}
L4::Cap related definitions.
A privileged interface to manage Dma_space associations for the clients.
Definition dma_space:378
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.
Block_flag
Attributes used when blocking an area.
Definition dma_space:409
@ Search_addr
Search suitable address.
Definition dma_space:416
l4_ret_t disassociate(L4::Ipc::Cap< Dma_space > dma_space)
Disassociate the (kernel) DMA space from this Dma_space.
Space_attrib
Attributes assigned to the DMA space when associated with a specific device.
Definition dma_space:389
@ Identity_map
Request identity mappings.
Definition dma_space:396
L4::Types::Flags_t< Space_attrib, unsigned > Space_attribs
Attributes used when associating the DMA space.
Definition dma_space:402
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 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.
Definition dma_space:542
L4::Types::Flags_t< Block_flag, unsigned > Block_flags
Attributes used when blocking an area.
Definition dma_space:422
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.
Managed DMA Address Space.
Definition dma_space:54
l4_ret_t map(L4::Ipc::Cap< L4Re::Dataspace > src, L4Re::Dataspace::Offset offset, Dma_size *size, Dma_addr *dma_addr, Dma_addr dma_max=-1, Attributes attrs=Search_addr, unsigned char align=L4_SUPERPAGESHIFT)
Map the given part of this data space into the DMA address space.
Definition dma_space:260
l4_ret_t unmap(Dma_addr dma_addr, Dma_size size, Unmap_flags flags=Unmap_flags())
Unmap the given part of this data space from the DMA address space.
Definition dma_space:358
L4::Types::Flags_t< Attribute, unsigned > Attributes
Attributes for DMA mappings.
Definition dma_space:144
l4_ret_t unmap(Dma_addr dma_addr, Dma_size size, Attributes attrs, Direction dir)
Unmap the given part of this data space from the DMA address space.
Definition dma_space:326
L4::Types::Flags_t< Unmap_flag, unsigned > Unmap_flags
Flags for Dma_space::unmap().
Definition dma_space:303
Unmap_flag
Flags used by Dma_space::unmap().
Definition dma_space:283
@ Cancel_reservation
Cancel a prior Attribute::Reserve claim instead of unmapping a dataspace mapping.
Definition dma_space:293
Attribute
Attributes used for the memory region.
Definition dma_space:79
@ Reserve
Reserve a region instead of mapping pages.
Definition dma_space:113
@ Replace
Replace mappings.
Definition dma_space:134
@ Search_addr
Search for suitable address.
Definition dma_space:91
@ Partial_map
Truncate mapping if it does not fit.
Definition dma_space:99
l4_uint64_t Dma_addr
Data type for DMA addresses.
Definition dma_space:57
Direction
Direction of the DMA transfers.
Definition dma_space:67
@ Bidirectional
device reads and writes to the memory
Definition dma_space:68
@ To_device
device reads the memory
Definition dma_space:69
@ None
device is coherently connected to the memory
Definition dma_space:71
@ From_device
device writes to the memory
Definition dma_space:70
l4_ret_t map(L4::Ipc::Cap< L4Re::Dataspace > src, L4Re::Dataspace::Offset offset, l4_size_t *size, Attributes attrs, Direction dir, Dma_addr *dma_addr)
Map the given part of this data space into the DMA address space.
Definition dma_space:190
Capability type for RPC interfaces (see L4::Cap<T>).
Definition ipc_types:725
Dataspace interface.
unsigned int l4_size_t
Unsigned size type.
Definition l4int.h:22
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
#define L4_SUPERPAGESHIFT
Size of a large page, log2-based.
Definition consts.h:31
Interface Definition Language.
#define L4_INLINE_RPC(res, name, args, attr...)
Define an inline RPC call (type and callable).
Definition ipc_iface:483
#define L4_RPC_NF(res, name, args...)
Define an RPC call type (the type only, no callable).
Definition ipc_iface:511
Fixed sized integer types, generic version.
Common L4 ABI Data Types.
l4_int16_t l4_ret_t
Return value of an IPC call as well as an RPC call.
Definition types.h:29
L4Re C++ Interfaces.
Definition cmd_control:14
L4Re Protocol Constants (C version).
Mark an argument as in-out argument.
Definition ipc_types:42
Attribute for defining an optional RPC argument.
Definition ipc_types:81
Standard list of RPCs of an interface.
Definition __typeinfo.h:428
Template type to define a flags type with bitwise operations.
Definition types:265