L4Re/departure

libfsserver/include/fsserver/copied_page_mapper.h

618:7123a7307a82
8 months ago Paul Boddie Introduced some debugging output control.
     1 /*     2  * A page mapper providing copied memory pages or deferring to another page     3  * mapper to satisfy file accesses.     4  *     5  * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk>     6  *     7  * This program is free software; you can redistribute it and/or     8  * modify it under the terms of the GNU General Public License as     9  * published by the Free Software Foundation; either version 2 of    10  * the License, or (at your option) any later version.    11  *    12  * This program is distributed in the hope that it will be useful,    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    15  * GNU General Public License for more details.    16  *    17  * You should have received a copy of the GNU General Public License    18  * along with this program; if not, write to the Free Software    19  * Foundation, Inc., 51 Franklin Street, Fifth Floor,    20  * Boston, MA  02110-1301, USA    21  */    22     23 #pragma once    24     25 #include <list>    26     27 #include <fsserver/access_map.h>    28 #include <fsserver/generic_page_mapper.h>    29 #include <mem/memory_incremental.h>    30     31     32     33 /* A special flexpage class for copied flexpages. */    34     35 class CopiedFlexpage : public Flexpage    36 {    37 public:    38     explicit CopiedFlexpage(Region *region = NULL);    39 };    40     41     42     43 /* A file mapper, associating flexpages with file regions. */    44     45 class CopiedPageMapper : public GenericPageMapper    46 {    47 protected:    48     GenericPageMapper *_mapper;    49     offset_t _size;    50     51     /* Copied page support. */    52     53     AccessMap _map;    54     MemoryIncremental _memory;    55     std::list<Flexpage *> _queue;    56     57     /* Internal flexpage retrieval methods. */    58     59     Flexpage *find(offset_t offset);    60     61     Flexpage *replicate_flexpage(offset_t offset, Flexpage *flexpage);    62     63 public:    64     explicit CopiedPageMapper(GenericPageMapper *mapper);    65     66     virtual ~CopiedPageMapper();    67     68     /* Interface for the pager, implementing GenericPageMapper. */    69     70     Flexpage *get(offset_t offset, map_flags_t flags);    71     72     void queue(Flexpage *flexpage);    73     74     void flush_all(offset_t start, offset_t size);    75     76     offset_t get_data_size();    77     78     void set_data_size(offset_t size);    79 };    80     81 // vim: tabstop=4 expandtab shiftwidth=4