mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-27 18:30:56 +00:00
Log kernel syscalls with a K.
This way they can be properly differentiated.
This commit is contained in:
parent
46fb7e7444
commit
4b4770bbc5
@ -349,17 +349,19 @@ u64 hleDelayResult(u64 result, const char *reason, int usec)
|
||||
return result;
|
||||
}
|
||||
|
||||
void hleEatCycles(int cycles)
|
||||
{
|
||||
void hleEatCycles(int cycles) {
|
||||
// Maybe this should Idle, at least for larger delays? Could that cause issues?
|
||||
currentMIPS->downcount -= cycles;
|
||||
}
|
||||
|
||||
void hleEatMicro(int usec)
|
||||
{
|
||||
void hleEatMicro(int usec) {
|
||||
hleEatCycles((int) usToCycles(usec));
|
||||
}
|
||||
|
||||
bool hleIsKernelMode() {
|
||||
return latestSyscall && (latestSyscall->flags & HLE_KERNEL_SYSCALL) != 0;
|
||||
}
|
||||
|
||||
const static u32 deadbeefRegs[12] = {0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF};
|
||||
inline static void SetDeadbeefRegs()
|
||||
{
|
||||
@ -675,31 +677,32 @@ void hleDoLogInternal(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, u64 res,
|
||||
|
||||
const char *fmt;
|
||||
if (retmask == 'x') {
|
||||
fmt = "%08llx=%s(%s)%s";
|
||||
fmt = "%s%08llx=%s(%s)%s";
|
||||
// Truncate the high bits of the result (from any sign extension.)
|
||||
res = (u32)res;
|
||||
} else if (retmask == 'i' || retmask == 'I') {
|
||||
fmt = "%lld=%s(%s)%s";
|
||||
fmt = "%s%lld=%s(%s)%s";
|
||||
} else if (retmask == 'f') {
|
||||
// TODO: For now, floats are just shown as bits.
|
||||
fmt = "%08x=%s(%s)%s";
|
||||
fmt = "%s%08x=%s(%s)%s";
|
||||
} else {
|
||||
_assert_msg_(HLE, false, "Invalid return format: %c", retmask);
|
||||
fmt = "%08llx=%s(%s)%s";
|
||||
fmt = "%s%08llx=%s(%s)%s";
|
||||
}
|
||||
|
||||
GenericLog(level, t, file, line, fmt, res, latestSyscall->name, formatted_args, formatted_reason);
|
||||
const char *kernelFlag = (latestSyscall->flags & HLE_KERNEL_SYSCALL) != 0 ? "K " : "";
|
||||
GenericLog(level, t, file, line, fmt, kernelFlag, res, latestSyscall->name, formatted_args, formatted_reason);
|
||||
|
||||
if (reportTag != nullptr) {
|
||||
// A blank string means always log, not just once.
|
||||
if (reportTag[0] == '\0' || Reporting::ShouldLogOnce(reportTag)) {
|
||||
// Here we want the original key, so that different args, etc. group together.
|
||||
std::string key = std::string("%08x=") + latestSyscall->name + "(%s)";
|
||||
std::string key = std::string(kernelFlag) + std::string("%08x=") + latestSyscall->name + "(%s)";
|
||||
if (reason != nullptr)
|
||||
key += std::string(": ") + reason;
|
||||
|
||||
char formatted_message[8192];
|
||||
snprintf(formatted_message, sizeof(formatted_message), fmt, res, latestSyscall->name, formatted_args, formatted_reason);
|
||||
snprintf(formatted_message, sizeof(formatted_message), fmt, kernelFlag, res, latestSyscall->name, formatted_args, formatted_reason);
|
||||
Reporting::ReportMessageFormatted(key.c_str(), formatted_message);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,9 @@ enum {
|
||||
// Don't allow the call if dispatch or interrupts are disabled.
|
||||
HLE_NOT_DISPATCH_SUSPENDED = 1 << 9,
|
||||
// Indicates the call should write zeros to the stack (stackBytesToClear in the table.)
|
||||
HLE_CLEAR_STACK_BYTES = 1 << 10
|
||||
HLE_CLEAR_STACK_BYTES = 1 << 10,
|
||||
// Indicates that this call operates in kernel mode.
|
||||
HLE_KERNEL_SYSCALL = 1 < 11,
|
||||
};
|
||||
|
||||
struct HLEFunction
|
||||
@ -116,6 +118,8 @@ void hleDebugBreak();
|
||||
void hleSkipDeadbeef();
|
||||
// Set time spent in debugger (for more useful debug stats while debugging.)
|
||||
void hleSetSteppingTime(double t);
|
||||
// Check if the current syscall context is kernel.
|
||||
bool hleIsKernelMode();
|
||||
|
||||
// Delays the result for usec microseconds, allowing other threads to run during this time.
|
||||
u32 hleDelayResult(u32 result, const char *reason, int usec);
|
||||
|
@ -180,7 +180,7 @@ const HLEFunction LoadCoreForKernel[] =
|
||||
{0XB4D6FECC, nullptr, "sceKernelApplyElfRelSection", '?', "" },
|
||||
{0X54AB2675, nullptr, "sceKernelApplyPspRelSection", '?', "" },
|
||||
{0X2952F5AC, nullptr, "sceKernelDcacheWBinvAll", '?', "" },
|
||||
{0XD8779AC6, &WrapU_V<sceKernelIcacheClearAll>, "sceKernelIcacheClearAll", 'x', "" },
|
||||
{0xD8779AC6, &WrapU_V<sceKernelIcacheClearAll>, "sceKernelIcacheClearAll", 'x', "", HLE_KERNEL_SYSCALL },
|
||||
{0X99A695F0, nullptr, "sceKernelRegisterLibrary", '?', "" },
|
||||
{0X5873A31F, nullptr, "sceKernelRegisterLibraryForUser", '?', "" },
|
||||
{0X0B464512, nullptr, "sceKernelReleaseLibrary", '?', "" },
|
||||
@ -202,7 +202,7 @@ const HLEFunction LoadCoreForKernel[] =
|
||||
{0XCCE4A157, nullptr, "sceKernelFindModuleByUID", '?', "" },
|
||||
{0X82CE54ED, nullptr, "sceKernelModuleCount", '?', "" },
|
||||
{0XC0584F0C, nullptr, "sceKernelGetModuleList", '?', "" },
|
||||
{0XCF8A41B1, &WrapU_C<sceKernelFindModuleByName>, "sceKernelFindModuleByName", 'x', "s" },
|
||||
{0XCF8A41B1, &WrapU_C<sceKernelFindModuleByName>, "sceKernelFindModuleByName", 'x', "s", HLE_KERNEL_SYSCALL },
|
||||
{0XB95FA50D, nullptr, "LoadCoreForKernel_B95FA50D", '?', "" },
|
||||
};
|
||||
|
||||
@ -213,7 +213,7 @@ const HLEFunction KDebugForKernel[] =
|
||||
{0X2FF4E9F9, nullptr, "sceKernelAssert", '?', "" },
|
||||
{0X9B868276, nullptr, "sceKernelGetDebugPutchar", '?', "" },
|
||||
{0XE146606D, nullptr, "sceKernelRegisterDebugPutchar", '?', "" },
|
||||
{0X7CEB2C09, &WrapU_V<sceKernelRegisterKprintfHandler>, "sceKernelRegisterKprintfHandler", 'x', "" },
|
||||
{0X7CEB2C09, &WrapU_V<sceKernelRegisterKprintfHandler>, "sceKernelRegisterKprintfHandler", 'x', "", HLE_KERNEL_SYSCALL },
|
||||
{0X84F370BC, nullptr, "Kprintf", '?', "" },
|
||||
{0X5CE9838B, nullptr, "sceKernelDebugWrite", '?', "" },
|
||||
{0X66253C4E, nullptr, "sceKernelRegisterDebugWrite", '?', "" },
|
||||
|
@ -671,24 +671,6 @@ static int sceKernelReferGlobalProfiler(u32 statusPtr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ThreadManForKernel_446d8de6(const char *threadName, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr)
|
||||
{
|
||||
WARN_LOG(SCEKERNEL,"ThreadManForKernel_446d8de6:Not support this patcher");
|
||||
return sceKernelCreateThread(threadName, entry, prio, stacksize, attr, optionAddr);
|
||||
}
|
||||
|
||||
static int ThreadManForKernel_f475845d(SceUID threadToStartID, int argSize, u32 argBlockPtr)
|
||||
{
|
||||
WARN_LOG(SCEKERNEL,"ThreadManForKernel_f475845d:Not support this patcher");
|
||||
return sceKernelStartThread(threadToStartID,argSize,argBlockPtr);
|
||||
}
|
||||
|
||||
static int ThreadManForKernel_ceadeb47(u32 usec)
|
||||
{
|
||||
WARN_LOG(SCEKERNEL,"ThreadManForKernel_ceadeb47:Not support this patcher");
|
||||
return sceKernelDelayThread(usec);
|
||||
}
|
||||
|
||||
const HLEFunction ThreadManForUser[] =
|
||||
{
|
||||
{0X55C20A00, &WrapI_CUUU<sceKernelCreateEventFlag>, "sceKernelCreateEventFlag", 'i', "sxxx" },
|
||||
@ -873,9 +855,9 @@ const HLEFunction ThreadManForUser[] =
|
||||
|
||||
const HLEFunction ThreadManForKernel[] =
|
||||
{
|
||||
{0XCEADEB47, &WrapI_U<ThreadManForKernel_ceadeb47>, "ThreadManForKernel_ceadeb47", 'i', "x" },
|
||||
{0X446D8DE6, &WrapI_CUUIUU<ThreadManForKernel_446d8de6>, "ThreadManForKernel_446d8de6", 'i', "sxxixx" },//Not sure right
|
||||
{0XF475845D, &WrapI_IIU<ThreadManForKernel_f475845d>, "ThreadManForKernel_f475845d", 'i', "iix" },//Not sure right
|
||||
{0xCEADEB47, &WrapI_U<sceKernelDelayThread>, "sceKernelDelayThread", 'i', "x", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED | HLE_KERNEL_SYSCALL },
|
||||
{0x446D8DE6, &WrapI_CUUIUU<sceKernelCreateThread>, "sceKernelCreateThread", 'i', "sxxixx", HLE_NOT_IN_INTERRUPT | HLE_KERNEL_SYSCALL },
|
||||
{0xF475845D, &WrapI_IIU<sceKernelStartThread>, "sceKernelStartThread", 'i', "iix", HLE_NOT_IN_INTERRUPT | HLE_KERNEL_SYSCALL },
|
||||
};
|
||||
|
||||
void Register_ThreadManForUser()
|
||||
@ -898,16 +880,10 @@ void Register_LoadExecForUser()
|
||||
{
|
||||
RegisterModule("LoadExecForUser", ARRAY_SIZE(LoadExecForUser), LoadExecForUser);
|
||||
}
|
||||
|
||||
static int LoadExecForKernel_4AC57943(SceUID cbId)
|
||||
{
|
||||
WARN_LOG(SCEKERNEL,"LoadExecForKernel_4AC57943:Not support this patcher");
|
||||
return sceKernelRegisterExitCallback(cbId);//not sure right
|
||||
}
|
||||
|
||||
const HLEFunction LoadExecForKernel[] =
|
||||
{
|
||||
{0X4AC57943, &WrapI_I<LoadExecForKernel_4AC57943>, "LoadExecForKernel_4AC57943", 'i', "i" },
|
||||
{0x4AC57943, &WrapI_I<sceKernelRegisterExitCallback>, "sceKernelRegisterExitCallback", 'i', "i", HLE_KERNEL_SYSCALL },
|
||||
{0XA3D5E142, nullptr, "LoadExecForKernel_a3d5e142", '?', "" },
|
||||
};
|
||||
|
||||
@ -927,7 +903,7 @@ const HLEFunction ExceptionManagerForKernel[] =
|
||||
{
|
||||
{0X3FB264FC, nullptr, "sceKernelRegisterExceptionHandler", '?', "" },
|
||||
{0X5A837AD4, nullptr, "sceKernelRegisterPriorityExceptionHandler", '?', "" },
|
||||
{0x565C0B0E, &WrapI_V<sceKernelRegisterDefaultExceptionHandler>, "sceKernelRegisterDefaultExceptionHandler", 'i', "" },
|
||||
{0x565C0B0E, &WrapI_V<sceKernelRegisterDefaultExceptionHandler>, "sceKernelRegisterDefaultExceptionHandler", 'i', "", HLE_KERNEL_SYSCALL },
|
||||
{0X1AA6CFFA, nullptr, "sceKernelReleaseExceptionHandler", '?', "" },
|
||||
{0XDF83875E, nullptr, "sceKernelGetActiveDefaultExceptionHandler", '?', "" },
|
||||
{0X291FF031, nullptr, "sceKernelReleaseDefaultExceptionHandler", '?', "" },
|
||||
@ -947,7 +923,7 @@ void Register_ExceptionManagerForKernel()
|
||||
|
||||
// Seen in some homebrew
|
||||
const HLEFunction UtilsForKernel[] = {
|
||||
{0XC2DF770E, WrapI_UI<sceKernelIcacheInvalidateRange>, "sceKernelIcacheInvalidateRange", '?', "" },
|
||||
{0xC2DF770E, WrapI_UI<sceKernelIcacheInvalidateRange>, "sceKernelIcacheInvalidateRange", '?', "", HLE_KERNEL_SYSCALL },
|
||||
{0X78934841, nullptr, "sceKernelGzipDecompress", '?', "" },
|
||||
{0XE8DB3CE6, nullptr, "sceKernelDeflateDecompress", '?', "" },
|
||||
{0X840259F1, nullptr, "sceKernelUtilsSha1Digest", '?', "" },
|
||||
|
@ -729,14 +729,14 @@ static u32 sysclib_memset(u32 destAddr, int data, int size) {
|
||||
|
||||
const HLEFunction SysclibForKernel[] =
|
||||
{
|
||||
{0XAB7592FF, &WrapU_UUU<sysclib_memcpy>, "memcpy", 'x', "xxx" },
|
||||
{0X476FD94A, &WrapU_UU<sysclib_strcat>, "strcat", 'x', "xx" },
|
||||
{0XC0AB8932, &WrapI_UU<sysclib_strcmp>, "strcmp", 'i', "xx" },
|
||||
{0XEC6F1CF2, &WrapU_UU<sysclib_strcpy>, "strcpy", 'x', "xx" },
|
||||
{0X52DF196C, &WrapU_U<sysclib_strlen>, "strlen", 'x', "x" },
|
||||
{0X81D0D1F7, &WrapI_UUU<sysclib_memcmp>, "memcmp", 'i', "xxx" },
|
||||
{0X7661E728, &WrapI_UU<sysclib_sprintf>, "sprintf", 'i', "xx" },
|
||||
{0X10F3BB61, &WrapU_UII<sysclib_memset>, "memset", 'x', "xii" },
|
||||
{0xAB7592FF, &WrapU_UUU<sysclib_memcpy>, "memcpy", 'x', "xxx", HLE_KERNEL_SYSCALL },
|
||||
{0x476FD94A, &WrapU_UU<sysclib_strcat>, "strcat", 'x', "xx", HLE_KERNEL_SYSCALL },
|
||||
{0xC0AB8932, &WrapI_UU<sysclib_strcmp>, "strcmp", 'i', "xx", HLE_KERNEL_SYSCALL },
|
||||
{0xEC6F1CF2, &WrapU_UU<sysclib_strcpy>, "strcpy", 'x', "xx", HLE_KERNEL_SYSCALL },
|
||||
{0x52DF196C, &WrapU_U<sysclib_strlen>, "strlen", 'x', "x", HLE_KERNEL_SYSCALL },
|
||||
{0x81D0D1F7, &WrapI_UUU<sysclib_memcmp>, "memcmp", 'i', "xxx", HLE_KERNEL_SYSCALL },
|
||||
{0x7661E728, &WrapI_UU<sysclib_sprintf>, "sprintf", 'i', "xx", HLE_KERNEL_SYSCALL },
|
||||
{0x10F3BB61, &WrapU_UII<sysclib_memset>, "memset", 'x', "xii", HLE_KERNEL_SYSCALL },
|
||||
};
|
||||
|
||||
void Register_Kernel_Library()
|
||||
|
@ -2326,22 +2326,8 @@ static u32 sceKernelGetModuleIdList(u32 resultBuffer, u32 resultBufferSize, u32
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 ModuleMgrForKernel_977de386(const char *name, u32 flags, u32 optionAddr)
|
||||
{
|
||||
WARN_LOG(SCEMODULE,"ModuleMgrForKernel_977de386:Not support this patcher");
|
||||
return sceKernelLoadModule(name, flags, optionAddr);
|
||||
}
|
||||
|
||||
static void ModuleMgrForKernel_50f0c1ec(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, u32 optionAddr)
|
||||
{
|
||||
WARN_LOG(SCEMODULE,"ModuleMgrForKernel_50f0c1ec:Not support this patcher");
|
||||
sceKernelStartModule(moduleId, argsize, argAddr, returnValueAddr, optionAddr);
|
||||
}
|
||||
|
||||
//fix for tiger x dragon
|
||||
static u32 ModuleMgrForKernel_a1a78c58(const char *name, u32 flags, u32 optionAddr)
|
||||
{
|
||||
WARN_LOG(SCEMODULE,"ModuleMgrForKernel_a1a78c58:Not support this patcher");
|
||||
static u32 sceKernelLoadModuleForLoadExecVSHDisc(const char *name, u32 flags, u32 optionAddr) {
|
||||
return sceKernelLoadModule(name, flags, optionAddr);
|
||||
}
|
||||
|
||||
@ -2370,11 +2356,11 @@ const HLEFunction ModuleMgrForUser[] =
|
||||
|
||||
const HLEFunction ModuleMgrForKernel[] =
|
||||
{
|
||||
{0X50F0C1EC, &WrapV_UUUUU<ModuleMgrForKernel_50f0c1ec>, "ModuleMgrForKernel_50f0c1ec", 'v', "xxxxx" },//Not sure right
|
||||
{0X977DE386, &WrapU_CUU<ModuleMgrForKernel_977de386>, "ModuleMgrForKernel_977de386", 'x', "sxx" },//Not sure right
|
||||
{0XA1A78C58, &WrapU_CUU<ModuleMgrForKernel_a1a78c58>, "ModuleMgrForKernel_a1a78c58", 'x', "sxx" }, //fix for tiger x dragon
|
||||
{0X748CBED9, &WrapU_UU<sceKernelQueryModuleInfo>, "sceKernelQueryModuleInfo", 'x', "xx" },//Bugz Homebrew
|
||||
{0X644395E2, &WrapU_UUU<sceKernelGetModuleIdList>, "sceKernelGetModuleIdList", 'x', "xxx" },//Bugz Homebrew
|
||||
{0x50F0C1EC, &WrapV_UUUUU<sceKernelStartModule>, "sceKernelStartModule", 'v', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED | HLE_KERNEL_SYSCALL },
|
||||
{0x977DE386, &WrapU_CUU<sceKernelLoadModule>, "sceKernelLoadModule", 'x', "sxx", HLE_KERNEL_SYSCALL },
|
||||
{0xA1A78C58, &WrapU_CUU<sceKernelLoadModuleForLoadExecVSHDisc>, "sceKernelLoadModuleForLoadExecVSHDisc", 'x', "sxx", HLE_KERNEL_SYSCALL }, //fix for tiger x dragon
|
||||
{0x748CBED9, &WrapU_UU<sceKernelQueryModuleInfo>, "sceKernelQueryModuleInfo", 'x', "xx", HLE_KERNEL_SYSCALL },
|
||||
{0x644395E2, &WrapU_UUU<sceKernelGetModuleIdList>, "sceKernelGetModuleIdList", 'x', "xxx", HLE_KERNEL_SYSCALL },
|
||||
};
|
||||
|
||||
void Register_ModuleMgrForUser()
|
||||
|
Loading…
Reference in New Issue
Block a user