2 * (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3 * Alexander Warg <warg@os.inf.tu-dresden.de>,
4 * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
5 * economic rights: Technische Universität Dresden (Germany)
7 * This file is part of TUD:OS and distributed under the terms of the
8 * GNU General Public License 2.
9 * Please see the COPYING-GPL-2 file for details.
13 * Description of the vbus C API
17 #include <l4/sys/compiler.h>
18 #include <l4/vbus/vbus_types.h>
19 #include <l4/sys/types.h>
21 /** Constants for device nodes */
23 L4VBUS_NULL = 0, /**< NULL device */
24 L4VBUS_ROOT_BUS = 0, /**< Root device on the vbus */
28 * \defgroup l4vbus_module L4 V-BUS functions
35 * \copybrief L4vbus::Device::device_by_hid()
36 * \param vbus Capability of the system bus
37 * \param parent Handle to the parent to start the search
38 * \copydetails L4vbus::Device::device_by_hid()
41 l4vbus_get_device_by_hid(l4_cap_idx_t vbus, l4vbus_device_handle_t parent,
42 l4vbus_device_handle_t *child, char const *hid,
43 int depth, l4vbus_device_t *devinfo);
46 * \copybrief L4vbus::Device::next_device()
47 * \param vbus Capability of the system bus
48 * \param parent Handle to the parent device (use 0 for the system bus)
49 * \param child Handle to the child device (use 0 to get the first
51 * \param depth Depth to look for
52 * \param[out] devinfo device information (might be NULL)
54 * \return 0 on success, else failure
57 l4vbus_get_next_device(l4_cap_idx_t vbus, l4vbus_device_handle_t parent,
58 l4vbus_device_handle_t *child, int depth,
59 l4vbus_device_t *devinfo);
62 * \copybrief L4vbus::Device::get_resource()
63 * \param vbus Capability of the system bus
64 * \param dev Handle of the device
65 * \copydetails L4vbus::Device::get_resource()
68 l4vbus_get_resource(l4_cap_idx_t vbus, l4vbus_device_handle_t dev,
69 int res_idx, l4vbus_resource_t *res);
73 * \copybrief L4vbus::Device::is_compatible()
74 * \param vbus Capability of the system bus
75 * \param dev device handle for which the CID shall be tested
76 * \copydetails L4vbus::Device::is_compatible()
79 l4vbus_is_compatible(l4_cap_idx_t vbus, l4vbus_device_handle_t dev,
83 * \brief Get the HID (hardware identifier) if a device
85 * \param vbus Capability of the system bus
86 * \param dev Handle of the device
87 * \param hid Pointer to a buffer for the HID string
88 * \param max_len The size of the buffer (\a hid)
90 * \return the length of the HID string on success, else failure
93 l4vbus_get_hid(l4_cap_idx_t vbus, l4vbus_device_handle_t dev, char *hid,
94 unsigned long max_len);
97 * \brief Request a resource of a specific type
99 * \param vbus Capability of the system bus
100 * \param res Descriptor of the resource
101 * \param flags Optional flags
103 * \return 0 on success, else failure
105 * If any resource is found that contains the requested
106 * type and addresses this resource is returned.
108 * Flags are only relevant to control the memory caching.
109 * If io-memory is requested.
111 * \return 0 on success, else failure
114 l4vbus_request_resource(l4_cap_idx_t vbus, l4vbus_resource_t const *res,
118 * Flags for l4vbus_assign_dma_domain().
120 enum L4vbus_dma_domain_assign_flags
122 /** Unbind the given DMA space from the DMA domain. */
123 L4VBUS_DMAD_UNBIND = 0,
124 /** Bind the given DMA space to the DMA domain. */
125 L4VBUS_DMAD_BIND = 1,
126 /** The given DMA space is an L4Re::Dma_space */
127 L4VBUS_DMAD_L4RE_DMA_SPACE = 0,
128 /** The goven DMA space is a kernel DMA space (L4::Task) */
129 L4VBUS_DMAD_KERNEL_DMA_SPACE = 2,
133 * Bind or unbind a kernel DMA space (L4::Task) or a L4Re::Dma_space to a
135 * \param vbus Capability of the system bus
136 * \param domain_id DMA domain ID (resource address of DMA domain found on
138 * \param flags A combination of #L4vbus_dma_domain_assign_flags.
139 * \param dma_space The DMA space capability to bind or unbind, this must
140 * either be an L4Re::Dma_space or a kernel DMA space
141 * (L4::Task created with L4_PROTO_DMA_SPACE) and the type
142 * must be reflected in the `flags`.
144 * \retval 0 Operation completed successfully.
145 * \retval -L4_ENOENT The vbus does not support a global DMA domain or no DMA
146 * domain could be found.
147 * \retval -L4_EINVAL Invalid argument used.
148 * \retval -L4_EBUSY DMA domain is already active, this means another DMA
149 * space is already assigned.
152 l4vbus_assign_dma_domain(l4_cap_idx_t vbus, unsigned domain_id,
153 unsigned flags, l4_cap_idx_t dma_space);
156 * \brief Release a previously requested resource
158 * \param vbus Capability of the system bus.
159 * \param res Descriptor of the resource.
161 * \return 0 on success, else failure
164 l4vbus_release_resource(l4_cap_idx_t vbus, l4vbus_resource_t const *res);
167 * \brief Get capability of ICU.
169 * \param vbus Capability of the system bus.
170 * \param icu ICU device handle.
171 * \param cap Capability slot for the capability.
173 * \return 0 on success, else failure
176 l4vbus_vicu_get_cap(l4_cap_idx_t vbus, l4vbus_device_handle_t icu,