mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-29 15:44:02 +00:00
base: move page flags interface to base
On hw, `Page_flags` is used throughout architectures. At the same time, it is used by the Intel IOMMU page table implementation in the pc platform driver. Consolidate the definition in base so it is available for all users. Issue #5217
This commit is contained in:
parent
c31adb77e7
commit
58e9856eb8
@ -66,9 +66,9 @@ Platform::Pd::Pd(Platform::Ram_allocator & alloc)
|
||||
using namespace Genode;
|
||||
addr_t const table_virt_base = Hw::Mm::core_page_tables().base;
|
||||
map_insert(Mapping((addr_t)table_base, table_virt_base,
|
||||
sizeof(Table), Hw::PAGE_FLAGS_KERN_DATA));
|
||||
sizeof(Table), Genode::PAGE_FLAGS_KERN_DATA));
|
||||
map_insert(Mapping((addr_t)array_base, table_virt_base + sizeof(Table),
|
||||
sizeof(Table_array), Hw::PAGE_FLAGS_KERN_DATA));
|
||||
sizeof(Table_array), Genode::PAGE_FLAGS_KERN_DATA));
|
||||
}
|
||||
|
||||
|
||||
@ -183,7 +183,7 @@ Platform::Platform()
|
||||
/* temporarily map all bootstrap memory 1:1 for transition to core */
|
||||
// FIXME do not insert as mapping for core
|
||||
core_pd->map_insert(Mapping(bootstrap_region.base, bootstrap_region.base,
|
||||
(addr_t)&_bss_end - (addr_t)&_prog_img_beg, Hw::PAGE_FLAGS_KERN_TEXT));
|
||||
(addr_t)&_bss_end - (addr_t)&_prog_img_beg, Genode::PAGE_FLAGS_KERN_TEXT));
|
||||
|
||||
/* map memory-mapped I/O for core */
|
||||
board.core_mmio.for_each_mapping([&] (Mapping const & m) {
|
||||
@ -195,7 +195,7 @@ Platform::Platform()
|
||||
/* setup boot info page */
|
||||
void * bi_base = ram_alloc.alloc(sizeof(Boot_info));
|
||||
core_pd->map_insert(Mapping((addr_t)bi_base, Hw::Mm::boot_info().base,
|
||||
sizeof(Boot_info), Hw::PAGE_FLAGS_KERN_TEXT));
|
||||
sizeof(Boot_info), Genode::PAGE_FLAGS_KERN_TEXT));
|
||||
Boot_info & bootinfo =
|
||||
*construct_at<Boot_info>(bi_base, (addr_t)&core_pd->table,
|
||||
(addr_t)&core_pd->array,
|
||||
|
@ -16,11 +16,11 @@
|
||||
|
||||
/* core includes */
|
||||
#include <types.h>
|
||||
#include <hw/page_flags.h>
|
||||
#include <cpu/page_flags.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
using Hw::Page_flags;
|
||||
using Genode::Page_flags;
|
||||
|
||||
/**
|
||||
* Map physical pages to core-local virtual address range
|
||||
@ -33,7 +33,7 @@ namespace Core {
|
||||
* \return true on success
|
||||
*/
|
||||
bool map_local(addr_t from_phys, addr_t to_virt, size_t num_pages,
|
||||
Page_flags flags = Hw::PAGE_FLAGS_KERN_DATA);
|
||||
Page_flags flags = Genode::PAGE_FLAGS_KERN_DATA);
|
||||
|
||||
/**
|
||||
* Unmap pages from core's address space
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <kernel/main.h>
|
||||
|
||||
/* base-hw internal includes */
|
||||
#include <hw/page_flags.h>
|
||||
#include <cpu/page_flags.h>
|
||||
#include <hw/util.h>
|
||||
#include <hw/memory_region.h>
|
||||
|
||||
|
@ -15,9 +15,19 @@
|
||||
#define _SRC__LIB__HW__MAPPING_H_
|
||||
|
||||
#include <hw/memory_region.h>
|
||||
#include <hw/page_flags.h>
|
||||
#include <cpu/page_flags.h>
|
||||
|
||||
namespace Hw {
|
||||
using Genode::Page_flags;
|
||||
using Genode::RO;
|
||||
using Genode::NO_EXEC;
|
||||
using Genode::KERN;
|
||||
using Genode::NO_GLOBAL;
|
||||
using Genode::RAM;
|
||||
|
||||
class Mapping;
|
||||
}
|
||||
|
||||
namespace Hw { class Mapping; }
|
||||
|
||||
|
||||
class Hw::Mapping
|
||||
|
@ -46,7 +46,7 @@ struct Hw::Mmio_space : Hw::Memory_region_array
|
||||
{
|
||||
addr_t virt_base = Mm::core_mmio().base;
|
||||
auto lambda = [&] (unsigned, Memory_region const & r) {
|
||||
f(Mapping { r.base, virt_base, r.size, PAGE_FLAGS_KERN_IO });
|
||||
f(Mapping { r.base, virt_base, r.size, Genode::PAGE_FLAGS_KERN_IO });
|
||||
virt_base += r.size + get_page_size();
|
||||
};
|
||||
for_each(lambda);
|
||||
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* \brief Generic page flags
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2014-02-24
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _SRC__LIB__HW__PAGE_FLAGS_H_
|
||||
#define _SRC__LIB__HW__PAGE_FLAGS_H_
|
||||
|
||||
#include <base/cache.h>
|
||||
#include <base/output.h>
|
||||
|
||||
namespace Hw {
|
||||
|
||||
enum Writeable { RO, RW };
|
||||
enum Executeable { NO_EXEC, EXEC };
|
||||
enum Privileged { USER, KERN };
|
||||
enum Global { NO_GLOBAL, GLOBAL };
|
||||
enum Type { RAM, DEVICE };
|
||||
|
||||
struct Page_flags;
|
||||
}
|
||||
|
||||
|
||||
struct Hw::Page_flags
|
||||
{
|
||||
Writeable writeable;
|
||||
Executeable executable;
|
||||
Privileged privileged;
|
||||
Global global;
|
||||
Type type;
|
||||
Genode::Cache cacheable;
|
||||
|
||||
void print(Genode::Output & out) const
|
||||
{
|
||||
using Genode::print;
|
||||
using namespace Genode;
|
||||
|
||||
print(out, (writeable == RW) ? "writeable, " : "readonly, ",
|
||||
(executable ==EXEC) ? "exec, " : "noexec, ");
|
||||
if (privileged == KERN) print(out, "privileged, ");
|
||||
if (global == GLOBAL) print(out, "global, ");
|
||||
if (type == 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;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
namespace Hw {
|
||||
|
||||
static constexpr Page_flags PAGE_FLAGS_KERN_IO
|
||||
{ RW, NO_EXEC, KERN, GLOBAL, DEVICE, Genode::UNCACHED };
|
||||
static constexpr Page_flags PAGE_FLAGS_KERN_DATA
|
||||
{ RW, EXEC, KERN, GLOBAL, RAM, Genode::CACHED };
|
||||
static constexpr Page_flags PAGE_FLAGS_KERN_TEXT
|
||||
{ RW, EXEC, KERN, GLOBAL, RAM, Genode::CACHED };
|
||||
static constexpr Page_flags PAGE_FLAGS_KERN_EXCEP
|
||||
{ RW, EXEC, KERN, GLOBAL, RAM, Genode::CACHED };
|
||||
static constexpr Page_flags PAGE_FLAGS_UTCB
|
||||
{ RW, NO_EXEC, USER, NO_GLOBAL, RAM, Genode::CACHED };
|
||||
}
|
||||
|
||||
#endif /* _SRC__LIB__HW__PAGE_FLAGS_H_ */
|
@ -16,10 +16,11 @@
|
||||
|
||||
#include <util/misc_math.h>
|
||||
#include <util/register.h>
|
||||
#include <hw/page_flags.h>
|
||||
#include <cpu/page_flags.h>
|
||||
#include <hw/page_table_allocator.h>
|
||||
|
||||
namespace Hw {
|
||||
using Genode::Page_flags;
|
||||
|
||||
enum {
|
||||
SIZE_LOG2_4KB = 12,
|
||||
@ -206,7 +207,7 @@ class Hw::Long_translation_table
|
||||
|
||||
static typename Descriptor::access_t create(Page_flags const &f)
|
||||
{
|
||||
if (f.type == Hw::DEVICE)
|
||||
if (f.type == Genode::DEVICE)
|
||||
return Attribute_index::bits(DEVICE);
|
||||
|
||||
switch (f.cacheable) {
|
||||
|
@ -15,13 +15,17 @@
|
||||
#ifndef _SRC__LIB__HW__SPEC__ARM__PAGE_TABLE_H_
|
||||
#define _SRC__LIB__HW__SPEC__ARM__PAGE_TABLE_H_
|
||||
|
||||
#include <cpu/page_flags.h>
|
||||
#include <hw/util.h>
|
||||
#include <hw/assert.h>
|
||||
#include <hw/page_flags.h>
|
||||
#include <hw/page_table_allocator.h>
|
||||
#include <util/register.h>
|
||||
|
||||
namespace Hw { class Page_table; }
|
||||
namespace Hw {
|
||||
using namespace Genode;
|
||||
|
||||
class Page_table;
|
||||
}
|
||||
|
||||
|
||||
class Hw::Page_table
|
||||
|
@ -15,7 +15,7 @@
|
||||
#define _SRC__LIB__HW__SPEC__RISCV__PAGE_TABLE_H_
|
||||
|
||||
#include <base/log.h>
|
||||
#include <hw/page_flags.h>
|
||||
#include <cpu/page_flags.h>
|
||||
#include <hw/page_table_allocator.h>
|
||||
#include <util/misc_math.h>
|
||||
#include <util/register.h>
|
||||
@ -73,7 +73,7 @@ struct Sv39::Descriptor : Register<64>
|
||||
struct Ppn : Bitfield<10, 38> { }; /* physical address 10 bit aligned */
|
||||
struct Base : Bitfield<12, 38> { }; /* physical address page aligned */
|
||||
|
||||
static access_t permission_bits(Hw::Page_flags const &f)
|
||||
static access_t permission_bits(Genode::Page_flags const &f)
|
||||
{
|
||||
access_t rights = 0;
|
||||
R::set(rights, 1);
|
||||
@ -125,7 +125,7 @@ struct Sv39::Table_descriptor : Descriptor
|
||||
|
||||
struct Sv39::Block_descriptor : Descriptor
|
||||
{
|
||||
static access_t create(Hw::Page_flags const &f, addr_t const pa)
|
||||
static access_t create(Genode::Page_flags const &f, addr_t const pa)
|
||||
{
|
||||
access_t base = Base::get(pa);
|
||||
access_t desc = 0;
|
||||
@ -219,10 +219,10 @@ class Sv39::Level_x_translation_table
|
||||
template <typename E>
|
||||
struct Insert_func
|
||||
{
|
||||
Hw::Page_flags const & flags;
|
||||
Genode::Page_flags const & flags;
|
||||
Allocator & alloc;
|
||||
|
||||
Insert_func(Hw::Page_flags const & flags, Allocator & alloc)
|
||||
Insert_func(Genode::Page_flags const & flags, Allocator & alloc)
|
||||
: flags(flags), alloc(alloc) { }
|
||||
|
||||
void operator () (addr_t const vo,
|
||||
@ -333,7 +333,7 @@ class Sv39::Level_x_translation_table
|
||||
* \param alloc level allocator
|
||||
*/
|
||||
void insert_translation(addr_t vo, addr_t pa, size_t size,
|
||||
Hw::Page_flags const & flags,
|
||||
Genode::Page_flags const & flags,
|
||||
Allocator & alloc )
|
||||
{
|
||||
_range_op(vo, pa, size, Insert_func<ENTRY>(flags, alloc));
|
||||
@ -367,9 +367,9 @@ namespace Sv39 {
|
||||
template <> template <>
|
||||
struct Level_3_translation_table::Insert_func<None>
|
||||
{
|
||||
Hw::Page_flags const & flags;
|
||||
Genode::Page_flags const & flags;
|
||||
|
||||
Insert_func(Hw::Page_flags const & flags, Allocator &)
|
||||
Insert_func(Genode::Page_flags const & flags, Allocator &)
|
||||
: flags(flags) { }
|
||||
|
||||
void operator () (addr_t const vo,
|
||||
|
@ -16,13 +16,14 @@
|
||||
|
||||
#include <base/log.h>
|
||||
#include <hw/assert.h>
|
||||
#include <hw/page_flags.h>
|
||||
#include <cpu/page_flags.h>
|
||||
#include <hw/page_table_allocator.h>
|
||||
#include <hw/util.h>
|
||||
#include <util/misc_math.h>
|
||||
#include <util/register.h>
|
||||
|
||||
namespace Hw {
|
||||
using namespace Genode;
|
||||
|
||||
/**
|
||||
* IA-32e paging translates 48-bit linear addresses to 52-bit physical
|
||||
|
@ -11,8 +11,8 @@
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__SPEC__X86_64__PAGE_TABLE__PAGE_FLAGS_H_
|
||||
#define _INCLUDE__SPEC__X86_64__PAGE_TABLE__PAGE_FLAGS_H_
|
||||
#ifndef _INCLUDE__CPU__PAGE_FLAGS_H_
|
||||
#define _INCLUDE__CPU__PAGE_FLAGS_H_
|
||||
|
||||
#include <base/cache.h>
|
||||
#include <base/output.h>
|
||||
@ -71,4 +71,4 @@ namespace Genode {
|
||||
{ RW, NO_EXEC, USER, NO_GLOBAL, RAM, Genode::CACHED };
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__SPEC__X86_64__PAGE_TABLE__PAGE_FLAGS_H_ */
|
||||
#endif /* _INCLUDE__CPU__PAGE_FLAGS_H_ */
|
@ -16,7 +16,7 @@
|
||||
#define _INCLUDE__SPEC__X86_64__PAGE_TABLE__PAGE_TABLE_BASE_H_
|
||||
|
||||
#include <base/log.h>
|
||||
#include <page_table/page_flags.h>
|
||||
#include <cpu/page_flags.h>
|
||||
#include <util/misc_math.h>
|
||||
#include <cpu/clflush.h>
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef _SRC__DRIVERS__PLATFORM__PC__INTEL__PAGE_TABLE_H_
|
||||
#define _SRC__DRIVERS__PLATFORM__PC__INTEL__PAGE_TABLE_H_
|
||||
|
||||
#include <base/env.h>
|
||||
#include <util/register.h>
|
||||
#include <util/xml_generator.h>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user