1.1 --- a/libexec/lib/src/process.cc Tue Feb 28 22:40:02 2023 +0100
1.2 +++ b/libexec/lib/src/process.cc Fri Mar 03 18:15:38 2023 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Support for initialising programs in new tasks and threads.
1.6 *
1.7 - * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -107,6 +107,13 @@
1.13 return l4_error(l4_factory_create_thread(l4re_env()->factory, *thread));
1.14 }
1.15
1.16 +/* Task access. */
1.17 +
1.18 +l4_cap_idx_t Process::get_task()
1.19 +{
1.20 + return _task;
1.21 +}
1.22 +
1.23 /* Configure the task environment. */
1.24
1.25 long Process::configure_task(unsigned int threads)
1.26 @@ -184,12 +191,11 @@
1.27
1.28 /* Create, initialise and start a thread. */
1.29
1.30 -long Process::thread_start(l4_addr_t program_start, Stack &st)
1.31 +long Process::thread_start(l4_addr_t program_start, Stack &st, l4_cap_idx_t *thread)
1.32 {
1.33 - l4_cap_idx_t thread;
1.34 long err;
1.35
1.36 - err = create_thread(&thread);
1.37 + err = create_thread(thread);
1.38
1.39 if (err)
1.40 return err;
1.41 @@ -208,11 +214,11 @@
1.42 l4_thread_control_exc_handler(_env.rm);
1.43 l4_thread_control_bind((l4_utcb_t *) l4_fpage_memaddr(_env.utcb_area), _task);
1.44
1.45 - err = l4_error(l4_thread_control_commit(thread));
1.46 + err = l4_error(l4_thread_control_commit(*thread));
1.47
1.48 if (err)
1.49 {
1.50 - ipc_cap_free(thread);
1.51 + ipc_cap_free(*thread);
1.52 return err;
1.53 }
1.54
1.55 @@ -220,7 +226,7 @@
1.56
1.57 _env.main_thread = allocate_cap();
1.58
1.59 - ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.main_thread, thread, L4_CAP_FPAGE_RWS, 0});
1.60 + ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.main_thread, *thread, L4_CAP_FPAGE_RWS, 0});
1.61
1.62 /* Populate the initial environment in the thread. */
1.63
1.64 @@ -236,7 +242,7 @@
1.65
1.66 /* Set the start details. */
1.67
1.68 - err = l4_error(l4_thread_ex_regs(thread, program_start, st.start_address(), 0));
1.69 + err = l4_error(l4_thread_ex_regs(*thread, program_start, st.start_address(), 0));
1.70
1.71 if (err)
1.72 return err;
1.73 @@ -249,7 +255,7 @@
1.74
1.75 l4_sched_param_t sp = l4_sched_param(L4RE_MAIN_THREAD_PRIO);
1.76
1.77 - return l4_error(l4_scheduler_run_thread(l4re_env()->scheduler, thread, &sp));
1.78 + return l4_error(l4_scheduler_run_thread(l4re_env()->scheduler, *thread, &sp));
1.79 }
1.80
1.81 /* vim: tabstop=2 expandtab shiftwidth=2