paul@93 | 1 | /* |
paul@93 | 2 | * A flexpage abstraction. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 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@94 | 24 | #include <mem/memory_utils.h> |
paul@94 | 25 | #include <mem/region.h> |
paul@94 | 26 | #include <mem/send_flexpage.h> |
paul@0 | 27 | |
paul@0 | 28 | |
paul@0 | 29 | |
paul@184 | 30 | /* Work around API change. */ |
paul@184 | 31 | |
paul@184 | 32 | #define L4RE_DS_MAP_FLAG_RO L4RE_DS_F_R |
paul@184 | 33 | #define L4RE_DS_MAP_FLAG_RW L4RE_DS_F_RW |
paul@184 | 34 | |
paul@184 | 35 | |
paul@184 | 36 | |
paul@0 | 37 | /* A flexpage abstraction. */ |
paul@0 | 38 | |
paul@0 | 39 | class Flexpage |
paul@0 | 40 | { |
paul@0 | 41 | protected: |
paul@0 | 42 | unsigned int _counter; |
paul@121 | 43 | map_flags_t _flags; |
paul@0 | 44 | |
paul@0 | 45 | public: |
paul@0 | 46 | Region *region; |
paul@0 | 47 | |
paul@0 | 48 | /* General flexpage characteristics. */ |
paul@0 | 49 | |
paul@0 | 50 | offset_t base_addr, size; |
paul@0 | 51 | offset_t base_offset; |
paul@0 | 52 | |
paul@0 | 53 | /* Transient debugging information. */ |
paul@0 | 54 | |
paul@0 | 55 | offset_t page_addr, page_offset; |
paul@0 | 56 | |
paul@0 | 57 | /* Associate a flexpage with a memory 'region'. */ |
paul@0 | 58 | |
paul@0 | 59 | explicit Flexpage(Region *region) : region(region) |
paul@0 | 60 | { |
paul@0 | 61 | } |
paul@0 | 62 | |
paul@0 | 63 | void reset(offset_t offset); |
paul@0 | 64 | |
paul@0 | 65 | bool decrement(); |
paul@0 | 66 | |
paul@0 | 67 | void increment(); |
paul@0 | 68 | |
paul@0 | 69 | void invalidate(); |
paul@0 | 70 | |
paul@0 | 71 | bool valid(); |
paul@0 | 72 | |
paul@0 | 73 | bool supports_position(offset_t position); |
paul@0 | 74 | |
paul@121 | 75 | void upgrade(map_flags_t flags); |
paul@11 | 76 | |
paul@115 | 77 | bool modified(); |
paul@115 | 78 | |
paul@121 | 79 | SendFlexpage to_send(offset_t offset, offset_t hot_spot, map_flags_t flags, |
paul@86 | 80 | offset_t max_offset=0); |
paul@0 | 81 | |
paul@0 | 82 | SendFlexpage to_unmap(); |
paul@0 | 83 | }; |
paul@0 | 84 | |
paul@0 | 85 | // vim: tabstop=4 expandtab shiftwidth=4 |