L4Re/departure

libexec/include/exec/process_creating.h

700:ab0cc68bfcaf
5 months ago Paul Boddie Added support for an error stream when creating processes. libc_newlib
     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                      l4_cap_idx_t error);    92     93   long _start(int argc, const char *argv[], l4_cap_idx_t reader,    94               l4_cap_idx_t writer, l4_cap_idx_t error, l4_cap_idx_t process);    95     96 public:    97   explicit ProcessCreating(const char *rm_filename, file_t *rm_file);    98     99   virtual long init_process_monitor(l4_cap_idx_t *monitor);   100    101   virtual long start(int argc, const char *argv[], l4_cap_idx_t reader,   102                      l4_cap_idx_t writer, l4_cap_idx_t error,   103                      l4_cap_idx_t process);   104 };   105    106 /* vim: tabstop=2 expandtab shiftwidth=2   107 */