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@0 | 30 | /* A flexpage abstraction. */ |
paul@0 | 31 | |
paul@0 | 32 | class Flexpage |
paul@0 | 33 | { |
paul@0 | 34 | protected: |
paul@0 | 35 | unsigned int _counter; |
paul@54 | 36 | flags_t _flags; |
paul@0 | 37 | |
paul@0 | 38 | public: |
paul@0 | 39 | Region *region; |
paul@0 | 40 | |
paul@0 | 41 | /* General flexpage characteristics. */ |
paul@0 | 42 | |
paul@0 | 43 | offset_t base_addr, size; |
paul@0 | 44 | offset_t base_offset; |
paul@0 | 45 | |
paul@0 | 46 | /* Transient debugging information. */ |
paul@0 | 47 | |
paul@0 | 48 | offset_t page_addr, page_offset; |
paul@0 | 49 | |
paul@0 | 50 | /* Associate a flexpage with a memory 'region'. */ |
paul@0 | 51 | |
paul@0 | 52 | explicit Flexpage(Region *region) : region(region) |
paul@0 | 53 | { |
paul@0 | 54 | } |
paul@0 | 55 | |
paul@0 | 56 | void reset(offset_t offset); |
paul@0 | 57 | |
paul@0 | 58 | bool decrement(); |
paul@0 | 59 | |
paul@0 | 60 | void increment(); |
paul@0 | 61 | |
paul@0 | 62 | void invalidate(); |
paul@0 | 63 | |
paul@0 | 64 | bool valid(); |
paul@0 | 65 | |
paul@0 | 66 | bool supports_position(offset_t position); |
paul@0 | 67 | |
paul@54 | 68 | void upgrade(flags_t flags); |
paul@11 | 69 | |
paul@86 | 70 | SendFlexpage to_send(offset_t offset, offset_t hot_spot, flags_t flags, |
paul@86 | 71 | offset_t max_offset=0); |
paul@0 | 72 | |
paul@0 | 73 | SendFlexpage to_unmap(); |
paul@0 | 74 | }; |
paul@0 | 75 | |
paul@0 | 76 | // vim: tabstop=4 expandtab shiftwidth=4 |