1.1 --- a/libexec/lib/src/process.cc Sat Mar 04 19:03:27 2023 +0100
1.2 +++ b/libexec/lib/src/process.cc Mon Mar 06 00:14:52 2023 +0100
1.3 @@ -149,30 +149,32 @@
1.4 }
1.5
1.6 /* Configure the thread environment, employing the given server as the region
1.7 - mapper. */
1.8 + mapper. Return the capability index for the server in the new task. */
1.9
1.10 -long Process::configure_thread(l4_cap_idx_t server, l4_cap_idx_t mapped_cap)
1.11 +long Process::configure_thread(l4_cap_idx_t server, l4_cap_idx_t *mapped_cap)
1.12 {
1.13 /* Employ a distinct region mapper for each thread's environment, this acting
1.14 as pager. */
1.15
1.16 - if (l4_is_valid_cap(mapped_cap))
1.17 + if ((mapped_cap != NULL) && l4_is_valid_cap(*mapped_cap))
1.18 {
1.19 - _env.rm = mapped_cap;
1.20 + _env.rm = *mapped_cap;
1.21 return L4_EOK;
1.22 }
1.23 else
1.24 {
1.25 _env.rm = allocate_cap();
1.26 + *mapped_cap = _env.rm;
1.27 return ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.rm, server, L4_CAP_FPAGE_RWS, 0});
1.28 }
1.29 }
1.30
1.31 /* Set the parent of the new thread. */
1.32
1.33 -long Process::set_parent(l4_cap_idx_t server)
1.34 +long Process::set_parent(l4_cap_idx_t parent, l4_cap_idx_t *rparent)
1.35 {
1.36 - return ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.parent, server, L4_CAP_FPAGE_RWS, 0});
1.37 + *rparent = _env.parent;
1.38 + return ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.parent, parent, L4_CAP_FPAGE_RWS, 0});
1.39 }
1.40
1.41 /* Map capabilities into the task, counting them if indicated. */
1.42 @@ -191,7 +193,7 @@
1.43
1.44 /* Create, initialise and start a thread. */
1.45
1.46 -long Process::thread_start(l4_addr_t program_start, Stack &st, l4_cap_idx_t *thread)
1.47 +long Process::thread_start(l4_addr_t program_start, Stack &st, l4_cap_idx_t *thread, l4_cap_idx_t *rthread)
1.48 {
1.49 long err;
1.50
1.51 @@ -255,6 +257,7 @@
1.52
1.53 l4_sched_param_t sp = l4_sched_param(L4RE_MAIN_THREAD_PRIO);
1.54
1.55 + *rthread = _env.main_thread;
1.56 return l4_error(l4_scheduler_run_thread(l4re_env()->scheduler, *thread, &sp));
1.57 }
1.58