base-hw: introduce 'cache_line_size' call

This call is used to query the cache line size of the underlying CPU.
For now it is only implemented and used by 'arm_v8' platforms.

It does not distinguish between D-/I-cache sizes and always uses the
smallest size. Furthermore it does not account for any discrepancy
in 'big.little' CPUs.

Issue #4339.
This commit is contained in:
Josef Söntgen 2021-12-13 15:32:21 +01:00 committed by Christian Helmuth
parent e8f748cfed
commit 66fd027b96
6 changed files with 40 additions and 7 deletions

View File

@ -38,13 +38,14 @@ namespace Kernel {
constexpr Call_arg call_id_cache_coherent_region() { return 13; }
constexpr Call_arg call_id_cache_clean_inv_region() { return 14; }
constexpr Call_arg call_id_cache_inv_region() { return 15; }
constexpr Call_arg call_id_ack_cap() { return 16; }
constexpr Call_arg call_id_delete_cap() { return 17; }
constexpr Call_arg call_id_timeout() { return 18; }
constexpr Call_arg call_id_timeout_max_us() { return 19; }
constexpr Call_arg call_id_time() { return 20; }
constexpr Call_arg call_id_run_vm() { return 21; }
constexpr Call_arg call_id_pause_vm() { return 22; }
constexpr Call_arg call_id_cache_line_size() { return 16; }
constexpr Call_arg call_id_ack_cap() { return 17; }
constexpr Call_arg call_id_delete_cap() { return 18; }
constexpr Call_arg call_id_timeout() { return 19; }
constexpr Call_arg call_id_timeout_max_us() { return 20; }
constexpr Call_arg call_id_time() { return 21; }
constexpr Call_arg call_id_run_vm() { return 22; }
constexpr Call_arg call_id_pause_vm() { return 23; }
/*****************************************************************
@ -214,6 +215,17 @@ namespace Kernel {
}
/**
* Get cache line size
*
* \param vm pointer to vm kernel object
*/
inline size_t cache_line_size()
{
return (size_t)call(call_id_cache_line_size());
}
/**
* Send request message and await reception of corresponding reply message
*

View File

@ -800,6 +800,7 @@ void Thread::_call()
case call_id_cache_coherent_region(): _call_cache_coherent_region(); return;
case call_id_cache_clean_inv_region(): _call_cache_clean_invalidate_data_region(); return;
case call_id_cache_inv_region(): _call_cache_invalidate_data_region(); return;
case call_id_cache_line_size(): _call_cache_line_size(); return;
case call_id_stop_thread(): _call_stop_thread(); return;
case call_id_restart_thread(): _call_restart_thread(); return;
case call_id_yield_thread(): _call_yield_thread(); return;

View File

@ -242,6 +242,7 @@ class Kernel::Thread : private Kernel::Object, public Cpu_job, private Timeout
void _call_cache_coherent_region();
void _call_cache_clean_invalidate_data_region();
void _call_cache_invalidate_data_region();
void _call_cache_line_size();
void _call_print_char();
void _call_await_signal();
void _call_pending_signal();

View File

@ -72,3 +72,10 @@ void Kernel::Thread::_call_cache_invalidate_data_region()
[] (addr_t addr, size_t size) {
Genode::Cpu::cache_invalidate_data_region(addr, size); });
}
void Kernel::Thread::_call_cache_line_size()
{
size_t const cache_line_size = Genode::Cpu::cache_line_size();
user_arg_0(cache_line_size);
}

View File

@ -98,6 +98,12 @@ void Kernel::Thread::_call_cache_clean_invalidate_data_region() { }
void Kernel::Thread::_call_cache_invalidate_data_region() { }
void Kernel::Thread::_call_cache_line_size()
{
user_arg_0(0);
}
void Kernel::Thread::proceed(Cpu & cpu)
{
/*

View File

@ -41,6 +41,12 @@ void Kernel::Thread::_call_cache_clean_invalidate_data_region() { }
void Kernel::Thread::_call_cache_invalidate_data_region() { }
void Kernel::Thread::_call_cache_line_size()
{
user_arg_0(0);
}
void Kernel::Thread::proceed(Cpu & cpu)
{
if (!cpu.active(pd().mmu_regs) && type() != CORE)