paul@93 | 1 | /* |
paul@93 | 2 | * A flexpage abstraction. |
paul@93 | 3 | * |
paul@332 | 4 | * Copyright (C) 2021, 2022 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@0 | 22 | #pragma once |
paul@0 | 23 | |
paul@332 | 24 | #include <list> |
paul@332 | 25 | |
paul@94 | 26 | #include <mem/memory_utils.h> |
paul@94 | 27 | #include <mem/region.h> |
paul@94 | 28 | #include <mem/send_flexpage.h> |
paul@0 | 29 | |
paul@0 | 30 | |
paul@0 | 31 | |
paul@184 | 32 | /* Work around API change. */ |
paul@184 | 33 | |
paul@184 | 34 | #define L4RE_DS_MAP_FLAG_RO L4RE_DS_F_R |
paul@184 | 35 | #define L4RE_DS_MAP_FLAG_RW L4RE_DS_F_RW |
paul@184 | 36 | |
paul@184 | 37 | |
paul@184 | 38 | |
paul@332 | 39 | /* Forward declaration. */ |
paul@332 | 40 | |
paul@332 | 41 | class Flexpage; |
paul@332 | 42 | |
paul@332 | 43 | /* Employed data types. */ |
paul@332 | 44 | |
paul@332 | 45 | typedef std::list<Flexpage *> DerivedFlexpages; |
paul@332 | 46 | |
paul@332 | 47 | |
paul@332 | 48 | |
paul@0 | 49 | /* A flexpage abstraction. */ |
paul@0 | 50 | |
paul@0 | 51 | class Flexpage |
paul@0 | 52 | { |
paul@0 | 53 | protected: |
paul@0 | 54 | unsigned int _counter; |
paul@121 | 55 | map_flags_t _flags; |
paul@0 | 56 | |
paul@0 | 57 | public: |
paul@0 | 58 | Region *region; |
paul@0 | 59 | |
paul@332 | 60 | /* Flexpage relationships to support masked regions. */ |
paul@332 | 61 | |
paul@332 | 62 | DerivedFlexpages derived; |
paul@332 | 63 | |
paul@0 | 64 | /* General flexpage characteristics. */ |
paul@0 | 65 | |
paul@0 | 66 | offset_t base_addr, size; |
paul@0 | 67 | offset_t base_offset; |
paul@0 | 68 | |
paul@0 | 69 | /* Transient debugging information. */ |
paul@0 | 70 | |
paul@0 | 71 | offset_t page_addr, page_offset; |
paul@0 | 72 | |
paul@0 | 73 | /* Associate a flexpage with a memory 'region'. */ |
paul@0 | 74 | |
paul@332 | 75 | explicit Flexpage(Region *region = NULL) |
paul@332 | 76 | : region(region) |
paul@0 | 77 | { |
paul@0 | 78 | } |
paul@0 | 79 | |
paul@332 | 80 | void set_region(Region *region); |
paul@332 | 81 | |
paul@0 | 82 | void reset(offset_t offset); |
paul@0 | 83 | |
paul@0 | 84 | bool decrement(); |
paul@0 | 85 | |
paul@0 | 86 | void increment(); |
paul@0 | 87 | |
paul@0 | 88 | void invalidate(); |
paul@0 | 89 | |
paul@0 | 90 | bool valid(); |
paul@0 | 91 | |
paul@0 | 92 | bool supports_position(offset_t position); |
paul@0 | 93 | |
paul@121 | 94 | void upgrade(map_flags_t flags); |
paul@11 | 95 | |
paul@115 | 96 | bool modified(); |
paul@115 | 97 | |
paul@121 | 98 | SendFlexpage to_send(offset_t offset, offset_t hot_spot, map_flags_t flags, |
paul@86 | 99 | offset_t max_offset=0); |
paul@0 | 100 | |
paul@0 | 101 | SendFlexpage to_unmap(); |
paul@332 | 102 | |
paul@332 | 103 | /* Associate other flexpages with this flexpage. */ |
paul@332 | 104 | |
paul@332 | 105 | void associate(Flexpage *flexpage); |
paul@332 | 106 | |
paul@332 | 107 | void disassociate(); |
paul@0 | 108 | }; |
paul@0 | 109 | |
paul@0 | 110 | // vim: tabstop=4 expandtab shiftwidth=4 |