]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libkproxy/lib/src/scheduler_svr.cc
Inital import
[l4.git] / l4 / pkg / libkproxy / lib / src / scheduler_svr.cc
1 // vi:ft=cpp
2 /**
3  * \internal
4  * \file
5  * \brief
6  */
7 /*
8  * (c) 2008-2009 Technische Universität Dresden
9  * This file is part of TUD:OS and distributed under the terms of the
10  * GNU General Public License 2.
11  * Please see the COPYING-GPL-2 file for details.
12  *
13  * As a special exception, you may use this file as part of a free software
14  * library without restriction.  Specifically, if other files instantiate
15  * templates or use macros or inline functions from this file, or you compile
16  * this file and link it with other files to produce an executable, this
17  * file does not by itself cause the resulting executable to be covered by
18  * the GNU General Public License.  This exception does not however
19  * invalidate any other reasons why the executable file might be covered by
20  * the GNU General Public License.
21  */
22 #include <l4/sys/scheduler.h>
23 #include <l4/sys/types.h>
24 #include <l4/cxx/ipc_stream>
25 #include <l4/libkproxy/scheduler_svr>
26
27 namespace L4kproxy {
28
29 int Scheduler_svr::scheduler_dispatch(l4_umword_t, L4::Ipc_iostream &ios)
30 {
31   L4::Opcode op;
32   ios >> op;
33   switch (op)
34     {
35     case L4_SCHEDULER_INFO_OP:
36         {
37           l4_sched_cpu_set_t cpus;
38           l4_umword_t cpu_max;
39
40             {
41               l4_umword_t gran_off;
42               ios >> gran_off;
43
44               cpus.offset = gran_off & 0x00ffffff;
45               cpus.granularity = (gran_off >> 24);
46               cpus.map = 0;
47             }
48
49           int ret = _sched->info(&cpu_max, &cpus);
50
51           if (ret == L4_EOK)
52             ios << cpus.map << cpu_max;
53
54           return ret;
55         }
56     case L4_SCHEDULER_RUN_THREAD_OP:
57         {
58           l4_sched_param_t sp;
59           L4::Snd_fpage thread;
60             {
61               l4_umword_t gran_off, prio, quantum;
62               ios >> gran_off >> sp.affinity.map >> prio >> quantum >> thread;
63               sp.prio = prio;
64               sp.quantum = quantum;
65               sp.affinity.offset = gran_off & 0x00ffffff;
66               sp.affinity.granularity = gran_off >> 24;
67             }
68
69           return _sched->run_thread(received_thread(thread), sp);
70         }
71     case L4_SCHEDULER_IDLE_TIME_OP:
72         {
73           l4_sched_cpu_set_t cpus;
74             {
75               l4_umword_t gran_off;
76               ios >> gran_off >> cpus.map;
77               cpus.offset = gran_off & 0x00ffffff;
78               cpus.granularity = gran_off >> 24;
79             }
80           return _sched->idle_time(cpus);
81         }
82     default:
83       return -L4_ENOSYS;
84     }
85 }
86
87 }