mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-26 00:34:18 +01:00
Address remaining feedback
This commit is contained in:
parent
5f88077406
commit
3749984b29
@ -56,15 +56,14 @@ namespace skyline::kernel {
|
|||||||
} else {
|
} else {
|
||||||
// If there are descriptors between first and last chunk, delete them
|
// If there are descriptors between first and last chunk, delete them
|
||||||
if ((firstChunkBase->first + firstChunk.size) != lastChunkBase->first) {
|
if ((firstChunkBase->first + firstChunk.size) != lastChunkBase->first) {
|
||||||
auto tempChunkBase{firstChunkBase};
|
auto tempChunkBase{std::next(firstChunkBase)};
|
||||||
|
|
||||||
++tempChunkBase;
|
|
||||||
while (tempChunkBase->first != lastChunkBase->first) {
|
while (tempChunkBase->first != lastChunkBase->first) {
|
||||||
auto tmp{tempChunkBase++};
|
auto tmp{tempChunkBase++};
|
||||||
if ((tmp->second.state == memory::states::Unmapped) != isUnmapping)
|
if ((tmp->second.state == memory::states::Unmapped) != isUnmapping)
|
||||||
needsReprotection = true;
|
needsReprotection = true;
|
||||||
chunks.erase(tmp);
|
|
||||||
}
|
}
|
||||||
|
chunks.erase(std::next(firstChunkBase), lastChunkBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldInsert{true};
|
bool shouldInsert{true};
|
||||||
@ -119,7 +118,7 @@ namespace skyline::kernel {
|
|||||||
Logger::Warn("Reprotection failed: {}", strerror(errno));
|
Logger::Warn("Reprotection failed: {}", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryManager::ForeachChunkinRange(span<u8> memory, auto editCallback) {
|
void MemoryManager::ForeachChunkInRange(span<u8> memory, auto editCallback) {
|
||||||
auto chunkBase{chunks.lower_bound(memory.data())};
|
auto chunkBase{chunks.lower_bound(memory.data())};
|
||||||
if (memory.data() < chunkBase->first)
|
if (memory.data() < chunkBase->first)
|
||||||
--chunkBase;
|
--chunkBase;
|
||||||
@ -349,7 +348,7 @@ namespace skyline::kernel {
|
|||||||
void MemoryManager::SetRegionBorrowed(span<u8> memory, bool value) {
|
void MemoryManager::SetRegionBorrowed(span<u8> memory, bool value) {
|
||||||
std::unique_lock lock{mutex};
|
std::unique_lock lock{mutex};
|
||||||
|
|
||||||
ForeachChunkinRange(memory, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
ForeachChunkInRange(memory, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
||||||
desc.second.attributes.isBorrowed = value;
|
desc.second.attributes.isBorrowed = value;
|
||||||
MapInternal(desc);
|
MapInternal(desc);
|
||||||
});
|
});
|
||||||
@ -358,7 +357,7 @@ namespace skyline::kernel {
|
|||||||
void MemoryManager::SetRegionCpuCaching(span<u8> memory, bool value) {
|
void MemoryManager::SetRegionCpuCaching(span<u8> memory, bool value) {
|
||||||
std::unique_lock lock{mutex};
|
std::unique_lock lock{mutex};
|
||||||
|
|
||||||
ForeachChunkinRange(memory, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
ForeachChunkInRange(memory, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
||||||
desc.second.attributes.isUncached = value;
|
desc.second.attributes.isUncached = value;
|
||||||
MapInternal(desc);
|
MapInternal(desc);
|
||||||
});
|
});
|
||||||
@ -367,7 +366,7 @@ namespace skyline::kernel {
|
|||||||
void MemoryManager::SetRegionPermission(span<u8> memory, memory::Permission permission) {
|
void MemoryManager::SetRegionPermission(span<u8> memory, memory::Permission permission) {
|
||||||
std::unique_lock lock{mutex};
|
std::unique_lock lock{mutex};
|
||||||
|
|
||||||
ForeachChunkinRange(memory, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
ForeachChunkInRange(memory, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
||||||
desc.second.permission = permission;
|
desc.second.permission = permission;
|
||||||
MapInternal(desc);
|
MapInternal(desc);
|
||||||
});
|
});
|
||||||
@ -480,7 +479,7 @@ namespace skyline::kernel {
|
|||||||
__attribute__((always_inline)) void MemoryManager::UnmapMemory(span<u8> memory) {
|
__attribute__((always_inline)) void MemoryManager::UnmapMemory(span<u8> memory) {
|
||||||
std::unique_lock lock{mutex};
|
std::unique_lock lock{mutex};
|
||||||
|
|
||||||
ForeachChunkinRange(memory, [&](const std::pair<u8 *, ChunkDescriptor> &desc) {
|
ForeachChunkInRange(memory, [&](const std::pair<u8 *, ChunkDescriptor> &desc) {
|
||||||
if (desc.second.state != memory::states::Unmapped)
|
if (desc.second.state != memory::states::Unmapped)
|
||||||
FreeMemory(span<u8>(desc.first, desc.second.size));
|
FreeMemory(span<u8>(desc.first, desc.second.size));
|
||||||
});
|
});
|
||||||
@ -515,7 +514,7 @@ namespace skyline::kernel {
|
|||||||
|
|
||||||
std::memcpy(destination.data(), source.data(), source.size());
|
std::memcpy(destination.data(), source.data(), source.size());
|
||||||
|
|
||||||
ForeachChunkinRange(source, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
ForeachChunkInRange(source, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
||||||
desc.second.permission = {false, false, false};
|
desc.second.permission = {false, false, false};
|
||||||
desc.second.attributes.isBorrowed = true;
|
desc.second.attributes.isBorrowed = true;
|
||||||
MapInternal(desc);
|
MapInternal(desc);
|
||||||
@ -532,7 +531,7 @@ namespace skyline::kernel {
|
|||||||
++dstChunk;
|
++dstChunk;
|
||||||
|
|
||||||
if ((destination.data() + destination.size()) > dstChunk->first) [[likely]] {
|
if ((destination.data() + destination.size()) > dstChunk->first) [[likely]] {
|
||||||
ForeachChunkinRange(span<u8>{source.data() + (dstChunk->first - destination.data()), dstChunk->second.size}, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
ForeachChunkInRange(span<u8>{source.data() + (dstChunk->first - destination.data()), dstChunk->second.size}, [&](std::pair<u8 *, ChunkDescriptor> &desc) __attribute__((always_inline)) {
|
||||||
desc.second.permission = dstChunk->second.permission;
|
desc.second.permission = dstChunk->second.permission;
|
||||||
desc.second.attributes.isBorrowed = false;
|
desc.second.attributes.isBorrowed = false;
|
||||||
MapInternal(desc);
|
MapInternal(desc);
|
||||||
|
@ -231,7 +231,7 @@ namespace skyline {
|
|||||||
|
|
||||||
void MapInternal(const std::pair<u8 *, ChunkDescriptor> &newDesc);
|
void MapInternal(const std::pair<u8 *, ChunkDescriptor> &newDesc);
|
||||||
|
|
||||||
void ForeachChunkinRange(span<u8> memory, auto editCallback);
|
void ForeachChunkInRange(span<u8> memory, auto editCallback);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
memory::AddressSpaceType addressSpaceType{};
|
memory::AddressSpaceType addressSpaceType{};
|
||||||
|
Loading…
Reference in New Issue
Block a user