]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/moe/server/src/app_task.cc
Update
[l4.git] / l4 / pkg / l4re-core / moe / server / src / app_task.cc
1 /*
2  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *               Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #include "app_task.h"
11 #include "globals.h"
12
13 using L4Re::Dataspace;
14
15
16 long
17 App_task::op_signal(L4Re::Parent::Rights, unsigned long sig, unsigned long val)
18 {
19   switch (sig)
20     {
21     case 0: // exit
22       {
23         object_pool.cap_alloc()->free(obj_cap());
24         if (val != 0)
25           L4::cout << "MOE: task " << this << " exited with " << val
26                    << '\n';
27
28         return -L4_ENOREPLY;
29       }
30     default: break;
31     }
32   return L4_EOK;
33 }
34
35 App_task::App_task()
36   : _task(L4::Cap<L4::Task>::Invalid),
37     _thread(L4::Cap<L4::Thread>::Invalid),
38     _alloc(Allocator::root_allocator()),
39     _rm(_alloc->make_obj<Region_map>())
40 {
41   auto c = object_pool.cap_alloc()->alloc(_rm.get());
42   c->dec_refcnt(1);
43 }
44
45 App_task::~App_task()
46 {
47   if (_rm)
48     delete _rm.get();
49
50   object_pool.cap_alloc()->free(_thread);
51   object_pool.cap_alloc()->free(_task);
52 }