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 11 #include <l4/cxx/iostream> 12 13 #include "app_task.h" 14 #include "globals.h" 15 16 using L4Re::Dataspace; 17 18 19 long op_signal(L4Re::Parent::Rights,unsigned long sig,unsigned long val)20App_task::op_signal(L4Re::Parent::Rights, unsigned long sig, unsigned long val) 21 { 22 switch (sig) 23 { 24 case 0: // exit 25 { 26 object_pool.cap_alloc()->free(obj_cap()); 27 if (val != 0) 28 L4::cout << "MOE: task " << this << " exited with " << val 29 << '\n'; 30 31 return -L4_ENOREPLY; 32 } 33 default: break; 34 } 35 return L4_EOK; 36 } 37 App_task()38App_task::App_task() 39 : _task(L4::Cap<L4::Task>::Invalid), 40 _thread(L4::Cap<L4::Thread>::Invalid), 41 _alloc(Allocator::root_allocator()), 42 _rm(_alloc->make_obj<Region_map>()) 43 { 44 auto c = object_pool.cap_alloc()->alloc(_rm.get()); 45 c->dec_refcnt(1); 46 } 47 ~App_task()48App_task::~App_task() 49 { 50 if (_rm) 51 delete _rm.get(); 52 53 object_pool.cap_alloc()->free(_thread); 54 object_pool.cap_alloc()->free(_task); 55 } 56