]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/server/src/ux.cc
update
[l4.git] / l4 / pkg / io / server / src / ux.cc
1 /*
2  * (c) 2010 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *          Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10
11 #include <l4/sys/vhw.h>
12 #include <l4/re/env.h>
13
14 #include "debug.h"
15 #include "ux.h"
16 #include "hw_device.h"
17
18 #include <cstdio>
19
20 void ux_setup(Hw::Device *bus)
21 {
22
23   struct l4_vhw_descriptor *vhw;
24   struct l4_vhw_entry *vhwe;
25
26   if (!(vhw = l4_vhw_get(l4re_kip())))
27     {
28       d_printf(DBG_WARN, "%s: No VHWs found.\n", __func__);
29       return;
30     }
31
32   if ((vhwe = l4_vhw_get_entry_type(vhw, L4_TYPE_VHW_INPUT))
33       && vhwe->irq_no)
34     {
35       Hw::Device *input = new Hw::Device();
36
37        if (!input)
38          d_printf(DBG_ERR, "Failed to allocate device for 'L4UXinput'\n");
39        else
40          {
41            input->set_hid("L4UXinput");
42            input->add_resource
43              (new Resource(Resource::Mmio_res,
44                            vhwe->mem_start,
45                            vhwe->mem_start + vhwe->mem_size - 1));
46            input->add_resource
47              (new Resource(Resource::Irq_res,
48                            vhwe->irq_no, vhwe->irq_no));
49           bus->add_child(input);
50          }
51     }
52
53   if ((vhwe = l4_vhw_get_entry_type(vhw, L4_TYPE_VHW_FRAMEBUFFER)))
54     {
55       Hw::Device *fb = new Hw::Device();
56
57       if (!fb)
58         d_printf(DBG_ERR, "Failed to allocate device for 'L4UXfb'\n");
59       else
60         {
61           fb->set_hid("L4UXfb");
62           fb->add_resource
63             (new Resource(Resource::Mmio_res,
64                           vhwe->mem_start,
65                           vhwe->mem_start + vhwe->mem_size - 1));
66           bus->add_child(fb);
67         }
68     }
69
70   if ((vhwe = l4_vhw_get_entry_type(vhw, L4_TYPE_VHW_NET)))
71     {
72       Hw::Device *net = new Hw::Device();
73
74       if (!net)
75         d_printf(DBG_ERR, "Failed to allocate device for 'L4UXnet'\n");
76       else
77         {
78           net->set_hid("L4UXnet");
79           net->add_resource
80             (new Resource(Resource::Irq_res,
81                           vhwe->irq_no, vhwe->irq_no));
82           net->add_resource
83             (new Resource(Resource::Io_res,
84                           vhwe->fd, vhwe->provider_pid));
85           bus->add_child(net);
86         }
87     }
88 }