1 /* 2 * A process server providing a way of creating new processes. 3 * 4 * Copyright (C) 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 #include <l4/sys/err.h> 23 24 #include <ipc/thread.h> 25 26 #include <stdio.h> 27 #include <stdlib.h> 28 29 #include <exec/process_creator_resource.h> 30 #include <fsserver/resource_server.h> 31 32 33 34 /* Server program. */ 35 36 int main(int argc, char *argv[]) 37 { 38 if (argc < 2) 39 { 40 printf("Need a region mapper.\n"); 41 return 1; 42 } 43 44 char *rm_filename = argv[1]; 45 const char *server_name = (argc > 2) ? argv[2] : "pserver"; 46 long err; 47 48 /* Introduce concurrency control. */ 49 50 err = ipc_thread_init(); 51 52 if (err) 53 { 54 printf("Initialisation error: %s\n", l4sys_errtostr(err)); 55 return 1; 56 } 57 58 ProcessCreatorResource creator(rm_filename); 59 60 /* Register a server associating it with the given object. */ 61 62 ResourceServer server(&creator); 63 err = server.bind(server_name); 64 65 if (err) 66 { 67 printf("Could not bind server: %s\n", l4sys_errtostr(err)); 68 return 1; 69 } 70 71 printf("Starting server...\n"); 72 server.start(); 73 return 0; 74 } 75 76 /* vim: tabstop=2 expandtab shiftwidth=2 77 */