# HG changeset patch # User Paul Boddie # Date 1655068099 -7200 # Node ID e9a3fa220a4c4518317c1200fbc619024a1858a3 # Parent 6ba2c6e1500c8271a9987f810a9539d96d7b318d Added a region mapper program. diff -r 6ba2c6e1500c -r e9a3fa220a4c test_files/Control --- a/test_files/Control Sun Jun 12 18:56:25 2022 +0200 +++ b/test_files/Control Sun Jun 12 23:08:19 2022 +0200 @@ -1,3 +1,3 @@ provides: fstest_files -requires: libc +requires: libc libstdc++ libexec libipc maintainer: paul@boddie.org.uk diff -r 6ba2c6e1500c -r e9a3fa220a4c test_files/programs/Makefile --- a/test_files/programs/Makefile Sun Jun 12 18:56:25 2022 +0200 +++ b/test_files/programs/Makefile Sun Jun 12 23:08:19 2022 +0200 @@ -1,12 +1,47 @@ PKGDIR ?= .. L4DIR ?= $(PKGDIR)/../../.. -TARGET = dstest_exec_payload +TARGET = dstest_exec_payload dstest_region_mapper MODE = static -SRC_C_dstest_exec_payload = exec_payload.c +# Locations for interface input and generated output. + +IDL_DIR = $(PKGDIR)/../libsystypes/idl +IDL_MK_DIR = $(L4DIR)/idl4re/mk +IDL_BUILD_DIR = . +IDL_EXPORT_DIR = . + +include $(IDL_MK_DIR)/idl.mk + +# Compound interfaces. + +pager_object_NAME = PagerObject +pager_object_INTERFACES = region_mapper system_pager + +COMP_INTERFACES_CC = pager_object + +# Individual interfaces. -REQUIRES_LIBS = libc +SERVER_INTERFACES_CC = $(call common_interfaces,$(COMP_INTERFACES_CC)) + +# Generated and plain source files. + +SERVER_INTERFACES_SRC_CC = $(call interfaces_to_server_cc,$(SERVER_INTERFACES_CC) $(COMP_INTERFACES_CC)) + +# Normal source files. + +SRC_C_dstest_exec_payload = exec_payload.c + +PLAIN_SRC_CC_dstest_region_mapper = region_mapper.cc +SRC_CC_dstest_region_mapper = \ + $(PLAIN_SRC_CC_dstest_region_mapper) \ + $(SERVER_INTERFACES_SRC_CC) + +REQUIRES_LIBS = libc libstdc++ libexec libipc +PRIVATE_INCDIR = $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) include $(L4DIR)/mk/prog.mk +include $(IDL_MK_DIR)/interface_rules.mk + +$(PLAIN_SRC_CC_dstest_region_mapper): $(SERVER_INTERFACES_SRC_CC) diff -r 6ba2c6e1500c -r e9a3fa220a4c test_files/programs/region_mapper.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test_files/programs/region_mapper.cc Sun Jun 12 23:08:19 2022 +0200 @@ -0,0 +1,69 @@ +/* + * A region mapper for deployment in a new task. + * + * Copyright (C) 2022 Paul Boddie + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + +#include + +#include +#include +#include +#include + +#include "pager_object_server.h" + + + +static InternalPager exec_pager; + + + +int main(int argc, char *argv[]) +{ + /* Initialise pager regions from region descriptions obtained via the + auxiliary data. */ + + l4re_aux_t *l4re_aux = exec_get_l4re_aux(argc, argv); + + /* Skip past the auxiliary structure itself. */ + + struct exec_region *region = (struct exec_region *) (l4re_aux + 1); + + if (!region) + { + printf("Could not find regions.\n"); + return 1; + } + + for (; region && (region->ds != L4_INVALID_CAP); region++) + { + printf("Adding region: %lx\n", region->start); + exec_pager.add(*region); + } + + /* Start the pager. */ + + printf("Starting pager...\n"); + ipc_server_loop_for(PagerObject, &exec_pager, "server"); + + return 0; +} + +/* vim: tabstop=2 expandtab shiftwidth=2 +*/