paul@308 | 1 | /* |
paul@308 | 2 | * Support for executing code in new tasks and threads. |
paul@308 | 3 | * |
paul@477 | 4 | * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk> |
paul@308 | 5 | * |
paul@308 | 6 | * This program is free software; you can redistribute it and/or |
paul@308 | 7 | * modify it under the terms of the GNU General Public License as |
paul@308 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@308 | 9 | * the License, or (at your option) any later version. |
paul@308 | 10 | * |
paul@308 | 11 | * This program is distributed in the hope that it will be useful, |
paul@308 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@308 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@308 | 14 | * GNU General Public License for more details. |
paul@308 | 15 | * |
paul@308 | 16 | * You should have received a copy of the GNU General Public License |
paul@308 | 17 | * along with this program; if not, write to the Free Software |
paul@308 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@308 | 19 | * Boston, MA 02110-1301, USA |
paul@308 | 20 | */ |
paul@308 | 21 | |
paul@308 | 22 | #include <l4/re/env.h> |
paul@308 | 23 | #include <l4/sys/err.h> |
paul@312 | 24 | #include <l4/util/util.h> |
paul@308 | 25 | |
paul@477 | 26 | #include <exec/process_creator.h> |
paul@477 | 27 | #include <systypes/fcntl.h> |
paul@312 | 28 | |
paul@308 | 29 | #include <stdio.h> |
paul@308 | 30 | |
paul@308 | 31 | |
paul@308 | 32 | |
paul@308 | 33 | int main(int argc, char *argv[]) |
paul@308 | 34 | { |
paul@308 | 35 | long err; |
paul@308 | 36 | |
paul@370 | 37 | if (argc < 3) |
paul@308 | 38 | { |
paul@477 | 39 | printf("Need a region mapper and the actual program to run.\n"); |
paul@370 | 40 | return 1; |
paul@370 | 41 | } |
paul@370 | 42 | |
paul@370 | 43 | char *rm_filename = argv[1]; |
paul@370 | 44 | char *program_filename = argv[2]; |
paul@370 | 45 | |
paul@477 | 46 | ProcessCreator creator(rm_filename); |
paul@477 | 47 | file_t *program_file = client_open(program_filename, O_RDONLY); |
paul@369 | 48 | |
paul@477 | 49 | if (!client_opened(program_file)) |
paul@365 | 50 | { |
paul@477 | 51 | printf("Could not open program file.\n"); |
paul@370 | 52 | return 1; |
paul@370 | 53 | } |
paul@370 | 54 | |
paul@477 | 55 | err = creator.start(program_file, argc - 2, (const char **) argv + 2); |
paul@308 | 56 | |
paul@308 | 57 | if (err) |
paul@308 | 58 | { |
paul@477 | 59 | printf("Could not start process: %s\n", l4sys_errtostr(err)); |
paul@308 | 60 | return 1; |
paul@308 | 61 | } |
paul@308 | 62 | |
paul@402 | 63 | printf("Finished program initiation.\n"); |
paul@402 | 64 | printf("End of test.\n"); |
paul@402 | 65 | |
paul@402 | 66 | /* NOTE: Should be able to obtain a notification for when the program |
paul@402 | 67 | finishes, which might be done using a capability deletion IRQ. |
paul@402 | 68 | Eventually, this program will operate as a server, invoking new |
paul@402 | 69 | programs and handling termination. This test would then merely |
paul@402 | 70 | involve the invocation of a utility function. */ |
paul@376 | 71 | |
paul@369 | 72 | while (1) |
paul@369 | 73 | l4_sleep_forever(); |
paul@308 | 74 | |
paul@308 | 75 | return 0; |
paul@308 | 76 | } |
paul@308 | 77 | |
paul@308 | 78 | /* vim: tabstop=2 expandtab shiftwidth=2 |
paul@308 | 79 | */ |