From f2bdea74bee37e3d2c32798a3e8cf2f5c7c1fd09 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 3 Mar 2013 20:20:49 -0800 Subject: [PATCH] Don't align size to grain for PMB. --- Core/HLE/sceKernelMemory.cpp | 2 +- Core/Util/BlockAllocator.cpp | 8 +++++--- Core/Util/BlockAllocator.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 60149b6cfe..16b5ac3bcb 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -427,7 +427,7 @@ public: address = alloc->AllocAt(alignment, size, name); } else if (type == PSP_SMEM_LowAligned || type == PSP_SMEM_HighAligned) - address = alloc->AllocAligned(size, alignment, type == PSP_SMEM_HighAligned, name); + address = alloc->AllocAligned(size, 0x100, alignment, type == PSP_SMEM_HighAligned, name); else address = alloc->Alloc(size, type == PSP_SMEM_High, name); alloc->ListBlocks(); diff --git a/Core/Util/BlockAllocator.cpp b/Core/Util/BlockAllocator.cpp index 666fd3e213..24809fe1be 100644 --- a/Core/Util/BlockAllocator.cpp +++ b/Core/Util/BlockAllocator.cpp @@ -45,7 +45,7 @@ void BlockAllocator::Shutdown() blocks.clear(); } -u32 BlockAllocator::AllocAligned(u32 &size, u32 grain, bool fromTop, const char *tag) +u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromTop, const char *tag) { // Sanity check if (size == 0 || size > rangeSize_) { @@ -56,9 +56,11 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 grain, bool fromTop, const char // It could be off step, but the grain should generally be a power of 2. if (grain < grain_) grain = grain_; + if (sizeGrain < grain_) + sizeGrain = grain_; // upalign size to grain - size = (size + grain - 1) & ~(grain - 1); + size = (size + sizeGrain - 1) & ~(sizeGrain - 1); if (!fromTop) { @@ -128,7 +130,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 grain, bool fromTop, const char u32 BlockAllocator::Alloc(u32 &size, bool fromTop, const char *tag) { // We want to make sure it's aligned in case AllocAt() was used. - return AllocAligned(size, grain_, fromTop, tag); + return AllocAligned(size, grain_, grain_, fromTop, tag); } u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) diff --git a/Core/Util/BlockAllocator.h b/Core/Util/BlockAllocator.h index b385fedcb9..a4354b6dbb 100644 --- a/Core/Util/BlockAllocator.h +++ b/Core/Util/BlockAllocator.h @@ -40,7 +40,7 @@ public: // WARNING: size can be modified upwards! u32 Alloc(u32 &size, bool fromTop = false, const char *tag = 0); - u32 AllocAligned(u32 &size, u32 grain, bool fromTop = false, const char *tag = 0); + u32 AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromTop = false, const char *tag = 0); u32 AllocAt(u32 position, u32 size, const char *tag = 0); bool Free(u32 position);