1 /* 2 * A region mapper for deployment in a new task. 3 * 4 * Copyright (C) 2022 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 24 #include <exec/common.h> 25 #include <exec/internal_pager.h> 26 #include <exec/stack.h> 27 #include <ipc/server.h> 28 29 #include "pager_object_server.h" 30 31 32 33 /* Initialise a pager for programs, reserving space below the allocated regions 34 for the region mapper itself. */ 35 36 static InternalPager exec_pager(L4_PAGESIZE * 10); 37 38 39 40 int main(int argc, char *argv[]) 41 { 42 /* Initialise pager regions from region descriptions obtained via the 43 auxiliary data. */ 44 45 l4re_aux_t *l4re_aux = exec_get_l4re_aux(argc, argv); 46 47 printf("aux = {%s, %lx, %lx, %lx}\n", l4re_aux->binary, l4re_aux->kip_ds, l4re_aux->dbg_lvl, l4re_aux->ldr_flags); 48 49 /* Skip past the auxiliary structure itself. */ 50 51 struct exec_region *region = (struct exec_region *) *((l4_addr_t *) (l4re_aux + 1)); 52 53 if (!region) 54 { 55 printf("Could not find regions.\n"); 56 return 1; 57 } 58 59 for (; region && (region->ds != L4_INVALID_CAP); region++) 60 { 61 printf("Adding region: {%lx, %llx, %lx, %lx}\n", region->start, region->size, region->flags, region->ds); 62 MappedRegion r(region->start, region->size, region->flags, region->ds); 63 exec_pager.add(r); 64 } 65 66 /* Start the pager. */ 67 68 printf("Starting pager...\n"); 69 printf("Pager capability: %lx\n", l4re_env_get_cap("server")); 70 printf("Main thread: %lx\n", l4re_env()->main_thread); 71 72 ipc_server_loop_for(PagerObject, &exec_pager, "server"); 73 74 printf("Ending pager...\n"); 75 return 0; 76 } 77 78 /* vim: tabstop=2 expandtab shiftwidth=2 79 */