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