core/kernel: Fix returns on `sceKernelAvailableDirectMemorySize`

This commit is contained in:
Daniel R 2024-08-24 22:16:08 +02:00
parent 902d279c0a
commit be1994f109
No known key found for this signature in database
GPG Key ID: B8ADC8F57BA18DBA
1 changed files with 7 additions and 9 deletions

View File

@ -75,28 +75,26 @@ s32 PS4_SYSV_ABI sceKernelAvailableDirectMemorySize(u64 searchStart, u64 searchE
LOG_WARNING(Kernel_Vmm, "called searchStart = {:#x}, searchEnd = {:#x}, alignment = {:#x}", LOG_WARNING(Kernel_Vmm, "called searchStart = {:#x}, searchEnd = {:#x}, alignment = {:#x}",
searchStart, searchEnd, alignment); searchStart, searchEnd, alignment);
if (searchEnd <= searchStart) { if (physAddrOut == nullptr || sizeOut == nullptr) {
return ORBIS_KERNEL_ERROR_EINVAL; return ORBIS_KERNEL_ERROR_EINVAL;
} }
if (searchEnd > SCE_KERNEL_MAIN_DMEM_SIZE) { if (searchEnd > SCE_KERNEL_MAIN_DMEM_SIZE) {
return ORBIS_KERNEL_ERROR_EINVAL; return ORBIS_KERNEL_ERROR_EINVAL;
} }
if (searchEnd <= searchStart) {
if (physAddrOut == nullptr || sizeOut == nullptr) { return ORBIS_KERNEL_ERROR_ENOMEM;
return ORBIS_KERNEL_ERROR_EINVAL;
} }
auto* memory = Core::Memory::Instance(); auto* memory = Core::Memory::Instance();
PAddr physAddr; PAddr physAddr{};
size_t size; size_t size{};
s32 result = s32 result = memory->DirectQueryAvailable(searchStart, searchEnd, alignment, &physAddr, &size);
memory->DirectQueryAvailable(searchStart, searchEnd, alignment, &physAddr, &size);
if (size == 0) { if (size == 0) {
return ORBIS_KERNEL_ERROR_ENOMEM; return ORBIS_KERNEL_ERROR_ENOMEM;
} }
*physAddrOut = static_cast<u64>(physAddr); *physAddrOut = static_cast<u64>(physAddr);
*sizeOut = size; *sizeOut = size;