]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/moe/server/src/sched_proxy.h
update
[l4.git] / l4 / pkg / moe / server / src / sched_proxy.h
1 /*
2  * (c) 2009 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/hlist>
12 #include <l4/cxx/ipc_server>
13 #include <l4/libkproxy/scheduler_svr>
14
15 #include "globals.h"
16 #include "server_obj.h"
17
18 class Sched_proxy :
19   public Moe::Server_object,
20   public L4kproxy::Scheduler_svr_t<Sched_proxy>,
21   public L4Re::Util::Icu_cap_array_svr<Sched_proxy>,
22   public cxx::H_list_item
23 {
24   typedef L4Re::Util::Icu_cap_array_svr<Sched_proxy> Icu;
25
26 public:
27   typedef L4::Cap<L4::Irq> Irq_cap;
28   static Irq_cap alloc_irq_cap()
29   { return object_pool.cap_alloc()->alloc<L4::Irq>(); }
30
31   static void free_irq_cap(Irq_cap cap)
32   { object_pool.cap_alloc()->free(cap); }
33
34   Sched_proxy();
35   ~Sched_proxy();
36
37   int info(l4_umword_t *cpu_max, l4_sched_cpu_set_t *cpus);
38
39   int run_thread(L4::Cap<L4::Thread> thread, l4_sched_param_t const &sp);
40
41   int idle_time(l4_sched_cpu_set_t const &cpus);
42
43   int dispatch(l4_umword_t label, L4::Ipc::Iostream &ios)
44   {
45     l4_msgtag_t tag;
46     ios >> tag;
47
48     if (tag.label() == L4_PROTO_IRQ)
49       return Icu::dispatch(label, ios);
50     if (tag.label() == L4_PROTO_SCHEDULER)
51       return scheduler_dispatch(label, ios);
52     else
53       return -L4_EBADPROTO;
54   }
55
56   void set_prio(unsigned offs, unsigned limit)
57   { _prio_offset = offs; _prio_limit = limit; }
58
59   L4::Cap<L4::Thread> received_thread(L4::Ipc::Snd_fpage const &fp);
60   L4::Cap<void> rcv_cap() const
61   { return L4::Cap<L4::Thread>(Rcv_cap << L4_CAP_SHIFT); }
62
63   void restrict_cpus(l4_umword_t cpus);
64   void rescan_cpus();
65
66   Icu::Irq *scheduler_irq() { return &_scheduler_irq; }
67   Icu::Irq const *scheduler_irq() const { return &_scheduler_irq; }
68
69 private:
70   friend class Cpu_hotplug_server;
71
72   l4_sched_cpu_set_t _cpus, _real_cpus, _cpu_mask;
73   unsigned _max_cpus;
74   unsigned _prio_offset, _prio_limit;
75   Icu::Irq _scheduler_irq;
76
77   typedef cxx::H_list_bss<Sched_proxy> List;
78   static List _list;
79 };
80