1.1 --- a/Makefile Fri Apr 02 22:38:14 2021 +0200
1.2 +++ b/Makefile Sat Apr 03 00:02:41 2021 +0200
1.3 @@ -70,25 +70,25 @@
1.4 $(PLAIN_SRC_CC_common_file_server) \
1.5 files/block_file_accessor.cc files/block_file_opener.cc \
1.6 files/host_file_accessor.cc files/host_file_opener.cc \
1.7 - tests/dstest_block_server.cc
1.8 + servers/block_file_server.cc
1.9
1.10 PLAIN_SRC_CC_dstest_host_server = \
1.11 $(PLAIN_SRC_CC_common_server) \
1.12 $(PLAIN_SRC_CC_common_file_server) \
1.13 files/host_file_accessor.cc files/host_file_opener.cc \
1.14 - tests/dstest_host_server.cc
1.15 + servers/host_file_server.cc
1.16
1.17 PLAIN_SRC_CC_dstest_pipe_server = \
1.18 $(PLAIN_SRC_CC_common_server) \
1.19 pipes/pipe_opener_resource.cc pipes/pipe_pager.cc \
1.20 pipes/pipe_accessor.cc pipes/pipe_paging.cc \
1.21 - tests/dstest_pipe_server.cc
1.22 + servers/pipe_server.cc
1.23
1.24 PLAIN_SRC_CC_dstest_test_server = \
1.25 $(PLAIN_SRC_CC_common_server) \
1.26 $(PLAIN_SRC_CC_common_file_server) \
1.27 files/test_file_accessor.cc files/test_file_opener.cc \
1.28 - tests/dstest_test_server.cc
1.29 + servers/test_file_server.cc
1.30
1.31 # Normal definitions.
1.32
2.1 --- a/conf/dstest_block.cfg Fri Apr 02 22:38:14 2021 +0200
2.2 +++ b/conf/dstest_block.cfg Sat Apr 03 00:02:41 2021 +0200
2.3 @@ -6,13 +6,13 @@
2.4
2.5 local server = l:new_channel();
2.6
2.7 -l:start({
2.8 +l:startv({
2.9 caps = {
2.10 server = server:svr(),
2.11 },
2.12 log = { "server", "r" },
2.13 },
2.14 - "rom/dstest_block_server");
2.15 + "rom/dstest_block_server", "10");
2.16
2.17 l:startv({
2.18 caps = {
3.1 --- a/conf/dstest_host.cfg Fri Apr 02 22:38:14 2021 +0200
3.2 +++ b/conf/dstest_host.cfg Sat Apr 03 00:02:41 2021 +0200
3.3 @@ -6,13 +6,13 @@
3.4
3.5 local server = l:new_channel();
3.6
3.7 -l:start({
3.8 +l:startv({
3.9 caps = {
3.10 server = server:svr(),
3.11 },
3.12 log = { "server", "r" },
3.13 },
3.14 - "rom/dstest_host_server");
3.15 + "rom/dstest_host_server", "10");
3.16
3.17 l:startv({
3.18 caps = {
4.1 --- a/conf/dstest_pipe.cfg Fri Apr 02 22:38:14 2021 +0200
4.2 +++ b/conf/dstest_pipe.cfg Sat Apr 03 00:02:41 2021 +0200
4.3 @@ -6,13 +6,13 @@
4.4
4.5 local server = l:new_channel();
4.6
4.7 -l:start({
4.8 +l:startv({
4.9 caps = {
4.10 server = server:svr(),
4.11 },
4.12 log = { "server", "r" },
4.13 },
4.14 - "rom/dstest_pipe_server");
4.15 + "rom/dstest_pipe_server", "10");
4.16
4.17 l:start({
4.18 caps = {
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/servers/block_file_server.cc Sat Apr 03 00:02:41 2021 +0200
5.3 @@ -0,0 +1,90 @@
5.4 +/*
5.5 + * A dataspace server exposing files each as a block of writable memory.
5.6 + *
5.7 + * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
5.8 + *
5.9 + * This program is free software; you can redistribute it and/or
5.10 + * modify it under the terms of the GNU General Public License as
5.11 + * published by the Free Software Foundation; either version 2 of
5.12 + * the License, or (at your option) any later version.
5.13 + *
5.14 + * This program is distributed in the hope that it will be useful,
5.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.17 + * GNU General Public License for more details.
5.18 + *
5.19 + * You should have received a copy of the GNU General Public License
5.20 + * along with this program; if not, write to the Free Software
5.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
5.22 + * Boston, MA 02110-1301, USA
5.23 + */
5.24 +
5.25 +#include <l4/re/env.h>
5.26 +#include <l4/sys/err.h>
5.27 +
5.28 +#include <ipc/thread.h>
5.29 +
5.30 +#include <stdio.h>
5.31 +#include <string.h>
5.32 +#include <stdlib.h>
5.33 +
5.34 +#include "memory_incremental.h"
5.35 +#include "memory_utils.h"
5.36 +#include "page_queue_shared.h"
5.37 +#include "pages.h"
5.38 +#include "resource_server.h"
5.39 +#include "block_file_opener.h"
5.40 +
5.41 +
5.42 +
5.43 +/* Default number of pages for files. */
5.44 +
5.45 +const unsigned int MEMORY_PAGES = 20;
5.46 +
5.47 +
5.48 +
5.49 +/* Server program. */
5.50 +
5.51 +int main(int argc, char *argv[])
5.52 +{
5.53 + long err;
5.54 +
5.55 + /* Introduce concurrency control. */
5.56 +
5.57 + err = ipc_thread_init();
5.58 +
5.59 + if (err)
5.60 + {
5.61 + printf("Initialisation error: %s\n", l4sys_errtostr(err));
5.62 + return 1;
5.63 + }
5.64 +
5.65 + unsigned int memory_pages = MEMORY_PAGES;
5.66 +
5.67 + if (argc > 1)
5.68 + memory_pages = atoi(argv[1]);
5.69 +
5.70 + /* Some memory plus infrastructure. */
5.71 +
5.72 + MemoryIncremental mem(memory_pages);
5.73 + PageQueueShared queue;
5.74 + Pages pages(&mem, &queue);
5.75 + BlockFileOpener opener(&pages);
5.76 +
5.77 + /* Register a server associating it with the given object. */
5.78 +
5.79 + ResourceServer server(&opener);
5.80 + err = server.bind("server");
5.81 +
5.82 + if (err)
5.83 + {
5.84 + printf("Could not bind server: %s\n", l4sys_errtostr(err));
5.85 + return 1;
5.86 + }
5.87 +
5.88 + printf("Starting server using %d pages...\n", memory_pages);
5.89 + server.start();
5.90 + return 0;
5.91 +}
5.92 +
5.93 +// vim: tabstop=2 expandtab shiftwidth=2
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/servers/host_file_server.cc Sat Apr 03 00:02:41 2021 +0200
6.3 @@ -0,0 +1,88 @@
6.4 +/*
6.5 + * A dataspace server exposing "host" file contents.
6.6 + *
6.7 + * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
6.8 + *
6.9 + * This program is free software; you can redistribute it and/or
6.10 + * modify it under the terms of the GNU General Public License as
6.11 + * published by the Free Software Foundation; either version 2 of
6.12 + * the License, or (at your option) any later version.
6.13 + *
6.14 + * This program is distributed in the hope that it will be useful,
6.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.17 + * GNU General Public License for more details.
6.18 + *
6.19 + * You should have received a copy of the GNU General Public License
6.20 + * along with this program; if not, write to the Free Software
6.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
6.22 + * Boston, MA 02110-1301, USA
6.23 + */
6.24 +
6.25 +#include <l4/re/env.h>
6.26 +#include <l4/sys/err.h>
6.27 +
6.28 +#include <ipc/thread.h>
6.29 +
6.30 +#include <stdio.h>
6.31 +#include <string.h>
6.32 +#include <stdlib.h>
6.33 +
6.34 +#include "memory_incremental.h"
6.35 +#include "memory_utils.h"
6.36 +#include "page_queue_shared.h"
6.37 +#include "pages.h"
6.38 +#include "resource_server.h"
6.39 +#include "host_file_opener.h"
6.40 +
6.41 +
6.42 +
6.43 +/* Default number of pages for files. */
6.44 +
6.45 +const unsigned int MEMORY_PAGES = 20;
6.46 +
6.47 +
6.48 +
6.49 +/* Server program. */
6.50 +
6.51 +int main(int argc, char *argv[])
6.52 +{
6.53 + long err;
6.54 +
6.55 + /* Introduce concurrency control. */
6.56 +
6.57 + err = ipc_thread_init();
6.58 +
6.59 + if (err)
6.60 + {
6.61 + printf("Initialisation error: %s\n", l4sys_errtostr(err));
6.62 + return 1;
6.63 + }
6.64 +
6.65 + unsigned int memory_pages = MEMORY_PAGES;
6.66 +
6.67 + if (argc > 1)
6.68 + memory_pages = atoi(argv[1]);
6.69 +
6.70 + /* Some memory plus infrastructure. */
6.71 +
6.72 + MemoryIncremental mem(memory_pages);
6.73 + PageQueueShared queue;
6.74 + Pages pages(&mem, &queue);
6.75 + HostFileOpener opener(&pages);
6.76 +
6.77 + /* Register a server associating it with the given object. */
6.78 +
6.79 + ResourceServer server(&opener);
6.80 + err = server.bind("server");
6.81 +
6.82 + if (err)
6.83 + {
6.84 + printf("Could not bind server: %s\n", l4sys_errtostr(err));
6.85 + return 1;
6.86 + }
6.87 +
6.88 + printf("Starting server using %d pages...\n", memory_pages);
6.89 + server.start();
6.90 + return 0;
6.91 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/servers/pipe_server.cc Sat Apr 03 00:02:41 2021 +0200
7.3 @@ -0,0 +1,83 @@
7.4 +/*
7.5 + * A pipe server.
7.6 + *
7.7 + * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
7.8 + *
7.9 + * This program is free software; you can redistribute it and/or
7.10 + * modify it under the terms of the GNU General Public License as
7.11 + * published by the Free Software Foundation; either version 2 of
7.12 + * the License, or (at your option) any later version.
7.13 + *
7.14 + * This program is distributed in the hope that it will be useful,
7.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.17 + * GNU General Public License for more details.
7.18 + *
7.19 + * You should have received a copy of the GNU General Public License
7.20 + * along with this program; if not, write to the Free Software
7.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
7.22 + * Boston, MA 02110-1301, USA
7.23 + */
7.24 +
7.25 +#include <l4/sys/err.h>
7.26 +
7.27 +#include <ipc/thread.h>
7.28 +
7.29 +#include <stdio.h>
7.30 +#include <stdlib.h>
7.31 +
7.32 +#include "memory_incremental.h"
7.33 +#include "pipe_opener_resource.h"
7.34 +#include "resource_server.h"
7.35 +
7.36 +
7.37 +
7.38 +/* Default number of pages for pipes. */
7.39 +
7.40 +const unsigned int MEMORY_PAGES = 20;
7.41 +
7.42 +
7.43 +
7.44 +/* Server program. */
7.45 +
7.46 +int main(int argc, char *argv[])
7.47 +{
7.48 + long err;
7.49 +
7.50 + /* Introduce concurrency control. */
7.51 +
7.52 + err = ipc_thread_init();
7.53 +
7.54 + if (err)
7.55 + {
7.56 + printf("Initialisation error: %s\n", l4sys_errtostr(err));
7.57 + return 1;
7.58 + }
7.59 +
7.60 + unsigned int memory_pages = MEMORY_PAGES;
7.61 +
7.62 + if (argc > 1)
7.63 + memory_pages = atoi(argv[1]);
7.64 +
7.65 + /* Some memory plus infrastructure. */
7.66 +
7.67 + MemoryIncremental mem(memory_pages);
7.68 + PipeOpenerResource opener(&mem);
7.69 +
7.70 + /* Register a server associating it with the given object. */
7.71 +
7.72 + ResourceServer server(&opener);
7.73 + err = server.bind("server");
7.74 +
7.75 + if (err)
7.76 + {
7.77 + printf("Could not bind server: %s\n", l4sys_errtostr(err));
7.78 + return 1;
7.79 + }
7.80 +
7.81 + printf("Starting server using %d pages...\n", memory_pages);
7.82 + server.start();
7.83 + return 0;
7.84 +}
7.85 +
7.86 +// vim: tabstop=2 expandtab shiftwidth=2
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/servers/test_file_server.cc Sat Apr 03 00:02:41 2021 +0200
8.3 @@ -0,0 +1,88 @@
8.4 +/*
8.5 + * Test dataspace operations.
8.6 + *
8.7 + * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
8.8 + *
8.9 + * This program is free software; you can redistribute it and/or
8.10 + * modify it under the terms of the GNU General Public License as
8.11 + * published by the Free Software Foundation; either version 2 of
8.12 + * the License, or (at your option) any later version.
8.13 + *
8.14 + * This program is distributed in the hope that it will be useful,
8.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.17 + * GNU General Public License for more details.
8.18 + *
8.19 + * You should have received a copy of the GNU General Public License
8.20 + * along with this program; if not, write to the Free Software
8.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
8.22 + * Boston, MA 02110-1301, USA
8.23 + */
8.24 +
8.25 +#include <l4/re/env.h>
8.26 +#include <l4/sys/err.h>
8.27 +
8.28 +#include <ipc/thread.h>
8.29 +
8.30 +#include <stdio.h>
8.31 +#include <string.h>
8.32 +#include <stdlib.h>
8.33 +
8.34 +#include "memory_incremental.h"
8.35 +#include "memory_utils.h"
8.36 +#include "page_queue_shared.h"
8.37 +#include "pages.h"
8.38 +#include "resource_server.h"
8.39 +#include "test_file_opener.h"
8.40 +
8.41 +
8.42 +
8.43 +const unsigned int REGION_PAGES = 8;
8.44 +const unsigned int MEMORY_PAGES = REGION_PAGES * 10;
8.45 +const unsigned int FILE_PAGES = 20;
8.46 +
8.47 +int main(int argc, char *argv[])
8.48 +{
8.49 + long err;
8.50 +
8.51 + /* Introduce concurrency control. */
8.52 +
8.53 + err = ipc_thread_init();
8.54 +
8.55 + if (err)
8.56 + {
8.57 + printf("Initialisation error: %s\n", l4sys_errtostr(err));
8.58 + return 1;
8.59 + }
8.60 +
8.61 + /* Configure the number of available pages using any argument. */
8.62 +
8.63 + unsigned int memory_pages = MEMORY_PAGES;
8.64 +
8.65 + if (argc > 1)
8.66 + memory_pages = atoi(argv[1]) * REGION_PAGES;
8.67 +
8.68 + /* Some memory plus infrastructure. */
8.69 +
8.70 + MemoryIncremental mem(memory_pages, page(REGION_PAGES));
8.71 + PageQueueShared queue;
8.72 + Pages pages(&mem, &queue);
8.73 + TestFileOpener opener(&pages, page(FILE_PAGES));
8.74 +
8.75 + /* Register a server associating it with the given object. */
8.76 +
8.77 + ResourceServer server(&opener);
8.78 + err = server.bind("server");
8.79 +
8.80 + if (err)
8.81 + {
8.82 + printf("Could not bind server: %s\n", l4sys_errtostr(err));
8.83 + return 1;
8.84 + }
8.85 +
8.86 + printf("Starting server...\n");
8.87 + server.start();
8.88 + return 0;
8.89 +}
8.90 +
8.91 +// vim: tabstop=2 expandtab shiftwidth=2
9.1 --- a/tests/dstest_block_server.cc Fri Apr 02 22:38:14 2021 +0200
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,65 +0,0 @@
9.4 -/*
9.5 - * Test dataspace operations.
9.6 - *
9.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
9.8 - *
9.9 - * This program is free software; you can redistribute it and/or
9.10 - * modify it under the terms of the GNU General Public License as
9.11 - * published by the Free Software Foundation; either version 2 of
9.12 - * the License, or (at your option) any later version.
9.13 - *
9.14 - * This program is distributed in the hope that it will be useful,
9.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
9.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9.17 - * GNU General Public License for more details.
9.18 - *
9.19 - * You should have received a copy of the GNU General Public License
9.20 - * along with this program; if not, write to the Free Software
9.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor,
9.22 - * Boston, MA 02110-1301, USA
9.23 - */
9.24 -
9.25 -#include <l4/re/env.h>
9.26 -#include <l4/sys/err.h>
9.27 -
9.28 -#include <stdio.h>
9.29 -#include <string.h>
9.30 -#include <stdlib.h>
9.31 -
9.32 -#include "memory_incremental.h"
9.33 -#include "memory_utils.h"
9.34 -#include "page_queue_shared.h"
9.35 -#include "pages.h"
9.36 -#include "resource_server.h"
9.37 -#include "block_file_opener.h"
9.38 -
9.39 -
9.40 -
9.41 -const unsigned int MEMORY_PAGES = 10;
9.42 -
9.43 -int main(void)
9.44 -{
9.45 - /* Some memory plus infrastructure. */
9.46 -
9.47 - MemoryIncremental mem(MEMORY_PAGES);
9.48 - PageQueueShared queue;
9.49 - Pages pages(&mem, &queue);
9.50 - BlockFileOpener opener(&pages);
9.51 -
9.52 - /* Register a server associating it with the given object. */
9.53 -
9.54 - ResourceServer server(&opener);
9.55 - long err = server.bind("server");
9.56 -
9.57 - if (err)
9.58 - {
9.59 - printf("Could not bind server: %s\n", l4sys_errtostr(err));
9.60 - return 1;
9.61 - }
9.62 -
9.63 - printf("Starting server...\n");
9.64 - server.start();
9.65 - return 0;
9.66 -}
9.67 -
9.68 -// vim: tabstop=2 expandtab shiftwidth=2
10.1 --- a/tests/dstest_host_server.cc Fri Apr 02 22:38:14 2021 +0200
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,63 +0,0 @@
10.4 -/*
10.5 - * Test dataspace operations.
10.6 - *
10.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
10.8 - *
10.9 - * This program is free software; you can redistribute it and/or
10.10 - * modify it under the terms of the GNU General Public License as
10.11 - * published by the Free Software Foundation; either version 2 of
10.12 - * the License, or (at your option) any later version.
10.13 - *
10.14 - * This program is distributed in the hope that it will be useful,
10.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
10.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10.17 - * GNU General Public License for more details.
10.18 - *
10.19 - * You should have received a copy of the GNU General Public License
10.20 - * along with this program; if not, write to the Free Software
10.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor,
10.22 - * Boston, MA 02110-1301, USA
10.23 - */
10.24 -
10.25 -#include <l4/re/env.h>
10.26 -#include <l4/sys/err.h>
10.27 -
10.28 -#include <stdio.h>
10.29 -#include <string.h>
10.30 -#include <stdlib.h>
10.31 -
10.32 -#include "memory_incremental.h"
10.33 -#include "memory_utils.h"
10.34 -#include "page_queue_shared.h"
10.35 -#include "pages.h"
10.36 -#include "resource_server.h"
10.37 -#include "host_file_opener.h"
10.38 -
10.39 -
10.40 -
10.41 -const unsigned int MEMORY_PAGES = 10;
10.42 -
10.43 -int main(void)
10.44 -{
10.45 - /* Some memory plus infrastructure. */
10.46 -
10.47 - MemoryIncremental mem(MEMORY_PAGES);
10.48 - PageQueueShared queue;
10.49 - Pages pages(&mem, &queue);
10.50 - HostFileOpener opener(&pages);
10.51 -
10.52 - /* Register a server associating it with the given object. */
10.53 -
10.54 - ResourceServer server(&opener);
10.55 - long err = server.bind("server");
10.56 -
10.57 - if (err)
10.58 - {
10.59 - printf("Could not bind server: %s\n", l4sys_errtostr(err));
10.60 - return 1;
10.61 - }
10.62 -
10.63 - printf("Starting server...\n");
10.64 - server.start();
10.65 - return 0;
10.66 -}
11.1 --- a/tests/dstest_pipe_server.cc Fri Apr 02 22:38:14 2021 +0200
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,57 +0,0 @@
11.4 -/*
11.5 - * Test pipe operations.
11.6 - *
11.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
11.8 - *
11.9 - * This program is free software; you can redistribute it and/or
11.10 - * modify it under the terms of the GNU General Public License as
11.11 - * published by the Free Software Foundation; either version 2 of
11.12 - * the License, or (at your option) any later version.
11.13 - *
11.14 - * This program is distributed in the hope that it will be useful,
11.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
11.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.17 - * GNU General Public License for more details.
11.18 - *
11.19 - * You should have received a copy of the GNU General Public License
11.20 - * along with this program; if not, write to the Free Software
11.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor,
11.22 - * Boston, MA 02110-1301, USA
11.23 - */
11.24 -
11.25 -#include <l4/sys/err.h>
11.26 -
11.27 -#include <stdio.h>
11.28 -
11.29 -#include "memory_incremental.h"
11.30 -#include "pipe_opener_resource.h"
11.31 -#include "resource_server.h"
11.32 -
11.33 -
11.34 -
11.35 -const unsigned int MEMORY_PAGES = 20;
11.36 -
11.37 -int main(void)
11.38 -{
11.39 - /* Some memory plus infrastructure. */
11.40 -
11.41 - MemoryIncremental mem(MEMORY_PAGES);
11.42 - PipeOpenerResource opener(&mem);
11.43 -
11.44 - /* Register a server associating it with the given object. */
11.45 -
11.46 - ResourceServer server(&opener);
11.47 - long err = server.bind("server");
11.48 -
11.49 - if (err)
11.50 - {
11.51 - printf("Could not bind server: %s\n", l4sys_errtostr(err));
11.52 - return 1;
11.53 - }
11.54 -
11.55 - printf("Starting server...\n");
11.56 - server.start();
11.57 - return 0;
11.58 -}
11.59 -
11.60 -// vim: tabstop=2 expandtab shiftwidth=2
12.1 --- a/tests/dstest_test_server.cc Fri Apr 02 22:38:14 2021 +0200
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,88 +0,0 @@
12.4 -/*
12.5 - * Test dataspace operations.
12.6 - *
12.7 - * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk>
12.8 - *
12.9 - * This program is free software; you can redistribute it and/or
12.10 - * modify it under the terms of the GNU General Public License as
12.11 - * published by the Free Software Foundation; either version 2 of
12.12 - * the License, or (at your option) any later version.
12.13 - *
12.14 - * This program is distributed in the hope that it will be useful,
12.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
12.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.17 - * GNU General Public License for more details.
12.18 - *
12.19 - * You should have received a copy of the GNU General Public License
12.20 - * along with this program; if not, write to the Free Software
12.21 - * Foundation, Inc., 51 Franklin Street, Fifth Floor,
12.22 - * Boston, MA 02110-1301, USA
12.23 - */
12.24 -
12.25 -#include <l4/re/env.h>
12.26 -#include <l4/sys/err.h>
12.27 -
12.28 -#include <ipc/thread.h>
12.29 -
12.30 -#include <stdio.h>
12.31 -#include <string.h>
12.32 -#include <stdlib.h>
12.33 -
12.34 -#include "memory_incremental.h"
12.35 -#include "memory_utils.h"
12.36 -#include "page_queue_shared.h"
12.37 -#include "pages.h"
12.38 -#include "resource_server.h"
12.39 -#include "test_file_opener.h"
12.40 -
12.41 -
12.42 -
12.43 -const unsigned int REGION_PAGES = 8;
12.44 -const unsigned int MEMORY_PAGES = REGION_PAGES * 10;
12.45 -const unsigned int FILE_PAGES = 20;
12.46 -
12.47 -int main(int argc, char *argv[])
12.48 -{
12.49 - long err;
12.50 -
12.51 - /* Introduce concurrency control. */
12.52 -
12.53 - err = ipc_thread_init();
12.54 -
12.55 - if (err)
12.56 - {
12.57 - printf("Initialisation error: %s\n", l4sys_errtostr(err));
12.58 - return 1;
12.59 - }
12.60 -
12.61 - /* Configure the number of available pages using any argument. */
12.62 -
12.63 - unsigned int memory_pages = MEMORY_PAGES;
12.64 -
12.65 - if (argc > 1)
12.66 - memory_pages = atoi(argv[1]) * REGION_PAGES;
12.67 -
12.68 - /* Some memory plus infrastructure. */
12.69 -
12.70 - MemoryIncremental mem(memory_pages, page(REGION_PAGES));
12.71 - PageQueueShared queue;
12.72 - Pages pages(&mem, &queue);
12.73 - TestFileOpener opener(&pages, page(FILE_PAGES));
12.74 -
12.75 - /* Register a server associating it with the given object. */
12.76 -
12.77 - ResourceServer server(&opener);
12.78 - err = server.bind("server");
12.79 -
12.80 - if (err)
12.81 - {
12.82 - printf("Could not bind server: %s\n", l4sys_errtostr(err));
12.83 - return 1;
12.84 - }
12.85 -
12.86 - printf("Starting server...\n");
12.87 - server.start();
12.88 - return 0;
12.89 -}
12.90 -
12.91 -// vim: tabstop=2 expandtab shiftwidth=2