# HG changeset patch # User Paul Boddie # Date 1617400961 -7200 # Node ID c1d7c64c3ec830720b736993d8eb834587c303f4 # Parent f76f98fe5ee439346a71e14f0fe3245f3f97c0bb Moved server programs, also making their memory usage somewhat configurable. diff -r f76f98fe5ee4 -r c1d7c64c3ec8 Makefile --- a/Makefile Fri Apr 02 22:38:14 2021 +0200 +++ b/Makefile Sat Apr 03 00:02:41 2021 +0200 @@ -70,25 +70,25 @@ $(PLAIN_SRC_CC_common_file_server) \ files/block_file_accessor.cc files/block_file_opener.cc \ files/host_file_accessor.cc files/host_file_opener.cc \ - tests/dstest_block_server.cc + servers/block_file_server.cc PLAIN_SRC_CC_dstest_host_server = \ $(PLAIN_SRC_CC_common_server) \ $(PLAIN_SRC_CC_common_file_server) \ files/host_file_accessor.cc files/host_file_opener.cc \ - tests/dstest_host_server.cc + servers/host_file_server.cc PLAIN_SRC_CC_dstest_pipe_server = \ $(PLAIN_SRC_CC_common_server) \ pipes/pipe_opener_resource.cc pipes/pipe_pager.cc \ pipes/pipe_accessor.cc pipes/pipe_paging.cc \ - tests/dstest_pipe_server.cc + servers/pipe_server.cc PLAIN_SRC_CC_dstest_test_server = \ $(PLAIN_SRC_CC_common_server) \ $(PLAIN_SRC_CC_common_file_server) \ files/test_file_accessor.cc files/test_file_opener.cc \ - tests/dstest_test_server.cc + servers/test_file_server.cc # Normal definitions. diff -r f76f98fe5ee4 -r c1d7c64c3ec8 conf/dstest_block.cfg --- a/conf/dstest_block.cfg Fri Apr 02 22:38:14 2021 +0200 +++ b/conf/dstest_block.cfg Sat Apr 03 00:02:41 2021 +0200 @@ -6,13 +6,13 @@ local server = l:new_channel(); -l:start({ +l:startv({ caps = { server = server:svr(), }, log = { "server", "r" }, }, - "rom/dstest_block_server"); + "rom/dstest_block_server", "10"); l:startv({ caps = { diff -r f76f98fe5ee4 -r c1d7c64c3ec8 conf/dstest_host.cfg --- a/conf/dstest_host.cfg Fri Apr 02 22:38:14 2021 +0200 +++ b/conf/dstest_host.cfg Sat Apr 03 00:02:41 2021 +0200 @@ -6,13 +6,13 @@ local server = l:new_channel(); -l:start({ +l:startv({ caps = { server = server:svr(), }, log = { "server", "r" }, }, - "rom/dstest_host_server"); + "rom/dstest_host_server", "10"); l:startv({ caps = { diff -r f76f98fe5ee4 -r c1d7c64c3ec8 conf/dstest_pipe.cfg --- a/conf/dstest_pipe.cfg Fri Apr 02 22:38:14 2021 +0200 +++ b/conf/dstest_pipe.cfg Sat Apr 03 00:02:41 2021 +0200 @@ -6,13 +6,13 @@ local server = l:new_channel(); -l:start({ +l:startv({ caps = { server = server:svr(), }, log = { "server", "r" }, }, - "rom/dstest_pipe_server"); + "rom/dstest_pipe_server", "10"); l:start({ caps = { diff -r f76f98fe5ee4 -r c1d7c64c3ec8 servers/block_file_server.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servers/block_file_server.cc Sat Apr 03 00:02:41 2021 +0200 @@ -0,0 +1,90 @@ +/* + * A dataspace server exposing files each as a block of writable memory. + * + * Copyright (C) 2020, 2021 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include +#include + +#include + +#include +#include +#include + +#include "memory_incremental.h" +#include "memory_utils.h" +#include "page_queue_shared.h" +#include "pages.h" +#include "resource_server.h" +#include "block_file_opener.h" + + + +/* Default number of pages for files. */ + +const unsigned int MEMORY_PAGES = 20; + + + +/* Server program. */ + +int main(int argc, char *argv[]) +{ + long err; + + /* Introduce concurrency control. */ + + err = ipc_thread_init(); + + if (err) + { + printf("Initialisation error: %s\n", l4sys_errtostr(err)); + return 1; + } + + unsigned int memory_pages = MEMORY_PAGES; + + if (argc > 1) + memory_pages = atoi(argv[1]); + + /* Some memory plus infrastructure. */ + + MemoryIncremental mem(memory_pages); + PageQueueShared queue; + Pages pages(&mem, &queue); + BlockFileOpener opener(&pages); + + /* Register a server associating it with the given object. */ + + ResourceServer server(&opener); + err = server.bind("server"); + + if (err) + { + printf("Could not bind server: %s\n", l4sys_errtostr(err)); + return 1; + } + + printf("Starting server using %d pages...\n", memory_pages); + server.start(); + return 0; +} + +// vim: tabstop=2 expandtab shiftwidth=2 diff -r f76f98fe5ee4 -r c1d7c64c3ec8 servers/host_file_server.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servers/host_file_server.cc Sat Apr 03 00:02:41 2021 +0200 @@ -0,0 +1,88 @@ +/* + * A dataspace server exposing "host" file contents. + * + * Copyright (C) 2020, 2021 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include +#include + +#include + +#include +#include +#include + +#include "memory_incremental.h" +#include "memory_utils.h" +#include "page_queue_shared.h" +#include "pages.h" +#include "resource_server.h" +#include "host_file_opener.h" + + + +/* Default number of pages for files. */ + +const unsigned int MEMORY_PAGES = 20; + + + +/* Server program. */ + +int main(int argc, char *argv[]) +{ + long err; + + /* Introduce concurrency control. */ + + err = ipc_thread_init(); + + if (err) + { + printf("Initialisation error: %s\n", l4sys_errtostr(err)); + return 1; + } + + unsigned int memory_pages = MEMORY_PAGES; + + if (argc > 1) + memory_pages = atoi(argv[1]); + + /* Some memory plus infrastructure. */ + + MemoryIncremental mem(memory_pages); + PageQueueShared queue; + Pages pages(&mem, &queue); + HostFileOpener opener(&pages); + + /* Register a server associating it with the given object. */ + + ResourceServer server(&opener); + err = server.bind("server"); + + if (err) + { + printf("Could not bind server: %s\n", l4sys_errtostr(err)); + return 1; + } + + printf("Starting server using %d pages...\n", memory_pages); + server.start(); + return 0; +} diff -r f76f98fe5ee4 -r c1d7c64c3ec8 servers/pipe_server.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servers/pipe_server.cc Sat Apr 03 00:02:41 2021 +0200 @@ -0,0 +1,83 @@ +/* + * A pipe server. + * + * Copyright (C) 2020, 2021 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include + +#include + +#include +#include + +#include "memory_incremental.h" +#include "pipe_opener_resource.h" +#include "resource_server.h" + + + +/* Default number of pages for pipes. */ + +const unsigned int MEMORY_PAGES = 20; + + + +/* Server program. */ + +int main(int argc, char *argv[]) +{ + long err; + + /* Introduce concurrency control. */ + + err = ipc_thread_init(); + + if (err) + { + printf("Initialisation error: %s\n", l4sys_errtostr(err)); + return 1; + } + + unsigned int memory_pages = MEMORY_PAGES; + + if (argc > 1) + memory_pages = atoi(argv[1]); + + /* Some memory plus infrastructure. */ + + MemoryIncremental mem(memory_pages); + PipeOpenerResource opener(&mem); + + /* Register a server associating it with the given object. */ + + ResourceServer server(&opener); + err = server.bind("server"); + + if (err) + { + printf("Could not bind server: %s\n", l4sys_errtostr(err)); + return 1; + } + + printf("Starting server using %d pages...\n", memory_pages); + server.start(); + return 0; +} + +// vim: tabstop=2 expandtab shiftwidth=2 diff -r f76f98fe5ee4 -r c1d7c64c3ec8 servers/test_file_server.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/servers/test_file_server.cc Sat Apr 03 00:02:41 2021 +0200 @@ -0,0 +1,88 @@ +/* + * Test dataspace operations. + * + * Copyright (C) 2020, 2021 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include +#include + +#include + +#include +#include +#include + +#include "memory_incremental.h" +#include "memory_utils.h" +#include "page_queue_shared.h" +#include "pages.h" +#include "resource_server.h" +#include "test_file_opener.h" + + + +const unsigned int REGION_PAGES = 8; +const unsigned int MEMORY_PAGES = REGION_PAGES * 10; +const unsigned int FILE_PAGES = 20; + +int main(int argc, char *argv[]) +{ + long err; + + /* Introduce concurrency control. */ + + err = ipc_thread_init(); + + if (err) + { + printf("Initialisation error: %s\n", l4sys_errtostr(err)); + return 1; + } + + /* Configure the number of available pages using any argument. */ + + unsigned int memory_pages = MEMORY_PAGES; + + if (argc > 1) + memory_pages = atoi(argv[1]) * REGION_PAGES; + + /* Some memory plus infrastructure. */ + + MemoryIncremental mem(memory_pages, page(REGION_PAGES)); + PageQueueShared queue; + Pages pages(&mem, &queue); + TestFileOpener opener(&pages, page(FILE_PAGES)); + + /* Register a server associating it with the given object. */ + + ResourceServer server(&opener); + err = server.bind("server"); + + if (err) + { + printf("Could not bind server: %s\n", l4sys_errtostr(err)); + return 1; + } + + printf("Starting server...\n"); + server.start(); + return 0; +} + +// vim: tabstop=2 expandtab shiftwidth=2 diff -r f76f98fe5ee4 -r c1d7c64c3ec8 tests/dstest_block_server.cc --- a/tests/dstest_block_server.cc Fri Apr 02 22:38:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Test dataspace operations. - * - * Copyright (C) 2020, 2021 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include -#include - -#include -#include -#include - -#include "memory_incremental.h" -#include "memory_utils.h" -#include "page_queue_shared.h" -#include "pages.h" -#include "resource_server.h" -#include "block_file_opener.h" - - - -const unsigned int MEMORY_PAGES = 10; - -int main(void) -{ - /* Some memory plus infrastructure. */ - - MemoryIncremental mem(MEMORY_PAGES); - PageQueueShared queue; - Pages pages(&mem, &queue); - BlockFileOpener opener(&pages); - - /* Register a server associating it with the given object. */ - - ResourceServer server(&opener); - long err = server.bind("server"); - - if (err) - { - printf("Could not bind server: %s\n", l4sys_errtostr(err)); - return 1; - } - - printf("Starting server...\n"); - server.start(); - return 0; -} - -// vim: tabstop=2 expandtab shiftwidth=2 diff -r f76f98fe5ee4 -r c1d7c64c3ec8 tests/dstest_host_server.cc --- a/tests/dstest_host_server.cc Fri Apr 02 22:38:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Test dataspace operations. - * - * Copyright (C) 2020, 2021 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include -#include - -#include -#include -#include - -#include "memory_incremental.h" -#include "memory_utils.h" -#include "page_queue_shared.h" -#include "pages.h" -#include "resource_server.h" -#include "host_file_opener.h" - - - -const unsigned int MEMORY_PAGES = 10; - -int main(void) -{ - /* Some memory plus infrastructure. */ - - MemoryIncremental mem(MEMORY_PAGES); - PageQueueShared queue; - Pages pages(&mem, &queue); - HostFileOpener opener(&pages); - - /* Register a server associating it with the given object. */ - - ResourceServer server(&opener); - long err = server.bind("server"); - - if (err) - { - printf("Could not bind server: %s\n", l4sys_errtostr(err)); - return 1; - } - - printf("Starting server...\n"); - server.start(); - return 0; -} diff -r f76f98fe5ee4 -r c1d7c64c3ec8 tests/dstest_pipe_server.cc --- a/tests/dstest_pipe_server.cc Fri Apr 02 22:38:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Test pipe operations. - * - * Copyright (C) 2020, 2021 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include - -#include - -#include "memory_incremental.h" -#include "pipe_opener_resource.h" -#include "resource_server.h" - - - -const unsigned int MEMORY_PAGES = 20; - -int main(void) -{ - /* Some memory plus infrastructure. */ - - MemoryIncremental mem(MEMORY_PAGES); - PipeOpenerResource opener(&mem); - - /* Register a server associating it with the given object. */ - - ResourceServer server(&opener); - long err = server.bind("server"); - - if (err) - { - printf("Could not bind server: %s\n", l4sys_errtostr(err)); - return 1; - } - - printf("Starting server...\n"); - server.start(); - return 0; -} - -// vim: tabstop=2 expandtab shiftwidth=2 diff -r f76f98fe5ee4 -r c1d7c64c3ec8 tests/dstest_test_server.cc --- a/tests/dstest_test_server.cc Fri Apr 02 22:38:14 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * Test dataspace operations. - * - * Copyright (C) 2020, 2021 Paul Boddie - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - -#include -#include - -#include - -#include -#include -#include - -#include "memory_incremental.h" -#include "memory_utils.h" -#include "page_queue_shared.h" -#include "pages.h" -#include "resource_server.h" -#include "test_file_opener.h" - - - -const unsigned int REGION_PAGES = 8; -const unsigned int MEMORY_PAGES = REGION_PAGES * 10; -const unsigned int FILE_PAGES = 20; - -int main(int argc, char *argv[]) -{ - long err; - - /* Introduce concurrency control. */ - - err = ipc_thread_init(); - - if (err) - { - printf("Initialisation error: %s\n", l4sys_errtostr(err)); - return 1; - } - - /* Configure the number of available pages using any argument. */ - - unsigned int memory_pages = MEMORY_PAGES; - - if (argc > 1) - memory_pages = atoi(argv[1]) * REGION_PAGES; - - /* Some memory plus infrastructure. */ - - MemoryIncremental mem(memory_pages, page(REGION_PAGES)); - PageQueueShared queue; - Pages pages(&mem, &queue); - TestFileOpener opener(&pages, page(FILE_PAGES)); - - /* Register a server associating it with the given object. */ - - ResourceServer server(&opener); - err = server.bind("server"); - - if (err) - { - printf("Could not bind server: %s\n", l4sys_errtostr(err)); - return 1; - } - - printf("Starting server...\n"); - server.start(); - return 0; -} - -// vim: tabstop=2 expandtab shiftwidth=2