1 // Copyright (c) 2012- PPSSPP Project.
2 
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0 or later versions.
6 
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 // GNU General Public License 2.0 for more details.
11 
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
14 
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17 
18 #pragma once
19 
20 #include "../Util/BlockAllocator.h"
21 #include "sceKernel.h"
22 
23 enum MemblockType
24 {
25 	PSP_SMEM_Low = 0,
26 	PSP_SMEM_High = 1,
27 	PSP_SMEM_Addr = 2,
28 	PSP_SMEM_LowAligned = 3,
29 	PSP_SMEM_HighAligned = 4,
30 };
31 
32 extern BlockAllocator userMemory;
33 extern BlockAllocator kernelMemory;
34 
35 void __KernelMemoryInit();
36 void __KernelMemoryDoState(PointerWrap &p);
37 void __KernelMemoryShutdown();
38 KernelObject *__KernelMemoryFPLObject();
39 KernelObject *__KernelMemoryVPLObject();
40 KernelObject *__KernelMemoryPMBObject();
41 KernelObject *__KernelTlsplObject();
42 
43 SceUID sceKernelCreateVpl(const char *name, int partition, u32 attr, u32 vplSize, u32 optPtr);
44 int sceKernelDeleteVpl(SceUID uid);
45 int sceKernelAllocateVpl(SceUID uid, u32 size, u32 addrPtr, u32 timeoutPtr);
46 int sceKernelAllocateVplCB(SceUID uid, u32 size, u32 addrPtr, u32 timeoutPtr);
47 int sceKernelTryAllocateVpl(SceUID uid, u32 size, u32 addrPtr);
48 int sceKernelFreeVpl(SceUID uid, u32 addr);
49 int sceKernelCancelVpl(SceUID uid, u32 numWaitThreadsPtr);
50 int sceKernelReferVplStatus(SceUID uid, u32 infoPtr);
51 
52 int sceKernelCreateFpl(const char *name, u32 mpid, u32 attr, u32 blocksize, u32 numBlocks, u32 optPtr);
53 int sceKernelDeleteFpl(SceUID uid);
54 int sceKernelAllocateFpl(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr);
55 int sceKernelAllocateFplCB(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr);
56 int sceKernelTryAllocateFpl(SceUID uid, u32 blockPtrAddr);
57 int sceKernelFreeFpl(SceUID uid, u32 blockPtr);
58 int sceKernelCancelFpl(SceUID uid, u32 numWaitThreadsPtr);
59 int sceKernelReferFplStatus(SceUID uid, u32 statusPtr);
60 
61 int sceKernelGetCompiledSdkVersion();
62 
63 SceUID sceKernelCreateTlspl(const char *name, u32 partitionid, u32 attr, u32 size, u32 count, u32 optionsPtr);
64 int sceKernelDeleteTlspl(SceUID uid);
65 int sceKernelGetTlsAddr(SceUID uid);
66 int sceKernelFreeTlspl(SceUID uid);
67 int sceKernelReferTlsplStatus(SceUID uid, u32 infoPtr);
68 
69 void Register_SysMemUserForUser();
70 
71 int sceKernelAllocPartitionMemory(int partition, const char *name, int type, u32 size, u32 addr);
72 int sceKernelFreePartitionMemory(SceUID id);
73 u32 sceKernelGetBlockHeadAddr(SceUID id);
74