29 using Device_type = DEV;
34 : _device(dev), _paddr(0), _dir(dir), _num_sectors(num_sectors)
36 auto lcap =
L4Re::chkcap(L4Re::Util::make_unique_cap<L4Re::Dataspace>(),
37 "Allocate dataspace capability for IO memory.");
40 long sz = num_sectors * _device->sector_size();
44 "Allocate pinned memory.");
53 cxx::make_unique<Block_device::Mem_region>(0, sz, 0, cxx::move(lcap));
54 L4Re::chksys(_device->dma_map(_mem_region.get(), 0, _num_sectors, dir,
56 "Lock memory region for DMA.");
66 _device = rhs._device;
67 _mem_region = cxx::move(rhs._mem_region);
68 _region = cxx::move(rhs._region);
71 _num_sectors = rhs._num_sectors;
87 L4Re::chksys(_device->dma_unmap(_paddr, _num_sectors, _dir));
95 blk.dma_addr = _paddr;
96 blk.virt_addr = _region.
get();
97 blk.num_sectors = _num_sectors;
104 T *get(
unsigned offset)
const
105 {
return reinterpret_cast<T *
>(_region.
get() + offset); }
108 Device_type *_device;
109 cxx::unique_ptr<Block_device::Mem_region> _mem_region;