1.1 --- a/libexec/include/exec/mapped_region.h Tue Mar 14 23:51:57 2023 +0100
1.2 +++ b/libexec/include/exec/mapped_region.h Wed Mar 15 00:33:40 2023 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Mapped memory region support.
1.6 *
1.7 - * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -23,32 +23,51 @@
1.13
1.14 #include <l4/sys/types.h>
1.15
1.16 +#include <exec/memory_area.h>
1.17 #include <systypes/base.h>
1.18
1.19
1.20
1.21 /* A mapped region abstraction. */
1.22
1.23 -class MappedRegion
1.24 +class MappedRegion : public MemoryArea
1.25 {
1.26 +protected:
1.27 + l4_umword_t _flags;
1.28 + l4_cap_idx_t _ds;
1.29 + address_t _ds_start;
1.30 +
1.31 public:
1.32 - l4_addr_t start;
1.33 - offset_t size;
1.34 - l4_umword_t flags;
1.35 - l4_cap_idx_t ds;
1.36 - l4_addr_t ds_start;
1.37 -
1.38 explicit MappedRegion()
1.39 - : start(0), size(0), flags(0), ds(L4_INVALID_CAP), ds_start(0)
1.40 + : MemoryArea(), _flags(0), _ds(L4_INVALID_CAP), _ds_start(0)
1.41 {
1.42 }
1.43
1.44 - explicit MappedRegion(l4_addr_t start, l4_addr_t size,
1.45 + explicit MappedRegion(address_t start, address_t end,
1.46 l4_umword_t flags, l4_cap_idx_t ds = L4_INVALID_CAP,
1.47 - l4_addr_t ds_start = 0)
1.48 - : start(start), size(size), flags(flags), ds(ds), ds_start(ds_start)
1.49 + address_t ds_start = 0)
1.50 + : MemoryArea(start, end), _flags(flags), _ds(ds), _ds_start(ds_start)
1.51 {
1.52 }
1.53 +
1.54 + virtual MemoryArea *copy()
1.55 + { return new MappedRegion(_start, _end, _flags, _ds, _ds_start); }
1.56 +
1.57 + /* Access to area properties. */
1.58 +
1.59 + virtual l4_umword_t flags()
1.60 + { return _flags; }
1.61 +
1.62 + virtual l4_cap_idx_t dataspace()
1.63 + { return _ds; }
1.64 +
1.65 + virtual address_t dataspace_start()
1.66 + { return _ds_start; }
1.67 +
1.68 + /* Return whether the area provides a mapped region. */
1.69 +
1.70 + virtual bool is_mapped()
1.71 + { return true; }
1.72 };
1.73
1.74 /* vim: tabstop=2 expandtab shiftwidth=2