paul@0 | 1 | /* |
paul@0 | 2 | * Test dataspace operations. |
paul@0 | 3 | * |
paul@1 | 4 | * Copyright (C) 2020, 2021 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 5 | * |
paul@0 | 6 | * This program is free software; you can redistribute it and/or |
paul@0 | 7 | * modify it under the terms of the GNU General Public License as |
paul@0 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@0 | 9 | * the License, or (at your option) any later version. |
paul@0 | 10 | * |
paul@0 | 11 | * This program is distributed in the hope that it will be useful, |
paul@0 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@0 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@0 | 14 | * GNU General Public License for more details. |
paul@0 | 15 | * |
paul@0 | 16 | * You should have received a copy of the GNU General Public License |
paul@0 | 17 | * along with this program; if not, write to the Free Software |
paul@0 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@0 | 19 | * Boston, MA 02110-1301, USA |
paul@0 | 20 | */ |
paul@0 | 21 | |
paul@0 | 22 | #include <l4/re/env.h> |
paul@0 | 23 | #include <l4/sys/err.h> |
paul@0 | 24 | |
paul@0 | 25 | #include <stdio.h> |
paul@0 | 26 | #include <string.h> |
paul@0 | 27 | #include <stdlib.h> |
paul@0 | 28 | |
paul@9 | 29 | #include "accessing.h" |
paul@72 | 30 | #include "memory_incremental.h" |
paul@9 | 31 | #include "memory_utils.h" |
paul@72 | 32 | #include "page_queue_shared.h" |
paul@6 | 33 | #include "pages.h" |
paul@9 | 34 | #include "paging.h" |
paul@10 | 35 | #include "resource_server.h" |
paul@12 | 36 | #include "host_file_opener.h" |
paul@0 | 37 | |
paul@0 | 38 | |
paul@0 | 39 | |
paul@9 | 40 | const unsigned int MEMORY_PAGES = 10; |
paul@7 | 41 | |
paul@0 | 42 | int main(void) |
paul@0 | 43 | { |
paul@9 | 44 | /* Some memory plus infrastructure. */ |
paul@0 | 45 | |
paul@72 | 46 | MemoryIncremental mem(MEMORY_PAGES); |
paul@9 | 47 | Accessing accessing; |
paul@9 | 48 | Paging paging; |
paul@72 | 49 | PageQueueShared queue; |
paul@72 | 50 | Pages pages(&mem, &queue); |
paul@12 | 51 | HostFileOpener opener(&accessing, &paging, &pages); |
paul@0 | 52 | |
paul@0 | 53 | /* Register a server associating it with the given object. */ |
paul@0 | 54 | |
paul@10 | 55 | ResourceServer server(&opener); |
paul@10 | 56 | long err = server.bind("server"); |
paul@0 | 57 | |
paul@0 | 58 | if (err) |
paul@0 | 59 | { |
paul@0 | 60 | printf("Could not bind server: %s\n", l4sys_errtostr(err)); |
paul@0 | 61 | return 1; |
paul@0 | 62 | } |
paul@0 | 63 | |
paul@10 | 64 | printf("Starting server...\n"); |
paul@10 | 65 | server.start(); |
paul@0 | 66 | return 0; |
paul@0 | 67 | } |