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 * License: see LICENSE.spdx (in this directory or the directories above)
7 */
8#pragma once
9
10#include <l4/vbus/vbus.h>
11#include <l4/vbus/vbus_pm.h>
12#include <l4/sys/icu>
13
14#include <l4/re/dataspace>
15#include <l4/re/dma_space>
16#include <l4/re/event>
17#include <l4/re/inhibitor>
18
40namespace L4vbus {
41
42class Vbus;
43
49template<typename DEC>
50class Pm
51{
52private:
53 DEC const *self() const { return static_cast<DEC const *>(this); }
54 DEC *self() { return static_cast<DEC *>(this); }
55public:
63 int pm_suspend() const
64 { return l4vbus_pm_suspend(self()->bus_cap().cap(), self()->dev_handle()); }
65
74 int pm_resume() const
75 { return l4vbus_pm_resume(self()->bus_cap().cap(), self()->dev_handle()); }
76};
77
78
83class Device : public Pm<Device>
84{
85public:
90
101 : _bus(bus), _dev(dev) {}
102
107 L4::Cap<Vbus> bus_cap() const { return _bus; }
108
117
118
148 int device_by_hid(Device *child, char const *hid,
149 int depth = L4VBUS_MAX_DEPTH,
150 l4vbus_device_t *devinfo = 0) const
151 {
152 child->_bus = _bus;
153 return l4vbus_get_device_by_hid(_bus.cap(), _dev, &child->_dev, hid,
154 depth, devinfo);
155 }
156
171 int next_device(Device *child, int depth = L4VBUS_MAX_DEPTH,
172 l4vbus_device_t *devinfo = 0) const
173 {
174 child->_bus = _bus;
175 return l4vbus_get_next_device(_bus.cap(), _dev, &child->_dev, depth,
176 devinfo);
177 }
178
189 int device(l4vbus_device_t *devinfo) const
190 { return l4vbus_get_device(_bus.cap(), _dev, devinfo); }
191
209 int get_resource(unsigned res_idx, l4vbus_resource_t *res) const
210 {
211 return l4vbus_get_resource(_bus.cap(), _dev, res_idx, res);
212 }
213
223 int is_compatible(char const *cid) const
224 { return l4vbus_is_compatible(_bus.cap(), _dev, cid); }
225
230 bool operator == (Device const &o) const
231 {
232 return _bus == o._bus && _dev == o._dev;
233 }
234
239 bool operator != (Device const &o) const
240 {
241 return _bus != o._bus || _dev != o._dev;
242 }
243
244protected:
248};
249
260class Icu : public Device
261{
262public:
275
285 int vicu(L4::Cap<L4::Icu> icu) const
286 {
287 return l4vbus_vicu_get_cap(_bus.cap(), _dev, icu.cap());
288 }
289};
290
298class Vbus : public L4::Kobject_3t<Vbus, L4Re::Dataspace, L4Re::Inhibitor, L4Re::Event>
299{
300public:
301
312 {
313 return l4vbus_request_ioport(cap(), res);
314 }
315
324 {
325 return l4vbus_release_ioport(cap(), res);
326 }
327
336 Device root() const
337 {
338 return Device(L4::Cap<Vbus>(cap()), L4VBUS_ROOT_BUS);
339 }
340
357 int assign_dma_domain(unsigned domain_id, unsigned flags,
358 L4::Cap<L4Re::Dma_space> dma_space) const
359 {
361 flags &= ~L4VBUS_DMAD_KERNEL_DMA_SPACE;
362 return l4vbus_assign_dma_domain(cap(), domain_id, flags, dma_space.cap());
363 }
364
382 int assign_dma_domain(unsigned domain_id, unsigned flags,
383 L4::Cap<L4::Task> dma_space) const
384 {
386 flags &= ~L4VBUS_DMAD_L4RE_DMA_SPACE;
387 return l4vbus_assign_dma_domain(cap(), domain_id, flags, dma_space.cap());
388 }
389
390 typedef L4::Typeid::Raw_ipc<Vbus> Rpcs;
391};
392
393} // 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:84
int device(l4vbus_device_t *devinfo) const
Obtain detailed information about a Vbus device.
Definition vbus:189
L4::Cap< Vbus > bus_cap() const
Access the Vbus capability of the underlying virtual bus.
Definition vbus:107
int get_resource(unsigned res_idx, l4vbus_resource_t *res) const
Obtain the resource description of an individual device resource.
Definition vbus:209
Device(L4::Cap< Vbus > bus, l4vbus_device_handle_t dev)
Construct a new vbus device using a device handle.
Definition vbus:100
Device()
Construct a new vbus device using the NULL device L4VBUS_NULL.
Definition vbus:89
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:148
l4vbus_device_handle_t dev_handle() const
Access the device handle of this device.
Definition vbus:116
bool operator==(Device const &o) const
Test if two devices are the same Vbus device.
Definition vbus:230
bool operator!=(Device const &o) const
Test if two Vbus devices are not the same.
Definition vbus:239
int next_device(Device *child, int depth=L4VBUS_MAX_DEPTH, l4vbus_device_t *devinfo=0) const
Find next child following child.
Definition vbus:171
l4vbus_device_handle_t _dev
The device handle for this device.
Definition vbus:247
L4::Cap< Vbus > _bus
The Vbus capability where this device is located on.
Definition vbus:245
int is_compatible(char const *cid) const
Check if the given device has a compatibility ID (CID) or HID that matches cid.
Definition vbus:223
Vbus Interrupt controller API.
Definition vbus:261
Src_types
Flags that can be used with the ICU on a vbus device.
Definition vbus:265
@ Src_dev_handle
Flag to denote that the value should be interpreted as a device handle.
Definition vbus:273
int vicu(L4::Cap< L4::Icu > icu) const
Request an L4::Icu capability for this Vbus's virtual ICU.
Definition vbus:285
Power-management API mixin.
Definition vbus:51
int pm_suspend() const
Suspend the device.
Definition vbus:63
int pm_resume() const
Resume the device.
Definition vbus:74
The virtual bus (Vbus) interface.
Definition vbus:299
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:357
Device root() const
Get the root device of the device tree of this bus.
Definition vbus:336
int request_ioport(l4vbus_resource_t *res) const
Request the given IO port resource from the bus.
Definition vbus:311
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:382
int release_ioport(l4vbus_resource_t *res) const
Release the given IO port resource from the bus.
Definition vbus:323
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:181
@ L4VBUS_DMAD_KERNEL_DMA_SPACE
The given DMA space is a kernel DMA space (L4::Task)
Definition vbus.h:183
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:40
Helper class to create an L4Re interface class that is derived from three base classes (see L4::Kobje...
Definition __typeinfo.h:931
RPCs list for passing raw incoming IPC to the server object.
Definition __typeinfo.h:413
Detailed information about a vbus device.
Definition vbus_types.h:68
Description of a single vbus resource.
Definition vbus_types.h:23
Description of the vbus C API.
@ L4VBUS_NULL
NULL device.
Definition vbus.h:21
@ L4VBUS_ROOT_BUS
Root device on the vbus.
Definition vbus.h:22
@ L4VBUS_ICU_SRC_DEV_HANDLE
Flag to denote that the value should be interpreted as a device handle.
Definition vbus.h:33
l4_mword_t l4vbus_device_handle_t
Device handle for a device on the vbus.
Definition vbus_types.h:18