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