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 30 31 32 /* Process creator functionality. */ 33 34 class ProcessCreating 35 { 36 protected: 37 const char *_rm_filename; 38 39 /* External pager configuration. */ 40 41 ExternalPager *_exec_pager = NULL; 42 43 /* Process construction. */ 44 45 Process _process; 46 47 /* Stack and payload descriptions. */ 48 49 ExplicitSegment *_rm_stack = NULL; 50 Payload *_rm_payload = NULL; 51 52 ExplicitSegment *_program_stack = NULL; 53 Payload *_program_payload = NULL; 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(l4_cap_idx_t *pager); 69 70 long configure_task(l4_cap_idx_t pager); 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(l4_cap_idx_t pager); 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(int argc, const char *argv[], l4_cap_idx_t *process); 86 }; 87 88 /* vim: tabstop=2 expandtab shiftwidth=2 89 */