From 017cda3c43b37d9191cd5c3045227e576327a949 Mon Sep 17 00:00:00 2001 From: DH Date: Wed, 13 Nov 2024 21:57:12 +0300 Subject: [PATCH] dmem: implement get direct memory type --- rpcsx/iodev/dmem.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/rpcsx/iodev/dmem.cpp b/rpcsx/iodev/dmem.cpp index cd28ee50b..574e7e8f5 100644 --- a/rpcsx/iodev/dmem.cpp +++ b/rpcsx/iodev/dmem.cpp @@ -149,6 +149,28 @@ static orbis::ErrorCode dmem_ioctl(orbis::File *file, std::uint64_t request, return {}; } + case 0xc0208004: { // get direct memory type + struct Args { + std::uint64_t start; + std::uint64_t regionStart; + std::uint64_t regionEnd; + std::uint32_t memoryType; + }; + + auto args = reinterpret_cast(argp); + + auto it = device->allocations.lowerBound(args->start); + + if (it == device->allocations.end() || it->memoryType == -1u) { + return orbis::ErrorCode::SRCH; + } + + args->regionStart = it.beginAddress(); + args->regionEnd = it.endAddress(); + args->memoryType = it->memoryType; + return {}; + } + case 0x80288012: { // direct memory query struct DirectMemoryQueryInfo { std::uint64_t start;