paul@324 | 1 | /* |
paul@324 | 2 | * Mapped memory region support. |
paul@324 | 3 | * |
paul@515 | 4 | * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk> |
paul@324 | 5 | * |
paul@324 | 6 | * This program is free software; you can redistribute it and/or |
paul@324 | 7 | * modify it under the terms of the GNU General Public License as |
paul@324 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@324 | 9 | * the License, or (at your option) any later version. |
paul@324 | 10 | * |
paul@324 | 11 | * This program is distributed in the hope that it will be useful, |
paul@324 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@324 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@324 | 14 | * GNU General Public License for more details. |
paul@324 | 15 | * |
paul@324 | 16 | * You should have received a copy of the GNU General Public License |
paul@324 | 17 | * along with this program; if not, write to the Free Software |
paul@324 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@324 | 19 | * Boston, MA 02110-1301, USA |
paul@324 | 20 | */ |
paul@324 | 21 | |
paul@324 | 22 | #pragma once |
paul@324 | 23 | |
paul@324 | 24 | #include <l4/sys/types.h> |
paul@324 | 25 | |
paul@515 | 26 | #include <exec/memory_area.h> |
paul@329 | 27 | #include <systypes/base.h> |
paul@329 | 28 | |
paul@324 | 29 | |
paul@324 | 30 | |
paul@324 | 31 | /* A mapped region abstraction. */ |
paul@324 | 32 | |
paul@515 | 33 | class MappedRegion : public MemoryArea |
paul@324 | 34 | { |
paul@515 | 35 | protected: |
paul@515 | 36 | l4_umword_t _flags; |
paul@515 | 37 | l4_cap_idx_t _ds; |
paul@515 | 38 | address_t _ds_start; |
paul@515 | 39 | |
paul@324 | 40 | public: |
paul@324 | 41 | explicit MappedRegion() |
paul@515 | 42 | : MemoryArea(), _flags(0), _ds(L4_INVALID_CAP), _ds_start(0) |
paul@324 | 43 | { |
paul@324 | 44 | } |
paul@324 | 45 | |
paul@515 | 46 | explicit MappedRegion(address_t start, address_t end, |
paul@431 | 47 | l4_umword_t flags, l4_cap_idx_t ds = L4_INVALID_CAP, |
paul@515 | 48 | address_t ds_start = 0) |
paul@515 | 49 | : MemoryArea(start, end), _flags(flags), _ds(ds), _ds_start(ds_start) |
paul@324 | 50 | { |
paul@324 | 51 | } |
paul@515 | 52 | |
paul@515 | 53 | virtual MemoryArea *copy() |
paul@515 | 54 | { return new MappedRegion(_start, _end, _flags, _ds, _ds_start); } |
paul@515 | 55 | |
paul@515 | 56 | /* Access to area properties. */ |
paul@515 | 57 | |
paul@515 | 58 | virtual l4_umword_t flags() |
paul@515 | 59 | { return _flags; } |
paul@515 | 60 | |
paul@515 | 61 | virtual l4_cap_idx_t dataspace() |
paul@515 | 62 | { return _ds; } |
paul@515 | 63 | |
paul@515 | 64 | virtual address_t dataspace_start() |
paul@515 | 65 | { return _ds_start; } |
paul@515 | 66 | |
paul@515 | 67 | /* Return whether the area provides a mapped region. */ |
paul@515 | 68 | |
paul@515 | 69 | virtual bool is_mapped() |
paul@515 | 70 | { return true; } |
paul@324 | 71 | }; |
paul@324 | 72 | |
paul@324 | 73 | /* vim: tabstop=2 expandtab shiftwidth=2 |
paul@324 | 74 | */ |