L4Re - L4 Runtime Environment
L4vbus::Device Class Reference

Device on a virtual bus (V-BUS) More...

+ Inheritance diagram for L4vbus::Device:
+ Collaboration diagram for L4vbus::Device:

Public Member Functions

L4::Cap< Vbusbus_cap () const
 Access the V-BUS capability of the underlying virtual bus. More...
 
l4vbus_device_handle_t dev_handle () const
 Access the device handle of this device. More...
 
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 HID. More...
 
int next_device (Device *child, int depth=L4VBUS_MAX_DEPTH, l4vbus_device_t *devinfo=0) const
 Find next child following child. More...
 
int device (l4vbus_device_t *devinfo) const
 Obtain detailed information about a vbus device. More...
 
int get_resource (int res_idx, l4vbus_resource_t *res) const
 Obtain the resource description of an individual device resource. More...
 
int is_compatible (char const *cid) const
 Check if the given device has a compatibility ID (CID) or HID that matches cid. More...
 
bool operator== (Device const &o) const
 Test if two devices are the same V-BUS device. More...
 
bool operator!= (Device const &o) const
 Test if two devices are not the same. More...
 
- Public Member Functions inherited from L4vbus::Pm< Device >
int pm_suspend () const
 Suspend the module.
 
int pm_resume () const
 Resume the module.
 

Protected Attributes

L4::Cap< Vbus_bus
 
l4vbus_device_handle_t _dev
 The device handle for this device.
 

Detailed Description

Device on a virtual bus (V-BUS)

Definition at line 66 of file vbus.

Member Function Documentation

◆ bus_cap()

L4::Cap<Vbus> L4vbus::Device::bus_cap ( ) const
inline

Access the V-BUS capability of the underlying virtual bus.

Returns
the capability to the underlying V-BUS.

Definition at line 78 of file vbus.

◆ dev_handle()

l4vbus_device_handle_t L4vbus::Device::dev_handle ( ) const
inline

Access the device handle of this device.

Returns
the device handle for this device.

The device handle is used to directly address the device on its virtual bus.

Definition at line 87 of file vbus.

◆ device()

int L4vbus::Device::device ( l4vbus_device_t devinfo) const
inline

Obtain detailed information about a vbus device.

Parameters
[out]devinfoInformation structure which contains details about the device. The pointer might be NULL after a successfull call.
Return values
0Success.
-L4_ENODEVNo device with the given device handle dev could be found.

Definition at line 159 of file vbus.

◆ device_by_hid()

int L4vbus::Device::device_by_hid ( Device child,
char const *  hid,
int  depth = L4VBUS_MAX_DEPTH,
l4vbus_device_t devinfo = 0 
) const
inline

Find a device by the HID.

This function searches the vbus for a device with the given HID and returns a handle to the first matching device. The HID usually conforms to an ACPI HID or a Linux device tree compatible ID.

It is possible to have multiple devices with the same HID on a vbus. In order to find all matching devices this function has to be called repeatedly with child pointing to the device found in the previous iteration. The iteration starts at child that might be any device node in the tree.

Parameters
[in,out]childHandle of the device from where in the device tree the search should start. To start searching from the beginning child must be initialized using the default (L4VBUS_NULL). If a matching device is found its handle is returned through this parameter.
hidHID of the device
depthMaximum depth for the recursive lookup
[out]devinfoDevice information structure (might be NULL)
Return values
>=0 A device with the given HID was found.
-L4_ENOENTNo device with the given HID could be found on the vbus.
-L4_EINVALInvalid or no HID provided.
-L4_ENODEVFunction called on a non-existing device.

Definition at line 119 of file vbus.

◆ get_resource()

int L4vbus::Device::get_resource ( int  res_idx,
l4vbus_resource_t res 
) const
inline

Obtain the resource description of an individual device resource.

Parameters
res_idxIndex of the resource for which the resource description should be returned. The total number of resources for a device is available in the l4vbus_device_t structure that is returned by L4vbus::Device::device_by_hid() and L4vbus::Device::next_device().
[out]resDescriptor of the resource.

This function returns the resource descriptor of an individual device resource selected by the res_idx parameter.

Return values
0Success.
-L4_ENOENTInvalid resource index res_idx.

Definition at line 179 of file vbus.

◆ is_compatible()

int L4vbus::Device::is_compatible ( char const *  cid) const
inline

Check if the given device has a compatibility ID (CID) or HID that matches cid.

Parameters
cidthe compatibility ID to test
Returns
1 when the given ID (cid) matches this device, 0 when the given ID does not match, <0 on error.

Definition at line 193 of file vbus.

◆ next_device()

int L4vbus::Device::next_device ( Device child,
int  depth = L4VBUS_MAX_DEPTH,
l4vbus_device_t devinfo = 0 
) const
inline

Find next child following child.

Parameters
[in,out]childHandle of the device that precedes the device that shall be found. To start from the beginning child must be initialized using the default (L4VBUS_NULL).
depthDepth to look for
[out]devinfodevice information (might be NULL)
Returns
0 on success, else failure

Definition at line 140 of file vbus.

◆ operator!=()

bool L4vbus::Device::operator!= ( Device const &  o) const
inline

Test if two devices are not the same.

Returns
true if the two devices are different, false else.

Definition at line 209 of file vbus.

◆ operator==()

bool L4vbus::Device::operator== ( Device const &  o) const
inline

Test if two devices are the same V-BUS device.

Returns
true if the two devices are the same, false else.

Definition at line 200 of file vbus.

Field Documentation

◆ _bus

L4::Cap<Vbus> L4vbus::Device::_bus
protected

The V-BUS capability (where this device is located on).

Definition at line 215 of file vbus.


The documentation for this class was generated from the following file: