mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-27 04:25:12 +00:00
Update MemoryPoolReserve
Only difference between real hw and our code is behavior with addr = 0.
This commit is contained in:
parent
4f1a8c57fc
commit
f7aee889de
@ -425,10 +425,6 @@ s32 PS4_SYSV_ABI sceKernelMemoryPoolReserve(void* addrIn, size_t len, size_t ali
|
|||||||
LOG_INFO(Kernel_Vmm, "addrIn = {}, len = {:#x}, alignment = {:#x}, flags = {:#x}",
|
LOG_INFO(Kernel_Vmm, "addrIn = {}, len = {:#x}, alignment = {:#x}, flags = {:#x}",
|
||||||
fmt::ptr(addrIn), len, alignment, flags);
|
fmt::ptr(addrIn), len, alignment, flags);
|
||||||
|
|
||||||
if (addrIn == nullptr) {
|
|
||||||
LOG_ERROR(Kernel_Vmm, "Address is invalid!");
|
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
|
||||||
}
|
|
||||||
if (len == 0 || !Common::Is2MBAligned(len)) {
|
if (len == 0 || !Common::Is2MBAligned(len)) {
|
||||||
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 2MB aligned!");
|
LOG_ERROR(Kernel_Vmm, "Map size is either zero or not 2MB aligned!");
|
||||||
return ORBIS_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
|
@ -213,8 +213,6 @@ void MemoryManager::Free(PAddr phys_addr, size_t size) {
|
|||||||
int MemoryManager::PoolReserve(void** out_addr, VAddr virtual_addr, size_t size,
|
int MemoryManager::PoolReserve(void** out_addr, VAddr virtual_addr, size_t size,
|
||||||
MemoryMapFlags flags, u64 alignment) {
|
MemoryMapFlags flags, u64 alignment) {
|
||||||
std::scoped_lock lk{mutex};
|
std::scoped_lock lk{mutex};
|
||||||
|
|
||||||
virtual_addr = (virtual_addr == 0) ? impl.SystemManagedVirtualBase() : virtual_addr;
|
|
||||||
alignment = alignment > 0 ? alignment : 2_MB;
|
alignment = alignment > 0 ? alignment : 2_MB;
|
||||||
VAddr mapped_addr = alignment > 0 ? Common::AlignUp(virtual_addr, alignment) : virtual_addr;
|
VAddr mapped_addr = alignment > 0 ? Common::AlignUp(virtual_addr, alignment) : virtual_addr;
|
||||||
|
|
||||||
@ -234,6 +232,9 @@ int MemoryManager::PoolReserve(void** out_addr, VAddr virtual_addr, size_t size,
|
|||||||
|
|
||||||
// Find the first free area starting with provided virtual address.
|
// Find the first free area starting with provided virtual address.
|
||||||
if (False(flags & MemoryMapFlags::Fixed)) {
|
if (False(flags & MemoryMapFlags::Fixed)) {
|
||||||
|
// When MemoryMapFlags::Fixed is not specified, mappings default to searching for
|
||||||
|
// a free area starting from address 0x200000000 instead.
|
||||||
|
mapped_addr = mapped_addr < 0x200000000 ? 0x200000000 : mapped_addr;
|
||||||
mapped_addr = SearchFree(mapped_addr, size, alignment);
|
mapped_addr = SearchFree(mapped_addr, size, alignment);
|
||||||
if (mapped_addr == -1) {
|
if (mapped_addr == -1) {
|
||||||
// No suitable memory areas to map to
|
// No suitable memory areas to map to
|
||||||
|
Loading…
Reference in New Issue
Block a user