Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLE: sceKernelAllocPartitionMemory volatile memory support (partition 5) #16052

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Core/HLE/sceKernelMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const int TLSPL_NUM_INDEXES = 16;
// STATE BEGIN
BlockAllocator userMemory(256);
BlockAllocator kernelMemory(256);
BlockAllocator volatileMemory(256);

static int vplWaitTimer = -1;
static int fplWaitTimer = -1;
Expand Down Expand Up @@ -432,6 +433,7 @@ void __KernelMemoryInit()
MemBlockInfoInit();
kernelMemory.Init(PSP_GetKernelMemoryBase(), PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase(), false);
userMemory.Init(PSP_GetUserMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase(), false);
volatileMemory.Init(PSP_GetVolatileMemoryStart(), PSP_GetVolatileMemoryEnd() - PSP_GetVolatileMemoryStart(), false);
ParallelMemset(&g_threadManager, Memory::GetPointerWrite(PSP_GetKernelMemoryBase()), 0, PSP_GetUserMemoryEnd() - PSP_GetKernelMemoryBase());
NotifyMemInfo(MemBlockFlags::WRITE, PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetKernelMemoryBase(), "MemInit");
INFO_LOG(SCEKERNEL, "Kernel and user memory pools initialized");
Expand Down Expand Up @@ -463,6 +465,7 @@ void __KernelMemoryDoState(PointerWrap &p)

kernelMemory.DoState(p);
userMemory.DoState(p);
volatileMemory.DoState(p);

Do(p, vplWaitTimer);
CoreTiming::RestoreRegisterEvent(vplWaitTimer, "VplTimeout", __KernelVplTimeout);
Expand All @@ -481,6 +484,11 @@ void __KernelMemoryDoState(PointerWrap &p)

void __KernelMemoryShutdown()
{
#ifdef _DEBUG
INFO_LOG(SCEKERNEL, "Shutting down volatile memory pool: ");
volatileMemory.ListBlocks();
#endif
volatileMemory.Shutdown();
#ifdef _DEBUG
INFO_LOG(SCEKERNEL,"Shutting down user memory pool: ");
userMemory.ListBlocks();
Expand Down Expand Up @@ -1021,7 +1029,7 @@ int sceKernelAllocPartitionMemory(int partition, const char *name, int type, u32
return SCE_KERNEL_ERROR_ILLEGAL_ALIGNMENT_SIZE;
}

PartitionMemoryBlock *block = new PartitionMemoryBlock(&userMemory, name, size, (MemblockType)type, addr);
PartitionMemoryBlock *block = new PartitionMemoryBlock((partition == 5) ? &volatileMemory : &userMemory, name, size, (MemblockType)type, addr);
if (!block->IsValid())
{
delete block;
Expand Down