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 <string>
21 #include "Core/HLE/sceKernel.h"
22 
23 struct PspModuleInfo {
24 	u16_le moduleAttrs; //0x0000 User Mode, 0x1000 Kernel Mode
25 	u16_le moduleVersion;
26 	// 28 bytes of module name, packed with 0's.
27 	char name[28];
28 	u32_le gp;               // ptr to MIPS GOT data  (global offset table)
29 	u32_le libent;           // ptr to .lib.ent section
30 	u32_le libentend;        // ptr to end of .lib.ent section
31 	u32_le libstub;          // ptr to .lib.stub section
32 	u32_le libstubend;       // ptr to end of .lib.stub section
33 };
34 
35 class PointerWrap;
36 struct SceKernelSMOption;
37 
38 KernelObject *__KernelModuleObject();
39 void __KernelModuleDoState(PointerWrap &p);
40 void __KernelModuleShutdown();
41 
42 u32 __KernelGetModuleGP(SceUID module);
43 bool KernelModuleIsKernelMode(SceUID module);
44 bool __KernelLoadGEDump(const std::string &base_filename, std::string *error_string);
45 bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_string);
46 void __KernelGPUReplay();
47 void __KernelReturnFromModuleFunc();
48 SceUID KernelLoadModule(const std::string &filename, std::string *error_string);
49 int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, SceKernelSMOption *smoption, bool *needsWait);
50 u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus);
51 u32 sceKernelFindModuleByUID(u32 uid);
52 
53 void Register_ModuleMgrForUser();
54 void Register_ModuleMgrForKernel();
55 
56 // Expose for use by KUBridge.
57 u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr);
58