1 /* 2 * Support for executing code in new tasks and threads. 3 * 4 * Copyright (C) 2022, 2023 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 <exec/elf.h> 25 #include <exec/external_pager.h> 26 #include <exec/memory.h> 27 #include <exec/process.h> 28 #include <ipc/map.h> 29 #include <ipc/server.h> 30 31 32 33 /* Process creator functionality. */ 34 35 class ProcessCreating 36 { 37 protected: 38 const char *_rm_filename; 39 40 /* External pager configuration. */ 41 42 ExternalPager _exec_pager; 43 ipc_server_config_type _config; 44 45 Process _process; 46 47 /* Stack and payload descriptions. */ 48 49 ExplicitSegment _rm_stack; 50 Payload *_rm_payload; 51 52 ExplicitSegment _program_stack; 53 Payload *_program_payload; 54 55 /* IPC gate for communication within the created task, plus allocated 56 capability. */ 57 58 l4_cap_idx_t _ipc_gate, _ipc_gate_cap; 59 60 /* Utility methods. */ 61 62 long start_pager(); 63 64 long init_region_mapper(); 65 66 long init_program(file_t *file); 67 68 long init_external_pager(); 69 70 long configure_task(); 71 72 long create_ipc_gate(); 73 74 void init_region(struct exec_region *regions, 75 struct ipc_mapped_cap *mapped_caps, 76 struct exec_region &r, unsigned int &index); 77 78 long start_region_mapper(); 79 80 long start_program(int argc, const char *argv[]); 81 82 public: 83 explicit ProcessCreating(const char *rm_filename); 84 85 virtual long start(file_t *file, int argc, const char *argv[]); 86 87 virtual l4_cap_idx_t get_pager(); 88 }; 89 90 /* vim: tabstop=2 expandtab shiftwidth=2 91 */