]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/server/src/ux.cc
c2c79e2cdb6aea3e4552e92c1d9b263e144ffb4e
[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 "ux.h"
15
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       printf("%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          printf("Failed to allocate device for 'L4UXinput'\n");
39        else
40          {
41            input->set_hid("L4UXinput");
42            input->add_resource
43              (new Adr_resource(Adr_resource::Mmio_res
44                                | Resource::F_fixed_size | Resource::F_fixed_addr,
45                                vhwe->mem_start,
46                                vhwe->mem_start + vhwe->mem_size - 1));
47            input->add_resource
48              (new Adr_resource(Adr_resource::Irq_res,
49                                vhwe->irq_no, vhwe->irq_no));
50           bus->add_child(input);
51          }
52     }
53
54   if ((vhwe = l4_vhw_get_entry_type(vhw, L4_TYPE_VHW_FRAMEBUFFER)))
55     {
56       Hw::Device *fb = new Hw::Device();
57
58       if (!fb)
59         printf("Failed to allocate device for 'L4UXfb'\n");
60       else
61         {
62           fb->set_hid("L4UXfb");
63           fb->add_resource
64             (new Adr_resource(Adr_resource::Mmio_res
65                               | Resource::F_fixed_size | Resource::F_fixed_addr,
66                               vhwe->mem_start,
67                               vhwe->mem_start + vhwe->mem_size - 1));
68           bus->add_child(fb);
69         }
70     }
71
72   if ((vhwe = l4_vhw_get_entry_type(vhw, L4_TYPE_VHW_NET)))
73     {
74       Hw::Device *net = new Hw::Device();
75
76       if (!net)
77         printf("Failed to allocate device for 'L4UXnet'\n");
78       else
79         {
80           net->set_hid("L4UXnet");
81           net->add_resource
82             (new Adr_resource(Adr_resource::Irq_res,
83                               vhwe->irq_no, vhwe->irq_no));
84           net->add_resource
85             (new Adr_resource(Adr_resource::Io_res,
86                               vhwe->fd, vhwe->provider_pid));
87           bus->add_child(net);
88         }
89     }
90 }