1 /* 2 * Test dataspace 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/re/env.h> 23 #include <l4/sys/err.h> 24 25 #include <ipc/thread.h> 26 27 #include <stdio.h> 28 #include <string.h> 29 #include <stdlib.h> 30 31 #include <mem/memory_incremental.h> 32 #include <mem/memory_utils.h> 33 #include <fsserver/page_queue_shared.h> 34 #include <fsserver/pages.h> 35 #include <fsserver/resource_server.h> 36 #include <fsserver/test_file_opener.h> 37 38 39 40 const unsigned int REGION_PAGES = 8; 41 const unsigned int MEMORY_PAGES = REGION_PAGES * 10; 42 const unsigned int FILE_PAGES = 20; 43 44 int main(int argc, char *argv[]) 45 { 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 /* Configure the number of available pages using any argument. */ 59 60 unsigned int memory_pages = MEMORY_PAGES; 61 62 if (argc > 1) 63 memory_pages = atoi(argv[1]) * REGION_PAGES; 64 65 /* Some memory plus infrastructure. */ 66 67 MemoryIncremental mem(memory_pages, page(REGION_PAGES)); 68 PageQueueShared queue; 69 Pages pages(&mem, &queue); 70 TestFileOpener opener(&pages, page(FILE_PAGES)); 71 72 /* Register a server associating it with the given object. */ 73 74 ResourceServer server(&opener); 75 err = server.bind("server"); 76 77 if (err) 78 { 79 printf("Could not bind server: %s\n", l4sys_errtostr(err)); 80 return 1; 81 } 82 83 printf("Starting server...\n"); 84 server.start(); 85 return 0; 86 } 87 88 // vim: tabstop=2 expandtab shiftwidth=2