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.
12 #include <l4/re/l4aux.h>
14 #include <l4/libloader/loader>
15 #include <l4/libloader/remote_app_model>
16 #include "remote_mem.h"
25 struct App_model : public Ldr::Base_app_model<Stack>
44 Default_base_prio = 0x00,
45 Default_max_prio = 0xff,
50 Utcb_area_start = 0xb3000000,
51 Default_max_threads = 16,
52 Total_max_threads = 256,
53 Kip_address = 0xa0000000,
56 typedef L4Re::Util::Ref_cap<L4Re::Dataspace>::Cap Const_dataspace;
57 typedef L4Re::Util::Ref_cap<L4Re::Dataspace>::Cap Dataspace;
58 typedef L4Re::Util::Ref_cap<L4Re::Rm>::Cap Rm;
60 typedef L4::Cap<L4Re::Dataspace> Const_dataspace;
61 typedef L4::Cap<L4Re::Dataspace> Dataspace;
62 typedef L4::Cap<L4Re::Rm> Rm;
68 Dataspace alloc_ds(unsigned long size) const;
70 static Const_dataspace open_file(char const *name);
72 virtual l4_cap_idx_t push_initial_caps(l4_cap_idx_t start) = 0;
73 virtual void map_initial_caps(L4::Cap<L4::Task> task, l4_cap_idx_t start) = 0;
75 void prog_attach_ds(l4_addr_t addr, unsigned long size,
76 Const_dataspace ds, unsigned long offset,
77 unsigned flags, char const *what);
79 static void copy_ds(Dataspace dst, unsigned long dst_offs,
80 Const_dataspace src, unsigned long src_offs,
83 static bool all_segs_cow() { return false; }
85 l4_addr_t local_attach_ds(Const_dataspace ds, unsigned long size,
86 unsigned long offset) const;
88 void local_detach_ds(l4_addr_t addr, unsigned long size) const;
90 int prog_reserve_area(l4_addr_t *start, unsigned long size, unsigned flags, unsigned char align);
92 Dataspace alloc_app_stack();
96 static Const_dataspace reserved_area()
97 { return Const_dataspace(); }
99 static Dataspace local_kip_ds()
101 extern l4re_aux_t* l4re_aux;
102 return L4::Cap<L4Re::Dataspace>(l4re_aux->kip_ds);
106 static L4::Cap<void> local_kip_cap()
107 { return local_kip_ds().get(); }
109 static L4::Cap<void> prog_kip_ds()
110 { return L4::Cap<void>(Kip_cap << L4_CAP_SHIFT); }
113 void get_task_caps(L4::Cap<L4::Factory> *factory,
114 L4::Cap<L4::Task> *task,
115 L4::Cap<L4::Thread> *thread);
117 l4_msgtag_t run_thread(L4::Cap<L4::Thread> thread,
118 l4_sched_param_t const &sp)
120 L4::Cap<L4::Scheduler> s(prog_info()->scheduler.raw & (~0UL << L4_FPAGE_ADDR_SHIFT));
121 return s->run_thread(thread, sp);
124 virtual void push_argv_strings() = 0;
125 virtual void push_env_strings() = 0;
128 L4::Cap<L4Re::Log> _log;
129 L4::Cap<L4::Scheduler> _sched;
130 L4::Cap<L4Re::Namespace> _ns;
131 L4::Cap<L4Re::Mem_alloc> _ma;
132 L4::Cap<L4Re::Mem_alloc> _ma;
133 L4::Cap<L4::Factory> _factory;
136 virtual ~App_model() throw() {}
140 typedef Ldr::Remote_app_model<App_model> Rmt_app_model;