L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
device.h
1/*
2 * Copyright (C) 2018-2020 Kernkonzept GmbH.
3 * Author(s): Sarah Hoffmann <sarah.hoffmann@kernkonzept.com>
4 *
5 * This file is distributed under the terms of the GNU General Public
6 * License, version 2. Please see the COPYING-GPL-2 file for details.
7 */
8#pragma once
9
10#include <l4/cxx/ref_ptr>
11#include <l4/cxx/string>
12#include <l4/re/dataspace>
13#include <l4/re/dma_space>
14
15#include <l4/libblock-device/errand.h>
16#include <l4/libblock-device/types.h>
17
18namespace Block_device {
19
34{
35};
36
37struct Device : public cxx::Ref_obj
38{
39 virtual ~Device() = 0;
40
42 virtual Notification_domain const *notification_domain() const = 0;
43
45 virtual bool is_read_only() const = 0;
47 virtual bool match_hid(cxx::String const &hid) const = 0;
49 virtual l4_uint64_t capacity() const = 0;
51 virtual l4_size_t sector_size() const = 0;
53 virtual l4_size_t max_size() const = 0;
55 virtual unsigned max_segments() const = 0;
56
58 virtual void reset() = 0;
59
61 virtual int dma_map(Block_device::Mem_region *region, l4_addr_t offset,
64
66 virtual int dma_unmap(L4Re::Dma_space::Dma_addr phys, l4_size_t num_sectors,
68
83 virtual int inout_data(l4_uint64_t sector,
84 Block_device::Inout_block const &blocks,
85 Block_device::Inout_callback const &cb,
87
98 virtual int flush(Block_device::Inout_callback const &cb) = 0;
99
101 virtual void start_device_scan(Block_device::Errand::Callback const &callback) = 0;
102};
103
104inline Device::~Device() = default;
105
109template <typename DEV>
111{
113 Notification_domain const *notification_domain() const override
114 { return &dom; }
115};
116
121{
122 struct Discard_info
123 {
124 unsigned max_discard_sectors = 0;
125 unsigned max_discard_seg = 0;
126 unsigned discard_sector_alignment = 1;
127 unsigned max_write_zeroes_sectors = 0;
128 unsigned max_write_zeroes_seg = 0;
129 bool write_zeroes_may_unmap = false;
130 };
131
132 virtual Discard_info discard_info() const = 0;
133
135 virtual int discard(l4_uint64_t offset,
136 Block_device::Inout_block const &blocks,
137 Block_device::Inout_callback const &cb, bool discard) = 0;
138
139protected:
140 ~Device_discard_feature() = default;
141};
142
143} // name space
l4_uint64_t Dma_addr
Data type for DMA addresses.
Definition dma_space:70
Direction
Direction of the DMA transfers.
Definition dma_space:76
Region of driver memory, that shall be managed locally.
Definition l4virtio:451
Allocation free string class with explicit length field.
Definition string:42
Dataspace interface.
unsigned int l4_size_t
Unsigned size type.
Definition l4int.h:35
unsigned long l4_addr_t
Address type.
Definition l4int.h:45
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:42
Partial interface for devices that offer discard functionality.
Definition device.h:121
virtual int discard(l4_uint64_t offset, Block_device::Inout_block const &blocks, Block_device::Inout_callback const &cb, bool discard)=0
Issues one or more WRITE_ZEROES or DISCARD commands.
Device with a per-device notification domain.
Definition device.h:111
Description of an inout block to be sent to the device.
Definition types.h:68
Opaque type for representing a notification domain.
Definition device.h:34