paul@93 | 1 | /* |
paul@93 | 2 | * Memory region abstractions. |
paul@93 | 3 | * |
paul@623 | 4 | * Copyright (C) 2021, 2022, 2024 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@623 | 24 | #include <l4/re/c/dma_space.h> |
paul@30 | 25 | #include <systypes/base.h> |
paul@30 | 26 | |
paul@0 | 27 | #include "types.h" |
paul@0 | 28 | |
paul@0 | 29 | |
paul@0 | 30 | |
paul@0 | 31 | /* Region-related state information. */ |
paul@0 | 32 | |
paul@0 | 33 | class RegionState |
paul@0 | 34 | { |
paul@0 | 35 | public: |
paul@0 | 36 | fileid_t fileid; |
paul@0 | 37 | offset_t filepos; |
paul@0 | 38 | |
paul@109 | 39 | explicit RegionState(fileid_t fileid=0, offset_t filepos=0); |
paul@0 | 40 | |
paul@0 | 41 | void fill(fileid_t fileid, offset_t filepos); |
paul@0 | 42 | |
paul@109 | 43 | void flush(); |
paul@0 | 44 | }; |
paul@0 | 45 | |
paul@0 | 46 | |
paul@0 | 47 | |
paul@0 | 48 | /* A memory region abstraction. */ |
paul@0 | 49 | |
paul@0 | 50 | class Region |
paul@0 | 51 | { |
paul@0 | 52 | public: |
paul@0 | 53 | offset_t start, end; |
paul@623 | 54 | l4re_dma_space_dma_addr_t physical_start; |
paul@0 | 55 | |
paul@0 | 56 | /* Debugging information. */ |
paul@0 | 57 | |
paul@0 | 58 | RegionState state; |
paul@0 | 59 | |
paul@0 | 60 | /* Methods. */ |
paul@0 | 61 | |
paul@623 | 62 | explicit Region(offset_t start, offset_t end, |
paul@623 | 63 | l4re_dma_space_dma_addr_t physical_start = 0); |
paul@0 | 64 | |
paul@0 | 65 | offset_t size(); |
paul@0 | 66 | |
paul@0 | 67 | int compare(Region *other); |
paul@0 | 68 | |
paul@0 | 69 | void fill(fileid_t fileid, offset_t filepos); |
paul@0 | 70 | |
paul@0 | 71 | void flush(); |
paul@0 | 72 | |
paul@0 | 73 | /* Simulation methods. */ |
paul@0 | 74 | |
paul@0 | 75 | char *read(offset_t offset=0); |
paul@0 | 76 | |
paul@0 | 77 | void write(const char *data, offset_t offset=0); |
paul@0 | 78 | }; |
paul@0 | 79 | |
paul@0 | 80 | // vim: tabstop=4 expandtab shiftwidth=4 |