Update sceBatchMap2 (#782)

* Update sceKernelBatchMap2

Improves placement of new BatchMap op types, and re-adds the BatchMap2 changes from https://github.com/shadps4-emu/shadPS4/pull/602.

* Update some logs.
This commit is contained in:
Stephen Miller 2024-09-04 16:12:04 -05:00 committed by GitHub
parent 28feb77982
commit 89fb1a024f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -292,41 +292,16 @@ s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEn
} }
case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_UNMAP: { case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_UNMAP: {
result = sceKernelMunmap(entries[i].start, entries[i].length); result = sceKernelMunmap(entries[i].start, entries[i].length);
LOG_INFO(Kernel_Vmm, "BatchMap: entry = {}, operation = {}, len = {:#x}, result = {}", LOG_INFO(Kernel_Vmm, "entry = {}, operation = {}, len = {:#x}, result = {}", i,
i, entries[i].operation, entries[i].length, result); entries[i].operation, entries[i].length, result);
break;
if (result == 0)
processed++;
} }
case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_PROTECT: { case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_PROTECT: {
result = sceKernelMProtect(entries[i].start, entries[i].length, entries[i].protection); result = sceKernelMProtect(entries[i].start, entries[i].length, entries[i].protection);
LOG_INFO(Kernel_Vmm, "BatchMap: entry = {}, operation = {}, len = {:#x}, result = {}", LOG_INFO(Kernel_Vmm, "entry = {}, operation = {}, len = {:#x}, result = {}", i,
i, entries[i].operation, entries[i].length, result); entries[i].operation, entries[i].length, result);
if (result != ORBIS_OK) {
LOG_ERROR(Kernel_Vmm, "BatchMap: MProtect failed on entry {} with result {}", i,
result);
}
if (result == 0) {
processed++;
}
break; break;
} }
case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_TYPE_PROTECT: {
result = sceKernelMTypeProtect(entries[i].start, entries[i].length, entries[i].type,
entries[i].protection);
LOG_INFO(Kernel_Vmm, "BatchMap: entry = {}, operation = {}, len = {:#x}, result = {}",
i, entries[i].operation, entries[i].length, result);
if (result != ORBIS_OK) {
LOG_ERROR(Kernel_Vmm, "BatchMap: MProtect failed on entry {} with result {}", i,
result);
}
if (result == 0) {
processed++;
}
break;
}
case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_MAP_FLEXIBLE: { case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_MAP_FLEXIBLE: {
result = sceKernelMapNamedFlexibleMemory(&entries[i].start, entries[i].length, result = sceKernelMapNamedFlexibleMemory(&entries[i].start, entries[i].length,
entries[i].protection, flags, ""); entries[i].protection, flags, "");
@ -336,7 +311,13 @@ s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEn
i, entries[i].operation, entries[i].length, (u8)entries[i].type, result); i, entries[i].operation, entries[i].length, (u8)entries[i].type, result);
break; break;
} }
case MemoryOpTypes::ORBIS_KERNEL_MAP_OP_TYPE_PROTECT: {
result = sceKernelMTypeProtect(entries[i].start, entries[i].length, entries[i].type,
entries[i].protection);
LOG_INFO(Kernel_Vmm, "entry = {}, operation = {}, len = {:#x}, result = {}", i,
entries[i].operation, entries[i].length, result);
break;
}
default: { default: {
UNREACHABLE(); UNREACHABLE();
} }
@ -346,8 +327,6 @@ s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEn
break; break;
} }
} }
LOG_INFO(Kernel_Vmm, "sceKernelBatchMap2 finished: processed = {}, result = {}", processed,
result);
if (numEntriesOut != NULL) { // can be zero. do not return an error code. if (numEntriesOut != NULL) { // can be zero. do not return an error code.
*numEntriesOut = processed; *numEntriesOut = processed;
} }