1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/libexec/include/exec/process_creating.h Thu Feb 23 23:49:26 2023 +0100
1.3 @@ -0,0 +1,91 @@
1.4 +/*
1.5 + * Support for executing code in new tasks and threads.
1.6 + *
1.7 + * Copyright (C) 2022, 2023 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 <exec/elf.h>
1.28 +#include <exec/external_pager.h>
1.29 +#include <exec/memory.h>
1.30 +#include <exec/process.h>
1.31 +#include <ipc/map.h>
1.32 +#include <ipc/server.h>
1.33 +
1.34 +
1.35 +
1.36 +/* Process creator functionality. */
1.37 +
1.38 +class ProcessCreating
1.39 +{
1.40 +protected:
1.41 + const char *_rm_filename;
1.42 +
1.43 + /* External pager configuration. */
1.44 +
1.45 + ExternalPager _exec_pager;
1.46 + ipc_server_config_type _config;
1.47 +
1.48 + Process _process;
1.49 +
1.50 + /* Stack and payload descriptions. */
1.51 +
1.52 + ExplicitSegment _rm_stack;
1.53 + Payload *_rm_payload;
1.54 +
1.55 + ExplicitSegment _program_stack;
1.56 + Payload *_program_payload;
1.57 +
1.58 + /* IPC gate for communication within the created task, plus allocated
1.59 + capability. */
1.60 +
1.61 + l4_cap_idx_t _ipc_gate, _ipc_gate_cap;
1.62 +
1.63 + /* Utility methods. */
1.64 +
1.65 + long start_pager();
1.66 +
1.67 + long init_region_mapper();
1.68 +
1.69 + long init_program(file_t *file);
1.70 +
1.71 + long init_external_pager();
1.72 +
1.73 + long configure_task();
1.74 +
1.75 + long create_ipc_gate();
1.76 +
1.77 + void init_region(struct exec_region *regions,
1.78 + struct ipc_mapped_cap *mapped_caps,
1.79 + struct exec_region &r, unsigned int &index);
1.80 +
1.81 + long start_region_mapper();
1.82 +
1.83 + long start_program(int argc, const char *argv[]);
1.84 +
1.85 +public:
1.86 + explicit ProcessCreating(const char *rm_filename);
1.87 +
1.88 + virtual long start(file_t *file, int argc, const char *argv[]);
1.89 +
1.90 + virtual void set_notifier(Notifier *notifier);
1.91 +};
1.92 +
1.93 +/* vim: tabstop=2 expandtab shiftwidth=2
1.94 +*/