genode/repos/base-nova/src/core/include/util.h
Stefan Kalkowski 2a2e5c2df4 base-*: remove usage of printf
base generic code:
  * Remove unused verbosity code from mmio framework
  * Remove escape sequence end heuristic from LOG
  * replace Core_console with Core_log (no format specifiers)
  * move test/printf to test/log
  * remove `printf()` tests from the log test
  * check for exact match of the log test output
base-fiasco:
  * remove unused Fiasco::print_l4_threadid function
base-nova:
  * remove unused hexdump utility from core
base-hw:
  * remove unused Kernel::Thread::_print_* debug utilities
  * always print resource summary of core during startup
  * remove Kernel::Ipc_node::pd_label (not used anymore)
base*:
  * Turn `printf`,`PWRN`, etc. calls into their log equivalents

Ref #1987
Fix #2119
2016-10-21 12:39:36 +02:00

57 lines
1.5 KiB
C++

/*
* \brief Core-internal utilities
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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 _CORE__INCLUDE__UTIL_H_
#define _CORE__INCLUDE__UTIL_H_
/* Genode includes */
#include <rm_session/rm_session.h>
#include <base/log.h>
/* base-internal includes */
#include <base/internal/page_size.h>
#include <platform_thread.h>
namespace Genode {
constexpr size_t get_super_page_size_log2() { return 22; }
constexpr size_t get_super_page_size() { return 1 << get_super_page_size_log2(); }
inline addr_t trunc_page(addr_t addr) { return addr & _align_mask(get_page_size_log2()); }
inline addr_t round_page(addr_t addr) { return trunc_page(addr + get_page_size() - 1); }
inline addr_t map_src_addr(addr_t core_local, addr_t phys) { return phys; }
inline size_t constrain_map_size_log2(size_t size_log2)
{
/* Nova::Mem_crd order has 5 bits available and is in 4K page units */
enum { MAX_MAP_LOG2 = (1U << 5) - 1 + 12 };
return size_log2 > MAX_MAP_LOG2 ? MAX_MAP_LOG2 : size_log2;
}
inline void backtrace()
{
using namespace Genode;
log("\nbacktrace");
log(" ", __builtin_return_address(0));
log(" ", __builtin_return_address(1));
log(" ", __builtin_return_address(2));
log(" ", __builtin_return_address(3));
log(" ", __builtin_return_address(4));
}
}
#endif /* _CORE__INCLUDE__UTIL_H_ */