Loading...
Searching...
No Matches
vbus
// vi:set ft=cpp: -*- Mode: C++ -*-
/*
* (c) 2011 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/vbus/vbus.h>
#include <l4/vbus/vbus_pm.h>
#include <l4/sys/icu>
#include <l4/re/dataspace>
#include <l4/re/dma_space>
#include <l4/re/event>
#include <l4/re/inhibitor>
namespace L4vbus {
class Vbus;
template<typename DEC>
class Pm
{
private:
DEC const *self() const { return static_cast<DEC const *>(this); }
DEC *self() { return static_cast<DEC *>(this); }
public:
int pm_suspend() const
{ return l4vbus_pm_suspend(self()->bus_cap().cap(), self()->dev_handle()); }
int pm_resume() const
{ return l4vbus_pm_resume(self()->bus_cap().cap(), self()->dev_handle()); }
};
class Device : public Pm<Device>
{
public:
Device() : _dev(L4VBUS_NULL) {}
Device(L4::Cap<Vbus> bus, l4vbus_device_handle_t dev)
: _bus(bus), _dev(dev) {}
L4::Cap<Vbus> bus_cap() const { return _bus; }
l4vbus_device_handle_t dev_handle() const { return _dev; }
int device_by_hid(Device *child, char const *hid,
int depth = L4VBUS_MAX_DEPTH,
l4vbus_device_t *devinfo = 0) const
{
child->_bus = _bus;
return l4vbus_get_device_by_hid(_bus.cap(), _dev, &child->_dev, hid,
depth, devinfo);
}
int next_device(Device *child, int depth = L4VBUS_MAX_DEPTH,
l4vbus_device_t *devinfo = 0) const
{
child->_bus = _bus;
return l4vbus_get_next_device(_bus.cap(), _dev, &child->_dev, depth,
devinfo);
}
int device(l4vbus_device_t *devinfo) const
{ return l4vbus_get_device(_bus.cap(), _dev, devinfo); }
int get_resource(unsigned res_idx, l4vbus_resource_t *res) const
{
return l4vbus_get_resource(_bus.cap(), _dev, res_idx, res);
}
int is_compatible(char const *cid) const
{ return l4vbus_is_compatible(_bus.cap(), _dev, cid); }
bool operator == (Device const &o) const
{
return _bus == o._bus && _dev == o._dev;
}
bool operator != (Device const &o) const
{
return _bus != o._bus || _dev != o._dev;
}
protected:
L4::Cap<Vbus> _bus;
l4vbus_device_handle_t _dev;
};
class Icu : public Device
{
public:
enum Src_types
{
Src_dev_handle = L4VBUS_ICU_SRC_DEV_HANDLE
};
int vicu(L4::Cap<L4::Icu> icu) const
{
return l4vbus_vicu_get_cap(_bus.cap(), _dev, icu.cap());
}
};
class Vbus : public L4::Kobject_3t<Vbus, L4Re::Dataspace, L4Re::Inhibitor, L4Re::Event>
{
public:
int request_ioport(l4vbus_resource_t *res) const
{
return l4vbus_request_ioport(cap(), res);
}
int release_ioport(l4vbus_resource_t *res) const
{
return l4vbus_release_ioport(cap(), res);
}
Device root() const
{
return Device(L4::Cap<Vbus>(cap()), L4VBUS_ROOT_BUS);
}
int assign_dma_domain(unsigned domain_id, unsigned flags,
L4::Cap<L4Re::Dma_space> dma_space) const
{
flags |= L4VBUS_DMAD_L4RE_DMA_SPACE;
flags &= ~L4VBUS_DMAD_KERNEL_DMA_SPACE;
return l4vbus_assign_dma_domain(cap(), domain_id, flags, dma_space.cap());
}
int assign_dma_domain(unsigned domain_id, unsigned flags,
L4::Cap<L4::Task> dma_space) const
{
flags |= L4VBUS_DMAD_KERNEL_DMA_SPACE;
flags &= ~L4VBUS_DMAD_L4RE_DMA_SPACE;
return l4vbus_assign_dma_domain(cap(), domain_id, flags, dma_space.cap());
}
typedef L4::Typeid::Raw_ipc<Vbus> Rpcs;
};
} // namespace L4vbus
L4Re::Dataspace::flags
Flags flags() const noexcept
Get flags of the dataspace.
Definition dataspace_impl.h:111
L4::Cap_base::cap
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition capability.h:49
L4::Cap
C++ interface for capabilities.
Definition capability.h:224
L4::Kobject::cap
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition kobject:69
L4vbus::Device
Device on a L4vbus::Vbus.
Definition vbus:84
L4vbus::Device::device
int device(l4vbus_device_t *devinfo) const
Obtain detailed information about a Vbus device.
Definition vbus:189
L4vbus::Device::bus_cap
L4::Cap< Vbus > bus_cap() const
Access the Vbus capability of the underlying virtual bus.
Definition vbus:107
L4vbus::Device::get_resource
int get_resource(unsigned res_idx, l4vbus_resource_t *res) const
Obtain the resource description of an individual device resource.
Definition vbus:209
L4vbus::Device::Device
Device(L4::Cap< Vbus > bus, l4vbus_device_handle_t dev)
Construct a new vbus device using a device handle.
Definition vbus:100
L4vbus::Device::Device
Device()
Construct a new vbus device using the NULL device L4VBUS_NULL.
Definition vbus:89
L4vbus::Device::device_by_hid
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::dev_handle
l4vbus_device_handle_t dev_handle() const
Access the device handle of this device.
Definition vbus:116
L4vbus::Device::operator==
bool operator==(Device const &o) const
Test if two devices are the same Vbus device.
Definition vbus:230
L4vbus::Device::operator!=
bool operator!=(Device const &o) const
Test if two Vbus devices are not the same.
Definition vbus:239
L4vbus::Device::next_device
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::_dev
l4vbus_device_handle_t _dev
The device handle for this device.
Definition vbus:247
L4vbus::Device::_bus
L4::Cap< Vbus > _bus
The Vbus capability where this device is located on.
Definition vbus:245
L4vbus::Device::is_compatible
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
L4vbus::Icu
Vbus Interrupt controller API.
Definition vbus:261
L4vbus::Icu::Src_types
Src_types
Flags that can be used with the ICU on a vbus device.
Definition vbus:265
L4vbus::Icu::Src_dev_handle
@ Src_dev_handle
Flag to denote that the value should be interpreted as a device handle.
Definition vbus:273
L4vbus::Icu::vicu
int vicu(L4::Cap< L4::Icu > icu) const
Request an L4::Icu capability for this Vbus's virtual ICU.
Definition vbus:285
L4vbus::Pm
Power-management API mixin.
Definition vbus:51
L4vbus::Pm::pm_suspend
int pm_suspend() const
Suspend the device.
Definition vbus:63
L4vbus::Pm::pm_resume
int pm_resume() const
Resume the device.
Definition vbus:74
L4vbus::Vbus
The virtual bus (Vbus) interface.
Definition vbus:299
L4vbus::Vbus::assign_dma_domain
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
L4vbus::Vbus::root
Device root() const
Get the root device of the device tree of this bus.
Definition vbus:336
L4vbus::Vbus::request_ioport
int request_ioport(l4vbus_resource_t *res) const
Request the given IO port resource from the bus.
Definition vbus:311
L4vbus::Vbus::assign_dma_domain
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
L4vbus::Vbus::release_ioport
int release_ioport(l4vbus_resource_t *res) const
Release the given IO port resource from the bus.
Definition vbus:323
dataspace
Dataspace interface.
dma_space
l4vbus_get_next_device
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.
l4vbus_assign_dma_domain
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.
l4vbus_get_device
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.
l4vbus_get_resource
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.
l4vbus_request_ioport
int l4vbus_request_ioport(l4_cap_idx_t vbus, l4vbus_resource_t const *res)
Request an IO port resource.
l4vbus_is_compatible
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.
l4vbus_vicu_get_cap
int l4vbus_vicu_get_cap(l4_cap_idx_t vbus, l4vbus_device_handle_t icu, l4_cap_idx_t cap)
Get capability of ICU.
l4vbus_release_ioport
int l4vbus_release_ioport(l4_cap_idx_t vbus, l4vbus_resource_t const *res)
Release a previously requested IO port resource.
l4vbus_get_device_by_hid
L4_BEGIN_DECLS 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).
L4VBUS_DMAD_L4RE_DMA_SPACE
@ L4VBUS_DMAD_L4RE_DMA_SPACE
The given DMA space is an L4Re::Dma_space.
Definition vbus.h:181
L4VBUS_DMAD_KERNEL_DMA_SPACE
@ L4VBUS_DMAD_KERNEL_DMA_SPACE
The given DMA space is a kernel DMA space (L4::Task).
Definition vbus.h:183
l4vbus_pm_resume
int l4vbus_pm_resume(l4_cap_idx_t vbus, l4vbus_device_handle_t handle)
Resume the device.
l4vbus_pm_suspend
L4_BEGIN_DECLS int l4vbus_pm_suspend(l4_cap_idx_t vbus, l4vbus_device_handle_t handle)
Suspend the device.
icu
Interrupt controller.
L4vbus
C++ interface of the Vbus API.
Definition vbus:40
L4::Kobject_3t
Helper class to create an L4Re interface class that is derived from three base classes (see L4::Kobje...
Definition __typeinfo.h:931
L4::Typeid::Raw_ipc
RPCs list for passing raw incoming IPC to the server object.
Definition __typeinfo.h:413
l4vbus_device_t
Detailed information about a vbus device.
Definition vbus_types.h:80
l4vbus_resource_t
Description of a single vbus resource.
Definition vbus_types.h:23
vbus.h
Description of the vbus C API.
L4VBUS_NULL
@ L4VBUS_NULL
NULL device.
Definition vbus.h:21
L4VBUS_ROOT_BUS
@ L4VBUS_ROOT_BUS
Root device on the vbus.
Definition vbus.h:22
L4VBUS_ICU_SRC_DEV_HANDLE
@ L4VBUS_ICU_SRC_DEV_HANDLE
Flag to denote that the value should be interpreted as a device handle.
Definition vbus.h:33
l4vbus_device_handle_t
l4_mword_t l4vbus_device_handle_t
Device handle for a device on the vbus.
Definition vbus_types.h:18