1 /* 2 * Support for initialising programs in new tasks and threads. 3 * 4 * Copyright (C) 2022 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 <l4/re/env.h> 25 #include <l4/re/l4aux.h> 26 #include <l4/sys/factory.h> 27 #include <l4/sys/task.h> 28 #include <l4/sys/thread.h> 29 30 #include <exec/stack.h> 31 32 33 34 /* UTCB properties. 35 See: moe/server/src/loader.cc */ 36 37 enum exec_utcb 38 { 39 Default_max_threads = 16, 40 #ifdef ARCH_mips 41 Utcb_area_start = 0x73000000, 42 #else 43 Utcb_area_start = 0xb3000000, 44 #endif 45 }; 46 47 48 49 /* Capability index definitions. */ 50 51 enum exec_task_caps 52 { 53 L4_EXEC_PAGER_CAP = 0x10 << L4_CAP_SHIFT, 54 L4_EXEC_RM_CAP = 0x11 << L4_CAP_SHIFT, 55 L4_EXEC_MA_CAP = 0x12 << L4_CAP_SHIFT, 56 L4_EXEC_KIP_CAP = 0x14 << L4_CAP_SHIFT, 57 }; 58 59 /* The default first free capability index must follow those above. */ 60 61 enum exec_task_cap_indexes 62 { 63 L4_EXEC_FIRST_FREE_CAP_INDEX = 0x15, 64 }; 65 66 67 68 /* A process abstraction. */ 69 70 class Process 71 { 72 protected: 73 l4_cap_idx_t _task = L4_INVALID_CAP; 74 75 /* UTCB details. */ 76 77 l4_addr_t _utcb_start; 78 79 /* Common environment details. */ 80 81 l4re_aux_t _aux; 82 l4re_env_t _env; 83 84 /* Task and thread initialisation. */ 85 86 long create_task(); 87 88 long create_thread(l4_cap_idx_t *thread); 89 90 public: 91 explicit Process(); 92 93 long configure(l4_cap_idx_t server); 94 95 long thread_start(l4_addr_t program_start, Stack &st); 96 }; 97 98 /* vim: tabstop=2 expandtab shiftwidth=2 99 */