mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
parent
b6490e913f
commit
8aa8423cfd
52
repos/base-hw/src/core/include/mapping.h
Normal file
52
repos/base-hw/src/core/include/mapping.h
Normal file
@ -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 <base/output.h>
|
||||
#include <page_flags.h>
|
||||
|
||||
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_ */
|
@ -15,37 +15,50 @@
|
||||
#define _CORE__INCLUDE__PAGE_FLAGS_H_
|
||||
|
||||
#include <base/cache.h>
|
||||
#include <base/output.h>
|
||||
|
||||
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_ */
|
||||
|
@ -26,17 +26,12 @@
|
||||
|
||||
/* core-local includes */
|
||||
#include <kernel/signal_receiver.h>
|
||||
#include <mapping.h>
|
||||
#include <object.h>
|
||||
#include <rpc_cap_factory.h>
|
||||
|
||||
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:
|
||||
|
@ -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 **
|
||||
***************/
|
||||
|
@ -81,13 +81,8 @@ void Pager_entrypoint::entry()
|
||||
if (!locked_ptr.valid()) return;
|
||||
|
||||
Hw::Address_space * as = static_cast<Hw::Address_space*>(&*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 */
|
||||
|
Loading…
Reference in New Issue
Block a user