2014-05-20 22:52:56 +02:00
|
|
|
/*
|
|
|
|
* \brief Implementation of the cache operations
|
|
|
|
* \author Christian Prochaska
|
|
|
|
* \date 2014-05-13
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2014-2017 Genode Labs GmbH
|
2014-05-20 22:52:56 +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.
|
2014-05-20 22:52:56 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <kernel/interface.h>
|
|
|
|
|
2020-03-03 15:56:50 +01:00
|
|
|
#include <base/internal/page_size.h>
|
2014-05-20 22:52:56 +02:00
|
|
|
#include <cpu/cache.h>
|
2020-03-03 15:56:50 +01:00
|
|
|
#include <util/misc_math.h>
|
2014-05-20 22:52:56 +02:00
|
|
|
|
|
|
|
void Genode::cache_coherent(Genode::addr_t addr, Genode::size_t size)
|
|
|
|
{
|
2020-03-03 15:56:50 +01:00
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The kernel accepts the 'cache_coherent_region' call for one designated
|
|
|
|
* page only. Otherwise, it just ignores the call to limit the time being
|
|
|
|
* uninteruppptible in the kernel. Therefor, we have to loop if more than
|
|
|
|
* one page is affected by the given region.
|
|
|
|
*/
|
|
|
|
while (size) {
|
|
|
|
addr_t next_page = align_addr(addr+1, get_page_size_log2());
|
|
|
|
size_t s = min(size, next_page - addr);
|
|
|
|
Kernel::cache_coherent_region(addr, s);
|
|
|
|
addr += s;
|
|
|
|
size -= s;
|
|
|
|
}
|
2014-05-20 22:52:56 +02:00
|
|
|
}
|