mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-25 19:44:57 +00:00
Improve accuracy of error cases
Some of our existing cases are normally EAGAIN returns.
This commit is contained in:
parent
0d1394ac2b
commit
32a8724635
@ -26,24 +26,31 @@ u64 PS4_SYSV_ABI sceKernelGetDirectMemorySize() {
|
|||||||
|
|
||||||
int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u64 len,
|
int PS4_SYSV_ABI sceKernelAllocateDirectMemory(s64 searchStart, s64 searchEnd, u64 len,
|
||||||
u64 alignment, int memoryType, s64* physAddrOut) {
|
u64 alignment, int memoryType, s64* physAddrOut) {
|
||||||
if (searchStart < 0 || searchEnd <= searchStart) {
|
if (searchStart < 0 || searchEnd < 0) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
const bool is_in_range = searchEnd - searchStart >= len;
|
|
||||||
if (len <= 0 || !Common::Is16KBAligned(len) || !is_in_range) {
|
|
||||||
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Provided address range is invalid!");
|
||||||
|
if (len <= 0 || !Common::Is16KBAligned(len)) {
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
if (alignment != 0 && !Common::Is16KBAligned(alignment)) {
|
if (alignment != 0 && !Common::Is16KBAligned(alignment)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
LOG_ERROR(Kernel_Vmm, "Alignment value is invalid!");
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
if (memoryType > 10) {
|
||||||
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
|
}
|
||||||
if (physAddrOut == nullptr) {
|
if (physAddrOut == nullptr) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Result physical address pointer is null!");
|
LOG_ERROR(Kernel_Vmm, "Result physical address pointer is null!");
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool is_in_range = searchEnd - searchStart >= len;
|
||||||
|
if (searchEnd <= searchStart || searchEnd < len || !is_in_range) {
|
||||||
|
return ORBIS_KERNEL_ERROR_EAGAIN;
|
||||||
|
}
|
||||||
|
|
||||||
auto* memory = Core::Memory::Instance();
|
auto* memory = Core::Memory::Instance();
|
||||||
PAddr phys_addr = memory->Allocate(searchStart, searchEnd, len, alignment, memoryType);
|
PAddr phys_addr = memory->Allocate(searchStart, searchEnd, len, alignment, memoryType);
|
||||||
if (phys_addr == -1) {
|
if (phys_addr == -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user