1.1 --- a/libexec/lib/src/process.cc Sun Jun 12 17:50:58 2022 +0200
1.2 +++ b/libexec/lib/src/process.cc Sun Jun 12 18:04:17 2022 +0200
1.3 @@ -50,7 +50,7 @@
1.4 /* Initialise a new process, this being an abstraction for a new task with some
1.5 threads. */
1.6
1.7 -Process::Process()
1.8 +Process::Process(int reserved_threads)
1.9 {
1.10 /* Obtain UTCB area details for the task. */
1.11
1.12 @@ -68,7 +68,7 @@
1.13 _env.mem_alloc = L4_EXEC_MA_CAP;
1.14 _env.first_free_cap = L4_EXEC_FIRST_FREE_CAP_INDEX;
1.15 _env.utcb_area = utcb_fpage;
1.16 - _env.first_free_utcb = l4_fpage_memaddr(utcb_fpage) + L4_UTCB_OFFSET;
1.17 + _env.first_free_utcb = l4_fpage_memaddr(utcb_fpage) + reserved_threads * L4_UTCB_OFFSET;
1.18
1.19 /* Populate auxiliary information. */
1.20
1.21 @@ -101,7 +101,7 @@
1.22
1.23 /* Configure the task environment. */
1.24
1.25 -long Process::configure(l4_cap_idx_t server)
1.26 +long Process::configure_task()
1.27 {
1.28 long err = create_task();
1.29
1.30 @@ -123,8 +123,6 @@
1.31
1.32 struct ipc_mapped_cap mapped_caps[] = {
1.33 {L4_BASE_TASK_CAP, _task, L4_CAP_FPAGE_RWS},
1.34 - {L4_EXEC_PAGER_CAP, server, L4_CAP_FPAGE_RWS},
1.35 - {_env.rm, server, L4_CAP_FPAGE_RWS},
1.36 {_env.factory, l4re_env()->factory, L4_CAP_FPAGE_RWS},
1.37 {_env.log, l4re_env()->log, L4_CAP_FPAGE_RWS},
1.38 {_env.scheduler, l4re_env()->scheduler, L4_CAP_FPAGE_RWS},
1.39 @@ -132,7 +130,28 @@
1.40 {0, L4_INVALID_CAP, 0},
1.41 };
1.42
1.43 - return ipc_map_capabilities(_task, mapped_caps);
1.44 + return map_capabilities(mapped_caps, false);
1.45 +}
1.46 +
1.47 +/* Configure the thread environment. */
1.48 +
1.49 +long Process::configure_thread(l4_cap_idx_t server)
1.50 +{
1.51 + struct ipc_mapped_cap mapped_caps[] = {
1.52 + {L4_EXEC_PAGER_CAP, server, L4_CAP_FPAGE_RWS},
1.53 + {_env.rm, server, L4_CAP_FPAGE_RWS},
1.54 + {0, L4_INVALID_CAP, 0},
1.55 + };
1.56 +
1.57 + return map_capabilities(mapped_caps, false);
1.58 +}
1.59 +
1.60 +/* Map capabilities into the task, counting them if indicated. */
1.61 +
1.62 +long Process::map_capabilities(struct ipc_mapped_cap mapped_caps[],
1.63 + bool to_count)
1.64 +{
1.65 + return ipc_map_capabilities(_task, mapped_caps, to_count ? &_num_mapped_caps : NULL);
1.66 }
1.67
1.68 /* Create, initialise and start a thread. */
1.69 @@ -166,6 +185,10 @@
1.70
1.71 ipc_map_capability(_task, (struct ipc_mapped_cap) {_env.main_thread, thread, L4_CAP_FPAGE_RWS});
1.72
1.73 + /* Update the environment for any mapped capabilities. */
1.74 +
1.75 + _env.first_free_cap = L4_EXEC_FIRST_FREE_CAP_INDEX + _num_mapped_caps;
1.76 +
1.77 /* Populate the initial environment in the thread. */
1.78
1.79 st.set_l4re_aux(&_aux);