diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index d603443199..bee423bf13 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -888,15 +888,6 @@ int sceKernelReferFplStatus(SceUID uid, u32 statusPtr) ////////////////////////////////////////////////////////////////////////// //00:49:12 ector, well the partitions are 1 = kernel, 2 = user, 3 = me, 4 = kernel mirror :) -enum MemblockType -{ - PSP_SMEM_Low = 0, - PSP_SMEM_High = 1, - PSP_SMEM_Addr = 2, - PSP_SMEM_LowAligned = 3, - PSP_SMEM_HighAligned = 4, -}; - class PartitionMemoryBlock : public KernelObject { public: diff --git a/Core/HLE/sceKernelMemory.h b/Core/HLE/sceKernelMemory.h index b19e592578..dce6df77e0 100644 --- a/Core/HLE/sceKernelMemory.h +++ b/Core/HLE/sceKernelMemory.h @@ -20,11 +20,14 @@ #include "../Util/BlockAllocator.h" #include "sceKernel.h" - -//todo: "real" memory block allocator, -// have elf loader grab its memory block first to avoid overwriting, -// etc - +enum MemblockType +{ + PSP_SMEM_Low = 0, + PSP_SMEM_High = 1, + PSP_SMEM_Addr = 2, + PSP_SMEM_LowAligned = 3, + PSP_SMEM_HighAligned = 4, +}; extern BlockAllocator userMemory; extern BlockAllocator kernelMemory; diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index ef74c30aac..d692a2bc30 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -970,6 +970,8 @@ Module *__KernelLoadELFFromPtr(const u8 *ptr, u32 loadAddress, bool fromTop, std module->nm.segmentsize[i] = reader.GetSegmentMemSize(i); if (module->nm.segmentsize[i] != 0) { module->nm.segmentaddr[i] = reader.GetSegmentVaddr(i); + } else { + module->nm.segmentaddr[i] = 0; } } module->nm.data_size += reader.GetSegmentDataSize(i); @@ -1667,15 +1669,15 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) SceKernelLMOption *lmoption = 0; if (optionAddr) { lmoption = (SceKernelLMOption *)Memory::GetPointer(optionAddr); - if (lmoption->position < 0 || lmoption->position > 4) { + if (lmoption->position < PSP_SMEM_Low || lmoption->position > PSP_SMEM_HighAligned) { ERROR_LOG_REPORT(LOADER, "sceKernelLoadModule(%s): invalid position", name, lmoption->position); return SCE_KERNEL_ERROR_ILLEGAL_MEMBLOCKTYPE; } - if (lmoption->position == 3 || lmoption->position == 4) { + if (lmoption->position == PSP_SMEM_LowAligned || lmoption->position == PSP_SMEM_HighAligned) { ERROR_LOG_REPORT(LOADER, "sceKernelLoadModule(%s): invalid position (aligned)", name, lmoption->position); return SCE_KERNEL_ERROR_ILLEGAL_ALIGNMENT_SIZE; } - if (lmoption->position == 2) { + if (lmoption->position == PSP_SMEM_Addr) { ERROR_LOG_REPORT(LOADER, "sceKernelLoadModule(%s): invalid position (fixed)", name, lmoption->position); return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; }