2 * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
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.
11 #include <l4/cxx/avl_set>
12 #include <l4/cxx/ipc_server>
13 #include <l4/cxx/hlist>
15 #include <l4/vbus/vbus_types.h>
23 class System_bus : public Device, public Dev_feature, public L4::Server_object
26 class Root_resource_factory : public cxx::H_list_item
29 virtual Root_resource *create(System_bus *bus) const = 0;
30 Root_resource_factory()
31 { _factories.push_front(this); }
33 typedef cxx::H_list<Root_resource_factory> Factory_list;
34 static Factory_list _factories;
37 template< unsigned TYPE, typename RS >
38 class Root_resource_factory_t : public Root_resource_factory
41 Root_resource *create(System_bus *bus) const
43 return new Root_resource(TYPE, new RS(bus));
50 // dispatch for the server object
51 int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios);
52 int dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios);
53 bool match_hw_feature(Hw::Dev_feature const *) const { return false; }
56 int request_resource(L4::Ipc::Iostream &ios);
57 int request_iomem(L4::Ipc::Iostream &ios);
60 bool resource_allocated(Resource const *) const;
62 void dump_resources() const;
67 bool operator () (Resource const *a, Resource const *b) const
69 if (a->type() == b->type())
70 return a->lt_compare(b);
71 return a->type() < b->type();
74 //typedef std::set<Resource*, Res_cmp> Resource_set;
77 typedef cxx::Avl_set<Resource*, Res_cmp> Resource_set;
79 Resource_set const *resource_set() const { return &_resources; }
80 Resource_set *resource_set() { return &_resources; }
82 void set_host(Device *d) { _host = d; }
83 Device *host() const { return _host; }
84 Sw_icu *sw_icu() const { return _sw_icu; }
86 void sw_icu(Sw_icu *icu) { _sw_icu = icu; }
89 Resource_set _resources;