Loading...
Searching...
No Matches
consts
// vi:set ft=cpp: -*- Mode: C++ -*-
#pragma once
#include <l4/sys/consts.h>
namespace L4 {
template<typename T>
constexpr T trunc_order(T val, unsigned char order)
{
return val & ((~T(0)) << order);
}
template<typename T>
constexpr T round_order(T val, unsigned char order)
{
return (val + (T(1) << order) - T(1)) & ((~T(0)) << order);
}
template<typename T>
constexpr T trunc_page(T val)
{
return trunc_order(val, L4_PAGESHIFT);
}
template<typename T>
constexpr T round_page(T val)
{
return round_order(val, L4_PAGESHIFT);
}
template<typename T>
inline unsigned char
max_order(unsigned char order, T addr,
T min_addr, T max_addr,
T hotspot = T(0))
{
while (order < 30 /* limit to 1GB flexpages */)
{
T mask;
T base = trunc_order(addr, order + 1);
if (base < min_addr)
return order;
if (base + (T(1) << (order + 1)) - T(1) > max_addr - T(1))
return order;
mask = ~((~T(0)) << (order + 1));
if (hotspot == ~T(0) || ((addr ^ hotspot) & mask))
break;
++order;
}
return order;
}
}
L4_PAGESHIFT
#define L4_PAGESHIFT
Size of a page, log2-based.
Definition consts.h:26
consts.h
Common constants.
L4
L4 low-level kernel interface.
Definition l4sys-l4f-groups.dox:50
L4::round_order
constexpr T round_order(T val, unsigned char order)
Round a value up so the given number of lsb is zero.
Definition consts:32
L4::trunc_order
constexpr T trunc_order(T val, unsigned char order)
Round a value down so the given number of lsb is zero.
Definition consts:18