L4Re/departure

libexec/include/exec/process_creating.h

615:b8942c43b125
9 months ago Paul Boddie Added support for input pipes in initiated programs, extending the fsaccess program to allow programs to be connected together and for programs to consume files as standard input. Fixed the clip program to behave more like it should since it is useful for testing connected programs.
     1 /*     2  * Support for executing code in new tasks and threads.     3  *     4  * Copyright (C) 2022, 2023, 2024 Paul Boddie <paul@boddie.org.uk>     5  *     6  * This program is free software; you can redistribute it and/or     7  * modify it under the terms of the GNU General Public License as     8  * published by the Free Software Foundation; either version 2 of     9  * the License, or (at your option) any later version.    10  *    11  * This program is distributed in the hope that it will be useful,    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    14  * GNU General Public License for more details.    15  *    16  * You should have received a copy of the GNU General Public License    17  * along with this program; if not, write to the Free Software    18  * Foundation, Inc., 51 Franklin Street, Fifth Floor,    19  * Boston, MA  02110-1301, USA    20  */    21     22 #pragma once    23     24 #include <mutex>    25     26 #include <exec/elf.h>    27 #include <exec/external_pager.h>    28 #include <exec/memory.h>    29 #include <exec/process.h>    30 #include <exec/process_monitor.h>    31 #include <ipc/map.h>    32     33     34     35 /* Process creator functionality. */    36     37 class ProcessCreating    38 {    39 protected:    40   std::mutex _lock;    41     42   /* Region mapper program file. */    43     44   const char *_rm_filename;    45   file_t *_rm_file;    46     47   /* External pager and process monitor. */    48     49   ExternalPager *_exec_pager = NULL;    50   ProcessMonitor *_monitor = NULL;    51     52   /* Process construction. */    53     54   Process _process;    55     56   /* Stack and payload descriptions. */    57     58   ExplicitSegment *_rm_stack = NULL;    59   Payload *_rm_payload = NULL;    60     61   ExplicitSegment *_program_stack = NULL;    62   Payload *_program_payload = NULL;    63     64   /* IPC gate for communication within the created task, plus allocated    65      capability. */    66     67   l4_cap_idx_t _internal_pager, _mapped_internal_pager;    68     69   /* Utility methods. */    70     71   long start_pager();    72     73   long init_region_mapper();    74     75   long init_program(file_t *file);    76     77   long init_external_pager(l4_cap_idx_t *pager);    78     79   long configure_task();    80     81   long allocate_internal_pager();    82     83   void init_region(struct exec_region *regions,    84                    struct ipc_mapped_cap *mapped_caps,    85                    struct exec_region &r, unsigned int &index);    86     87   long start_region_mapper(l4_cap_idx_t pager);    88     89   long start_program(l4_cap_idx_t monitor, int argc, const char *argv[],    90                      l4_cap_idx_t reader, l4_cap_idx_t writer);    91     92   long _start(int argc, const char *argv[], l4_cap_idx_t reader,    93               l4_cap_idx_t writer, l4_cap_idx_t process);    94     95 public:    96   explicit ProcessCreating(const char *rm_filename, file_t *rm_file);    97     98   virtual long init_process_monitor(l4_cap_idx_t *monitor);    99    100   virtual long start(int argc, const char *argv[], l4_cap_idx_t reader,   101                      l4_cap_idx_t writer, l4_cap_idx_t process);   102 };   103    104 /* vim: tabstop=2 expandtab shiftwidth=2   105 */