1 /* 2 * Test pipe operations. 3 * 4 * Copyright (C) 2020, 2021 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 <stdio.h> 25 26 #include "memory.h" 27 #include "pages_conserving.h" 28 #include "pipe_opener_resource.h" 29 #include "resource_server.h" 30 31 32 33 const unsigned int MEMORY_PAGES = 20; 34 const unsigned int PIPE_PAGES = 2; 35 36 int main(void) 37 { 38 /* Some memory plus infrastructure. */ 39 40 Memory mem(MEMORY_PAGES); 41 PagesConserving pages(&mem, PIPE_PAGES); 42 PipeOpenerResource opener(&pages); 43 44 /* Register a server associating it with the given object. */ 45 46 ResourceServer server(&opener); 47 long err = server.bind("server"); 48 49 if (err) 50 { 51 printf("Could not bind server: %s\n", l4sys_errtostr(err)); 52 return 1; 53 } 54 55 printf("Starting server...\n"); 56 server.start(); 57 return 0; 58 }