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.
11 #include <l4/vbus/vbus.h>
12 #include <l4/cxx/ipc_stream>
13 #include <l4/util/splitlog2.h>
15 #include <l4/vbus/vdevice-ops.h>
18 l4vbus_get_device_by_hid(l4_cap_idx_t vbus, l4vbus_device_handle_t parent,
19 l4vbus_device_handle_t *child, char const *hid,
20 int depth, l4vbus_device_t *devinfo)
22 L4::Ipc::Iostream s(l4_utcb());
23 s << parent << l4_uint32_t(L4vbus_vdevice_get_by_hid) << *child << depth
25 int err = l4_error(s.call(vbus));
32 s.skip<l4vbus_device_handle_t>(1);
36 s.skip<l4vbus_device_t>(1);
41 l4vbus_get_next_device(l4_cap_idx_t vbus, l4vbus_device_handle_t parent,
42 l4vbus_device_handle_t *child, int depth,
43 l4vbus_device_t *devinfo)
45 L4::Ipc::Iostream s(l4_utcb());
46 s << parent << l4_uint32_t(L4vbus_vdevice_get_next) << *child << depth;
47 int err = l4_error(s.call(vbus));
60 l4vbus_get_resource(l4_cap_idx_t vbus, l4vbus_device_handle_t dev,
61 int res_idx, l4vbus_resource_t *res)
63 L4::Ipc::Iostream s(l4_utcb());
64 s << dev << l4_uint32_t(L4vbus_vdevice_get_resource) << res_idx;
65 int err = l4_error(s.call(vbus));
75 __vbus_request_port(l4_cap_idx_t vbus, l4vbus_resource_t const &res)
80 while (r.start <= res.end)
82 l4_uint16_t log2_size = l4util_splitlog2_size(r.start, res.end);
83 r.end = r.start + (1UL << log2_size) -1;
85 L4::Ipc::Iostream s(l4_utcb());
86 s << l4vbus_device_handle_t(0)
87 << L4::Opcode(L4vbus_vbus_request_resource);
89 s << L4::Ipc::Rcv_fpage::io(r.start, log2_size, 0);
91 long err= l4_error(s.call(vbus));
94 r.start += (1 << log2_size);
101 l4vbus_request_resource(l4_cap_idx_t vbus, l4vbus_resource_t *res,
104 if (res->type == L4VBUS_RESOURCE_PORT)
105 return __vbus_request_port(vbus, *res);
110 l4vbus_release_resource(l4_cap_idx_t vbus, l4vbus_resource_t *res)
112 L4::Ipc::Iostream s(l4_utcb());
113 s << l4vbus_device_handle_t(0)
114 << l4_uint32_t(L4vbus_vbus_release_resource) << res->type << res->start
116 int err = l4_error(s.call(vbus));
122 l4vbus_vicu_get_cap(l4_cap_idx_t vbus, l4vbus_device_handle_t icu,
125 L4::Ipc::Iostream s(l4_utcb());
126 s << icu << l4_uint32_t(L4vbus_vicu_get_cap);
127 s << L4::Ipc::Small_buf(res);
128 int err = l4_error(s.call(vbus));