1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/libexec/rm/region_mapper.cc Fri Jun 17 23:54:54 2022 +0200
1.3 @@ -0,0 +1,75 @@
1.4 +/*
1.5 + * A region mapper for deployment in a new task.
1.6 + *
1.7 + * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk>
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License as
1.11 + * published by the Free Software Foundation; either version 2 of
1.12 + * the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 + * Boston, MA 02110-1301, USA
1.23 + */
1.24 +
1.25 +#include <l4/re/env.h>
1.26 +
1.27 +#include <exec/common.h>
1.28 +#include <exec/internal_pager.h>
1.29 +#include <exec/stack.h>
1.30 +#include <ipc/server.h>
1.31 +
1.32 +#include "pager_object_server.h"
1.33 +
1.34 +
1.35 +
1.36 +static InternalPager exec_pager;
1.37 +
1.38 +
1.39 +
1.40 +int main(int argc, char *argv[])
1.41 +{
1.42 + /* Initialise pager regions from region descriptions obtained via the
1.43 + auxiliary data. */
1.44 +
1.45 + l4re_aux_t *l4re_aux = exec_get_l4re_aux(argc, argv);
1.46 +
1.47 + printf("aux = {%s, %lx, %lx, %lx}\n", l4re_aux->binary, l4re_aux->kip_ds, l4re_aux->dbg_lvl, l4re_aux->ldr_flags);
1.48 +
1.49 + /* Skip past the auxiliary structure itself. */
1.50 +
1.51 + struct exec_region *region = (struct exec_region *) *((l4_addr_t *) (l4re_aux + 1));
1.52 +
1.53 + if (!region)
1.54 + {
1.55 + printf("Could not find regions.\n");
1.56 + return 1;
1.57 + }
1.58 +
1.59 + for (; region && (region->ds != L4_INVALID_CAP); region++)
1.60 + {
1.61 + printf("Adding region: {%lx, %lx, %lx, %lx}\n", region->start, region->size, region->flags, region->ds);
1.62 + exec_pager.add(*region);
1.63 + }
1.64 +
1.65 + /* Start the pager. */
1.66 +
1.67 + printf("Starting pager...\n");
1.68 + printf("Pager capability: %lx\n", l4re_env_get_cap("server"));
1.69 + printf("Main thread: %lx\n", l4re_env()->main_thread);
1.70 +
1.71 + ipc_server_loop_for(PagerObject, &exec_pager, "server");
1.72 +
1.73 + printf("Ending pager...\n");
1.74 + return 0;
1.75 +}
1.76 +
1.77 +/* vim: tabstop=2 expandtab shiftwidth=2
1.78 +*/