mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Some logging cleanup in kernel
This commit is contained in:
parent
f117cea4b9
commit
ff8b51e6b7
6 changed files with 74 additions and 134 deletions
|
@ -226,31 +226,31 @@ T hleDoLog(Log t, LogLevel level, T res, const char *file, int line, const char
|
||||||
#undef VERBOSE_LOG
|
#undef VERBOSE_LOG
|
||||||
#define VERBOSE_LOG DEBUG_LOG
|
#define VERBOSE_LOG DEBUG_LOG
|
||||||
#else
|
#else
|
||||||
#define HLE_LOG_LDEBUG LDEBUG
|
#define HLE_LOG_LDEBUG LogLevel::LDEBUG
|
||||||
#define HLE_LOG_LVERBOSE LVERBOSE
|
#define HLE_LOG_LVERBOSE LogLevel::LVERBOSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// IMPORTANT: These *must* only be used directly in HLE functions. They cannot be used by utility functions
|
// IMPORTANT: These *must* only be used directly in HLE functions. They cannot be used by utility functions
|
||||||
// called by them. Use regular ERROR_LOG etc for those.
|
// called by them. Use regular ERROR_LOG etc for those.
|
||||||
|
|
||||||
#define hleLogHelper(t, level, res, retmask, ...) hleDoLog(t, LogLevel::level, res, __FILE__, __LINE__, nullptr, retmask, ##__VA_ARGS__)
|
#define hleLogHelper(t, level, res, retmask, ...) hleDoLog(t, level, res, __FILE__, __LINE__, nullptr, retmask, ##__VA_ARGS__)
|
||||||
#define hleLogError(t, res, ...) hleLogHelper(t, LERROR, res, 'x', ##__VA_ARGS__)
|
#define hleLogError(t, res, ...) hleLogHelper(t, LogLevel::LERROR, res, 'x', ##__VA_ARGS__)
|
||||||
#define hleLogWarning(t, res, ...) hleLogHelper(t, LWARNING, res, 'x', ##__VA_ARGS__)
|
#define hleLogWarning(t, res, ...) hleLogHelper(t, LogLevel::LWARNING, res, 'x', ##__VA_ARGS__)
|
||||||
#define hleLogVerbose(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'x', ##__VA_ARGS__)
|
#define hleLogVerbose(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'x', ##__VA_ARGS__)
|
||||||
|
|
||||||
// If res is negative, log warn/error, otherwise log debug.
|
// If res is negative, log warn/error, otherwise log debug.
|
||||||
#define hleLogSuccessOrWarn(t, res, ...) hleLogHelper(t, res < 0 ? LWARNING : HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
#define hleLogSuccessOrWarn(t, res, ...) hleLogHelper(t, res < 0 ? LogLevel::LWARNING : HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
||||||
#define hleLogSuccessOrError(t, res, ...) hleLogHelper(t, res < 0 ? LERROR : HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
#define hleLogSuccessOrError(t, res, ...) hleLogHelper(t, res < 0 ? LogLevel::LERROR : HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
||||||
|
|
||||||
// NOTE: hleLogDebug is equivalent to hleLogSuccessI/X.
|
// NOTE: hleLogDebug is equivalent to hleLogSuccessI/X.
|
||||||
#define hleLogDebug(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
#define hleLogDebug(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
||||||
#define hleLogSuccessX(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
#define hleLogSuccessX(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
||||||
#define hleLogSuccessI(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'i', ##__VA_ARGS__)
|
#define hleLogSuccessI(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'i', ##__VA_ARGS__)
|
||||||
#define hleLogSuccessInfoX(t, res, ...) hleLogHelper(t, LINFO, res, 'x', ##__VA_ARGS__)
|
#define hleLogSuccessInfoX(t, res, ...) hleLogHelper(t, LogLevel::LINFO, res, 'x', ##__VA_ARGS__)
|
||||||
#define hleLogSuccessInfoI(t, res, ...) hleLogHelper(t, LINFO, res, 'i', ##__VA_ARGS__)
|
#define hleLogSuccessInfoI(t, res, ...) hleLogHelper(t, LogLevel::LINFO, res, 'i', ##__VA_ARGS__)
|
||||||
#define hleLogSuccessVerboseX(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'x', ##__VA_ARGS__)
|
#define hleLogSuccessVerboseX(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'x', ##__VA_ARGS__)
|
||||||
#define hleLogSuccessVerboseI(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'i', ##__VA_ARGS__)
|
#define hleLogSuccessVerboseI(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'i', ##__VA_ARGS__)
|
||||||
|
|
||||||
#define hleReportError(t, res, ...) hleDoLog(t, LogLevel::LERROR, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__)
|
#define hleReportError(t, res, ...) hleDoLog(t, LogLevel::LERROR, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__)
|
||||||
#define hleReportWarning(t, res, ...) hleDoLog(t, LogLevel::LWARNING, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__)
|
#define hleReportWarning(t, res, ...) hleDoLog(t, LogLevel::LWARNING, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__)
|
||||||
#define hleReportDebug(t, res, ...) hleDoLog(t, LogLevel::HLE_LOG_LDEBUG, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__)
|
#define hleReportDebug(t, res, ...) hleDoLog(t, HLE_LOG_LDEBUG, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__)
|
||||||
|
|
|
@ -453,18 +453,14 @@ static u32 sceAudioSRCOutputBlocking(u32 vol, u32 buf) {
|
||||||
|
|
||||||
static int sceAudioInputBlocking(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
|
static int sceAudioInputBlocking(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
|
||||||
if (!Memory::IsValidAddress(bufAddr)) {
|
if (!Memory::IsValidAddress(bufAddr)) {
|
||||||
ERROR_LOG(Log::HLE, "sceAudioInputBlocking(%d, %d, %08x): invalid addresses", maxSamples, sampleRate, bufAddr);
|
return hleLogError(Log::HLE, -1, "invalid address");
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
return hleLogSuccessInfoI(Log::HLE, __MicInput(maxSamples, sampleRate, bufAddr, AUDIOINPUT));
|
||||||
INFO_LOG(Log::HLE, "sceAudioInputBlocking: maxSamples: %d, samplerate: %d, bufAddr: %08x", maxSamples, sampleRate, bufAddr);
|
|
||||||
return __MicInput(maxSamples, sampleRate, bufAddr, AUDIOINPUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sceAudioInput(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
|
static int sceAudioInput(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
|
||||||
if (!Memory::IsValidAddress(bufAddr)) {
|
if (!Memory::IsValidAddress(bufAddr)) {
|
||||||
ERROR_LOG(Log::HLE, "sceAudioInput(%d, %d, %08x): invalid addresses", maxSamples, sampleRate, bufAddr);
|
return hleLogError(Log::HLE, -1, "invalid address");
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR_LOG(Log::HLE, "UNTEST sceAudioInput: maxSamples: %d, samplerate: %d, bufAddr: %08x", maxSamples, sampleRate, bufAddr);
|
ERROR_LOG(Log::HLE, "UNTEST sceAudioInput: maxSamples: %d, samplerate: %d, bufAddr: %08x", maxSamples, sampleRate, bufAddr);
|
||||||
|
|
|
@ -1625,37 +1625,32 @@ static u32 sceIoClose(int id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceIoRemove(const char *filename) {
|
static u32 sceIoRemove(const char *filename) {
|
||||||
DEBUG_LOG(Log::sceIo, "sceIoRemove(%s)", filename);
|
|
||||||
|
|
||||||
// TODO: This timing isn't necessarily accurate, low end for now.
|
// TODO: This timing isn't necessarily accurate, low end for now.
|
||||||
if(!pspFileSystem.GetFileInfo(filename).exists)
|
if (!pspFileSystem.GetFileInfo(filename).exists)
|
||||||
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file removed", 100);
|
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file removed", 100);
|
||||||
|
|
||||||
pspFileSystem.RemoveFile(filename);
|
pspFileSystem.RemoveFile(filename);
|
||||||
return hleDelayResult(0, "file removed", 100);
|
return hleDelayResult(hleLogDebug(Log::sceIo, 0), "file removed", 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceIoMkdir(const char *dirname, int mode) {
|
static u32 sceIoMkdir(const char *dirname, int mode) {
|
||||||
DEBUG_LOG(Log::sceIo, "sceIoMkdir(%s, %i)", dirname, mode);
|
|
||||||
// TODO: Improve timing.
|
// TODO: Improve timing.
|
||||||
if (pspFileSystem.MkDir(dirname))
|
if (pspFileSystem.MkDir(dirname))
|
||||||
return hleDelayResult(0, "mkdir", 1000);
|
return hleDelayResult(hleLogDebug(Log::sceIo, 0), "mkdir", 1000);
|
||||||
else
|
else
|
||||||
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS, "mkdir", 1000);
|
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS, "mkdir", 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceIoRmdir(const char *dirname) {
|
static u32 sceIoRmdir(const char *dirname) {
|
||||||
DEBUG_LOG(Log::sceIo, "sceIoRmdir(%s)", dirname);
|
|
||||||
// TODO: Improve timing.
|
// TODO: Improve timing.
|
||||||
if (pspFileSystem.RmDir(dirname))
|
if (pspFileSystem.RmDir(dirname))
|
||||||
return hleDelayResult(0, "rmdir", 1000);
|
return hleDelayResult(hleLogDebug(Log::sceIo, 0), "rmdir", 1000);
|
||||||
else
|
else
|
||||||
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "rmdir", 1000);
|
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "rmdir", 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceIoSync(const char *devicename, int flag) {
|
static u32 sceIoSync(const char *devicename, int flag) {
|
||||||
DEBUG_LOG(Log::sceIo, "UNIMPL sceIoSync(%s, %i)", devicename, flag);
|
return hleLogDebug(Log::sceIo, 0);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DeviceSize {
|
struct DeviceSize {
|
||||||
|
@ -2124,21 +2119,18 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceIoRename(const char *from, const char *to) {
|
static u32 sceIoRename(const char *from, const char *to) {
|
||||||
DEBUG_LOG(Log::sceIo, "sceIoRename(%s, %s)", from, to);
|
|
||||||
|
|
||||||
// TODO: Timing isn't terribly accurate.
|
// TODO: Timing isn't terribly accurate.
|
||||||
if (!pspFileSystem.GetFileInfo(from).exists)
|
if (!pspFileSystem.GetFileInfo(from).exists)
|
||||||
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file renamed", 1000);
|
return hleDelayResult(hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND), "file renamed", 1000);
|
||||||
|
|
||||||
int result = pspFileSystem.RenameFile(from, to);
|
int result = pspFileSystem.RenameFile(from, to);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
WARN_LOG(Log::sceIo, "Could not move %s to %s", from, to);
|
WARN_LOG(Log::sceIo, "Could not move %s to %s", from, to);
|
||||||
return hleDelayResult(result, "file renamed", 1000);
|
return hleDelayResult(hleLogDebug(Log::sceIo, result), "file renamed", 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceIoChdir(const char *dirname) {
|
static u32 sceIoChdir(const char *dirname) {
|
||||||
DEBUG_LOG(Log::sceIo, "sceIoChdir(%s)", dirname);
|
return hleLogDebug(Log::sceIo, pspFileSystem.ChDir(dirname));
|
||||||
return pspFileSystem.ChDir(dirname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sceIoChangeAsyncPriority(int id, int priority) {
|
static int sceIoChangeAsyncPriority(int id, int priority) {
|
||||||
|
@ -2187,21 +2179,15 @@ static int sceIoCloseAsync(int id) {
|
||||||
return hleLogSuccessI(Log::sceIo, 0);
|
return hleLogSuccessI(Log::sceIo, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceIoSetAsyncCallback(int id, u32 clbckId, u32 clbckArg)
|
static u32 sceIoSetAsyncCallback(int id, u32 clbckId, u32 clbckArg) {
|
||||||
{
|
|
||||||
DEBUG_LOG(Log::sceIo, "sceIoSetAsyncCallback(%d, %i, %08x)", id, clbckId, clbckArg);
|
|
||||||
|
|
||||||
u32 error;
|
u32 error;
|
||||||
FileNode *f = __IoGetFd(id, error);
|
FileNode *f = __IoGetFd(id, error);
|
||||||
if (f)
|
if (f) {
|
||||||
{
|
|
||||||
f->callbackID = clbckId;
|
f->callbackID = clbckId;
|
||||||
f->callbackArg = clbckArg;
|
f->callbackArg = clbckArg;
|
||||||
return 0;
|
return hleLogDebug(Log::sceIo, 0);
|
||||||
}
|
} else {
|
||||||
else
|
return hleLogError(Log::sceIo, error);
|
||||||
{
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2347,7 +2333,7 @@ static int sceIoWaitAsyncCB(int id, u32 address) {
|
||||||
FileNode *f = __IoGetFd(id, error);
|
FileNode *f = __IoGetFd(id, error);
|
||||||
if (f) {
|
if (f) {
|
||||||
if (__IsInInterrupt()) {
|
if (__IsInInterrupt()) {
|
||||||
return hleLogDebug(Log::sceIo, SCE_KERNEL_ERROR_ILLEGAL_CONTEXT, "illegal context");
|
return hleLogWarning(Log::sceIo, SCE_KERNEL_ERROR_ILLEGAL_CONTEXT, "illegal context");
|
||||||
}
|
}
|
||||||
|
|
||||||
hleCheckCurrentCallbacks();
|
hleCheckCurrentCallbacks();
|
||||||
|
@ -2515,9 +2501,8 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
|
||||||
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointer(dirent_addr);
|
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointer(dirent_addr);
|
||||||
|
|
||||||
if (dir->index == (int) dir->listing.size()) {
|
if (dir->index == (int) dir->listing.size()) {
|
||||||
DEBUG_LOG(Log::sceIo, "sceIoDread( %d %08x ) - end", id, dirent_addr);
|
|
||||||
entry->d_name[0] = '\0';
|
entry->d_name[0] = '\0';
|
||||||
return 0;
|
return hleLogDebug(Log::sceIo, 0, "end");
|
||||||
}
|
}
|
||||||
|
|
||||||
PSPFileInfo &info = dir->listing[dir->index];
|
PSPFileInfo &info = dir->listing[dir->index];
|
||||||
|
@ -2563,8 +2548,7 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_LOG(Log::sceIo, "sceIoDread - invalid listing %i, error %08x", id, error);
|
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_BADF, "invalid listing");
|
||||||
return SCE_KERNEL_ERROR_BADF;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2577,12 +2561,11 @@ int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 out
|
||||||
u32 error;
|
u32 error;
|
||||||
FileNode *f = __IoGetFd(id, error);
|
FileNode *f = __IoGetFd(id, error);
|
||||||
if (error) {
|
if (error) {
|
||||||
ERROR_LOG(Log::sceIo, "%08x=sceIoIoctl id: %08x, cmd %08x, bad file", error, id, cmd);
|
return hleLogError(Log::sceIo, error, "bad file");
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->asyncBusy()) {
|
if (f->asyncBusy()) {
|
||||||
ERROR_LOG(Log::sceIo, "%08x=sceIoIoctl id: %08x, cmd %08x, async busy", error, id, cmd);
|
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ASYNC_BUSY, "async busy");
|
||||||
return SCE_KERNEL_ERROR_ASYNC_BUSY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this into each command, probably?
|
// TODO: Move this into each command, probably?
|
||||||
|
@ -2607,7 +2590,7 @@ int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 out
|
||||||
memcpy(keybuf, Memory::GetPointerUnchecked(indataPtr), 16);
|
memcpy(keybuf, Memory::GetPointerUnchecked(indataPtr), 16);
|
||||||
key_ptr = keybuf;
|
key_ptr = keybuf;
|
||||||
}else{
|
}else{
|
||||||
key_ptr = NULL;
|
key_ptr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(Log::sceIo, "Decrypting PGD DRM files");
|
DEBUG_LOG(Log::sceIo, "Decrypting PGD DRM files");
|
||||||
|
@ -2618,13 +2601,11 @@ int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 out
|
||||||
f->npdrm = false;
|
f->npdrm = false;
|
||||||
pspFileSystem.SeekFile(f->handle, (s32)0, FILEMOVE_BEGIN);
|
pspFileSystem.SeekFile(f->handle, (s32)0, FILEMOVE_BEGIN);
|
||||||
if (memcmp(pgd_header, pgd_magic, 4) == 0) {
|
if (memcmp(pgd_header, pgd_magic, 4) == 0) {
|
||||||
ERROR_LOG(Log::sceIo, "%s is PGD file, but there's likely a key mismatch. Returning error.", f->fullpath.c_str());
|
|
||||||
// File is PGD file, but key mismatch
|
// File is PGD file, but key mismatch
|
||||||
return ERROR_PGD_INVALID_HEADER;
|
return hleLogError(Log::sceIo, ERROR_PGD_INVALID_HEADER, "%s is PGD file, but there's likely a key mismatch. Returning error.", f->fullpath.c_str());
|
||||||
} else {
|
} else {
|
||||||
INFO_LOG(Log::sceIo, "%s is not an encrypted PGD file as was expected. Proceeding.", f->fullpath.c_str());
|
|
||||||
// File is not encrypted.
|
// File is not encrypted.
|
||||||
return 0;
|
return hleLogSuccessInfoI(Log::sceIo, 0, "%s is not an encrypted PGD file as was expected. Proceeding.", f->fullpath.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Everything OK.
|
// Everything OK.
|
||||||
|
|
|
@ -376,8 +376,7 @@ u32 sceKernelGetGPI()
|
||||||
{
|
{
|
||||||
// Always returns 0 on production systems.
|
// Always returns 0 on production systems.
|
||||||
// On developer systems, there are 8 switches that control the lower 8 bits of the return value.
|
// On developer systems, there are 8 switches that control the lower 8 bits of the return value.
|
||||||
DEBUG_LOG(Log::sceKernel, "%d=sceKernelGetGPI()", g_GPIBits);
|
return hleLogDebug(Log::sceKernel, g_GPIBits);
|
||||||
return g_GPIBits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// #define LOG_CACHE
|
// #define LOG_CACHE
|
||||||
|
@ -407,10 +406,9 @@ int sceKernelDcacheInvalidateRange(u32 addr, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
int sceKernelIcacheInvalidateRange(u32 addr, int size) {
|
int sceKernelIcacheInvalidateRange(u32 addr, int size) {
|
||||||
DEBUG_LOG(Log::CPU, "sceKernelIcacheInvalidateRange(%08x, %i)", addr, size);
|
|
||||||
if (size != 0)
|
if (size != 0)
|
||||||
currentMIPS->InvalidateICache(addr, size);
|
currentMIPS->InvalidateICache(addr, size);
|
||||||
return 0;
|
return hleLogDebug(Log::CPU, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sceKernelDcacheWritebackAll()
|
int sceKernelDcacheWritebackAll()
|
||||||
|
@ -692,16 +690,14 @@ static u32 sceKernelReferThreadProfiler() {
|
||||||
// This seems to simply has no parameter:
|
// This seems to simply has no parameter:
|
||||||
// https://pspdev.github.io/pspsdk/group__ThreadMan.html#ga8fd30da51b9dc0507ac4dae04a7e4a17
|
// https://pspdev.github.io/pspsdk/group__ThreadMan.html#ga8fd30da51b9dc0507ac4dae04a7e4a17
|
||||||
// In testing it just returns null in around 140-150 cycles. See issue #17623.
|
// In testing it just returns null in around 140-150 cycles. See issue #17623.
|
||||||
DEBUG_LOG(Log::sceKernel, "0=sceKernelReferThreadProfiler()");
|
|
||||||
hleEatCycles(140);
|
hleEatCycles(140);
|
||||||
return 0;
|
return hleLogDebug(Log::sceKernel, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sceKernelReferGlobalProfiler() {
|
static int sceKernelReferGlobalProfiler() {
|
||||||
DEBUG_LOG(Log::sceKernel, "0=sceKernelReferGlobalProfiler()");
|
|
||||||
// See sceKernelReferThreadProfiler(), similar.
|
// See sceKernelReferThreadProfiler(), similar.
|
||||||
hleEatCycles(140);
|
hleEatCycles(140);
|
||||||
return 0;
|
return hleLogDebug(Log::sceKernel, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const HLEFunction ThreadManForUser[] =
|
const HLEFunction ThreadManForUser[] =
|
||||||
|
|
|
@ -145,7 +145,7 @@ void __KernelAlarmDoState(PointerWrap &p)
|
||||||
|
|
||||||
KernelObject *__KernelAlarmObject() {
|
KernelObject *__KernelAlarmObject() {
|
||||||
// Default object to load from state.
|
// Default object to load from state.
|
||||||
return new PSPAlarm;
|
return new PSPAlarm();
|
||||||
}
|
}
|
||||||
|
|
||||||
void __KernelScheduleAlarm(PSPAlarm *alarm, u64 micro) {
|
void __KernelScheduleAlarm(PSPAlarm *alarm, u64 micro) {
|
||||||
|
@ -169,10 +169,8 @@ static SceUID __KernelSetAlarm(u64 micro, u32 handlerPtr, u32 commonPtr)
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
SceUID sceKernelSetAlarm(SceUInt micro, u32 handlerPtr, u32 commonPtr)
|
SceUID sceKernelSetAlarm(SceUInt micro, u32 handlerPtr, u32 commonPtr) {
|
||||||
{
|
return hleLogDebug(Log::sceKernel, __KernelSetAlarm((u64) micro, handlerPtr, commonPtr));
|
||||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetAlarm(%d, %08x, %08x)", micro, handlerPtr, commonPtr);
|
|
||||||
return __KernelSetAlarm((u64) micro, handlerPtr, commonPtr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SceUID sceKernelSetSysClockAlarm(u32 microPtr, u32 handlerPtr, u32 commonPtr)
|
SceUID sceKernelSetSysClockAlarm(u32 microPtr, u32 handlerPtr, u32 commonPtr)
|
||||||
|
@ -184,33 +182,26 @@ SceUID sceKernelSetSysClockAlarm(u32 microPtr, u32 handlerPtr, u32 commonPtr)
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetSysClockAlarm(%lld, %08x, %08x)", micro, handlerPtr, commonPtr);
|
return hleLogDebug(Log::sceKernel, __KernelSetAlarm(micro, handlerPtr, commonPtr));
|
||||||
return __KernelSetAlarm(micro, handlerPtr, commonPtr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int sceKernelCancelAlarm(SceUID uid)
|
int sceKernelCancelAlarm(SceUID uid)
|
||||||
{
|
{
|
||||||
DEBUG_LOG(Log::sceKernel, "sceKernelCancelAlarm(%08x)", uid);
|
|
||||||
|
|
||||||
CoreTiming::UnscheduleEvent(alarmTimer, uid);
|
CoreTiming::UnscheduleEvent(alarmTimer, uid);
|
||||||
|
|
||||||
return kernelObjects.Destroy<PSPAlarm>(uid);
|
return hleLogDebug(Log::sceKernel, kernelObjects.Destroy<PSPAlarm>(uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr)
|
int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr)
|
||||||
{
|
{
|
||||||
u32 error;
|
u32 error;
|
||||||
PSPAlarm *alarm = kernelObjects.Get<PSPAlarm>(uid, error);
|
PSPAlarm *alarm = kernelObjects.Get<PSPAlarm>(uid, error);
|
||||||
if (!alarm)
|
if (!alarm) {
|
||||||
{
|
return hleLogError(Log::sceKernel, error, "invalid alarm", uid, infoPtr);
|
||||||
ERROR_LOG(Log::sceKernel, "sceKernelReferAlarmStatus(%08x, %08x): invalid alarm", uid, infoPtr);
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(Log::sceKernel, "sceKernelReferAlarmStatus(%08x, %08x)", uid, infoPtr);
|
|
||||||
|
|
||||||
if (!Memory::IsValidAddress(infoPtr))
|
if (!Memory::IsValidAddress(infoPtr))
|
||||||
return -1;
|
return hleLogError(Log::sceKernel, -1);
|
||||||
|
|
||||||
u32 size = Memory::Read_U32(infoPtr);
|
u32 size = Memory::Read_U32(infoPtr);
|
||||||
|
|
||||||
|
@ -224,5 +215,5 @@ int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr)
|
||||||
if (size > 16)
|
if (size > 16)
|
||||||
Memory::Write_U32(alarm->alm.commonPtr, infoPtr + 16);
|
Memory::Write_U32(alarm->alm.commonPtr, infoPtr + 16);
|
||||||
|
|
||||||
return 0;
|
return hleLogDebug(Log::sceKernel, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,15 +113,13 @@ static void sceKernelCpuResumeIntr(u32 enable)
|
||||||
static int sceKernelIsCpuIntrEnable()
|
static int sceKernelIsCpuIntrEnable()
|
||||||
{
|
{
|
||||||
u32 retVal = __InterruptsEnabled();
|
u32 retVal = __InterruptsEnabled();
|
||||||
DEBUG_LOG(Log::sceIntc, "%i=sceKernelIsCpuIntrEnable()", retVal);
|
return hleLogDebug(Log::sceIntc, retVal);
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sceKernelIsCpuIntrSuspended(int flag)
|
static int sceKernelIsCpuIntrSuspended(int flag)
|
||||||
{
|
{
|
||||||
int retVal = flag == 0 ? 1 : 0;
|
int retVal = flag == 0 ? 1 : 0;
|
||||||
DEBUG_LOG(Log::sceIntc, "%i=sceKernelIsCpuIntrSuspended(%d)", retVal, flag);
|
return hleLogDebug(Log::sceIntc, retVal);
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sceKernelCpuResumeIntrWithSync(u32 enable)
|
static void sceKernelCpuResumeIntrWithSync(u32 enable)
|
||||||
|
@ -132,8 +130,7 @@ static void sceKernelCpuResumeIntrWithSync(u32 enable)
|
||||||
bool IntrHandler::run(PendingInterrupt& pend)
|
bool IntrHandler::run(PendingInterrupt& pend)
|
||||||
{
|
{
|
||||||
SubIntrHandler *handler = get(pend.subintr);
|
SubIntrHandler *handler = get(pend.subintr);
|
||||||
if (handler == NULL)
|
if (!handler) {
|
||||||
{
|
|
||||||
WARN_LOG(Log::sceIntc, "Ignoring interrupt, already been released.");
|
WARN_LOG(Log::sceIntc, "Ignoring interrupt, already been released.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -496,87 +493,73 @@ int __ReleaseSubIntrHandler(int intrNumber, int subIntrNumber) {
|
||||||
|
|
||||||
u32 sceKernelRegisterSubIntrHandler(u32 intrNumber, u32 subIntrNumber, u32 handler, u32 handlerArg) {
|
u32 sceKernelRegisterSubIntrHandler(u32 intrNumber, u32 subIntrNumber, u32 handler, u32 handlerArg) {
|
||||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelRegisterSubIntrHandler(%i, %i, %08x, %08x): invalid interrupt", intrNumber, subIntrNumber, handler, handlerArg);
|
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt");
|
||||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
|
||||||
}
|
}
|
||||||
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelRegisterSubIntrHandler(%i, %i, %08x, %08x): invalid subinterrupt", intrNumber, subIntrNumber, handler, handlerArg);
|
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid subinterrupt");
|
||||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 error;
|
u32 error;
|
||||||
SubIntrHandler *subIntrHandler = __RegisterSubIntrHandler(intrNumber, subIntrNumber, handler, handlerArg, error);
|
SubIntrHandler *subIntrHandler = __RegisterSubIntrHandler(intrNumber, subIntrNumber, handler, handlerArg, error);
|
||||||
if (subIntrHandler) {
|
if (subIntrHandler) {
|
||||||
if (handler == 0) {
|
if (handler == 0) {
|
||||||
WARN_LOG_REPORT(Log::sceIntc, "sceKernelRegisterSubIntrHandler(%i, %i, %08x, %08x): ignored NULL handler", intrNumber, subIntrNumber, handler, handlerArg);
|
return hleLogWarning(Log::sceIntc, error, "ignored NULL handler");
|
||||||
} else {
|
} else {
|
||||||
DEBUG_LOG(Log::sceIntc, "sceKernelRegisterSubIntrHandler(%i, %i, %08x, %08x)", intrNumber, subIntrNumber, handler, handlerArg);
|
return hleLogDebug(Log::sceIntc, error);
|
||||||
}
|
}
|
||||||
} else if (error == SCE_KERNEL_ERROR_FOUND_HANDLER) {
|
} else if (error == SCE_KERNEL_ERROR_FOUND_HANDLER) {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelRegisterSubIntrHandler(%i, %i, %08x, %08x): duplicate handler", intrNumber, subIntrNumber, handler, handlerArg);
|
return hleReportError(Log::sceIntc, error, "duplicate handler");
|
||||||
} else {
|
} else {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelRegisterSubIntrHandler(%i, %i, %08x, %08x): error %08x", intrNumber, subIntrNumber, handler, handlerArg, error);
|
return hleReportError(Log::sceIntc, error);
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 sceKernelReleaseSubIntrHandler(u32 intrNumber, u32 subIntrNumber) {
|
u32 sceKernelReleaseSubIntrHandler(u32 intrNumber, u32 subIntrNumber) {
|
||||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelReleaseSubIntrHandler(%i, %i): invalid interrupt", intrNumber, subIntrNumber);
|
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt");
|
||||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
|
||||||
}
|
}
|
||||||
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelReleaseSubIntrHandler(%i, %i): invalid subinterrupt", intrNumber, subIntrNumber);
|
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid subinterrupt");
|
||||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 error = __ReleaseSubIntrHandler(intrNumber, subIntrNumber);
|
u32 error = __ReleaseSubIntrHandler(intrNumber, subIntrNumber);
|
||||||
if (error != SCE_KERNEL_ERROR_OK) {
|
return hleLogSuccessOrError(Log::sceIntc, error);
|
||||||
ERROR_LOG(Log::sceIntc, "sceKernelReleaseSubIntrHandler(%i, %i): error %08x", intrNumber, subIntrNumber, error);
|
|
||||||
}
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 sceKernelEnableSubIntr(u32 intrNumber, u32 subIntrNumber) {
|
u32 sceKernelEnableSubIntr(u32 intrNumber, u32 subIntrNumber) {
|
||||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelEnableSubIntr(%i, %i): invalid interrupt", intrNumber, subIntrNumber);
|
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt");
|
||||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
|
||||||
}
|
}
|
||||||
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelEnableSubIntr(%i, %i): invalid subinterrupt", intrNumber, subIntrNumber);
|
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid subinterrupt");
|
||||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(Log::sceIntc, "sceKernelEnableSubIntr(%i, %i)", intrNumber, subIntrNumber);
|
|
||||||
u32 error;
|
u32 error;
|
||||||
if (!intrHandlers[intrNumber]->has(subIntrNumber)) {
|
if (!intrHandlers[intrNumber]->has(subIntrNumber)) {
|
||||||
// Enableing a handler before registering it works fine.
|
// Enabling a handler before registering it works fine.
|
||||||
__RegisterSubIntrHandler(intrNumber, subIntrNumber, 0, 0, error);
|
__RegisterSubIntrHandler(intrNumber, subIntrNumber, 0, 0, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
intrHandlers[intrNumber]->enable(subIntrNumber);
|
intrHandlers[intrNumber]->enable(subIntrNumber);
|
||||||
return 0;
|
return hleLogDebug(Log::sceIntc, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceKernelDisableSubIntr(u32 intrNumber, u32 subIntrNumber) {
|
static u32 sceKernelDisableSubIntr(u32 intrNumber, u32 subIntrNumber) {
|
||||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelDisableSubIntr(%i, %i): invalid interrupt", intrNumber, subIntrNumber);
|
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt");
|
||||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
|
||||||
}
|
}
|
||||||
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
||||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelDisableSubIntr(%i, %i): invalid subinterrupt", intrNumber, subIntrNumber);
|
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid subinterrupt");
|
||||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_LOG(Log::sceIntc, "sceKernelDisableSubIntr(%i, %i)", intrNumber, subIntrNumber);
|
|
||||||
|
|
||||||
if (!intrHandlers[intrNumber]->has(subIntrNumber)) {
|
if (!intrHandlers[intrNumber]->has(subIntrNumber)) {
|
||||||
// Disabling when not registered is not an error.
|
// Disabling when not registered is not an error.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
intrHandlers[intrNumber]->disable(subIntrNumber);
|
intrHandlers[intrNumber]->disable(subIntrNumber);
|
||||||
return 0;
|
return hleLogDebug(Log::sceIntc, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -605,10 +588,8 @@ static int QueryIntrHandlerInfo()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceKernelMemset(u32 addr, u32 fillc, u32 n)
|
static u32 sceKernelMemset(u32 addr, u32 fillc, u32 n) {
|
||||||
{
|
|
||||||
u8 c = fillc & 0xff;
|
u8 c = fillc & 0xff;
|
||||||
DEBUG_LOG(Log::sceIntc, "sceKernelMemset(ptr = %08x, c = %02x, n = %08x)", addr, c, n);
|
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
if (n != 0) {
|
if (n != 0) {
|
||||||
if (Memory::IsVRAMAddress(addr)) {
|
if (Memory::IsVRAMAddress(addr)) {
|
||||||
|
@ -619,13 +600,10 @@ static u32 sceKernelMemset(u32 addr, u32 fillc, u32 n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NotifyMemInfo(MemBlockFlags::WRITE, addr, n, "KernelMemset");
|
NotifyMemInfo(MemBlockFlags::WRITE, addr, n, "KernelMemset");
|
||||||
return addr;
|
return hleLogDebug(Log::sceIntc, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
|
static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size) {
|
||||||
{
|
|
||||||
DEBUG_LOG(Log::sceKernel, "sceKernelMemcpy(dest=%08x, src=%08x, size=%i)", dst, src, size);
|
|
||||||
|
|
||||||
// Some games copy from executable code. We need to flush emuhack ops.
|
// Some games copy from executable code. We need to flush emuhack ops.
|
||||||
if (size != 0)
|
if (size != 0)
|
||||||
currentMIPS->InvalidateICache(src, size);
|
currentMIPS->InvalidateICache(src, size);
|
||||||
|
@ -636,16 +614,14 @@ static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Technically should crash if these are invalid and size > 0...
|
// Technically should crash if these are invalid and size > 0...
|
||||||
if (!skip && Memory::IsValidAddress(dst) && Memory::IsValidAddress(src) && Memory::IsValidAddress(dst + size - 1) && Memory::IsValidAddress(src + size - 1))
|
if (!skip && Memory::IsValidAddress(dst) && Memory::IsValidAddress(src) && Memory::IsValidAddress(dst + size - 1) && Memory::IsValidAddress(src + size - 1)) {
|
||||||
{
|
|
||||||
u8 *dstp = Memory::GetPointerWriteUnchecked(dst);
|
u8 *dstp = Memory::GetPointerWriteUnchecked(dst);
|
||||||
const u8 *srcp = Memory::GetPointerUnchecked(src);
|
const u8 *srcp = Memory::GetPointerUnchecked(src);
|
||||||
|
|
||||||
// If it's non-overlapping, just do it in one go.
|
// If it's non-overlapping, just do it in one go.
|
||||||
if (dst + size < src || src + size < dst)
|
if (dst + size < src || src + size < dst) {
|
||||||
memcpy(dstp, srcp, size);
|
memcpy(dstp, srcp, size);
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
// Try to handle overlapped copies with similar properties to hardware, just in case.
|
// Try to handle overlapped copies with similar properties to hardware, just in case.
|
||||||
// Not that anyone ought to rely on it.
|
// Not that anyone ought to rely on it.
|
||||||
for (u32 size64 = size / 8; size64 > 0; --size64)
|
for (u32 size64 = size / 8; size64 > 0; --size64)
|
||||||
|
@ -663,7 +639,7 @@ static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
|
||||||
NotifyMemInfoCopy(dst, src, size, "KernelMemcpy/");
|
NotifyMemInfoCopy(dst, src, size, "KernelMemcpy/");
|
||||||
}
|
}
|
||||||
|
|
||||||
return dst;
|
return hleLogDebug(Log::sceKernel, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
const HLEFunction Kernel_Library[] =
|
const HLEFunction Kernel_Library[] =
|
||||||
|
|
Loading…
Add table
Reference in a new issue