L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
vbus
1// vi:set ft=cpp: -*- Mode: C++ -*-
2/*
3 * (c) 2011 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
5 *
6 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
9 */
10#pragma once
11
12#include <l4/vbus/vbus.h>
13#include <l4/vbus/vbus_pm.h>
14#include <l4/sys/icu>
15
16#include <l4/re/dataspace>
17#include <l4/re/dma_space>
18#include <l4/re/event>
19#include <l4/re/inhibitor>
20
42namespace L4vbus {
43
44class Vbus;
45
51template<typename DEC>
52class Pm
53{
54private:
55 DEC const *self() const { return static_cast<DEC const *>(this); }
56 DEC *self() { return static_cast<DEC *>(this); }
57public:
65 int pm_suspend() const
66 { return l4vbus_pm_suspend(self()->bus_cap().cap(), self()->dev_handle()); }
67
76 int pm_resume() const
77 { return l4vbus_pm_resume(self()->bus_cap().cap(), self()->dev_handle()); }
78};
79
80
85class Device : public Pm<Device>
86{
87public:
92
103 : _bus(bus), _dev(dev) {}
104
109 L4::Cap<Vbus> bus_cap() const { return _bus; }
110
119
120
150 int device_by_hid(Device *child, char const *hid,
151 int depth = L4VBUS_MAX_DEPTH,
152 l4vbus_device_t *devinfo = 0) const
153 {
154 child->_bus = _bus;
155 return l4vbus_get_device_by_hid(_bus.cap(), _dev, &child->_dev, hid,
156 depth, devinfo);
157 }
158
173 int next_device(Device *child, int depth = L4VBUS_MAX_DEPTH,
174 l4vbus_device_t *devinfo = 0) const
175 {
176 child->_bus = _bus;
177 return l4vbus_get_next_device(_bus.cap(), _dev, &child->_dev, depth,
178 devinfo);
179 }
180
191 int device(l4vbus_device_t *devinfo) const
192 { return l4vbus_get_device(_bus.cap(), _dev, devinfo); }
193
211 int get_resource(unsigned res_idx, l4vbus_resource_t *res) const
212 {
213 return l4vbus_get_resource(_bus.cap(), _dev, res_idx, res);
214 }
215
225 int is_compatible(char const *cid) const
226 { return l4vbus_is_compatible(_bus.cap(), _dev, cid); }
227
232 bool operator == (Device const &o) const
233 {
234 return _bus == o._bus && _dev == o._dev;
235 }
236
241 bool operator != (Device const &o) const
242 {
243 return _bus != o._bus || _dev != o._dev;
244 }
245
246protected:
250};
251
262class Icu : public Device
263{
264public:
277
287 int vicu(L4::Cap<L4::Icu> icu) const
288 {
289 return l4vbus_vicu_get_cap(_bus.cap(), _dev, icu.cap());
290 }
291};
292
300class Vbus : public L4::Kobject_3t<Vbus, L4Re::Dataspace, L4Re::Inhibitor, L4Re::Event>
301{
302public:
303
314 {
315 return l4vbus_request_ioport(cap(), res);
316 }
317
326 {
327 return l4vbus_release_ioport(cap(), res);
328 }
329
338 Device root() const
339 {
340 return Device(L4::Cap<Vbus>(cap()), L4VBUS_ROOT_BUS);
341 }
342
359 int assign_dma_domain(unsigned domain_id, unsigned flags,
360 L4::Cap<L4Re::Dma_space> dma_space) const
361 {
363 flags &= ~L4VBUS_DMAD_KERNEL_DMA_SPACE;
364 return l4vbus_assign_dma_domain(cap(), domain_id, flags, dma_space.cap());
365 }
366
384 int assign_dma_domain(unsigned domain_id, unsigned flags,
385 L4::Cap<L4::Task> dma_space) const
386 {
388 flags &= ~L4VBUS_DMAD_L4RE_DMA_SPACE;
389 return l4vbus_assign_dma_domain(cap(), domain_id, flags, dma_space.cap());
390 }
391
392 typedef L4::Typeid::Raw_ipc<Vbus> Rpcs;
393};
394
395} // namespace L4vbus
Flags flags() const noexcept
Get flags of the dataspace.
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition capability.h:49
C++ interface for capabilities.
Definition capability.h:219
Device on a L4vbus::Vbus.
Definition vbus:86
int device(l4vbus_device_t *devinfo) const
Obtain detailed information about a Vbus device.
Definition vbus:191
L4::Cap< Vbus > bus_cap() const
Access the Vbus capability of the underlying virtual bus.
Definition vbus:109
int get_resource(unsigned res_idx, l4vbus_resource_t *res) const
Obtain the resource description of an individual device resource.
Definition vbus:211
Device(L4::Cap< Vbus > bus, l4vbus_device_handle_t dev)
Construct a new vbus device using a device handle.
Definition vbus:102
Device()
Construct a new vbus device using the NULL device L4VBUS_NULL.
Definition vbus:91
int device_by_hid(Device *child, char const *hid, int depth=L4VBUS_MAX_DEPTH, l4vbus_device_t *devinfo=0) const
Find a device by the hardware interface identifier (HID).
Definition vbus:150
l4vbus_device_handle_t dev_handle() const
Access the device handle of this device.
Definition vbus:118
bool operator==(Device const &o) const
Test if two devices are the same Vbus device.
Definition vbus:232
bool operator!=(Device const &o) const
Test if two Vbus devices are not the same.
Definition vbus:241
int next_device(Device *child, int depth=L4VBUS_MAX_DEPTH, l4vbus_device_t *devinfo=0) const
Find next child following child.
Definition vbus:173
l4vbus_device_handle_t _dev
The device handle for this device.
Definition vbus:249
L4::Cap< Vbus > _bus
The Vbus capability where this device is located on.
Definition vbus:247
int is_compatible(char const *cid) const
Check if the given device has a compatibility ID (CID) or HID that matches cid.
Definition vbus:225
Vbus Interrupt controller API.
Definition vbus:263
Src_types
Flags that can be used with the ICU on a vbus device.
Definition vbus:267
@ Src_dev_handle
Flag to denote that the value should be interpreted as a device handle.
Definition vbus:275
int vicu(L4::Cap< L4::Icu > icu) const
Request an L4::Icu capability for this Vbus's virtual ICU.
Definition vbus:287
Power-management API mixin.
Definition vbus:53
int pm_suspend() const
Suspend the device.
Definition vbus:65
int pm_resume() const
Resume the device.
Definition vbus:76
The virtual bus (Vbus) interface.
Definition vbus:301
int assign_dma_domain(unsigned domain_id, unsigned flags, L4::Cap< L4Re::Dma_space > dma_space) const
Bind or unbind an L4Re::Dma_space to a DMA domain.
Definition vbus:359
Device root() const
Get the root device of the device tree of this bus.
Definition vbus:338
int request_ioport(l4vbus_resource_t *res) const
Request the given IO port resource from the bus.
Definition vbus:313
int assign_dma_domain(unsigned domain_id, unsigned flags, L4::Cap< L4::Task > dma_space) const
Bind or unbind a kernel DMA space to a DMA domain.
Definition vbus:384
int release_ioport(l4vbus_resource_t *res) const
Release the given IO port resource from the bus.
Definition vbus:325
Dataspace interface.
int l4vbus_get_next_device(l4_cap_idx_t vbus, l4vbus_device_handle_t parent, l4vbus_device_handle_t *child, int depth, l4vbus_device_t *devinfo)
Find next child following child.
int l4vbus_assign_dma_domain(l4_cap_idx_t vbus, unsigned domain_id, unsigned flags, l4_cap_idx_t dma_space)
Bind or unbind a kernel DMA space or a L4Re::Dma_space to a DMA domain.
int l4vbus_get_device(l4_cap_idx_t vbus, l4vbus_device_handle_t dev, l4vbus_device_t *devinfo)
Obtain detailed information about a Vbus device.
int l4vbus_get_resource(l4_cap_idx_t vbus, l4vbus_device_handle_t dev, unsigned res_idx, l4vbus_resource_t *res)
Obtain the resource description of an individual device resource.
int l4vbus_request_ioport(l4_cap_idx_t vbus, l4vbus_resource_t const *res)
Request an IO port resource.
int l4vbus_get_device_by_hid(l4_cap_idx_t vbus, l4vbus_device_handle_t parent, l4vbus_device_handle_t *child, char const *hid, int depth, l4vbus_device_t *devinfo)
Find a device by the hardware interface identifier (HID).
int l4vbus_is_compatible(l4_cap_idx_t vbus, l4vbus_device_handle_t dev, char const *cid)
Check if the given device has a compatibility ID (CID) or HID that matches cid.
int l4vbus_vicu_get_cap(l4_cap_idx_t vbus, l4vbus_device_handle_t icu, l4_cap_idx_t cap)
Get capability of ICU.
int l4vbus_release_ioport(l4_cap_idx_t vbus, l4vbus_resource_t const *res)
Release a previously requested IO port resource.
@ L4VBUS_DMAD_L4RE_DMA_SPACE
The given DMA space is an L4Re::Dma_space.
Definition vbus.h:183
@ L4VBUS_DMAD_KERNEL_DMA_SPACE
The given DMA space is a kernel DMA space (L4::Task)
Definition vbus.h:185
int l4vbus_pm_resume(l4_cap_idx_t vbus, l4vbus_device_handle_t handle)
Resume the device.
int l4vbus_pm_suspend(l4_cap_idx_t vbus, l4vbus_device_handle_t handle)
Suspend the device.
Interrupt controller.
C++ interface of the Vbus API.
Definition vbus:42
Helper class to create an L4Re interface class that is derived from three base classes (see L4::Kobje...
Definition __typeinfo.h:942
RPCs list for passing raw incoming IPC to the server object.
Definition __typeinfo.h:424
Detailed information about a vbus device.
Definition vbus_types.h:70
Description of a single vbus resource.
Definition vbus_types.h:25
Description of the vbus C API.
@ L4VBUS_ICU_SRC_DEV_HANDLE
Flag to denote that the value should be interpreted as a device handle.
Definition vbus.h:35
@ L4VBUS_NULL
NULL device.
Definition vbus.h:23
@ L4VBUS_ROOT_BUS
Root device on the vbus.
Definition vbus.h:24
l4_mword_t l4vbus_device_handle_t
Device handle for a device on the vbus.
Definition vbus_types.h:20