diff --git a/repos/base-hw/src/core/include/mapping.h b/repos/base-hw/src/core/include/mapping.h
new file mode 100644
index 0000000000..bb4d483dea
--- /dev/null
+++ b/repos/base-hw/src/core/include/mapping.h
@@ -0,0 +1,52 @@
+/*
+ * \brief Representation of physical to virtual memory mappings
+ * \author Stefan Kalkowski
+ * \date 2016-11-03
+ */
+
+/*
+ * Copyright (C) 2016 Genode Labs GmbH
+ *
+ * This file is part of the Genode OS framework, which is distributed
+ * under the terms of the GNU General Public License version 2.
+ */
+
+#ifndef _MAPPING_H_
+#define _MAPPING_H_
+
+#include
+#include
+
+namespace Genode { struct Mapping; }
+
+struct Genode::Mapping
+{
+ addr_t phys = 0;
+ addr_t virt = 0;
+ size_t size = 0;
+ Page_flags flags;
+
+ Mapping() {}
+
+ Mapping(addr_t virt, addr_t phys, Cache_attribute cacheable,
+ bool io, unsigned size_log2, bool writeable)
+ : phys(phys), virt(virt), size(1 << size_log2),
+ flags{ writeable, true, false, false, io, cacheable } {}
+
+ Mapping(addr_t phys, addr_t virt, size_t size, Page_flags flags)
+ : phys(phys), virt(virt), size(size), flags(flags) {}
+
+ void print(Output & out) const
+ {
+ Genode::print(out, "phys=", (void*)phys, " => virt=", (void*) virt,
+ " (size=", Hex(size, Hex::PREFIX, Hex::PAD),
+ " page-flags: ", flags, ")");
+ }
+
+ /**
+ * Dummy implementation used by generic region_map code
+ */
+ void prepare_map_operation() {}
+};
+
+#endif /* _MAPPING_H_ */
diff --git a/repos/base-hw/src/core/include/page_flags.h b/repos/base-hw/src/core/include/page_flags.h
index 891d041d4f..a833776577 100644
--- a/repos/base-hw/src/core/include/page_flags.h
+++ b/repos/base-hw/src/core/include/page_flags.h
@@ -15,37 +15,50 @@
#define _CORE__INCLUDE__PAGE_FLAGS_H_
#include
+#include
-namespace Genode
+namespace Genode { struct Page_flags; }
+
+struct Genode::Page_flags
{
+ bool writeable;
+ bool executable;
+ bool privileged;
+ bool global;
+ bool device;
+ Cache_attribute cacheable;
+
/**
- * Map app-specific mem attributes to a TLB-specific POD
+ * Create flag POD for Genode pagers
*/
- struct Page_flags
+ static const Page_flags
+ apply_mapping(bool const writeable,
+ Cache_attribute const cacheable,
+ bool const io_mem) {
+ return Page_flags { writeable, true, false, false,
+ io_mem, cacheable }; }
+
+ /**
+ * Create flag POD for the mode transition region
+ */
+ static const Page_flags mode_transition() {
+ return Page_flags { true, true, true, true, false, CACHED }; }
+
+ void print(Output & out) const
{
- bool writeable;
- bool executable;
- bool privileged;
- bool global;
- bool device;
- Cache_attribute cacheable;
+ using Genode::print;
- /**
- * Create flag POD for Genode pagers
- */
- static const Page_flags
- apply_mapping(bool const writeable,
- Cache_attribute const cacheable,
- bool const io_mem) {
- return Page_flags { writeable, true, false, false,
- io_mem, cacheable }; }
-
- /**
- * Create flag POD for the mode transition region
- */
- static const Page_flags mode_transition() {
- return Page_flags { true, true, true, true, false, CACHED }; }
- };
-}
+ print(out, writeable ? "writeable, " : "readonly, ",
+ executable ? "exec, " : "noexec, ");
+ if (privileged) print(out, "privileged, ");
+ if (global) print(out, "global, ");
+ if (device) print(out, "iomem, ");
+ switch (cacheable) {
+ case UNCACHED: print(out, "uncached"); break;
+ case CACHED: print(out, "cached"); break;
+ case WRITE_COMBINED: print(out, "write-combined"); break;
+ };
+ }
+};
#endif /* _CORE__INCLUDE__PAGE_FLAGS_H_ */
diff --git a/repos/base-hw/src/core/include/pager.h b/repos/base-hw/src/core/include/pager.h
index 5b9b4c651c..520538cc20 100644
--- a/repos/base-hw/src/core/include/pager.h
+++ b/repos/base-hw/src/core/include/pager.h
@@ -26,17 +26,12 @@
/* core-local includes */
#include
+#include
#include
#include
namespace Genode
{
-
- /**
- * Translation of a virtual page frame
- */
- struct Mapping;
-
/**
* Interface between the generic paging system and the base-hw backend
*/
@@ -55,32 +50,6 @@ namespace Genode
enum { PAGER_EP_STACK_SIZE = sizeof(addr_t) * 2048 };
}
-struct Genode::Mapping
-{
- addr_t virt_address;
- addr_t phys_address;
- Cache_attribute cacheable;
- bool io_mem;
- unsigned size_log2;
- bool writable;
-
- /**
- * Constructor for invalid mappings
- */
- Mapping();
-
- /**
- * Constructor for valid mappings
- */
- Mapping(addr_t const va, addr_t const pa, Cache_attribute const c,
- bool const io, unsigned const sl2, bool const w);
-
- /**
- * Prepare for the application of the mapping
- */
- void prepare_map_operation();
-};
-
class Genode::Ipc_pager
{
protected:
diff --git a/repos/base-hw/src/core/pager.cc b/repos/base-hw/src/core/pager.cc
index 8bafbde4ee..db25a4ea87 100644
--- a/repos/base-hw/src/core/pager.cc
+++ b/repos/base-hw/src/core/pager.cc
@@ -25,29 +25,6 @@
using namespace Genode;
-/*************
- ** Mapping **
- *************/
-
-Mapping::Mapping(addr_t const va, addr_t const pa,
- Cache_attribute const c, bool const io,
- unsigned const sl2, bool const w)
-:
- virt_address(va), phys_address(pa), cacheable(c),
- io_mem(io), size_log2(sl2), writable(w)
-{ }
-
-
-Mapping::Mapping()
-:
-virt_address(0), phys_address(0), cacheable(CACHED),
- io_mem(0), size_log2(0), writable(0)
-{ }
-
-
-void Mapping::prepare_map_operation() { }
-
-
/***************
** Ipc_pager **
***************/
diff --git a/repos/base-hw/src/core/region_map_support.cc b/repos/base-hw/src/core/region_map_support.cc
index 7ff8320127..75badc1aef 100644
--- a/repos/base-hw/src/core/region_map_support.cc
+++ b/repos/base-hw/src/core/region_map_support.cc
@@ -81,13 +81,8 @@ void Pager_entrypoint::entry()
if (!locked_ptr.valid()) return;
Hw::Address_space * as = static_cast(&*locked_ptr);
- Page_flags const flags =
- Page_flags::apply_mapping(_mapping.writable,
- _mapping.cacheable,
- _mapping.io_mem);
- as->insert_translation(_mapping.virt_address,
- _mapping.phys_address,
- 1 << _mapping.size_log2, flags);
+ as->insert_translation(_mapping.virt, _mapping.phys,
+ _mapping.size, _mapping.flags);
}
/* let pager object go back to no-fault state */