Core: Refactor direct memory handling (#3645)

* Refactor direct memory areas

At this point, swapping the multiple booleans for an enum is cleaner, and makes it easier to track the state of a direct memory area.

I've also sped up the logic for mapping direct memory by checking for out-of-bounds physical addresses before looping, and made the logic more solid using my dma type logic.

* Fix PoolCommit assert

Windows devices will throw an access violation if we don't check for iterator reaching end.
This commit is contained in:
Stephen Miller
2025-09-23 14:42:15 -05:00
committed by GitHub
parent 1eead6a5ee
commit 5d8027f0c0
3 changed files with 66 additions and 35 deletions

View File

@@ -50,6 +50,14 @@ enum class MemoryMapFlags : u32 {
};
DECLARE_ENUM_FLAG_OPERATORS(MemoryMapFlags)
enum class DMAType : u32 {
Free = 0,
Allocated = 1,
Mapped = 2,
Pooled = 3,
Committed = 4,
};
enum class VMAType : u32 {
Free = 0,
Reserved = 1,
@@ -66,9 +74,7 @@ struct DirectMemoryArea {
PAddr base = 0;
u64 size = 0;
s32 memory_type = 0;
bool is_pooled = false;
bool is_committed = false;
bool is_free = true;
DMAType dma_type = DMAType::Free;
PAddr GetEnd() const {
return base + size;
@@ -81,8 +87,7 @@ struct DirectMemoryArea {
if (memory_type != next.memory_type) {
return false;
}
if (is_free != next.is_free || is_pooled != next.is_pooled ||
is_committed != next.is_committed) {
if (dma_type != next.dma_type) {
return false;
}
return true;