Partially implement KUBridge, trying to help #8925. However, it doesn't even call the function.... Odd.

This commit is contained in:
Henrik Rydgard 2016-08-28 11:41:41 +02:00 committed by Henrik Rydgård
parent c78dcb4c54
commit d3305b88b9
7 changed files with 89 additions and 8 deletions

View file

@ -182,6 +182,7 @@
<ClCompile Include="..\ext\udis86\syn.c" />
<ClCompile Include="..\ext\udis86\udis86.c" />
<ClCompile Include="AVIDump.cpp" />
<ClCompile Include="HLE\KUBridge.cpp" />
<ClCompile Include="MIPS\IR\IRAsm.cpp" />
<ClCompile Include="MIPS\IR\IRCompALU.cpp" />
<ClCompile Include="MIPS\IR\IRCompBranch.cpp" />
@ -522,6 +523,7 @@
<ClInclude Include="..\ext\udis86\udint.h" />
<ClInclude Include="..\ext\udis86\udis86.h" />
<ClInclude Include="AVIDump.h" />
<ClInclude Include="HLE\KUBridge.h" />
<ClInclude Include="MIPS\IR\IRFrontend.h" />
<ClInclude Include="MIPS\IR\IRInst.h" />
<ClInclude Include="MIPS\IR\IRInterpreter.h" />
@ -759,4 +761,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View file

@ -677,6 +677,9 @@
<Filter>Core</Filter>
</ClCompile>
<ClCompile Include="WaveFile.cpp" />
<ClCompile Include="HLE\KUBridge.cpp">
<Filter>HLE\Libraries</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ELF\ElfReader.h">
@ -1244,10 +1247,13 @@
<Filter>Core</Filter>
</ClInclude>
<ClInclude Include="WaveFile.h" />
<ClInclude Include="HLE\KUBridge.h">
<Filter>HLE\Libraries</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
<None Include="..\LICENSE.TXT" />
<None Include="..\android\jni\Android.mk" />
</ItemGroup>
</Project>
</Project>

View file

@ -74,6 +74,7 @@
#include "sceAdler.h"
#include "sceSfmt19937.h"
#include "sceG729.h"
#include "KUBridge.h"
#define N(s) s
@ -266,12 +267,12 @@ void RegisterAllModules() {
Register_sceAudiocodec();
Register_sceHeap();
for (int i = 0; i < numModules; i++)
{
for (int i = 0; i < numModules; i++) {
RegisterModule(moduleList[i].name, moduleList[i].numFunctions, moduleList[i].funcTable);
}
// New modules have to be added at the end, or they will break savestates.
// IMPORTANT: New modules have to be added at the end, or they will break savestates.
Register_StdioForKernel();
RegisterModule("LoadCoreForKernel", ARRAY_SIZE(LoadCoreForKernel), LoadCoreForKernel);
Register_IoFileMgrForKernel();
@ -292,5 +293,8 @@ void RegisterAllModules() {
Register_sceG729();
Register_sceNetUpnp();
Register_sceNetIfhandle();
Register_KUBridge();
// add new modules here.
}

47
Core/HLE/KUBridge.cpp Normal file
View file

@ -0,0 +1,47 @@
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
// KUBridge seems to be some utility module that comes with some custom firmware for PSP,
// providing the ability to call some kernel-only functions from user mode.
// A few homebrew applications use this. We only simulate a small subset of the functionality for now.
#include "Core/HLE/HLE.h"
#include "Core/HLE/FunctionWrappers.h"
#include "Core/HLE/KUBridge.h"
#include "Core/HLE/sceKernelModule.h"
#include "Core/Config.h"
static int kuKernelLoadModule(const char *path, uint32_t flags, uint32_t lmOptionAddr) {
INFO_LOG(HLE, "kuKernelLoadModule - forwarding to sceKernelLoadModule");
// Simply forward the call, like JPSCP does.
return sceKernelLoadModule(path, flags, lmOptionAddr);
}
static int kuKernelGetModel() {
INFO_LOG(HLE, "kuKernelGetModel()");
return g_Config.iPSPModel;
}
const HLEFunction KUBridge[] =
{
{ 0x4C25EA72, &WrapI_CUU<kuKernelLoadModule>, "kuKernelLoadModule", 'i', "cuu" },
{ 0x24331850, &WrapI_V<kuKernelGetModel>, "kuKernelGetModel", 'i', "" },
};
void Register_KUBridge() {
RegisterModule("KUBridge", ARRAY_SIZE(KUBridge), KUBridge);
}

20
Core/HLE/KUBridge.h Normal file
View file

@ -0,0 +1,20 @@
// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
void Register_KUBridge();

View file

@ -1678,8 +1678,7 @@ int sceKernelLoadExec(const char *filename, u32 paramPtr)
return 0;
}
static u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
if (!name) {
return hleLogError(LOADER, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "bad filename");
}

View file

@ -44,4 +44,7 @@ void __KernelReturnFromModuleFunc();
u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus);
void Register_ModuleMgrForUser();
void Register_ModuleMgrForKernel();
void Register_ModuleMgrForKernel();
// Expose for use by KUBridge.
u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr);