1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/libexec/include/exec/process.h Tue May 10 22:39:15 2022 +0200
1.3 @@ -0,0 +1,99 @@
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 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License as
1.11 + * published by the Free Software Foundation; either version 2 of
1.12 + * the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 + * Boston, MA 02110-1301, USA
1.23 + */
1.24 +
1.25 +#pragma once
1.26 +
1.27 +#include <l4/re/env.h>
1.28 +#include <l4/re/l4aux.h>
1.29 +#include <l4/sys/factory.h>
1.30 +#include <l4/sys/task.h>
1.31 +#include <l4/sys/thread.h>
1.32 +
1.33 +#include <exec/stack.h>
1.34 +
1.35 +
1.36 +
1.37 +/* UTCB properties.
1.38 + See: moe/server/src/loader.cc */
1.39 +
1.40 +enum exec_utcb
1.41 +{
1.42 + Default_max_threads = 16,
1.43 +#ifdef ARCH_mips
1.44 + Utcb_area_start = 0x73000000,
1.45 +#else
1.46 + Utcb_area_start = 0xb3000000,
1.47 +#endif
1.48 +};
1.49 +
1.50 +
1.51 +
1.52 +/* Capability index definitions. */
1.53 +
1.54 +enum exec_task_caps
1.55 +{
1.56 + L4_EXEC_PAGER_CAP = 0x10 << L4_CAP_SHIFT,
1.57 + L4_EXEC_RM_CAP = 0x11 << L4_CAP_SHIFT,
1.58 + L4_EXEC_MA_CAP = 0x12 << L4_CAP_SHIFT,
1.59 + L4_EXEC_KIP_CAP = 0x14 << L4_CAP_SHIFT,
1.60 +};
1.61 +
1.62 +/* The default first free capability index must follow those above. */
1.63 +
1.64 +enum exec_task_cap_indexes
1.65 +{
1.66 + L4_EXEC_FIRST_FREE_CAP_INDEX = 0x15,
1.67 +};
1.68 +
1.69 +
1.70 +
1.71 +/* A process abstraction. */
1.72 +
1.73 +class Process
1.74 +{
1.75 +protected:
1.76 + l4_cap_idx_t _task = L4_INVALID_CAP;
1.77 +
1.78 + /* UTCB details. */
1.79 +
1.80 + l4_addr_t _utcb_start;
1.81 +
1.82 + /* Common environment details. */
1.83 +
1.84 + l4re_aux_t _aux;
1.85 + l4re_env_t _env;
1.86 +
1.87 + /* Task and thread initialisation. */
1.88 +
1.89 + long create_task();
1.90 +
1.91 + long create_thread(l4_cap_idx_t *thread);
1.92 +
1.93 +public:
1.94 + explicit Process();
1.95 +
1.96 + long configure(l4_cap_idx_t server);
1.97 +
1.98 + long thread_start(l4_addr_t program_start, Stack &st);
1.99 +};
1.100 +
1.101 +/* vim: tabstop=2 expandtab shiftwidth=2
1.102 +*/