2012-05-30 20:13:09 +02:00
|
|
|
/*
|
|
|
|
* \brief Core-internal utilities
|
|
|
|
* \author Martin Stein
|
2017-02-21 13:46:59 +01:00
|
|
|
* \author Stefan Kalkowski
|
2012-05-30 20:13:09 +02:00
|
|
|
* \date 2012-01-02
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2012-2017 Genode Labs GmbH
|
2012-05-30 20:13:09 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-05-30 20:13:09 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-20 20:52:51 +01:00
|
|
|
#ifndef _CORE__INCLUDE__UTIL_H_
|
|
|
|
#define _CORE__INCLUDE__UTIL_H_
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
#include <hw/util.h>
|
2016-06-15 15:04:54 +02:00
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
namespace Genode
|
|
|
|
{
|
2017-02-21 13:46:59 +01:00
|
|
|
using Hw::get_page_mask;
|
|
|
|
using Hw::trunc_page;
|
|
|
|
using Hw::round_page;
|
|
|
|
using Hw::trunc;
|
|
|
|
using Hw::aligned;
|
|
|
|
using Hw::round;
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Select source used for map operations
|
|
|
|
*/
|
2017-02-21 13:46:59 +01:00
|
|
|
constexpr addr_t map_src_addr(addr_t core_local, addr_t phys) { return phys; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return highest supported flexpage size for the given mapping size
|
|
|
|
*
|
|
|
|
* This function is called by the page-fault handler to determine the
|
|
|
|
* mapping granularity to be used for a page-fault answer. If a kernel
|
|
|
|
* supports flexible page sizes, this function can just return the
|
|
|
|
* argument. If a kernel only supports a certain set of map sizes such
|
|
|
|
* as 4K and 4M, this function should select one of those smaller or
|
|
|
|
* equal to the argument.
|
|
|
|
*/
|
2017-02-21 13:46:59 +01:00
|
|
|
constexpr size_t constrain_map_size_log2(size_t size_log2) {
|
|
|
|
return (size_log2 < 20) ? 12 : 20; }
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
|
|
|
|
2016-01-20 20:52:51 +01:00
|
|
|
#endif /* _CORE__INCLUDE__UTIL_H_ */
|