]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/server/src/vbus.h
70719c2c2ca77855285e94f5fe25d67116cdc9bb
[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
21 class System_bus : public Device, public Dev_feature, public L4::Server_object
22 {
23 public:
24   System_bus();
25   ~System_bus();
26
27   // dispatch for the server object
28   int dispatch(l4_umword_t obj, L4::Ipc_iostream &ios);
29   int dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc_iostream &ios);
30   bool match_hw_feature(Hw::Dev_feature const *) const { return false; }
31
32 private:
33   int request_resource(L4::Ipc_iostream &ios);
34   int request_iomem(L4::Ipc_iostream &ios);
35
36 public:
37   bool resource_allocated(Resource const *) const;
38
39   void dump_resources() const;
40
41 private:
42   struct Res_cmp
43   {
44     bool operator () (Adr_resource const *a, Adr_resource const *b) const
45     {
46       if (a->type() == b->type())
47         return a->_data().end() < b->_data().start();
48       return a->type() < b->type();
49     }
50   };
51   //typedef std::set<Adr_resource*, Res_cmp> Resource_set;
52
53 public:
54   typedef cxx::Avl_set<Adr_resource*, Res_cmp> Resource_set;
55
56   Resource_set const *resource_set() const { return &_resources; }
57   Resource_set *resource_set() { return &_resources; }
58
59 private:
60   Resource_set _resources;
61 };
62
63 }