kernel: implement FlushProcessDataCache
This commit is contained in:
parent
70ea1c2000
commit
651f6598ac
4 changed files with 125 additions and 8 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "common/assert.h"
|
||||
#include "common/atomic_ops.h"
|
||||
#include "common/cache_management.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/page_table.h"
|
||||
|
@ -329,6 +330,55 @@ struct Memory::Impl {
|
|||
});
|
||||
}
|
||||
|
||||
template <typename Callback>
|
||||
Result PerformCacheOperation(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size,
|
||||
Callback&& cb) {
|
||||
class InvalidMemoryException : public std::exception {};
|
||||
|
||||
try {
|
||||
WalkBlock(
|
||||
process, dest_addr, size,
|
||||
[&](const std::size_t block_size, const VAddr current_vaddr) {
|
||||
LOG_ERROR(HW_Memory, "Unmapped cache maintenance @ {:#018X}", current_vaddr);
|
||||
throw InvalidMemoryException();
|
||||
},
|
||||
[&](const std::size_t block_size, u8* const host_ptr) { cb(block_size, host_ptr); },
|
||||
[&](const VAddr current_vaddr, const std::size_t block_size, u8* const host_ptr) {
|
||||
system.GPU().FlushRegion(current_vaddr, block_size);
|
||||
cb(block_size, host_ptr);
|
||||
},
|
||||
[](const std::size_t block_size) {});
|
||||
} catch (InvalidMemoryException&) {
|
||||
return Kernel::ResultInvalidCurrentMemory;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result InvalidateDataCache(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size) {
|
||||
auto perform = [&](const std::size_t block_size, u8* const host_ptr) {
|
||||
// Do nothing; this operation (dc ivac) cannot be supported
|
||||
// from EL0
|
||||
};
|
||||
return PerformCacheOperation(process, dest_addr, size, perform);
|
||||
}
|
||||
|
||||
Result StoreDataCache(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size) {
|
||||
auto perform = [&](const std::size_t block_size, u8* const host_ptr) {
|
||||
// dc cvac: Store to point of coherency
|
||||
Common::DataCacheLineCleanByVAToPoC(host_ptr, block_size);
|
||||
};
|
||||
return PerformCacheOperation(process, dest_addr, size, perform);
|
||||
}
|
||||
|
||||
Result FlushDataCache(const Kernel::KProcess& process, VAddr dest_addr, std::size_t size) {
|
||||
auto perform = [&](const std::size_t block_size, u8* const host_ptr) {
|
||||
// dc civac: Store to point of coherency, and invalidate from cache
|
||||
Common::DataCacheLineCleanAndInvalidateByVAToPoC(host_ptr, block_size);
|
||||
};
|
||||
return PerformCacheOperation(process, dest_addr, size, perform);
|
||||
}
|
||||
|
||||
void MarkRegionDebug(VAddr vaddr, u64 size, bool debug) {
|
||||
if (vaddr == 0) {
|
||||
return;
|
||||
|
@ -786,6 +836,21 @@ void Memory::ZeroBlock(const Kernel::KProcess& process, VAddr dest_addr, const s
|
|||
impl->ZeroBlock(process, dest_addr, size);
|
||||
}
|
||||
|
||||
Result Memory::InvalidateDataCache(const Kernel::KProcess& process, VAddr dest_addr,
|
||||
const std::size_t size) {
|
||||
return impl->InvalidateDataCache(process, dest_addr, size);
|
||||
}
|
||||
|
||||
Result Memory::StoreDataCache(const Kernel::KProcess& process, VAddr dest_addr,
|
||||
const std::size_t size) {
|
||||
return impl->StoreDataCache(process, dest_addr, size);
|
||||
}
|
||||
|
||||
Result Memory::FlushDataCache(const Kernel::KProcess& process, VAddr dest_addr,
|
||||
const std::size_t size) {
|
||||
return impl->FlushDataCache(process, dest_addr, size);
|
||||
}
|
||||
|
||||
void Memory::RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached) {
|
||||
impl->RasterizerMarkRegionCached(vaddr, size, cached);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue