L4Re/departure

libexec/lib/src/pager.cc

515:bae2ddb47ecd
20 months ago Paul Boddie Introduced support for reserve_area in the internal pager along with different kinds of memory area. This permits the execution of threaded programs.
     1 /*     2  * Common system pager functionality.     3  *     4  * Copyright (C) 2022, 2023 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 <mem/memory_utils.h>    25     26 #include "pager.h"    27     28     29     30 /* Initialise common functionality. */    31     32 ExecPager::ExecPager(address_t start, address_t end)    33 : _area(start, end)    34 {    35 }    36     37 /* Necessary virtual destructor. */    38     39 ExecPager::~ExecPager()    40 {    41 }    42     43     44     45 /* Add an area to the pager. */    46     47 void ExecPager::add(MemoryArea &area)    48 {    49   _area.add(area);    50 }    51     52 /* Remove an area from the pager. */    53     54 void ExecPager::remove(MemoryArea &area)    55 {    56   _area.remove(area);    57 }    58     59     60     61 /* Find an area suitable for attaching a memory region. */    62     63 long ExecPager::find(address_t *start, address_t *size, map_flags_t flags,    64                      unsigned char align, MemoryArea **area)    65 {    66   if (align < L4_PAGESHIFT)    67     align = L4_PAGESHIFT;    68     69   /* Attempt to find an address for the specified region, starting from    70      any indicated address. */    71     72   return _area.find(start, size, flags, align, area);    73 }    74     75 /* vim: tabstop=2 expandtab shiftwidth=2    76 */