L4Re/departure

libfsserver/include/fsserver/masked_page_mapper.h

618:7123a7307a82
8 months ago Paul Boddie Introduced some debugging output control.
     1 /*     2  * A page mapper providing memory pages to satisfy file accesses, masking the     3  * limits of a visible region of the file's contents.     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 <fsserver/generic_page_mapper.h>    26 #include <mem/memory_incremental.h>    27     28     29     30 /* A special flexpage class for masked flexpages. */    31     32 class MaskedFlexpage : public Flexpage    33 {    34 public:    35     explicit MaskedFlexpage(Region *region = NULL);    36 };    37     38     39     40 /* A file mapper, associating flexpages with file regions. */    41     42 class MaskedPageMapper : public GenericPageMapper    43 {    44 protected:    45     GenericPageMapper *_mapper;    46     offset_t _size;    47     48     /* Masked region support. */    49     50     MemoryIncremental _memory;    51     offset_t _start_visible, _end_visible;    52     MaskedFlexpage _start_flexpage, _end_flexpage, _zero_flexpage;    53     54     /* Internal flexpage retrieval methods. */    55     56     Flexpage *get_masked_flexpage(Flexpage *flexpage);    57     58     void allocate_region(Flexpage *flexpage, Flexpage &masked);    59     60     void populate_region(Flexpage *flexpage, Flexpage &masked,    61                          bool has_start, bool has_end);    62     63 public:    64     explicit MaskedPageMapper(GenericPageMapper *mapper, offset_t start_visible,    65                               offset_t end_visible);    66     67     virtual ~MaskedPageMapper();    68     69     /* Interface for the pager, implementing GenericPageMapper. */    70     71     Flexpage *get(offset_t offset, map_flags_t flags);    72     73     void queue(Flexpage *flexpage);    74     75     void flush_all(offset_t start, offset_t size);    76     77     offset_t get_data_size();    78     79     void set_data_size(offset_t size);    80 };    81     82 // vim: tabstop=4 expandtab shiftwidth=4