]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/server/src/vbus.h
03344ea6024984ec101b84957572eb4986cdacba
[l4.git] / l4 / pkg / io / server / src / vbus.h
1 /*
2  * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9 #pragma once
10
11 #include <l4/cxx/avl_set>
12 #include <l4/cxx/ipc_server>
13
14 #include <l4/vbus/vbus_types.h>
15
16 #include "vdevice.h"
17 #include "device.h"
18
19 namespace Vi {
20 class Sw_icu;
21
22 class System_bus : public Device, public Dev_feature, public L4::Server_object
23 {
24 public:
25   System_bus();
26   ~System_bus();
27
28   // dispatch for the server object
29   int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios);
30   int dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios);
31   bool match_hw_feature(Hw::Dev_feature const *) const { return false; }
32
33 private:
34   int request_resource(L4::Ipc::Iostream &ios);
35   int request_iomem(L4::Ipc::Iostream &ios);
36
37 public:
38   bool resource_allocated(Resource const *) const;
39
40   void dump_resources() const;
41
42 private:
43   struct Res_cmp
44   {
45     bool operator () (Resource const *a, Resource const *b) const
46     {
47       if (a->type() == b->type())
48         return a->end() < b->start();
49       return a->type() < b->type();
50     }
51   };
52   //typedef std::set<Resource*, Res_cmp> Resource_set;
53
54 public:
55   typedef cxx::Avl_set<Resource*, Res_cmp> Resource_set;
56
57   Resource_set const *resource_set() const { return &_resources; }
58   Resource_set *resource_set() { return &_resources; }
59
60   void set_host(Device *d) { _host = d; }
61   Device *host() const { return _host; }
62   Sw_icu *sw_icu() const { return _sw_icu; }
63
64   void sw_icu(Sw_icu *icu) { _sw_icu = icu; }
65
66 private:
67   Resource_set _resources;
68   Device *_host;
69   Sw_icu *_sw_icu;
70 };
71
72 }