mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #19890 from hrydgard/hle-prepare-recursion
HLE: Convert a lot more logging to the "automatic" parameter logging system
This commit is contained in:
commit
b92d822efe
29 changed files with 556 additions and 826 deletions
|
@ -692,7 +692,7 @@ std::string ChoiceWithValueDisplay::ValueText() const {
|
|||
}
|
||||
|
||||
FileChooserChoice::FileChooserChoice(RequesterToken token, std::string *value, std::string_view text, BrowseFileType fileType, LayoutParams *layoutParams)
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value), fileType_(fileType), token_(token) {
|
||||
: AbstractChoiceWithValueDisplay(text, layoutParams), value_(value) {
|
||||
OnClick.Add([=](UI::EventParams &) {
|
||||
System_BrowseForFile(token, text_, fileType, [=](const std::string &returnValue, int) {
|
||||
if (*value_ != returnValue) {
|
||||
|
|
|
@ -430,8 +430,6 @@ public:
|
|||
|
||||
private:
|
||||
std::string *value_;
|
||||
BrowseFileType fileType_;
|
||||
RequesterToken token_;
|
||||
};
|
||||
|
||||
class FolderChooserChoice : public AbstractChoiceWithValueDisplay {
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
#include "Common/Log.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (error: 4834) // discarding return value of function with 'nodiscard' attribute
|
||||
#endif
|
||||
|
||||
class PointerWrap;
|
||||
class PSPAction;
|
||||
typedef void (* HLEFunc)();
|
||||
|
@ -136,10 +140,12 @@ void hleSplitSyscallOverGe();
|
|||
// Called after a split syscall from System.cpp
|
||||
void hleFinishSyscallAfterGe();
|
||||
|
||||
[[nodiscard]]
|
||||
inline int hleDelayResult(int result, const char *reason, int usec) {
|
||||
return hleDelayResult((u32) result, reason, usec);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline s64 hleDelayResult(s64 result, const char *reason, int usec) {
|
||||
return hleDelayResult((u64) result, reason, usec);
|
||||
}
|
||||
|
@ -164,6 +170,7 @@ void *GetQuickSyscallFunc(MIPSOpcode op);
|
|||
void hleDoLogInternal(Log t, LogLevel level, u64 res, const char *file, int line, const char *reportTag, char retmask, const char *reason, const char *formatted_reason);
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]]
|
||||
T hleDoLog(Log t, LogLevel level, T res, const char *file, int line, const char *reportTag, char retmask, const char *reason, ...) {
|
||||
if ((int)level > MAX_LOGLEVEL || !GenericLogEnabled(level, t)) {
|
||||
return res;
|
||||
|
@ -192,6 +199,7 @@ T hleDoLog(Log t, LogLevel level, T res, const char *file, int line, const char
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]]
|
||||
T hleDoLog(Log t, LogLevel level, T res, const char *file, int line, const char *reportTag, char retmask) {
|
||||
if (((int)level > MAX_LOGLEVEL || !GenericLogEnabled(level, t)) && !reportTag) {
|
||||
return res;
|
||||
|
@ -208,6 +216,14 @@ T hleDoLog(Log t, LogLevel level, T res, const char *file, int line, const char
|
|||
return res;
|
||||
}
|
||||
|
||||
// These will become important later.
|
||||
template <typename T>
|
||||
[[nodiscard]]
|
||||
inline T hleNoLog(T t) {
|
||||
return t;
|
||||
}
|
||||
inline void hleNoLogVoid() {}
|
||||
|
||||
// This is just a quick way to force logging to be more visible for one file.
|
||||
#ifdef HLE_LOG_FORCE
|
||||
#define HLE_LOG_LDEBUG LNOTICE
|
||||
|
@ -218,22 +234,31 @@ T hleDoLog(Log t, LogLevel level, T res, const char *file, int line, const char
|
|||
#undef VERBOSE_LOG
|
||||
#define VERBOSE_LOG DEBUG_LOG
|
||||
#else
|
||||
#define HLE_LOG_LDEBUG LDEBUG
|
||||
#define HLE_LOG_LVERBOSE LVERBOSE
|
||||
#define HLE_LOG_LDEBUG LogLevel::LDEBUG
|
||||
#define HLE_LOG_LVERBOSE LogLevel::LVERBOSE
|
||||
#endif
|
||||
|
||||
#define hleLogHelper(t, level, res, retmask, ...) hleDoLog(t, LogLevel::level, res, __FILE__, __LINE__, nullptr, retmask, ##__VA_ARGS__)
|
||||
#define hleLogError(t, res, ...) hleLogHelper(t, LERROR, res, 'x', ##__VA_ARGS__)
|
||||
#define hleLogWarning(t, res, ...) hleLogHelper(t, LWARNING, res, 'x', ##__VA_ARGS__)
|
||||
#define hleLogDebug(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
||||
// 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.
|
||||
|
||||
#define hleLogHelper(t, level, res, retmask, ...) hleDoLog(t, level, res, __FILE__, __LINE__, nullptr, retmask, ##__VA_ARGS__)
|
||||
#define hleLogError(t, res, ...) hleLogHelper(t, LogLevel::LERROR, 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__)
|
||||
|
||||
// If res is negative, log warn/error, otherwise log debug.
|
||||
#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 ? LogLevel::LERROR : HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
|
||||
|
||||
// NOTE: hleLogDebug is equivalent to hleLogSuccessI/X.
|
||||
#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 hleLogSuccessI(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'i', ##__VA_ARGS__)
|
||||
#define hleLogSuccessInfoX(t, res, ...) hleLogHelper(t, LINFO, res, 'x', ##__VA_ARGS__)
|
||||
#define hleLogSuccessInfoI(t, res, ...) hleLogHelper(t, LINFO, res, 'i', ##__VA_ARGS__)
|
||||
#define hleLogSuccessInfoX(t, res, ...) hleLogHelper(t, LogLevel::LINFO, res, 'x', ##__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 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 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__)
|
||||
|
|
|
@ -190,7 +190,7 @@ bool Load() {
|
|||
continue;
|
||||
}
|
||||
|
||||
int ret = KernelStartModule(module, 0, 0, 0, nullptr, nullptr);
|
||||
int ret = __KernelStartModule(module, 0, 0, 0, nullptr, nullptr);
|
||||
if (ret < 0) {
|
||||
ERROR_LOG(Log::System, "Unable to start plugin %s: %08x", filename.c_str(), ret);
|
||||
} else {
|
||||
|
|
|
@ -86,86 +86,68 @@ void AudioChannel::clear()
|
|||
// max or 50%?
|
||||
static u32 sceAudioOutputBlocking(u32 chan, int vol, u32 samplePtr) {
|
||||
if (vol > 0xFFFF) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutputBlocking() - invalid volume");
|
||||
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_VOLUME, "invalid volume");
|
||||
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutputBlocking() - bad channel");
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_CHANNEL, "bad channel");
|
||||
} else if (!chans[chan].reserved) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutputBlocking() - channel not reserved");
|
||||
return SCE_ERROR_AUDIO_CHANNEL_NOT_INIT;
|
||||
} else {
|
||||
DEBUG_LOG(Log::sceAudio, "sceAudioOutputBlocking(%08x, %08x, %08x)", chan, vol, samplePtr);
|
||||
if (vol >= 0) {
|
||||
chans[chan].leftVolume = vol;
|
||||
chans[chan].rightVolume = vol;
|
||||
}
|
||||
chans[chan].sampleAddress = samplePtr;
|
||||
return __AudioEnqueue(chans[chan], chan, true);
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_CHANNEL_NOT_INIT, "channel not reserved");
|
||||
}
|
||||
|
||||
if (vol >= 0) {
|
||||
chans[chan].leftVolume = vol;
|
||||
chans[chan].rightVolume = vol;
|
||||
}
|
||||
chans[chan].sampleAddress = samplePtr;
|
||||
return hleLogDebug(Log::sceAudio, __AudioEnqueue(chans[chan], chan, true));
|
||||
}
|
||||
|
||||
static u32 sceAudioOutputPannedBlocking(u32 chan, int leftvol, int rightvol, u32 samplePtr) {
|
||||
int result = 0;
|
||||
// For some reason, this is the only one that checks for negative.
|
||||
if (leftvol > 0xFFFF || rightvol > 0xFFFF || leftvol < 0 || rightvol < 0) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutputPannedBlocking() - invalid volume");
|
||||
result = SCE_ERROR_AUDIO_INVALID_VOLUME;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_VOLUME, "invalid volume");
|
||||
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutputPannedBlocking() - bad channel");
|
||||
result = SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_CHANNEL, "bad channel");
|
||||
} else if (!chans[chan].reserved) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutputPannedBlocking() - channel not reserved");
|
||||
result = SCE_ERROR_AUDIO_CHANNEL_NOT_INIT;
|
||||
} else {
|
||||
if (leftvol >= 0) {
|
||||
chans[chan].leftVolume = leftvol;
|
||||
}
|
||||
if (rightvol >= 0) {
|
||||
chans[chan].rightVolume = rightvol;
|
||||
}
|
||||
chans[chan].sampleAddress = samplePtr;
|
||||
result = __AudioEnqueue(chans[chan], chan, true);
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_CHANNEL_NOT_INIT, "channel not reserved");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceAudio, "%08x = sceAudioOutputPannedBlocking(%08x, %08x, %08x, %08x)", result, chan, leftvol, rightvol, samplePtr);
|
||||
return result;
|
||||
|
||||
if (leftvol >= 0) {
|
||||
chans[chan].leftVolume = leftvol;
|
||||
}
|
||||
if (rightvol >= 0) {
|
||||
chans[chan].rightVolume = rightvol;
|
||||
}
|
||||
chans[chan].sampleAddress = samplePtr;
|
||||
u32 result = __AudioEnqueue(chans[chan], chan, true);
|
||||
return hleLogDebug(Log::sceAudio, result);
|
||||
}
|
||||
|
||||
static u32 sceAudioOutput(u32 chan, int vol, u32 samplePtr) {
|
||||
if (vol > 0xFFFF) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutput() - invalid volume");
|
||||
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_VOLUME, "invalid volume");
|
||||
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutput() - bad channel");
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_CHANNEL, "bad channel");
|
||||
} else if (!chans[chan].reserved) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutput(%08x, %08x, %08x) - channel not reserved", chan, vol, samplePtr);
|
||||
return SCE_ERROR_AUDIO_CHANNEL_NOT_INIT;
|
||||
} else {
|
||||
DEBUG_LOG(Log::sceAudio, "sceAudioOutput(%08x, %08x, %08x)", chan, vol, samplePtr);
|
||||
if (vol >= 0) {
|
||||
chans[chan].leftVolume = vol;
|
||||
chans[chan].rightVolume = vol;
|
||||
}
|
||||
chans[chan].sampleAddress = samplePtr;
|
||||
return __AudioEnqueue(chans[chan], chan, false);
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_CHANNEL_NOT_INIT, "channel not reserved");
|
||||
}
|
||||
|
||||
if (vol >= 0) {
|
||||
chans[chan].leftVolume = vol;
|
||||
chans[chan].rightVolume = vol;
|
||||
}
|
||||
chans[chan].sampleAddress = samplePtr;
|
||||
u32 result = __AudioEnqueue(chans[chan], chan, false);
|
||||
return hleLogDebug(Log::sceAudio, result);
|
||||
}
|
||||
|
||||
static u32 sceAudioOutputPanned(u32 chan, int leftvol, int rightvol, u32 samplePtr) {
|
||||
if (leftvol > 0xFFFF || rightvol > 0xFFFF) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutputPanned() - invalid volume");
|
||||
return SCE_ERROR_AUDIO_INVALID_VOLUME;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_VOLUME, "invalid volume");
|
||||
} else if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutputPanned() - bad channel");
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_CHANNEL, "bad channel");
|
||||
} else if (!chans[chan].reserved) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioOutputPanned(%08x, %08x, %08x, %08x) - channel not reserved", chan, leftvol, rightvol, samplePtr);
|
||||
return SCE_ERROR_AUDIO_CHANNEL_NOT_INIT;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_CHANNEL_NOT_INIT, "channel not reserved");
|
||||
} else {
|
||||
DEBUG_LOG(Log::sceAudio, "sceAudioOutputPanned(%08x, %08x, %08x, %08x)", chan, leftvol, rightvol, samplePtr);
|
||||
if (leftvol >= 0) {
|
||||
chans[chan].leftVolume = leftvol;
|
||||
}
|
||||
|
@ -173,28 +155,25 @@ static u32 sceAudioOutputPanned(u32 chan, int leftvol, int rightvol, u32 sampleP
|
|||
chans[chan].rightVolume = rightvol;
|
||||
}
|
||||
chans[chan].sampleAddress = samplePtr;
|
||||
return __AudioEnqueue(chans[chan], chan, false);
|
||||
u32 result = __AudioEnqueue(chans[chan], chan, false);
|
||||
return hleLogDebug(Log::sceAudio, result);
|
||||
}
|
||||
}
|
||||
|
||||
static int sceAudioGetChannelRestLen(u32 chan) {
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioGetChannelRestLen(%08x) - bad channel", chan);
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_CHANNEL, "bad channel");
|
||||
}
|
||||
int remainingSamples = (int)chanSampleQueues[chan].size() / 2;
|
||||
VERBOSE_LOG(Log::sceAudio, "%d=sceAudioGetChannelRestLen(%08x)", remainingSamples, chan);
|
||||
return remainingSamples;
|
||||
return hleLogVerbose(Log::sceAudio, remainingSamples);
|
||||
}
|
||||
|
||||
static int sceAudioGetChannelRestLength(u32 chan) {
|
||||
if (chan >= PSP_AUDIO_CHANNEL_MAX) {
|
||||
ERROR_LOG(Log::sceAudio, "sceAudioGetChannelRestLength(%08x) - bad channel", chan);
|
||||
return SCE_ERROR_AUDIO_INVALID_CHANNEL;
|
||||
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_INVALID_CHANNEL, "bad channel");
|
||||
}
|
||||
int remainingSamples = (int)chanSampleQueues[chan].size() / 2;
|
||||
VERBOSE_LOG(Log::sceAudio, "%d=sceAudioGetChannelRestLength(%08x)", remainingSamples, chan);
|
||||
return remainingSamples;
|
||||
return hleLogVerbose(Log::sceAudio, remainingSamples);
|
||||
}
|
||||
|
||||
static u32 GetFreeChannel() {
|
||||
|
@ -474,18 +453,14 @@ static u32 sceAudioSRCOutputBlocking(u32 vol, u32 buf) {
|
|||
|
||||
static int sceAudioInputBlocking(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
|
||||
if (!Memory::IsValidAddress(bufAddr)) {
|
||||
ERROR_LOG(Log::HLE, "sceAudioInputBlocking(%d, %d, %08x): invalid addresses", maxSamples, sampleRate, bufAddr);
|
||||
return -1;
|
||||
return hleLogError(Log::HLE, -1, "invalid address");
|
||||
}
|
||||
|
||||
INFO_LOG(Log::HLE, "sceAudioInputBlocking: maxSamples: %d, samplerate: %d, bufAddr: %08x", maxSamples, sampleRate, bufAddr);
|
||||
return __MicInput(maxSamples, sampleRate, bufAddr, AUDIOINPUT);
|
||||
return hleLogSuccessInfoI(Log::HLE, __MicInput(maxSamples, sampleRate, bufAddr, AUDIOINPUT));
|
||||
}
|
||||
|
||||
static int sceAudioInput(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
|
||||
if (!Memory::IsValidAddress(bufAddr)) {
|
||||
ERROR_LOG(Log::HLE, "sceAudioInput(%d, %d, %08x): invalid addresses", maxSamples, sampleRate, bufAddr);
|
||||
return -1;
|
||||
return hleLogError(Log::HLE, -1, "invalid address");
|
||||
}
|
||||
|
||||
ERROR_LOG(Log::HLE, "UNTEST sceAudioInput: maxSamples: %d, samplerate: %d, bufAddr: %08x", maxSamples, sampleRate, bufAddr);
|
||||
|
|
|
@ -514,8 +514,7 @@ static int sceCtrlReadBufferPositive(u32 ctrlDataPtr, u32 nBufs)
|
|||
{
|
||||
int done = __CtrlReadBuffer(ctrlDataPtr, nBufs, false, false);
|
||||
hleEatCycles(330);
|
||||
if (done != 0)
|
||||
{
|
||||
if (done != 0) {
|
||||
DEBUG_LOG(Log::sceCtrl, "%d=sceCtrlReadBufferPositive(%08x, %i)", done, ctrlDataPtr, nBufs);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -775,7 +775,7 @@ static u32 sceDisplayIsVblank() {
|
|||
return hleLogSuccessI(Log::sceDisplay, DisplayIsVblank());
|
||||
}
|
||||
|
||||
static int DisplayWaitForVblanks(const char *reason, int vblanks, bool callbacks = false) {
|
||||
void __DisplayWaitForVblanks(const char *reason, int vblanks, bool callbacks) {
|
||||
const s64 ticksIntoFrame = CoreTiming::GetTicks() - DisplayFrameStartTicks();
|
||||
const s64 cyclesToNextVblank = msToCycles(frameMs) - ticksIntoFrame;
|
||||
|
||||
|
@ -787,12 +787,6 @@ static int DisplayWaitForVblanks(const char *reason, int vblanks, bool callbacks
|
|||
|
||||
vblankWaitingThreads.push_back(WaitVBlankInfo(__KernelGetCurThread(), vblanks));
|
||||
__KernelWaitCurThread(WAITTYPE_VBLANK, 1, 0, 0, callbacks, reason);
|
||||
|
||||
return hleLogSuccessVerboseI(Log::sceDisplay, 0, "waiting for %d vblanks", vblanks);
|
||||
}
|
||||
|
||||
void __DisplayWaitForVblanks(const char* reason, int vblanks, bool callbacks) {
|
||||
DisplayWaitForVblanks(reason, vblanks, callbacks);
|
||||
}
|
||||
|
||||
static u32 sceDisplaySetMode(int displayMode, int displayWidth, int displayHeight) {
|
||||
|
@ -811,9 +805,9 @@ static u32 sceDisplaySetMode(int displayMode, int displayWidth, int displayHeigh
|
|||
width = displayWidth;
|
||||
height = displayHeight;
|
||||
|
||||
hleLogSuccessI(Log::sceDisplay, 0);
|
||||
// On success, this implicitly waits for a vblank start.
|
||||
return DisplayWaitForVblanks("display mode", 1);
|
||||
__DisplayWaitForVblanks("display mode", 1);
|
||||
return hleLogSuccessI(Log::sceDisplay, 0);
|
||||
}
|
||||
|
||||
void __DisplaySetFramebuf(u32 topaddr, int linesize, int pixelFormat, int sync) {
|
||||
|
@ -951,17 +945,19 @@ static u32 sceDisplayGetFramebuf(u32 topaddrPtr, u32 linesizePtr, u32 pixelForma
|
|||
return hleLogSuccessI(Log::sceDisplay, 0);
|
||||
}
|
||||
|
||||
static int DisplayWaitForVblanksCB(const char *reason, int vblanks) {
|
||||
return DisplayWaitForVblanks(reason, vblanks, true);
|
||||
static void __DisplayWaitForVblanksCB(const char *reason, int vblanks) {
|
||||
__DisplayWaitForVblanks(reason, vblanks, true);
|
||||
}
|
||||
|
||||
static u32 sceDisplayWaitVblankStart() {
|
||||
return DisplayWaitForVblanks("vblank start waited", 1);
|
||||
__DisplayWaitForVblanks("vblank start waited", 1);
|
||||
return hleLogSuccessI(Log::sceDisplay, 0);
|
||||
}
|
||||
|
||||
static u32 sceDisplayWaitVblank() {
|
||||
if (!DisplayIsVblank()) {
|
||||
return DisplayWaitForVblanks("vblank waited", 1);
|
||||
__DisplayWaitForVblanks("vblank waited", 1);
|
||||
return hleLogSuccessI(Log::sceDisplay, 0);
|
||||
} else {
|
||||
hleEatCycles(1110);
|
||||
hleReSchedule("vblank wait skipped");
|
||||
|
@ -978,12 +974,14 @@ static u32 sceDisplayWaitVblankStartMulti(int vblanks) {
|
|||
if (__IsInInterrupt())
|
||||
return hleLogWarning(Log::sceDisplay, SCE_KERNEL_ERROR_ILLEGAL_CONTEXT, "in interrupt");
|
||||
|
||||
return DisplayWaitForVblanks("vblank start multi waited", vblanks);
|
||||
__DisplayWaitForVblanks("vblank start multi waited", vblanks);
|
||||
return hleLogSuccessI(Log::sceDisplay, 0);
|
||||
}
|
||||
|
||||
static u32 sceDisplayWaitVblankCB() {
|
||||
if (!DisplayIsVblank()) {
|
||||
return DisplayWaitForVblanksCB("vblank waited", 1);
|
||||
__DisplayWaitForVblanksCB("vblank waited", 1);
|
||||
return hleLogSuccessI(Log::sceDisplay, 0);
|
||||
} else {
|
||||
hleEatCycles(1110);
|
||||
hleReSchedule("vblank wait skipped");
|
||||
|
@ -992,7 +990,8 @@ static u32 sceDisplayWaitVblankCB() {
|
|||
}
|
||||
|
||||
static u32 sceDisplayWaitVblankStartCB() {
|
||||
return DisplayWaitForVblanksCB("vblank start waited", 1);
|
||||
__DisplayWaitForVblanksCB("vblank start waited", 1);
|
||||
return hleLogSuccessI(Log::sceDisplay, 0);
|
||||
}
|
||||
|
||||
static u32 sceDisplayWaitVblankStartMultiCB(int vblanks) {
|
||||
|
@ -1004,7 +1003,8 @@ static u32 sceDisplayWaitVblankStartMultiCB(int vblanks) {
|
|||
if (__IsInInterrupt())
|
||||
return hleLogWarning(Log::sceDisplay, SCE_KERNEL_ERROR_ILLEGAL_CONTEXT, "in interrupt");
|
||||
|
||||
return DisplayWaitForVblanksCB("vblank start multi waited", vblanks);
|
||||
__DisplayWaitForVblanksCB("vblank start multi waited", vblanks);
|
||||
return hleLogSuccessI(Log::sceDisplay, 0);
|
||||
}
|
||||
|
||||
static u32 sceDisplayGetVcount() {
|
||||
|
@ -1039,8 +1039,7 @@ static int sceDisplayGetAccumulatedHcount() {
|
|||
|
||||
static float sceDisplayGetFramePerSec() {
|
||||
const static float framePerSec = 59.9400599f;
|
||||
VERBOSE_LOG(Log::sceDisplay,"%f=sceDisplayGetFramePerSec()", framePerSec);
|
||||
return framePerSec; // (9MHz * 1)/(525 * 286)
|
||||
return hleLogVerbose(Log::sceDisplay, framePerSec); // (9MHz * 1)/(525 * 286)
|
||||
}
|
||||
|
||||
static u32 sceDisplayIsForeground() {
|
||||
|
|
|
@ -73,51 +73,40 @@ static int __DmacMemcpy(u32 dst, u32 src, u32 size) {
|
|||
static u32 sceDmacMemcpy(u32 dst, u32 src, u32 size) {
|
||||
if (size == 0) {
|
||||
// Some games seem to do this frequently.
|
||||
DEBUG_LOG(Log::HLE, "sceDmacMemcpy(dest=%08x, src=%08x, size=%i): invalid size", dst, src, size);
|
||||
return SCE_KERNEL_ERROR_INVALID_SIZE;
|
||||
return hleLogDebug(Log::HLE, SCE_KERNEL_ERROR_INVALID_SIZE, "invalid size");
|
||||
}
|
||||
if (!Memory::IsValidAddress(dst) || !Memory::IsValidAddress(src)) {
|
||||
ERROR_LOG(Log::HLE, "sceDmacMemcpy(dest=%08x, src=%08x, size=%i): invalid address", dst, src, size);
|
||||
return SCE_KERNEL_ERROR_INVALID_POINTER;
|
||||
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_INVALID_POINTER, "invalid address (dst or src)");
|
||||
}
|
||||
if (dst + size >= 0x80000000 || src + size >= 0x80000000 || size >= 0x80000000) {
|
||||
ERROR_LOG(Log::HLE, "sceDmacMemcpy(dest=%08x, src=%08x, size=%i): illegal size", dst, src, size);
|
||||
return SCE_KERNEL_ERROR_PRIV_REQUIRED;
|
||||
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_PRIV_REQUIRED, "illegal size");
|
||||
}
|
||||
|
||||
if (dmacMemcpyDeadline > CoreTiming::GetTicks()) {
|
||||
WARN_LOG_REPORT_ONCE(overlapDmacMemcpy, Log::HLE, "sceDmacMemcpy(dest=%08x, src=%08x, size=%d): overlapping read", dst, src, size);
|
||||
// TODO: Should block, seems like copy doesn't start until previous finishes.
|
||||
// Might matter for overlapping copies.
|
||||
} else {
|
||||
DEBUG_LOG(Log::HLE, "sceDmacMemcpy(dest=%08x, src=%08x, size=%i)", dst, src, size);
|
||||
}
|
||||
|
||||
return __DmacMemcpy(dst, src, size);
|
||||
return hleLogDebug(Log::HLE, __DmacMemcpy(dst, src, size));
|
||||
}
|
||||
|
||||
static u32 sceDmacTryMemcpy(u32 dst, u32 src, u32 size) {
|
||||
if (size == 0) {
|
||||
ERROR_LOG(Log::HLE, "sceDmacTryMemcpy(dest=%08x, src=%08x, size=%i): invalid size", dst, src, size);
|
||||
return SCE_KERNEL_ERROR_INVALID_SIZE;
|
||||
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_INVALID_SIZE, "invalid size");
|
||||
}
|
||||
if (!Memory::IsValidAddress(dst) || !Memory::IsValidAddress(src)) {
|
||||
ERROR_LOG(Log::HLE, "sceDmacTryMemcpy(dest=%08x, src=%08x, size=%i): invalid address", dst, src, size);
|
||||
return SCE_KERNEL_ERROR_INVALID_POINTER;
|
||||
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_INVALID_POINTER, "invalid address", dst, src, size);
|
||||
}
|
||||
if (dst + size >= 0x80000000 || src + size >= 0x80000000 || size >= 0x80000000) {
|
||||
ERROR_LOG(Log::HLE, "sceDmacTryMemcpy(dest=%08x, src=%08x, size=%i): illegal size", dst, src, size);
|
||||
return SCE_KERNEL_ERROR_PRIV_REQUIRED;
|
||||
return hleLogError(Log::HLE, SCE_KERNEL_ERROR_PRIV_REQUIRED, "illegal size", dst, src, size);
|
||||
}
|
||||
|
||||
if (dmacMemcpyDeadline > CoreTiming::GetTicks()) {
|
||||
DEBUG_LOG(Log::HLE, "sceDmacTryMemcpy(dest=%08x, src=%08x, size=%i): busy", dst, src, size);
|
||||
return SCE_KERNEL_ERROR_BUSY;
|
||||
} else {
|
||||
DEBUG_LOG(Log::HLE, "sceDmacTryMemcpy(dest=%08x, src=%08x, size=%i)", dst, src, size);
|
||||
return hleLogDebug(Log::HLE, SCE_KERNEL_ERROR_BUSY, "busy", dst, src, size);
|
||||
}
|
||||
|
||||
return __DmacMemcpy(dst, src, size);
|
||||
return hleLogDebug(Log::HLE, __DmacMemcpy(dst, src, size));
|
||||
}
|
||||
|
||||
const HLEFunction sceDmac[] = {
|
||||
|
|
|
@ -624,12 +624,12 @@ public:
|
|||
|
||||
if (foundFontIndex < 0 || fontRefCount_[foundFontIndex] >= MAX_FONT_REFS) {
|
||||
error = ERROR_FONT_TOO_MANY_OPEN_FONTS;
|
||||
hleLogError(Log::sceFont, 0, "Too many fonts opened in FontLib");
|
||||
ERROR_LOG(Log::sceFont, "OpenFont: Too many fonts opened in FontLib");
|
||||
return nullptr;
|
||||
}
|
||||
if (!font->IsValid()) {
|
||||
error = ERROR_FONT_INVALID_FONT_DATA;
|
||||
hleLogError(Log::sceFont, 0, "Invalid font data");
|
||||
ERROR_LOG(Log::sceFont, "OpenFont: Invalid font data");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -422,9 +422,8 @@ static int sceGeListUpdateStallAddr(u32 displayListID, u32 stallAddress) {
|
|||
|
||||
// 0 : wait for completion. 1:check and return
|
||||
int sceGeListSync(u32 displayListID, u32 mode) {
|
||||
DEBUG_LOG(Log::sceGe, "sceGeListSync(dlid=%08x, mode=%08x)", displayListID, mode);
|
||||
hleEatCycles(220); // Fudged without measuring, copying sceGeContinue.
|
||||
return gpu->ListSync(LIST_ID_MAGIC ^ displayListID, mode);
|
||||
return hleLogDebug(Log::sceGe, gpu->ListSync(LIST_ID_MAGIC ^ displayListID, mode));
|
||||
}
|
||||
|
||||
static u32 sceGeDrawSync(u32 mode) {
|
||||
|
@ -433,12 +432,10 @@ static u32 sceGeDrawSync(u32 mode) {
|
|||
hleEatCycles(500000); //HACK(?) : Potential fix for Crash Tag Team Racing and a few Gundam games
|
||||
else if (!PSP_CoreParameter().compat.flags().DrawSyncInstant)
|
||||
hleEatCycles(1240);
|
||||
DEBUG_LOG(Log::sceGe, "sceGeDrawSync(mode=%d) (0=wait for completion, 1=peek)", mode);
|
||||
return gpu->DrawSync(mode);
|
||||
return hleLogDebug(Log::sceGe, gpu->DrawSync(mode));
|
||||
}
|
||||
|
||||
static int sceGeContinue() {
|
||||
DEBUG_LOG(Log::sceGe, "sceGeContinue()");
|
||||
bool runList;
|
||||
int ret = gpu->Continue(&runList);
|
||||
if (runList) {
|
||||
|
@ -450,13 +447,12 @@ static int sceGeContinue() {
|
|||
}
|
||||
hleEatCycles(220);
|
||||
hleReSchedule("ge continue");
|
||||
return ret;
|
||||
return hleLogDebug(Log::sceGe, ret);
|
||||
}
|
||||
|
||||
static int sceGeBreak(u32 mode, u32 unknownPtr) {
|
||||
if (mode > 1) {
|
||||
WARN_LOG(Log::sceGe, "sceGeBreak(mode=%d, unknown=%08x): invalid mode", mode, unknownPtr);
|
||||
return SCE_KERNEL_ERROR_INVALID_MODE;
|
||||
return hleLogWarning(Log::sceGe, SCE_KERNEL_ERROR_INVALID_MODE, "invalid mode");
|
||||
}
|
||||
// Not sure what this is supposed to be for...
|
||||
if ((int)unknownPtr < 0 || (int)(unknownPtr + 16) < 0) {
|
||||
|
@ -615,8 +611,7 @@ static u32 sceGeGetCmd(int cmd) {
|
|||
}
|
||||
|
||||
static int sceGeGetStack(int index, u32 stackPtr) {
|
||||
WARN_LOG_REPORT(Log::sceGe, "sceGeGetStack(%i, %08x)", index, stackPtr);
|
||||
return gpu->GetStack(index, stackPtr);
|
||||
return hleReportWarning(Log::sceGe, gpu->GetStack(index, stackPtr));
|
||||
}
|
||||
|
||||
static u32 sceGeEdramSetAddrTranslation(u32 new_size) {
|
||||
|
|
|
@ -1625,37 +1625,33 @@ static u32 sceIoClose(int id) {
|
|||
}
|
||||
|
||||
static u32 sceIoRemove(const char *filename) {
|
||||
DEBUG_LOG(Log::sceIo, "sceIoRemove(%s)", filename);
|
||||
|
||||
// TODO: This timing isn't necessarily accurate, low end for now.
|
||||
if(!pspFileSystem.GetFileInfo(filename).exists)
|
||||
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file removed", 100);
|
||||
if (!pspFileSystem.GetFileInfo(filename).exists) {
|
||||
return hleDelayResult(hleLogWarning(Log::sceIo, SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND), "file removed", 100);
|
||||
}
|
||||
|
||||
pspFileSystem.RemoveFile(filename);
|
||||
return hleDelayResult(0, "file removed", 100);
|
||||
// TODO: This timing isn't necessarily accurate, low end for now.
|
||||
return hleDelayResult(hleLogDebug(Log::sceIo, 0), "file removed", 100);
|
||||
}
|
||||
|
||||
static u32 sceIoMkdir(const char *dirname, int mode) {
|
||||
DEBUG_LOG(Log::sceIo, "sceIoMkdir(%s, %i)", dirname, mode);
|
||||
// TODO: Improve timing.
|
||||
if (pspFileSystem.MkDir(dirname))
|
||||
return hleDelayResult(0, "mkdir", 1000);
|
||||
return hleDelayResult(hleLogDebug(Log::sceIo, 0), "mkdir", 1000);
|
||||
else
|
||||
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS, "mkdir", 1000);
|
||||
return hleDelayResult(hleLogWarning(Log::sceIo, SCE_KERNEL_ERROR_ERRNO_FILE_ALREADY_EXISTS), "mkdir", 1000);
|
||||
}
|
||||
|
||||
static u32 sceIoRmdir(const char *dirname) {
|
||||
DEBUG_LOG(Log::sceIo, "sceIoRmdir(%s)", dirname);
|
||||
// TODO: Improve timing.
|
||||
if (pspFileSystem.RmDir(dirname))
|
||||
return hleDelayResult(0, "rmdir", 1000);
|
||||
return hleDelayResult(hleLogDebug(Log::sceIo, 0), "rmdir", 1000);
|
||||
else
|
||||
return hleDelayResult(SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "rmdir", 1000);
|
||||
return hleDelayResult(hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND), "rmdir", 1000);
|
||||
}
|
||||
|
||||
static u32 sceIoSync(const char *devicename, int flag) {
|
||||
DEBUG_LOG(Log::sceIo, "UNIMPL sceIoSync(%s, %i)", devicename, flag);
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceIo, 0);
|
||||
}
|
||||
|
||||
struct DeviceSize {
|
||||
|
@ -1679,7 +1675,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
Memory::Write_U32(0x10, outPtr + 4); // Always return game disc (if present)
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x01F20002:
|
||||
|
@ -1688,7 +1684,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
Memory::Write_U32(0x10, outPtr); // Assume first sector
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x01F20003:
|
||||
|
@ -1697,7 +1693,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
Memory::Write_U32((u32) (info.size) - 1, outPtr);
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x01F100A3:
|
||||
|
@ -1705,7 +1701,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
if (Memory::IsValidAddress(argAddr) && argLen >= 4) {
|
||||
return hleDelayResult(0, "dev seek", 100);
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x01F100A4:
|
||||
|
@ -1713,7 +1709,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
if (Memory::IsValidAddress(argAddr) && argLen >= 4) {
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x01F300A5:
|
||||
|
@ -1722,7 +1718,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
Memory::Write_U32(1, outPtr); // Status (unitary index of the requested read, greater or equal to 1)
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x01F300A7:
|
||||
|
@ -1732,7 +1728,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
// Place the calling thread in wait state
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x01F300A8:
|
||||
|
@ -1743,7 +1739,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
// 0x20 - UMD data cache thread is running
|
||||
return 0; // Return finished
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x01F300A9:
|
||||
|
@ -1753,7 +1749,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
// Wake up the thread waiting for the UMD data cache handling.
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
// TODO: What do these do? Seem to require a u32 in, no output.
|
||||
|
@ -1781,7 +1777,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
}
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x02015804:
|
||||
|
@ -1809,7 +1805,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
|
||||
}
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x02015805:
|
||||
|
@ -1833,7 +1829,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
|
||||
}
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x02025806:
|
||||
|
@ -1844,7 +1840,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
Memory::Write_U32(MemoryStick_State(), outPtr);
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x02425818:
|
||||
|
@ -1873,7 +1869,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
case 0x02425824:
|
||||
|
@ -1885,8 +1881,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
Memory::WriteUnchecked_U32(0, outPtr);
|
||||
return 0;
|
||||
} else {
|
||||
ERROR_LOG(Log::sceIo, "Failed 0x02425824 fat");
|
||||
return -1;
|
||||
return hleLogError(Log::sceIo, -1, "Failed 0x02425824 fat");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1919,10 +1914,10 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
}
|
||||
return 0;
|
||||
} else {
|
||||
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
|
||||
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT);
|
||||
}
|
||||
} else {
|
||||
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
|
||||
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT);
|
||||
}
|
||||
break;
|
||||
case 0x02415822:
|
||||
|
@ -1943,7 +1938,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
DEBUG_LOG(Log::sceIo, "sceIoDevCtl: Unregistered memstick FAT callback %i", cbId);
|
||||
return 0;
|
||||
} else {
|
||||
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
|
||||
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1966,7 +1961,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
} else if (!Memory::IsValidAddress(outPtr)) {
|
||||
// Technically, only checks for NULL, crashes for many bad addresses.
|
||||
ERROR_LOG(Log::sceIo, "sceIoDevctl: fatms0: 0x02425823 command, no output address");
|
||||
return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT;
|
||||
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT);
|
||||
} else {
|
||||
// Does not care about outLen, even if it's 0.
|
||||
// Note: writes 1 when inserted, 0 when not inserted.
|
||||
|
@ -1983,8 +1978,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
Memory::Write_U32(0, outPtr);
|
||||
return 0;
|
||||
} else {
|
||||
ERROR_LOG(Log::sceIo, "Failed 0x02425824 fat");
|
||||
return -1;
|
||||
return hleLogError(Log::sceIo, -1, "Failed 0x02425824 fat");
|
||||
}
|
||||
break;
|
||||
case 0x02425818:
|
||||
|
@ -2011,14 +2005,13 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
}
|
||||
return 0;
|
||||
} else {
|
||||
return ERROR_MEMSTICK_DEVCTL_BAD_PARAMS;
|
||||
return hleLogError(Log::sceIo, ERROR_MEMSTICK_DEVCTL_BAD_PARAMS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(name, "kemulator:") || !strcmp(name, "emulator:"))
|
||||
{
|
||||
if (!strcmp(name, "kemulator:") || !strcmp(name, "emulator:")) {
|
||||
// Emulator special tricks!
|
||||
|
||||
enum {
|
||||
|
@ -2109,9 +2102,7 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
return 0;
|
||||
}
|
||||
|
||||
ERROR_LOG(Log::sceIo, "sceIoDevCtl: UNKNOWN PARAMETERS");
|
||||
|
||||
return 0;
|
||||
return hleLogError(Log::sceIo, 0, "UNKNOWN PARAMETERS");
|
||||
}
|
||||
|
||||
//089c6d1c weird branch
|
||||
|
@ -2119,26 +2110,24 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
089c6bdc ]: HLE: sceKernelCreateCallback(name= MemoryStick Detection ,entry= 089c7484 ) (z_un_089c6bc4)
|
||||
089c6c40 ]: HLE: sceKernelCreateCallback(name= MemoryStick Assignment ,entry= 089c7534 ) (z_un_089c6bc4)
|
||||
*/
|
||||
// Keeping this report intact
|
||||
ERROR_LOG_REPORT(Log::sceIo, "UNIMPL sceIoDevctl(\"%s\", %08x, %08x, %i, %08x, %i)", name, cmd, argAddr, argLen, outPtr, outLen);
|
||||
return SCE_KERNEL_ERROR_UNSUP;
|
||||
return hleNoLog(SCE_KERNEL_ERROR_UNSUP);
|
||||
}
|
||||
|
||||
static u32 sceIoRename(const char *from, const char *to) {
|
||||
DEBUG_LOG(Log::sceIo, "sceIoRename(%s, %s)", from, to);
|
||||
|
||||
// TODO: Timing isn't terribly accurate.
|
||||
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);
|
||||
if (result < 0)
|
||||
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) {
|
||||
DEBUG_LOG(Log::sceIo, "sceIoChdir(%s)", dirname);
|
||||
return pspFileSystem.ChDir(dirname);
|
||||
return hleLogDebug(Log::sceIo, pspFileSystem.ChDir(dirname));
|
||||
}
|
||||
|
||||
static int sceIoChangeAsyncPriority(int id, int priority) {
|
||||
|
@ -2187,21 +2176,15 @@ static int sceIoCloseAsync(int id) {
|
|||
return hleLogSuccessI(Log::sceIo, 0);
|
||||
}
|
||||
|
||||
static u32 sceIoSetAsyncCallback(int id, u32 clbckId, u32 clbckArg)
|
||||
{
|
||||
DEBUG_LOG(Log::sceIo, "sceIoSetAsyncCallback(%d, %i, %08x)", id, clbckId, clbckArg);
|
||||
|
||||
static u32 sceIoSetAsyncCallback(int id, u32 clbckId, u32 clbckArg) {
|
||||
u32 error;
|
||||
FileNode *f = __IoGetFd(id, error);
|
||||
if (f)
|
||||
{
|
||||
if (f) {
|
||||
f->callbackID = clbckId;
|
||||
f->callbackArg = clbckArg;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return error;
|
||||
return hleLogDebug(Log::sceIo, 0);
|
||||
} else {
|
||||
return hleLogError(Log::sceIo, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2347,7 +2330,7 @@ static int sceIoWaitAsyncCB(int id, u32 address) {
|
|||
FileNode *f = __IoGetFd(id, error);
|
||||
if (f) {
|
||||
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();
|
||||
|
@ -2515,9 +2498,8 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
|
|||
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointer(dirent_addr);
|
||||
|
||||
if (dir->index == (int) dir->listing.size()) {
|
||||
DEBUG_LOG(Log::sceIo, "sceIoDread( %d %08x ) - end", id, dirent_addr);
|
||||
entry->d_name[0] = '\0';
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceIo, 0, "end");
|
||||
}
|
||||
|
||||
PSPFileInfo &info = dir->listing[dir->index];
|
||||
|
@ -2563,8 +2545,7 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
|
|||
}
|
||||
return 1;
|
||||
} else {
|
||||
DEBUG_LOG(Log::sceIo, "sceIoDread - invalid listing %i, error %08x", id, error);
|
||||
return SCE_KERNEL_ERROR_BADF;
|
||||
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_BADF, "invalid listing");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2577,12 +2558,11 @@ int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 out
|
|||
u32 error;
|
||||
FileNode *f = __IoGetFd(id, error);
|
||||
if (error) {
|
||||
ERROR_LOG(Log::sceIo, "%08x=sceIoIoctl id: %08x, cmd %08x, bad file", error, id, cmd);
|
||||
return error;
|
||||
return hleLogError(Log::sceIo, error, "bad file");
|
||||
}
|
||||
|
||||
if (f->asyncBusy()) {
|
||||
ERROR_LOG(Log::sceIo, "%08x=sceIoIoctl id: %08x, cmd %08x, async busy", error, id, cmd);
|
||||
return SCE_KERNEL_ERROR_ASYNC_BUSY;
|
||||
return hleLogError(Log::sceIo, SCE_KERNEL_ERROR_ASYNC_BUSY, "async busy");
|
||||
}
|
||||
|
||||
// TODO: Move this into each command, probably?
|
||||
|
@ -2607,7 +2587,7 @@ int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 out
|
|||
memcpy(keybuf, Memory::GetPointerUnchecked(indataPtr), 16);
|
||||
key_ptr = keybuf;
|
||||
}else{
|
||||
key_ptr = NULL;
|
||||
key_ptr = nullptr;
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceIo, "Decrypting PGD DRM files");
|
||||
|
@ -2618,13 +2598,11 @@ int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 out
|
|||
f->npdrm = false;
|
||||
pspFileSystem.SeekFile(f->handle, (s32)0, FILEMOVE_BEGIN);
|
||||
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
|
||||
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 {
|
||||
INFO_LOG(Log::sceIo, "%s is not an encrypted PGD file as was expected. Proceeding.", f->fullpath.c_str());
|
||||
// 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 {
|
||||
// Everything OK.
|
||||
|
|
|
@ -376,8 +376,7 @@ u32 sceKernelGetGPI()
|
|||
{
|
||||
// Always returns 0 on production systems.
|
||||
// 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 g_GPIBits;
|
||||
return hleLogDebug(Log::sceKernel, g_GPIBits);
|
||||
}
|
||||
|
||||
// #define LOG_CACHE
|
||||
|
@ -407,10 +406,9 @@ int sceKernelDcacheInvalidateRange(u32 addr, int size)
|
|||
}
|
||||
|
||||
int sceKernelIcacheInvalidateRange(u32 addr, int size) {
|
||||
DEBUG_LOG(Log::CPU, "sceKernelIcacheInvalidateRange(%08x, %i)", addr, size);
|
||||
if (size != 0)
|
||||
currentMIPS->InvalidateICache(addr, size);
|
||||
return 0;
|
||||
return hleLogDebug(Log::CPU, 0);
|
||||
}
|
||||
|
||||
int sceKernelDcacheWritebackAll()
|
||||
|
@ -692,16 +690,14 @@ static u32 sceKernelReferThreadProfiler() {
|
|||
// This seems to simply has no parameter:
|
||||
// https://pspdev.github.io/pspsdk/group__ThreadMan.html#ga8fd30da51b9dc0507ac4dae04a7e4a17
|
||||
// In testing it just returns null in around 140-150 cycles. See issue #17623.
|
||||
DEBUG_LOG(Log::sceKernel, "0=sceKernelReferThreadProfiler()");
|
||||
hleEatCycles(140);
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelReferGlobalProfiler() {
|
||||
DEBUG_LOG(Log::sceKernel, "0=sceKernelReferGlobalProfiler()");
|
||||
// See sceKernelReferThreadProfiler(), similar.
|
||||
hleEatCycles(140);
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
const HLEFunction ThreadManForUser[] =
|
||||
|
|
|
@ -145,7 +145,7 @@ void __KernelAlarmDoState(PointerWrap &p)
|
|||
|
||||
KernelObject *__KernelAlarmObject() {
|
||||
// Default object to load from state.
|
||||
return new PSPAlarm;
|
||||
return new PSPAlarm();
|
||||
}
|
||||
|
||||
void __KernelScheduleAlarm(PSPAlarm *alarm, u64 micro) {
|
||||
|
@ -169,10 +169,8 @@ static SceUID __KernelSetAlarm(u64 micro, u32 handlerPtr, u32 commonPtr)
|
|||
return uid;
|
||||
}
|
||||
|
||||
SceUID sceKernelSetAlarm(SceUInt micro, u32 handlerPtr, u32 commonPtr)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetAlarm(%d, %08x, %08x)", micro, handlerPtr, commonPtr);
|
||||
return __KernelSetAlarm((u64) micro, handlerPtr, commonPtr);
|
||||
SceUID sceKernelSetAlarm(SceUInt micro, u32 handlerPtr, u32 commonPtr) {
|
||||
return hleLogDebug(Log::sceKernel, __KernelSetAlarm((u64) micro, handlerPtr, commonPtr));
|
||||
}
|
||||
|
||||
SceUID sceKernelSetSysClockAlarm(u32 microPtr, u32 handlerPtr, u32 commonPtr)
|
||||
|
@ -184,33 +182,26 @@ SceUID sceKernelSetSysClockAlarm(u32 microPtr, u32 handlerPtr, u32 commonPtr)
|
|||
else
|
||||
return -1;
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetSysClockAlarm(%lld, %08x, %08x)", micro, handlerPtr, commonPtr);
|
||||
return __KernelSetAlarm(micro, handlerPtr, commonPtr);
|
||||
return hleLogDebug(Log::sceKernel, __KernelSetAlarm(micro, handlerPtr, commonPtr));
|
||||
}
|
||||
|
||||
int sceKernelCancelAlarm(SceUID uid)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelCancelAlarm(%08x)", uid);
|
||||
|
||||
CoreTiming::UnscheduleEvent(alarmTimer, uid);
|
||||
|
||||
return kernelObjects.Destroy<PSPAlarm>(uid);
|
||||
return hleLogDebug(Log::sceKernel, kernelObjects.Destroy<PSPAlarm>(uid));
|
||||
}
|
||||
|
||||
int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr)
|
||||
{
|
||||
u32 error;
|
||||
PSPAlarm *alarm = kernelObjects.Get<PSPAlarm>(uid, error);
|
||||
if (!alarm)
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelReferAlarmStatus(%08x, %08x): invalid alarm", uid, infoPtr);
|
||||
return error;
|
||||
if (!alarm) {
|
||||
return hleLogError(Log::sceKernel, error, "invalid alarm", uid, infoPtr);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelReferAlarmStatus(%08x, %08x)", uid, infoPtr);
|
||||
|
||||
if (!Memory::IsValidAddress(infoPtr))
|
||||
return -1;
|
||||
return hleLogError(Log::sceKernel, -1);
|
||||
|
||||
u32 size = Memory::Read_U32(infoPtr);
|
||||
|
||||
|
@ -224,5 +215,5 @@ int sceKernelReferAlarmStatus(SceUID uid, u32 infoPtr)
|
|||
if (size > 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()
|
||||
{
|
||||
u32 retVal = __InterruptsEnabled();
|
||||
DEBUG_LOG(Log::sceIntc, "%i=sceKernelIsCpuIntrEnable()", retVal);
|
||||
return retVal;
|
||||
return hleLogDebug(Log::sceIntc, retVal);
|
||||
}
|
||||
|
||||
static int sceKernelIsCpuIntrSuspended(int flag)
|
||||
{
|
||||
int retVal = flag == 0 ? 1 : 0;
|
||||
DEBUG_LOG(Log::sceIntc, "%i=sceKernelIsCpuIntrSuspended(%d)", retVal, flag);
|
||||
return retVal;
|
||||
return hleLogDebug(Log::sceIntc, retVal);
|
||||
}
|
||||
|
||||
static void sceKernelCpuResumeIntrWithSync(u32 enable)
|
||||
|
@ -132,8 +130,7 @@ static void sceKernelCpuResumeIntrWithSync(u32 enable)
|
|||
bool IntrHandler::run(PendingInterrupt& pend)
|
||||
{
|
||||
SubIntrHandler *handler = get(pend.subintr);
|
||||
if (handler == NULL)
|
||||
{
|
||||
if (!handler) {
|
||||
WARN_LOG(Log::sceIntc, "Ignoring interrupt, already been released.");
|
||||
return false;
|
||||
}
|
||||
|
@ -496,87 +493,73 @@ int __ReleaseSubIntrHandler(int intrNumber, int subIntrNumber) {
|
|||
|
||||
u32 sceKernelRegisterSubIntrHandler(u32 intrNumber, u32 subIntrNumber, u32 handler, u32 handlerArg) {
|
||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelRegisterSubIntrHandler(%i, %i, %08x, %08x): invalid interrupt", intrNumber, subIntrNumber, handler, handlerArg);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
||||
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt");
|
||||
}
|
||||
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelRegisterSubIntrHandler(%i, %i, %08x, %08x): invalid subinterrupt", intrNumber, subIntrNumber, handler, handlerArg);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
||||
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid subinterrupt");
|
||||
}
|
||||
|
||||
u32 error;
|
||||
SubIntrHandler *subIntrHandler = __RegisterSubIntrHandler(intrNumber, subIntrNumber, handler, handlerArg, error);
|
||||
if (subIntrHandler) {
|
||||
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 {
|
||||
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) {
|
||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelRegisterSubIntrHandler(%i, %i, %08x, %08x): duplicate handler", intrNumber, subIntrNumber, handler, handlerArg);
|
||||
return hleReportError(Log::sceIntc, error, "duplicate handler");
|
||||
} 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;
|
||||
}
|
||||
|
||||
u32 sceKernelReleaseSubIntrHandler(u32 intrNumber, u32 subIntrNumber) {
|
||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelReleaseSubIntrHandler(%i, %i): invalid interrupt", intrNumber, subIntrNumber);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
||||
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt");
|
||||
}
|
||||
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelReleaseSubIntrHandler(%i, %i): invalid subinterrupt", intrNumber, subIntrNumber);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
||||
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid subinterrupt");
|
||||
}
|
||||
|
||||
u32 error = __ReleaseSubIntrHandler(intrNumber, subIntrNumber);
|
||||
if (error != SCE_KERNEL_ERROR_OK) {
|
||||
ERROR_LOG(Log::sceIntc, "sceKernelReleaseSubIntrHandler(%i, %i): error %08x", intrNumber, subIntrNumber, error);
|
||||
}
|
||||
return error;
|
||||
return hleLogSuccessOrError(Log::sceIntc, error);
|
||||
}
|
||||
|
||||
u32 sceKernelEnableSubIntr(u32 intrNumber, u32 subIntrNumber) {
|
||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelEnableSubIntr(%i, %i): invalid interrupt", intrNumber, subIntrNumber);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
||||
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt");
|
||||
}
|
||||
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelEnableSubIntr(%i, %i): invalid subinterrupt", intrNumber, subIntrNumber);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
||||
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid subinterrupt");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceIntc, "sceKernelEnableSubIntr(%i, %i)", intrNumber, subIntrNumber);
|
||||
u32 error;
|
||||
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);
|
||||
}
|
||||
|
||||
intrHandlers[intrNumber]->enable(subIntrNumber);
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceIntc, 0);
|
||||
}
|
||||
|
||||
static u32 sceKernelDisableSubIntr(u32 intrNumber, u32 subIntrNumber) {
|
||||
if (intrNumber >= PSP_NUMBER_INTERRUPTS) {
|
||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelDisableSubIntr(%i, %i): invalid interrupt", intrNumber, subIntrNumber);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
||||
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt");
|
||||
}
|
||||
if (subIntrNumber >= PSP_NUMBER_SUBINTERRUPTS) {
|
||||
ERROR_LOG_REPORT(Log::sceIntc, "sceKernelDisableSubIntr(%i, %i): invalid subinterrupt", intrNumber, subIntrNumber);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_INTRCODE;
|
||||
return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid subinterrupt");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceIntc, "sceKernelDisableSubIntr(%i, %i)", intrNumber, subIntrNumber);
|
||||
|
||||
if (!intrHandlers[intrNumber]->has(subIntrNumber)) {
|
||||
// Disabling when not registered is not an error.
|
||||
return 0;
|
||||
}
|
||||
|
||||
intrHandlers[intrNumber]->disable(subIntrNumber);
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceIntc, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -605,10 +588,8 @@ static int QueryIntrHandlerInfo()
|
|||
return 0;
|
||||
}
|
||||
|
||||
static u32 sceKernelMemset(u32 addr, u32 fillc, u32 n)
|
||||
{
|
||||
static u32 sceKernelMemset(u32 addr, u32 fillc, u32 n) {
|
||||
u8 c = fillc & 0xff;
|
||||
DEBUG_LOG(Log::sceIntc, "sceKernelMemset(ptr = %08x, c = %02x, n = %08x)", addr, c, n);
|
||||
bool skip = false;
|
||||
if (n != 0) {
|
||||
if (Memory::IsVRAMAddress(addr)) {
|
||||
|
@ -619,13 +600,10 @@ static u32 sceKernelMemset(u32 addr, u32 fillc, u32 n)
|
|||
}
|
||||
}
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, addr, n, "KernelMemset");
|
||||
return addr;
|
||||
return hleLogDebug(Log::sceIntc, addr);
|
||||
}
|
||||
|
||||
static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelMemcpy(dest=%08x, src=%08x, size=%i)", dst, src, size);
|
||||
|
||||
static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size) {
|
||||
// Some games copy from executable code. We need to flush emuhack ops.
|
||||
if (size != 0)
|
||||
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...
|
||||
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);
|
||||
const u8 *srcp = Memory::GetPointerUnchecked(src);
|
||||
|
||||
// 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);
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Try to handle overlapped copies with similar properties to hardware, just in case.
|
||||
// Not that anyone ought to rely on it.
|
||||
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/");
|
||||
}
|
||||
|
||||
return dst;
|
||||
return hleLogDebug(Log::sceKernel, dst);
|
||||
}
|
||||
|
||||
const HLEFunction Kernel_Library[] =
|
||||
|
|
|
@ -678,9 +678,7 @@ int sceKernelCreateFpl(const char *name, u32 mpid, u32 attr, u32 blockSize, u32
|
|||
bool atEnd = (attr & PSP_FPL_ATTR_HIGHMEM) != 0;
|
||||
u32 address = allocator->Alloc(totalSize, atEnd, StringFromFormat("FPL/%s", name).c_str());
|
||||
if (address == (u32)-1) {
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelCreateFpl(\"%s\", partition=%i, attr=%08x, bsize=%i, nb=%i) FAILED - out of ram",
|
||||
name, mpid, attr, blockSize, numBlocks);
|
||||
return SCE_KERNEL_ERROR_NO_MEMORY;
|
||||
return hleLogDebug(Log::sceKernel, SCE_KERNEL_ERROR_NO_MEMORY, "FAILED - out of ram");
|
||||
}
|
||||
|
||||
FPL *fpl = new FPL;
|
||||
|
@ -700,10 +698,7 @@ int sceKernelCreateFpl(const char *name, u32 mpid, u32 attr, u32 blockSize, u32
|
|||
fpl->address = address;
|
||||
fpl->alignedSize = alignedSize;
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "%i=sceKernelCreateFpl(\"%s\", partition=%i, attr=%08x, bsize=%i, nb=%i)",
|
||||
id, name, mpid, attr, blockSize, numBlocks);
|
||||
|
||||
return id;
|
||||
return hleLogDebug(Log::sceKernel, id);
|
||||
}
|
||||
|
||||
int sceKernelDeleteFpl(SceUID uid)
|
||||
|
@ -711,25 +706,19 @@ int sceKernelDeleteFpl(SceUID uid)
|
|||
hleEatCycles(600);
|
||||
u32 error;
|
||||
FPL *fpl = kernelObjects.Get<FPL>(uid, error);
|
||||
if (fpl)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelDeleteFpl(%i)", uid);
|
||||
|
||||
bool wokeThreads = __KernelClearFplThreads(fpl, SCE_KERNEL_ERROR_WAIT_DELETE);
|
||||
if (wokeThreads)
|
||||
hleReSchedule("fpl deleted");
|
||||
|
||||
BlockAllocator *alloc = BlockAllocatorFromAddr(fpl->address);
|
||||
_assert_msg_(alloc != nullptr, "Should always have a valid allocator/address");
|
||||
if (alloc)
|
||||
alloc->Free(fpl->address);
|
||||
return kernelObjects.Destroy<FPL>(uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelDeleteFpl(%i): invalid fpl", uid);
|
||||
return error;
|
||||
if (!fpl) {
|
||||
return hleLogDebug(Log::sceKernel, error, "invalid fpl", uid);
|
||||
}
|
||||
|
||||
bool wokeThreads = __KernelClearFplThreads(fpl, SCE_KERNEL_ERROR_WAIT_DELETE);
|
||||
if (wokeThreads)
|
||||
hleReSchedule("fpl deleted");
|
||||
|
||||
BlockAllocator *alloc = BlockAllocatorFromAddr(fpl->address);
|
||||
_assert_msg_(alloc != nullptr, "Should always have a valid allocator/address");
|
||||
if (alloc)
|
||||
alloc->Free(fpl->address);
|
||||
return hleLogDebug(Log::sceKernel, kernelObjects.Destroy<FPL>(uid));
|
||||
}
|
||||
|
||||
void __KernelFplTimeout(u64 userdata, int cyclesLate)
|
||||
|
@ -764,8 +753,6 @@ int sceKernelAllocateFpl(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr)
|
|||
FPL *fpl = kernelObjects.Get<FPL>(uid, error);
|
||||
if (fpl)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelAllocateFpl(%i, %08x, %08x)", uid, blockPtrAddr, timeoutPtr);
|
||||
|
||||
int blockNum = fpl->allocateBlock();
|
||||
if (blockNum >= 0) {
|
||||
u32 blockPtr = fpl->address + fpl->alignedSize * blockNum;
|
||||
|
@ -781,12 +768,11 @@ int sceKernelAllocateFpl(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr)
|
|||
__KernelWaitCurThread(WAITTYPE_FPL, uid, 0, timeoutPtr, false, "fpl waited");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelAllocateFpl(%i, %08x, %08x): invalid fpl", uid, blockPtrAddr, timeoutPtr);
|
||||
return error;
|
||||
return hleLogDebug(Log::sceKernel, error, "invalid fpl");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -817,8 +803,7 @@ int sceKernelAllocateFplCB(SceUID uid, u32 blockPtrAddr, u32 timeoutPtr)
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelAllocateFplCB(%i, %08x, %08x): invalid fpl", uid, blockPtrAddr, timeoutPtr);
|
||||
return error;
|
||||
return hleLogDebug(Log::sceKernel, error, "invalid fpl");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -842,8 +827,7 @@ int sceKernelTryAllocateFpl(SceUID uid, u32 blockPtrAddr)
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelTryAllocateFpl(%i, %08x): invalid fpl", uid, blockPtrAddr);
|
||||
return error;
|
||||
return hleLogDebug(Log::sceKernel, error, "invalid fpl");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -891,8 +875,7 @@ retry:
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelFreeFpl(%i, %08x): invalid fpl", uid, blockPtr);
|
||||
return error;
|
||||
return hleLogDebug(Log::sceKernel, error, "invalid fpl");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -916,8 +899,7 @@ int sceKernelCancelFpl(SceUID uid, u32 numWaitThreadsPtr)
|
|||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelCancelFpl(%i, %08x): invalid fpl", uid, numWaitThreadsPtr);
|
||||
return error;
|
||||
return hleLogDebug(Log::sceKernel, error, "invalid fpl");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1020,15 +1002,13 @@ public:
|
|||
static u32 sceKernelMaxFreeMemSize()
|
||||
{
|
||||
u32 retVal = userMemory.GetLargestFreeBlockSize();
|
||||
DEBUG_LOG(Log::sceKernel, "%08x (dec %i)=sceKernelMaxFreeMemSize()", retVal, retVal);
|
||||
return retVal;
|
||||
return hleLogDebug(Log::sceKernel, retVal);
|
||||
}
|
||||
|
||||
static u32 sceKernelTotalFreeMemSize()
|
||||
{
|
||||
u32 retVal = userMemory.GetTotalFreeBytes();
|
||||
DEBUG_LOG(Log::sceKernel, "%08x (dec %i)=sceKernelTotalFreeMemSize()", retVal, retVal);
|
||||
return retVal;
|
||||
return hleLogDebug(Log::sceKernel, retVal);
|
||||
}
|
||||
|
||||
int sceKernelAllocPartitionMemory(int partition, const char *name, int type, u32 size, u32 addr) {
|
||||
|
@ -1054,44 +1034,31 @@ int sceKernelAllocPartitionMemory(int partition, const char *name, int type, u32
|
|||
PartitionMemoryBlock *block = new PartitionMemoryBlock(allocator, name, size, (MemblockType)type, addr);
|
||||
if (!block->IsValid()) {
|
||||
delete block;
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelAllocPartitionMemory(partition = %i, %s, type= %i, size= %i, addr= %08x): allocation failed", partition, name, type, size, addr);
|
||||
return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED;
|
||||
return hleLogError(Log::sceKernel, SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED);
|
||||
}
|
||||
SceUID uid = kernelObjects.Create(block);
|
||||
|
||||
DEBUG_LOG(Log::sceKernel,"%i = sceKernelAllocPartitionMemory(partition = %i, %s, type= %i, size= %i, addr= %08x)",
|
||||
uid, partition, name, type, size, addr);
|
||||
|
||||
return uid;
|
||||
return hleLogDebug(Log::sceKernel, uid);
|
||||
}
|
||||
|
||||
int sceKernelFreePartitionMemory(SceUID id)
|
||||
{
|
||||
int sceKernelFreePartitionMemory(SceUID id) {
|
||||
DEBUG_LOG(Log::sceKernel,"sceKernelFreePartitionMemory(%d)",id);
|
||||
|
||||
return kernelObjects.Destroy<PartitionMemoryBlock>(id);
|
||||
}
|
||||
|
||||
u32 sceKernelGetBlockHeadAddr(SceUID id)
|
||||
{
|
||||
u32 sceKernelGetBlockHeadAddr(SceUID id) {
|
||||
u32 error;
|
||||
PartitionMemoryBlock *block = kernelObjects.Get<PartitionMemoryBlock>(id, error);
|
||||
if (block)
|
||||
{
|
||||
DEBUG_LOG(Log::sceKernel,"%08x = sceKernelGetBlockHeadAddr(%i)", block->address, id);
|
||||
return block->address;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel,"sceKernelGetBlockHeadAddr failed(%i)", id);
|
||||
return 0;
|
||||
if (block) {
|
||||
return hleLogDebug(Log::sceKernel, block->address, "addr: %08x", block->address);
|
||||
} else {
|
||||
// TODO: return value?
|
||||
return hleLogError(Log::sceKernel, 0, "sceKernelGetBlockHeadAddr failed(%i)", id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int sceKernelPrintf(const char *formatString)
|
||||
{
|
||||
if (formatString == NULL)
|
||||
static int sceKernelPrintf(const char *formatString) {
|
||||
if (!formatString)
|
||||
return -1;
|
||||
|
||||
bool supported = true;
|
||||
|
@ -1209,10 +1176,9 @@ static int sceKernelPrintf(const char *formatString)
|
|||
result.resize(result.size() - 1);
|
||||
|
||||
if (supported)
|
||||
INFO_LOG(Log::Printf, "sceKernelPrintf: %s", result.c_str());
|
||||
return hleLogSuccessInfoI(Log::Printf, 0, "\"%s\"", result.c_str());
|
||||
else
|
||||
ERROR_LOG(Log::Printf, "UNIMPL sceKernelPrintf(%s, %08x, %08x, %08x)", format.c_str(), PARAM(1), PARAM(2), PARAM(3));
|
||||
return 0;
|
||||
return hleLogError(Log::Printf, 0, "UNIMPL fmt (%s, %08x, %08x, %08x)", format.c_str(), PARAM(1), PARAM(2), PARAM(3));
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion(int sdkVersion) {
|
||||
|
@ -1243,10 +1209,9 @@ static int sceKernelSetCompiledSdkVersion(int sdkVersion) {
|
|||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelSetCompiledSdkVersion unknown SDK: %x", sdkVersion);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion370(int sdkVersion) {
|
||||
|
@ -1255,10 +1220,9 @@ static int sceKernelSetCompiledSdkVersion370(int sdkVersion) {
|
|||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelSetCompiledSdkVersion370 unknown SDK: %x", sdkVersion);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion370(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion380_390(int sdkVersion) {
|
||||
|
@ -1269,10 +1233,9 @@ static int sceKernelSetCompiledSdkVersion380_390(int sdkVersion) {
|
|||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion380_390(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion395(int sdkVersion) {
|
||||
|
@ -1285,10 +1248,9 @@ static int sceKernelSetCompiledSdkVersion395(int sdkVersion) {
|
|||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelSetCompiledSdkVersion395 unknown SDK: %x", sdkVersion);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion395(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion600_602(int sdkVersion) {
|
||||
|
@ -1299,10 +1261,9 @@ static int sceKernelSetCompiledSdkVersion600_602(int sdkVersion) {
|
|||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelSetCompiledSdkVersion600_602 unknown SDK: %x", sdkVersion);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion600_602(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion500_505(int sdkVersion)
|
||||
|
@ -1313,10 +1274,9 @@ static int sceKernelSetCompiledSdkVersion500_505(int sdkVersion)
|
|||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelSetCompiledSdkVersion500_505 unknown SDK: %x", sdkVersion);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion500_505(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion401_402(int sdkVersion) {
|
||||
|
@ -1326,10 +1286,9 @@ static int sceKernelSetCompiledSdkVersion401_402(int sdkVersion) {
|
|||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelSetCompiledSdkVersion401_402 unknown SDK: %x", sdkVersion);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion401_402(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion507(int sdkVersion) {
|
||||
|
@ -1338,10 +1297,9 @@ static int sceKernelSetCompiledSdkVersion507(int sdkVersion) {
|
|||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelSetCompiledSdkVersion507 unknown SDK: %x", sdkVersion);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion507(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion603_605(int sdkVersion) {
|
||||
|
@ -1352,10 +1310,9 @@ static int sceKernelSetCompiledSdkVersion603_605(int sdkVersion) {
|
|||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelSetCompiledSdkVersion603_605 unknown SDK: %x", sdkVersion);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion603_605(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static int sceKernelSetCompiledSdkVersion606(int sdkVersion) {
|
||||
|
@ -1364,10 +1321,9 @@ static int sceKernelSetCompiledSdkVersion606(int sdkVersion) {
|
|||
ERROR_LOG_REPORT(Log::sceKernel, "sceKernelSetCompiledSdkVersion606 unknown SDK: %x (would crash)", sdkVersion);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompiledSdkVersion606(%08x)", sdkVersion);
|
||||
sdkVersion_ = sdkVersion;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILEDSDKVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
int sceKernelGetCompiledSdkVersion() {
|
||||
|
@ -1377,10 +1333,9 @@ int sceKernelGetCompiledSdkVersion() {
|
|||
}
|
||||
|
||||
static int sceKernelSetCompilerVersion(int version) {
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSetCompilerVersion(%08x)", version);
|
||||
compilerVersion_ = version;
|
||||
flags_ |= SCE_KERNEL_HASCOMPILERVERSION;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
KernelObject *__KernelMemoryFPLObject()
|
||||
|
|
|
@ -2033,8 +2033,7 @@ int __KernelGPUReplay() {
|
|||
return result == GPURecord::ReplayResult::Break ? 1 : 0;
|
||||
}
|
||||
|
||||
int sceKernelLoadExec(const char *filename, u32 paramPtr)
|
||||
{
|
||||
int sceKernelLoadExec(const char *filename, u32 paramPtr) {
|
||||
std::string exec_filename = filename;
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(exec_filename);
|
||||
|
||||
|
@ -2050,27 +2049,24 @@ int sceKernelLoadExec(const char *filename, u32 paramPtr)
|
|||
}
|
||||
|
||||
if (!info.exists) {
|
||||
ERROR_LOG(Log::Loader, "sceKernelLoadExec(%s, ...): File does not exist", filename);
|
||||
return SCE_KERNEL_ERROR_NOFILE;
|
||||
return hleLogError(Log::Loader, SCE_KERNEL_ERROR_NOFILE, "File does not exist");
|
||||
}
|
||||
|
||||
s64 size = (s64)info.size;
|
||||
if (!size) {
|
||||
ERROR_LOG(Log::Loader, "sceKernelLoadExec(%s, ...): File is size 0", filename);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_OBJECT;
|
||||
return hleLogError(Log::Loader, SCE_KERNEL_ERROR_ILLEGAL_OBJECT, "File is size 0", filename);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceModule, "sceKernelLoadExec(name=%s,...): loading %s", filename, exec_filename.c_str());
|
||||
std::string error_string;
|
||||
if (!__KernelLoadExec(exec_filename.c_str(), paramPtr, &error_string)) {
|
||||
ERROR_LOG(Log::sceModule, "sceKernelLoadExec failed: %s", error_string.c_str());
|
||||
Core_UpdateState(CORE_RUNTIME_ERROR);
|
||||
return -1;
|
||||
return hleLogError(Log::sceModule, -1, "failed: %s", error_string.c_str());;
|
||||
}
|
||||
if (gpu) {
|
||||
gpu->Reinitialize();
|
||||
}
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceModule, 0);
|
||||
}
|
||||
|
||||
u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
|
||||
|
@ -2147,10 +2143,8 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
|
|||
|
||||
if (!module) {
|
||||
if (magic == 0x46535000) {
|
||||
ERROR_LOG(Log::Loader, "Game tried to load an SFO as a module. Go figure? Magic = %08x", magic);
|
||||
// TODO: What's actually going on here?
|
||||
error = -1;
|
||||
return hleDelayResult(error, "module loaded", 500);
|
||||
return hleDelayResult(hleLogError(Log::Loader, error, "Game tried to load an SFO as a module. Go figure? Magic = %08x", magic), "module loaded", 500);
|
||||
}
|
||||
|
||||
PSPFileInfo info = pspFileSystem.GetFileInfo(name);
|
||||
|
@ -2163,8 +2157,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
|
|||
}
|
||||
return __KernelLoadExec(safeName.c_str(), 0, &error_string);
|
||||
} else {
|
||||
hleLogError(Log::Loader, error, "failed to load");
|
||||
return hleDelayResult(error, "module loaded", 500);
|
||||
return hleDelayResult(hleLogError(Log::Loader, error, "failed to load"), "module loaded", 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2177,17 +2170,16 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) {
|
|||
}
|
||||
|
||||
// TODO: This is not the right timing and probably not the right wait type, just an approximation.
|
||||
return hleDelayResult(module->GetUID(), "module loaded", 500);
|
||||
return hleDelayResult(hleNoLog(module->GetUID()), "module loaded", 500);
|
||||
}
|
||||
|
||||
static u32 sceKernelLoadModuleNpDrm(const char *name, u32 flags, u32 optionAddr)
|
||||
{
|
||||
DEBUG_LOG(Log::Loader, "sceKernelLoadModuleNpDrm(%s, %08x)", name, flags);
|
||||
|
||||
return sceKernelLoadModule(name, flags, optionAddr);
|
||||
// TODO: Handle recursive syscall properly
|
||||
return hleLogSuccessOrError(Log::Loader, sceKernelLoadModule(name, flags, optionAddr));
|
||||
}
|
||||
|
||||
int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, SceKernelSMOption *smoption, bool *needsWait) {
|
||||
int __KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, SceKernelSMOption *smoption, bool *needsWait) {
|
||||
if (needsWait) {
|
||||
*needsWait = false;
|
||||
}
|
||||
|
@ -2225,6 +2217,7 @@ int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValue
|
|||
// TODO: Why do we skip smoption->attribute here?
|
||||
|
||||
SceUID threadID = __KernelCreateThread(module->nm.name, moduleId, entryAddr, priority, stacksize, attribute, 0, (module->nm.attribute & 0x1000) != 0);
|
||||
_dbg_assert_(threadID > 0);
|
||||
__KernelStartThreadValidate(threadID, argsize, argAddr);
|
||||
__KernelSetThreadRA(threadID, NID_MODULERETURN);
|
||||
|
||||
|
@ -2232,46 +2225,32 @@ int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValue
|
|||
*needsWait = true;
|
||||
}
|
||||
} else if (entryAddr == 0 || entryAddr == (u32)-1) {
|
||||
INFO_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x): no entry address", moduleId, argsize, argAddr, returnValueAddr);
|
||||
INFO_LOG(Log::sceModule, "__KernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x): no entry address", moduleId, argsize, argAddr, returnValueAddr);
|
||||
module->nm.status = MODULE_STATUS_STARTED;
|
||||
} else {
|
||||
ERROR_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x): invalid entry address", moduleId, argsize, argAddr, returnValueAddr);
|
||||
ERROR_LOG(Log::sceModule, "__KernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x): invalid entry address", moduleId, argsize, argAddr, returnValueAddr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, u32 optionAddr)
|
||||
{
|
||||
static u32 sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, u32 optionAddr) {
|
||||
u32 error;
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module) {
|
||||
INFO_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x): error %08x", moduleId, argsize, argAddr, returnValueAddr, optionAddr, error);
|
||||
RETURN(error);
|
||||
return;
|
||||
return hleLogWarning(Log::sceModule, error, "error %08x", error);
|
||||
} else if (module->isFake) {
|
||||
INFO_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x): faked (undecryptable module)",
|
||||
moduleId,argsize,argAddr,returnValueAddr,optionAddr);
|
||||
if (returnValueAddr)
|
||||
Memory::Write_U32(0, returnValueAddr);
|
||||
RETURN(moduleId);
|
||||
return;
|
||||
return hleLogSuccessInfoI(Log::sceModule, moduleId, "Faked (undecryptable module)");
|
||||
} else if (module->nm.status == MODULE_STATUS_STARTED) {
|
||||
ERROR_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x) : already started",
|
||||
moduleId,argsize,argAddr,returnValueAddr,optionAddr);
|
||||
// TODO: Maybe should be SCE_KERNEL_ERROR_ALREADY_STARTED, but I get SCE_KERNEL_ERROR_ERROR.
|
||||
// But I also get crashes...
|
||||
RETURN(SCE_KERNEL_ERROR_ERROR);
|
||||
return;
|
||||
return hleLogError(Log::sceModule, SCE_KERNEL_ERROR_ERROR);
|
||||
} else {
|
||||
INFO_LOG(Log::sceModule, "sceKernelStartModule(%d,asize=%08x,aptr=%08x,retptr=%08x,%08x)",
|
||||
moduleId,argsize,argAddr,returnValueAddr,optionAddr);
|
||||
|
||||
bool needsWait;
|
||||
auto smoption = PSPPointer<SceKernelSMOption>::Create(optionAddr);
|
||||
int ret = KernelStartModule(moduleId, argsize, argAddr, returnValueAddr, smoption.PtrOrNull(), &needsWait);
|
||||
|
||||
int ret = __KernelStartModule(moduleId, argsize, argAddr, returnValueAddr, smoption.PtrOrNull(), &needsWait);
|
||||
if (needsWait) {
|
||||
__KernelWaitCurThread(WAITTYPE_MODULE, moduleId, 1, 0, false, "started module");
|
||||
|
||||
|
@ -2279,8 +2258,7 @@ static void sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 ret
|
|||
module->nm.status = MODULE_STATUS_STARTING;
|
||||
module->waitingThreads.push_back(mwt);
|
||||
}
|
||||
|
||||
RETURN(ret);
|
||||
return hleLogSuccessInfoI(Log::sceModule, ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2296,21 +2274,16 @@ static u32 sceKernelStopModule(u32 moduleId, u32 argSize, u32 argAddr, u32 retur
|
|||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module)
|
||||
{
|
||||
ERROR_LOG(Log::sceModule, "sceKernelStopModule(%08x, %08x, %08x, %08x, %08x): invalid module id", moduleId, argSize, argAddr, returnValueAddr, optionAddr);
|
||||
return error;
|
||||
return hleLogError(Log::sceModule, error, "invalid module id");
|
||||
}
|
||||
|
||||
if (module->isFake)
|
||||
{
|
||||
INFO_LOG(Log::sceModule, "sceKernelStopModule(%08x, %08x, %08x, %08x, %08x) - faking", moduleId, argSize, argAddr, returnValueAddr, optionAddr);
|
||||
if (module->isFake) {
|
||||
if (returnValueAddr)
|
||||
Memory::Write_U32(0, returnValueAddr);
|
||||
return 0;
|
||||
return hleLogSuccessInfoI(Log::sceModule, 0, "faking");
|
||||
}
|
||||
if (module->nm.status != MODULE_STATUS_STARTED)
|
||||
{
|
||||
ERROR_LOG(Log::sceModule, "sceKernelStopModule(%08x, %08x, %08x, %08x, %08x): already stopped", moduleId, argSize, argAddr, returnValueAddr, optionAddr);
|
||||
return SCE_KERNEL_ERROR_ALREADY_STOPPED;
|
||||
if (module->nm.status != MODULE_STATUS_STARTED) {
|
||||
return hleLogError(Log::sceModule, SCE_KERNEL_ERROR_ALREADY_STOPPED, "already stopped");
|
||||
}
|
||||
|
||||
u32 stopFunc = module->nm.module_stop_func;
|
||||
|
@ -2340,6 +2313,7 @@ static u32 sceKernelStopModule(u32 moduleId, u32 argSize, u32 argAddr, u32 retur
|
|||
if (Memory::IsValidAddress(stopFunc))
|
||||
{
|
||||
SceUID threadID = __KernelCreateThread(module->nm.name, moduleId, stopFunc, priority, stacksize, attr, 0, (module->nm.attribute & 0x1000) != 0);
|
||||
_dbg_assert_(threadID > 0);
|
||||
__KernelStartThreadValidate(threadID, argSize, argAddr);
|
||||
__KernelSetThreadRA(threadID, NID_MODULERETURN);
|
||||
__KernelWaitCurThread(WAITTYPE_MODULE, moduleId, 1, 0, false, "stopped module");
|
||||
|
@ -2350,32 +2324,29 @@ static u32 sceKernelStopModule(u32 moduleId, u32 argSize, u32 argAddr, u32 retur
|
|||
}
|
||||
else if (stopFunc == 0)
|
||||
{
|
||||
INFO_LOG(Log::sceModule, "sceKernelStopModule(%08x, %08x, %08x, %08x, %08x): no stop func, skipping", moduleId, argSize, argAddr, returnValueAddr, optionAddr);
|
||||
module->nm.status = MODULE_STATUS_STOPPED;
|
||||
return hleLogSuccessInfoI(Log::sceModule, 0, "no stop func, skipping");
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG_REPORT(Log::sceModule, "sceKernelStopModule(%08x, %08x, %08x, %08x, %08x): bad stop func address", moduleId, argSize, argAddr, returnValueAddr, optionAddr);
|
||||
module->nm.status = MODULE_STATUS_STOPPED;
|
||||
return hleLogError(Log::sceModule, 0, "sceKernelStopModule(%08x, %08x, %08x, %08x, %08x): bad stop func address", moduleId, argSize, argAddr, returnValueAddr, optionAddr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceModule, 0);
|
||||
}
|
||||
|
||||
static u32 sceKernelUnloadModule(u32 moduleId)
|
||||
{
|
||||
INFO_LOG(Log::sceModule,"sceKernelUnloadModule(%i)", moduleId);
|
||||
static u32 sceKernelUnloadModule(u32 moduleId) {
|
||||
u32 error;
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(moduleId, error);
|
||||
if (!module)
|
||||
return hleDelayResult(error, "module unloaded", 150);
|
||||
return hleDelayResult(hleLogError(Log::sceModule, error), "module unloaded", 150);
|
||||
|
||||
module->Cleanup();
|
||||
kernelObjects.Destroy<PSPModule>(moduleId);
|
||||
return hleDelayResult(moduleId, "module unloaded", 500);
|
||||
return hleDelayResult(hleLogDebug(Log::sceModule, moduleId), "module unloaded", 500);
|
||||
}
|
||||
|
||||
u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus) {
|
||||
u32 __KernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus) {
|
||||
if (loadedModules.size() > 1) {
|
||||
if (WithStatus) {
|
||||
ERROR_LOG_REPORT(Log::sceModule, "UNIMPL sceKernelStopUnloadSelfModuleWithStatus(%08x, %08x, %08x, %08x, %08x): game may have crashed", exitCode, argSize, argp, statusAddr, optionAddr);
|
||||
|
@ -2425,6 +2396,7 @@ u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize,
|
|||
|
||||
if (Memory::IsValidAddress(stopFunc)) {
|
||||
SceUID threadID = __KernelCreateThread(module->nm.name, moduleID, stopFunc, priority, stacksize, attr, 0, (module->nm.attribute & 0x1000) != 0);
|
||||
_dbg_assert_(threadID > 0);
|
||||
__KernelStartThreadValidate(threadID, argSize, argp);
|
||||
__KernelSetThreadRA(threadID, NID_MODULERETURN);
|
||||
__KernelWaitCurThread(WAITTYPE_MODULE, moduleID, 1, 0, false, "unloadstopped module");
|
||||
|
@ -2460,12 +2432,12 @@ u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize,
|
|||
}
|
||||
|
||||
static u32 sceKernelSelfStopUnloadModule(u32 exitCode, u32 argSize, u32 argp) {
|
||||
// Used in Tom Clancy's Splinter Cell Essentials,Ghost in the Shell Stand Alone Complex
|
||||
return hleKernelStopUnloadSelfModuleWithOrWithoutStatus(exitCode, argSize, argp, 0, 0, false);
|
||||
// Used in Tom Clancy's Splinter Cell Essentials, Ghost in the Shell Stand Alone Complex
|
||||
return __KernelStopUnloadSelfModuleWithOrWithoutStatus(exitCode, argSize, argp, 0, 0, false);
|
||||
}
|
||||
|
||||
static u32 sceKernelStopUnloadSelfModuleWithStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr) {
|
||||
return hleKernelStopUnloadSelfModuleWithOrWithoutStatus(exitCode, argSize, argp, statusAddr, optionAddr, true);
|
||||
return __KernelStopUnloadSelfModuleWithOrWithoutStatus(exitCode, argSize, argp, statusAddr, optionAddr, true);
|
||||
}
|
||||
|
||||
void __KernelReturnFromModuleFunc()
|
||||
|
@ -2539,11 +2511,11 @@ static u32 sceKernelGetModuleIdByAddress(u32 moduleAddr)
|
|||
state.result = SCE_KERNEL_ERROR_UNKNOWN_MODULE;
|
||||
|
||||
kernelObjects.Iterate(&__GetModuleIdByAddressIterator, &state);
|
||||
if (state.result == (SceUID)SCE_KERNEL_ERROR_UNKNOWN_MODULE)
|
||||
ERROR_LOG(Log::sceModule, "sceKernelGetModuleIdByAddress(%08x): module not found", moduleAddr);
|
||||
else
|
||||
DEBUG_LOG(Log::sceModule, "%x=sceKernelGetModuleIdByAddress(%08x)", state.result, moduleAddr);
|
||||
return state.result;
|
||||
if (state.result == (SceUID)SCE_KERNEL_ERROR_UNKNOWN_MODULE) {
|
||||
return hleLogError(Log::sceModule, state.result, "module not found at address");
|
||||
} else {
|
||||
return hleLogSuccessOrError(Log::sceModule, state.result, "%08x", state.result);
|
||||
}
|
||||
}
|
||||
|
||||
static u32 sceKernelGetModuleId()
|
||||
|
@ -2556,8 +2528,7 @@ u32 sceKernelFindModuleByUID(u32 uid)
|
|||
u32 error;
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(uid, error);
|
||||
if (!module || module->isFake) {
|
||||
ERROR_LOG(Log::sceModule, "0 = sceKernelFindModuleByUID(%d): Module Not Found or Fake", uid);
|
||||
return 0;
|
||||
return hleLogError(Log::sceModule, 0, "Module Not Found or Fake");
|
||||
}
|
||||
return hleLogSuccessInfoI(Log::sceModule, module->modulePtr.ptr);
|
||||
}
|
||||
|
@ -2572,16 +2543,13 @@ u32 sceKernelFindModuleByName(const char *name)
|
|||
if (strcmp(name, module->nm.name) == 0) {
|
||||
if (!module->isFake) {
|
||||
INFO_LOG(Log::sceModule, "%d = sceKernelFindModuleByName(%s)", module->modulePtr.ptr, name);
|
||||
return module->modulePtr.ptr;
|
||||
}
|
||||
else {
|
||||
WARN_LOG(Log::sceModule, "0 = sceKernelFindModuleByName(%s): Module Fake", name);
|
||||
return hleDelayResult(0, "Module Fake", 1000 * 1000);
|
||||
return hleLogSuccessInfoI(Log::sceModule, module->modulePtr.ptr);
|
||||
} else {
|
||||
return hleDelayResult(hleLogWarning(Log::sceModule, 0, "Module Fake"), "Module Fake", 1000 * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
WARN_LOG(Log::sceModule, "0 = sceKernelFindModuleByName(%s): Module Not Found", name);
|
||||
return 0;
|
||||
return hleLogWarning(Log::sceModule, 0, "Module Not Found", name);
|
||||
}
|
||||
|
||||
static u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr)
|
||||
|
@ -2589,8 +2557,7 @@ static u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr)
|
|||
u32 error;
|
||||
u32 handle = __IoGetFileHandleFromId(id, error);
|
||||
if (handle == (u32)-1) {
|
||||
ERROR_LOG(Log::sceModule,"sceKernelLoadModuleByID(%08x, %08x, %08x): could not open file id",id,flags,lmoptionPtr);
|
||||
return error;
|
||||
return hleLogError(Log::sceModule, error, "couldn't open file");
|
||||
}
|
||||
if (flags != 0) {
|
||||
WARN_LOG_REPORT(Log::Loader, "sceKernelLoadModuleByID: unsupported flags: %08x", flags);
|
||||
|
@ -2615,8 +2582,7 @@ static u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr)
|
|||
// Some games try to load strange stuff as PARAM.SFO as modules and expect it to fail.
|
||||
// This checks for the SFO magic number.
|
||||
if (magic == 0x46535000) {
|
||||
ERROR_LOG(Log::Loader, "Game tried to load an SFO as a module. Go figure? Magic = %08x", magic);
|
||||
return error;
|
||||
return hleLogError(Log::Loader, error, "Game tried to load an SFO as a module. Go figure? Magic = %08x", magic);
|
||||
}
|
||||
|
||||
if ((int)error >= 0)
|
||||
|
@ -2629,7 +2595,7 @@ static u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr)
|
|||
else
|
||||
{
|
||||
NOTICE_LOG(Log::Loader, "Module %d failed to load: %08x", id, error);
|
||||
return error;
|
||||
return hleLogError(Log::Loader, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2641,13 +2607,13 @@ static u32 sceKernelLoadModuleByID(u32 id, u32 flags, u32 lmoptionPtr)
|
|||
INFO_LOG(Log::sceModule,"%i=sceKernelLoadModuleByID(%d,flag=%08x,(...))", module->GetUID(), id, flags);
|
||||
}
|
||||
|
||||
return module->GetUID();
|
||||
return hleNoLog(module->GetUID());
|
||||
}
|
||||
|
||||
static u32 sceKernelLoadModuleDNAS(const char *name, u32 flags)
|
||||
{
|
||||
ERROR_LOG_REPORT(Log::sceModule, "UNIMPL 0=sceKernelLoadModuleDNAS()");
|
||||
return 0;
|
||||
return hleNoLog(0);
|
||||
}
|
||||
|
||||
// Pretty sure this is a badly brute-forced function name...
|
||||
|
@ -2671,12 +2637,10 @@ static SceUID sceKernelLoadModuleBufferUsbWlan(u32 size, u32 bufPtr, u32 flags,
|
|||
// Some games try to load strange stuff as PARAM.SFO as modules and expect it to fail.
|
||||
// This checks for the SFO magic number.
|
||||
if (magic == 0x46535000) {
|
||||
ERROR_LOG(Log::Loader, "Game tried to load an SFO as a module. Go figure? Magic = %08x", magic);
|
||||
return error;
|
||||
return hleLogError(Log::Loader, error, "Game tried to load an SFO as a module. Go figure? Magic = %08x", magic);
|
||||
}
|
||||
|
||||
if ((int)error >= 0)
|
||||
{
|
||||
if ((int)error >= 0) {
|
||||
// Module was blacklisted or couldn't be decrypted, which means it's a kernel module we don't want to run..
|
||||
// Let's just act as if it worked.
|
||||
NOTICE_LOG(Log::Loader, "Module is blacklisted or undecryptable - we lie about success");
|
||||
|
@ -2697,7 +2661,7 @@ static SceUID sceKernelLoadModuleBufferUsbWlan(u32 size, u32 bufPtr, u32 flags,
|
|||
INFO_LOG(Log::sceModule,"%i=sceKernelLoadModuleBufferUsbWlan(%x,%08x,flag=%08x,(...))", module->GetUID(), size,bufPtr, flags);
|
||||
}
|
||||
|
||||
return module->GetUID();
|
||||
return hleNoLog(module->GetUID());
|
||||
}
|
||||
|
||||
static u32 sceKernelQueryModuleInfo(u32 uid, u32 infoAddr)
|
||||
|
@ -2705,11 +2669,11 @@ static u32 sceKernelQueryModuleInfo(u32 uid, u32 infoAddr)
|
|||
DEBUG_LOG(Log::sceModule, "sceKernelQueryModuleInfo(%i, %08x)", uid, infoAddr);
|
||||
u32 error;
|
||||
PSPModule *module = kernelObjects.Get<PSPModule>(uid, error);
|
||||
if (!module)
|
||||
if (!module) {
|
||||
return error;
|
||||
}
|
||||
if (!Memory::IsValidAddress(infoAddr)) {
|
||||
ERROR_LOG(Log::sceModule, "sceKernelQueryModuleInfo(%i, %08x) - bad infoAddr", uid, infoAddr);
|
||||
return -1;
|
||||
return hleLogError(Log::sceModule, -1, "bad infoAddr");
|
||||
}
|
||||
|
||||
auto info = PSPPointer<ModuleInfo>::Create(infoAddr);
|
||||
|
@ -2733,7 +2697,7 @@ static u32 sceKernelQueryModuleInfo(u32 uid, u32 infoAddr)
|
|||
memcpy(info->name, module->nm.name, 28);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return hleNoLog(0);
|
||||
}
|
||||
|
||||
static u32 sceKernelGetModuleIdList(u32 resultBuffer, u32 resultBufferSize, u32 idCountAddr)
|
||||
|
@ -2757,7 +2721,7 @@ static u32 sceKernelGetModuleIdList(u32 resultBuffer, u32 resultBufferSize, u32
|
|||
|
||||
Memory::Write_U32(idCount, idCountAddr);
|
||||
|
||||
return 0;
|
||||
return hleNoLog(0);
|
||||
}
|
||||
|
||||
//fix for tiger x dragon
|
||||
|
@ -2765,11 +2729,10 @@ static u32 sceKernelLoadModuleForLoadExecVSHDisc(const char *name, u32 flags, u3
|
|||
return sceKernelLoadModule(name, flags, optionAddr);
|
||||
}
|
||||
|
||||
const HLEFunction ModuleMgrForUser[] =
|
||||
{
|
||||
const HLEFunction ModuleMgrForUser[] = {
|
||||
{0X977DE386, &WrapU_CUU<sceKernelLoadModule>, "sceKernelLoadModule", 'x', "sxx" },
|
||||
{0XB7F46618, &WrapU_UUU<sceKernelLoadModuleByID>, "sceKernelLoadModuleByID", 'x', "xxx" },
|
||||
{0X50F0C1EC, &WrapV_UUUUU<sceKernelStartModule>, "sceKernelStartModule", 'v', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED },
|
||||
{0X50F0C1EC, &WrapU_UUUUU<sceKernelStartModule>, "sceKernelStartModule", 'v', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED },
|
||||
{0XD675EBB8, &WrapU_UUU<sceKernelSelfStopUnloadModule>, "sceKernelSelfStopUnloadModule", 'x', "xxx" },
|
||||
{0XD1FF982A, &WrapU_UUUUU<sceKernelStopModule>, "sceKernelStopModule", 'x', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED },
|
||||
{0X2E0911AA, &WrapU_U<sceKernelUnloadModule>, "sceKernelUnloadModule", 'x', "x" },
|
||||
|
@ -2788,9 +2751,8 @@ const HLEFunction ModuleMgrForUser[] =
|
|||
};
|
||||
|
||||
|
||||
const HLEFunction ModuleMgrForKernel[] =
|
||||
{
|
||||
{0x50F0C1EC, &WrapV_UUUUU<sceKernelStartModule>, "sceKernelStartModule", 'v', "xxxxx", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED | HLE_KERNEL_SYSCALL },
|
||||
const HLEFunction ModuleMgrForKernel[] = {
|
||||
{0x50F0C1EC, &WrapU_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
|
||||
{0xCC1D3699, &WrapU_UUU<sceKernelSelfStopUnloadModule>, "sceKernelStopUnloadSelfModule", 'x', "xxx", HLE_KERNEL_SYSCALL }, // used in Dissidia final fantasy chinese patch
|
||||
|
@ -2800,13 +2762,10 @@ const HLEFunction ModuleMgrForKernel[] =
|
|||
{0X2E0911AA, &WrapU_U<sceKernelUnloadModule>, "sceKernelUnloadModule", 'x', "x" , HLE_KERNEL_SYSCALL },
|
||||
};
|
||||
|
||||
void Register_ModuleMgrForUser()
|
||||
{
|
||||
void Register_ModuleMgrForUser() {
|
||||
RegisterModule("ModuleMgrForUser", ARRAY_SIZE(ModuleMgrForUser), ModuleMgrForUser);
|
||||
}
|
||||
|
||||
void Register_ModuleMgrForKernel()
|
||||
{
|
||||
void Register_ModuleMgrForKernel() {
|
||||
RegisterModule("ModuleMgrForKernel", ARRAY_SIZE(ModuleMgrForKernel), ModuleMgrForKernel);
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str
|
|||
int __KernelGPUReplay();
|
||||
void __KernelReturnFromModuleFunc();
|
||||
SceUID KernelLoadModule(const std::string &filename, std::string *error_string);
|
||||
int KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, SceKernelSMOption *smoption, bool *needsWait);
|
||||
u32 hleKernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus);
|
||||
int __KernelStartModule(SceUID moduleId, u32 argsize, u32 argAddr, u32 returnValueAddr, SceKernelSMOption *smoption, bool *needsWait);
|
||||
u32 __KernelStopUnloadSelfModuleWithOrWithoutStatus(u32 exitCode, u32 argSize, u32 argp, u32 statusAddr, u32 optionAddr, bool WithStatus);
|
||||
u32 sceKernelFindModuleByUID(u32 uid);
|
||||
|
||||
void Register_ModuleMgrForUser();
|
||||
|
|
|
@ -810,8 +810,7 @@ int sceKernelSendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitMode
|
|||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelSendMsgPipe(%i) - ERROR %08x", uid, error);
|
||||
return error;
|
||||
return hleLogError(Log::sceKernel, error, "ERROR %08x", error);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSendMsgPipe(id=%i, addr=%08x, size=%i, mode=%i, result=%08x, timeout=%08x)", uid, sendBufAddr, sendSize, waitMode, resultAddr, timeoutPtr);
|
||||
|
@ -826,8 +825,7 @@ int sceKernelSendMsgPipeCB(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitMo
|
|||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelSendMsgPipeCB(%i) - ERROR %08x", uid, error);
|
||||
return error;
|
||||
return hleLogError(Log::sceKernel, error, "ERROR %08x", error);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelSendMsgPipeCB(id=%i, addr=%08x, size=%i, mode=%i, result=%08x, timeout=%08x)", uid, sendBufAddr, sendSize, waitMode, resultAddr, timeoutPtr);
|
||||
|
@ -844,8 +842,7 @@ int sceKernelTrySendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, u32 waitM
|
|||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelTrySendMsgPipe(%i) - ERROR %08x", uid, error);
|
||||
return error;
|
||||
return hleLogError(Log::sceKernel, error, "ERROR %08x, couldn't find msgpipe", error);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelTrySendMsgPipe(id=%i, addr=%08x, size=%i, mode=%i, result=%08x)", uid, sendBufAddr, sendSize, waitMode, resultAddr);
|
||||
|
@ -917,8 +914,7 @@ int sceKernelReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize, u32
|
|||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelReceiveMsgPipe(%i) - ERROR %08x", uid, error);
|
||||
return error;
|
||||
return hleLogError(Log::sceKernel, error, "ERROR %08x", error);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelReceiveMsgPipe(%i, %08x, %i, %i, %08x, %08x)", uid, receiveBufAddr, receiveSize, waitMode, resultAddr, timeoutPtr);
|
||||
|
@ -933,8 +929,7 @@ int sceKernelReceiveMsgPipeCB(SceUID uid, u32 receiveBufAddr, u32 receiveSize, u
|
|||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelReceiveMsgPipeCB(%i) - ERROR %08x", uid, error);
|
||||
return error;
|
||||
return hleLogError(Log::sceKernel, error, "ERROR %08x", error);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelReceiveMsgPipeCB(%i, %08x, %i, %i, %08x, %08x)", uid, receiveBufAddr, receiveSize, waitMode, resultAddr, timeoutPtr);
|
||||
|
@ -951,8 +946,7 @@ int sceKernelTryReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize,
|
|||
}
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m) {
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelTryReceiveMsgPipe(%i) - ERROR %08x", uid, error);
|
||||
return error;
|
||||
return hleLogError(Log::sceKernel, error, "ERROR %08x", error);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelTryReceiveMsgPipe(%i, %08x, %i, %i, %08x)", uid, receiveBufAddr, receiveSize, waitMode, resultAddr);
|
||||
|
@ -965,10 +959,8 @@ int sceKernelCancelMsgPipe(SceUID uid, u32 numSendThreadsAddr, u32 numReceiveThr
|
|||
|
||||
u32 error;
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m)
|
||||
{
|
||||
ERROR_LOG(Log::sceKernel, "sceKernelCancelMsgPipe(%i) - ERROR %08x", uid, error);
|
||||
return error;
|
||||
if (!m) {
|
||||
return hleLogError(Log::sceKernel, error, "ERROR %08x", error);
|
||||
}
|
||||
|
||||
hleEatCycles(1100);
|
||||
|
@ -990,8 +982,7 @@ int sceKernelCancelMsgPipe(SceUID uid, u32 numSendThreadsAddr, u32 numReceiveThr
|
|||
// And now the entire buffer is free.
|
||||
m->nmp.freeSize = m->nmp.bufSize;
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelCancelMsgPipe(%i, %i, %i)", uid, numSendThreadsAddr, numReceiveThreadsAddr);
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
int sceKernelReferMsgPipeStatus(SceUID uid, u32 statusPtr) {
|
||||
|
|
|
@ -221,16 +221,17 @@ int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32
|
|||
s->ns.maxCount = maxVal;
|
||||
s->ns.numWaitThreads = 0;
|
||||
|
||||
if ((attr & ~PSP_SEMA_ATTR_PRIORITY) != 0) {
|
||||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelCreateSema(%s) unsupported attr parameter: %08x", name, attr);
|
||||
}
|
||||
|
||||
// Many games pass garbage into optionPtr, it doesn't have any options.
|
||||
if (optionPtr != 0) {
|
||||
if (!Memory::IsValidRange(optionPtr, 4))
|
||||
hleLogWarning(Log::sceKernel, id, "invalid options parameter");
|
||||
return hleLogWarning(Log::sceKernel, id, "invalid options parameter");
|
||||
else if (Memory::Read_U32(optionPtr) > 4)
|
||||
hleLogDebug(Log::sceKernel, id, "invalid options parameter size");
|
||||
return hleLogDebug(Log::sceKernel, id, "invalid options parameter size");
|
||||
}
|
||||
if ((attr & ~PSP_SEMA_ATTR_PRIORITY) != 0)
|
||||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelCreateSema(%s) unsupported attr parameter: %08x", name, attr);
|
||||
|
||||
return hleLogSuccessX(Log::sceKernel, id);
|
||||
}
|
||||
|
||||
|
|
|
@ -606,7 +606,7 @@ struct WaitTypeFuncs
|
|||
|
||||
bool __KernelExecuteMipsCallOnCurrentThread(u32 callId, bool reschedAfter);
|
||||
|
||||
PSPThread *__KernelCreateThread(SceUID &id, SceUID moduleID, const char *name, u32 entryPoint, u32 priority, int stacksize, u32 attr);
|
||||
PSPThread *__KernelCreateThreadObject(SceUID &id, SceUID moduleID, const char *name, u32 entryPoint, u32 priority, int stacksize, u32 attr);
|
||||
void __KernelResetThread(PSPThread *t, int lowestPriority);
|
||||
void __KernelCancelWakeup(SceUID threadID);
|
||||
void __KernelCancelThreadEndTimeout(SceUID threadID);
|
||||
|
@ -943,8 +943,8 @@ void __KernelThreadingInit()
|
|||
|
||||
// Create the two idle threads, as well. With the absolute minimal possible priority.
|
||||
// 4096 stack size - don't know what the right value is. Hm, if callbacks are ever to run on these threads...
|
||||
__KernelResetThread(__KernelCreateThread(threadIdleID[0], 0, "idle0", idleThreadHackAddr, 0x7f, 4096, PSP_THREAD_ATTR_KERNEL), 0);
|
||||
__KernelResetThread(__KernelCreateThread(threadIdleID[1], 0, "idle1", idleThreadHackAddr, 0x7f, 4096, PSP_THREAD_ATTR_KERNEL), 0);
|
||||
__KernelResetThread(__KernelCreateThreadObject(threadIdleID[0], 0, "idle0", idleThreadHackAddr, 0x7f, 4096, PSP_THREAD_ATTR_KERNEL), 0);
|
||||
__KernelResetThread(__KernelCreateThreadObject(threadIdleID[1], 0, "idle1", idleThreadHackAddr, 0x7f, 4096, PSP_THREAD_ATTR_KERNEL), 0);
|
||||
// These idle threads are later started in LoadExec, which calls __KernelStartIdleThreads below.
|
||||
|
||||
__KernelListenThreadEnd(__KernelCancelWakeup);
|
||||
|
@ -1858,7 +1858,7 @@ void __KernelResetThread(PSPThread *t, int lowestPriority) {
|
|||
ERROR_LOG_REPORT(Log::sceKernel, "Resetting thread with threads waiting on end?");
|
||||
}
|
||||
|
||||
PSPThread *__KernelCreateThread(SceUID &id, SceUID moduleId, const char *name, u32 entryPoint, u32 priority, int stacksize, u32 attr) {
|
||||
PSPThread *__KernelCreateThreadObject(SceUID &id, SceUID moduleId, const char *name, u32 entryPoint, u32 priority, int stacksize, u32 attr) {
|
||||
std::lock_guard<std::mutex> guard(threadqueueLock);
|
||||
|
||||
PSPThread *t = new PSPThread();
|
||||
|
@ -1908,7 +1908,7 @@ SceUID __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int
|
|||
{
|
||||
//grab mips regs
|
||||
SceUID id;
|
||||
PSPThread *thread = __KernelCreateThread(id, moduleID, "root", currentMIPS->pc, prio, stacksize, attr);
|
||||
PSPThread *thread = __KernelCreateThreadObject(id, moduleID, "root", currentMIPS->pc, prio, stacksize, attr);
|
||||
if (thread->currentStack.start == 0)
|
||||
ERROR_LOG_REPORT(Log::sceKernel, "Unable to allocate stack for root thread.");
|
||||
__KernelResetThread(thread, 0);
|
||||
|
@ -1919,7 +1919,7 @@ SceUID __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int
|
|||
__SetCurrentThread(thread, id, "root");
|
||||
thread->nt.status = THREADSTATUS_RUNNING; // do not schedule
|
||||
|
||||
strcpy(thread->nt.name, "root");
|
||||
truncate_cpy(thread->nt.name, "root");
|
||||
|
||||
KernelValidateThreadTarget(thread->context.pc);
|
||||
|
||||
|
@ -1939,32 +1939,44 @@ SceUID __KernelSetupRootThread(SceUID moduleID, int args, const char *argp, int
|
|||
SceUID __KernelCreateThreadInternal(const char *threadName, SceUID moduleID, u32 entry, u32 prio, int stacksize, u32 attr)
|
||||
{
|
||||
SceUID id;
|
||||
PSPThread *newThread = __KernelCreateThread(id, moduleID, threadName, entry, prio, stacksize, attr);
|
||||
PSPThread *newThread = __KernelCreateThreadObject(id, moduleID, threadName, entry, prio, stacksize, attr);
|
||||
if (newThread->currentStack.start == 0)
|
||||
return SCE_KERNEL_ERROR_NO_MEMORY;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
// Note: Removed all the uses of hleReport* etc.
|
||||
int __KernelCreateThread(const char *threadName, SceUID moduleID, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr, bool allowKernel) {
|
||||
if (threadName == nullptr)
|
||||
return hleReportError(Log::sceKernel, SCE_KERNEL_ERROR_ERROR, "NULL thread name");
|
||||
if (!threadName) {
|
||||
ERROR_LOG(Log::sceKernel, "__KernelCreateThread: NULL thread name");
|
||||
return SCE_KERNEL_ERROR_ERROR;
|
||||
}
|
||||
|
||||
if ((u32)stacksize < 0x200)
|
||||
return hleReportWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_STACK_SIZE, "bogus thread stack size %08x", stacksize);
|
||||
if ((u32)stacksize < 0x200) {
|
||||
WARN_LOG_REPORT(Log::sceKernel, "bogus thread stack size %08x", stacksize);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_STACK_SIZE;
|
||||
}
|
||||
if (prio < 0x08 || prio > 0x77) {
|
||||
return hleReportWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_PRIORITY, "bogus thread priority %08x", prio);
|
||||
WARN_LOG(Log::sceKernel, "bogus thread priority %08x", prio);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_PRIORITY;
|
||||
}
|
||||
if (!Memory::IsValidAddress(entry)) {
|
||||
// The PSP firmware seems to allow NULL...?
|
||||
if (entry != 0)
|
||||
return hleReportError(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid thread entry %08x", entry);
|
||||
if (entry != 0) {
|
||||
ERROR_LOG(Log::sceKernel, "invalid thread entry %08x", entry);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ADDR;
|
||||
}
|
||||
}
|
||||
if ((attr & ~PSP_THREAD_ATTR_USER_MASK) != 0 && !allowKernel)
|
||||
return hleReportWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ATTR, "illegal thread attributes %08x", attr);
|
||||
|
||||
if ((attr & ~PSP_THREAD_ATTR_SUPPORTED) != 0)
|
||||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelCreateThread(name=%s): unsupported attributes %08x", threadName, attr);
|
||||
if ((attr & ~PSP_THREAD_ATTR_USER_MASK) != 0 && !allowKernel) {
|
||||
WARN_LOG(Log::sceKernel, "illegal thread attributes %08x", attr);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ATTR;
|
||||
}
|
||||
|
||||
if ((attr & ~PSP_THREAD_ATTR_SUPPORTED) != 0) {
|
||||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelCreateThread(name=%s): unsupported attributes %08x, ignoring", threadName, attr & ~PSP_THREAD_ATTR_SUPPORTED);
|
||||
}
|
||||
|
||||
// TODO: Not sure what these values are, but they are removed from the attr silently.
|
||||
// Some are USB/VSH specific, probably removes when they are from the wrong module?
|
||||
|
@ -1979,11 +1991,14 @@ int __KernelCreateThread(const char *threadName, SceUID moduleID, u32 entry, u32
|
|||
}
|
||||
|
||||
SceUID id = __KernelCreateThreadInternal(threadName, moduleID, entry, prio, stacksize, attr);
|
||||
if ((u32)id == SCE_KERNEL_ERROR_NO_MEMORY)
|
||||
return hleReportError(Log::sceKernel, SCE_KERNEL_ERROR_NO_MEMORY, "out of memory, %08x stack requested", stacksize);
|
||||
if ((u32)id == SCE_KERNEL_ERROR_NO_MEMORY) {
|
||||
ERROR_LOG_REPORT(Log::sceKernel, "out of memory, %08x stack requested", stacksize);
|
||||
return SCE_KERNEL_ERROR_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (optionAddr != 0)
|
||||
if (optionAddr != 0) {
|
||||
WARN_LOG_REPORT(Log::sceKernel, "sceKernelCreateThread(name=%s): unsupported options parameter %08x", threadName, optionAddr);
|
||||
}
|
||||
|
||||
// Creating a thread resumes dispatch automatically. Probably can't create without it.
|
||||
dispatchEnabled = true;
|
||||
|
@ -1996,14 +2011,19 @@ int __KernelCreateThread(const char *threadName, SceUID moduleID, u32 entry, u32
|
|||
// Before triggering, set v0, since we restore on return.
|
||||
RETURN(id);
|
||||
__KernelThreadTriggerEvent((attr & PSP_THREAD_ATTR_KERNEL) != 0, id, THREADEVENT_CREATE);
|
||||
return hleLogSuccessInfoI(Log::sceKernel, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
int sceKernelCreateThread(const char *threadName, u32 entry, u32 prio, int stacksize, u32 attr, u32 optionAddr) {
|
||||
PSPThread *cur = __GetCurrentThread();
|
||||
SceUID module = __KernelGetCurThreadModuleId();
|
||||
bool allowKernel = KernelModuleIsKernelMode(module) || hleIsKernelMode() || (cur ? (cur->nt.attr & PSP_THREAD_ATTR_KERNEL) != 0 : false);
|
||||
return __KernelCreateThread(threadName, module, entry, prio, stacksize, attr, optionAddr, allowKernel);
|
||||
int retval = __KernelCreateThread(threadName, module, entry, prio, stacksize, attr, optionAddr, allowKernel);
|
||||
if (retval < 0) {
|
||||
return hleLogError(Log::sceKernel, retval);
|
||||
} else {
|
||||
return hleLogSuccessInfoI(Log::sceKernel, retval);
|
||||
}
|
||||
}
|
||||
|
||||
int __KernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr, bool forceArgs) {
|
||||
|
@ -3613,9 +3633,8 @@ int sceKernelRegisterExitCallback(SceUID cbId)
|
|||
return 0;
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::sceKernel, "sceKernelRegisterExitCallback(%i)", cbId);
|
||||
registeredExitCbId = cbId;
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
int LoadExecForUser_362A956B()
|
||||
|
@ -3624,33 +3643,28 @@ int LoadExecForUser_362A956B()
|
|||
u32 error;
|
||||
PSPCallback *cb = kernelObjects.Get<PSPCallback>(registeredExitCbId, error);
|
||||
if (!cb) {
|
||||
WARN_LOG(Log::sceKernel, "LoadExecForUser_362A956B() : registeredExitCbId not found 0x%x", registeredExitCbId);
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_CBID;
|
||||
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_UNKNOWN_CBID, "registeredExitCbId not found 0x%x", registeredExitCbId);
|
||||
}
|
||||
int cbArg = cb->nc.commonArgument;
|
||||
if (!Memory::IsValidAddress(cbArg)) {
|
||||
WARN_LOG(Log::sceKernel, "LoadExecForUser_362A956B() : invalid address for cbArg (0x%08X)", cbArg);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ADDR;
|
||||
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid address for cbArg (0x%08X)", cbArg);
|
||||
}
|
||||
u32 unknown1 = Memory::Read_U32(cbArg - 8);
|
||||
if (unknown1 >= 4) {
|
||||
WARN_LOG(Log::sceKernel, "LoadExecForUser_362A956B() : invalid value unknown1 (0x%08X)", unknown1);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT;
|
||||
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ARGUMENT, "invalid value unknown1 (0x%08X)", unknown1);
|
||||
}
|
||||
u32 parameterArea = Memory::Read_U32(cbArg - 4);
|
||||
if (!Memory::IsValidAddress(parameterArea)) {
|
||||
WARN_LOG(Log::sceKernel, "LoadExecForUser_362A956B() : invalid address for parameterArea on userMemory (0x%08X)", parameterArea);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ADDR;
|
||||
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid address for parameterArea on userMemory (0x%08X)", parameterArea);
|
||||
}
|
||||
|
||||
u32 size = Memory::Read_U32(parameterArea);
|
||||
if (size < 12) {
|
||||
WARN_LOG(Log::sceKernel, "LoadExecForUser_362A956B() : invalid parameterArea size %d", size);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_SIZE;
|
||||
return hleLogWarning(Log::sceKernel, SCE_KERNEL_ERROR_ILLEGAL_SIZE, "invalid parameterArea size %d", size);
|
||||
}
|
||||
Memory::Write_U32(0, parameterArea + 4);
|
||||
Memory::Write_U32(-1, parameterArea + 8);
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceKernel, 0);
|
||||
}
|
||||
|
||||
static const SceUID SCE_TE_THREADID_ALL_USER = 0xFFFFFFF0;
|
||||
|
|
|
@ -166,7 +166,6 @@ std::string __KernelThreadingSummary();
|
|||
KernelObject *__KernelThreadObject();
|
||||
KernelObject *__KernelCallbackObject();
|
||||
|
||||
void __KernelScheduleWakeup(int threadnumber, s64 usFromNow);
|
||||
SceUID __KernelGetCurThread();
|
||||
int KernelCurThreadPriority();
|
||||
bool KernelChangeThreadPriority(SceUID threadID, int priority);
|
||||
|
@ -259,9 +258,8 @@ int __KernelRegisterActionType(ActionCreator creator);
|
|||
void __KernelRestoreActionType(int actionType, ActionCreator creator);
|
||||
|
||||
struct MipsCall {
|
||||
MipsCall()
|
||||
{
|
||||
doAfter = NULL;
|
||||
MipsCall() {
|
||||
doAfter = nullptr;
|
||||
}
|
||||
|
||||
u32 entryPoint;
|
||||
|
|
|
@ -1172,6 +1172,8 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr
|
|||
// We stored the video stream id here in sceMpegGetAvcAu().
|
||||
ctx->mediaengine->setVideoStream(avcAu.esBuffer);
|
||||
|
||||
int accumDelay = 0;
|
||||
|
||||
if (ispmp){
|
||||
#ifdef USE_FFMPEG
|
||||
while (pmp_queue.size() != 0){
|
||||
|
@ -1183,12 +1185,11 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr
|
|||
ctx->videoFrameCount++;
|
||||
|
||||
// free front frame
|
||||
hleDelayResult(0, "pmp video decode", 30);
|
||||
accumDelay += 30;
|
||||
pmp_queue.pop_front();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if(ctx->mediaengine->stepVideo(ctx->videoPixelMode)) {
|
||||
} else if (ctx->mediaengine->stepVideo(ctx->videoPixelMode)) {
|
||||
int bufferSize = ctx->mediaengine->writeVideoImage(buffer, frameWidth, ctx->videoPixelMode);
|
||||
gpu->PerformWriteFormattedFromMemory(buffer, bufferSize, frameWidth, (GEBufferFormat)ctx->videoPixelMode);
|
||||
ctx->avc.avcFrameStatus = 1;
|
||||
|
@ -1220,12 +1221,11 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr
|
|||
}
|
||||
ctx->avc.avcDecodeResult = MPEG_AVC_DECODE_SUCCESS;
|
||||
|
||||
DEBUG_LOG(Log::ME, "sceMpegAvcDecode(%08x, %08x, %i, %08x, %08x)", mpeg, auAddr, frameWidth, bufferAddr, initAddr);
|
||||
|
||||
if (ctx->videoFrameCount <= 1)
|
||||
return hleDelayResult(0, "mpeg decode", avcFirstDelayMs);
|
||||
else
|
||||
return hleDelayResult(0, "mpeg decode", avcDecodeDelayMs);
|
||||
if (ctx->videoFrameCount <= 1) {
|
||||
return hleDelayResult(hleLogSuccessI(Log::ME, 0), "mpeg decode", accumDelay + avcFirstDelayMs);
|
||||
} else {
|
||||
return hleDelayResult(hleLogSuccessI(Log::ME, 0), "mpeg decode", accumDelay + avcDecodeDelayMs);
|
||||
}
|
||||
//hleEatMicro(3300);
|
||||
//return hleDelayResult(0, "mpeg decode", 200);
|
||||
}
|
||||
|
|
|
@ -695,12 +695,11 @@ static u32 sceNetTerm() {
|
|||
auto n = GetI18NCategory(I18NCat::NETWORKING);
|
||||
g_OSD.Show(OSDType::MESSAGE_INFO, n->T("Network shutdown"), 2.0, "networkinit");
|
||||
|
||||
WARN_LOG(Log::sceNet, "sceNetTerm() at %08x", currentMIPS->pc);
|
||||
int retval = Net_Term();
|
||||
|
||||
// Give time to make sure everything are cleaned up
|
||||
hleEatMicro(adhocDefaultDelay);
|
||||
return retval;
|
||||
return hleLogWarning(Log::sceNet, retval, "at %08x", currentMIPS->pc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -820,16 +819,12 @@ static int sceNetInit(u32 poolSize, u32 calloutPri, u32 calloutStack, u32 netini
|
|||
// Free(delete) thread info / data.
|
||||
// Normal usage: sceKernelDeleteThread followed by sceNetFreeThreadInfo with the same threadID as argument
|
||||
static int sceNetFreeThreadinfo(SceUID thid) {
|
||||
ERROR_LOG(Log::sceNet, "UNIMPL sceNetFreeThreadinfo(%i)", thid);
|
||||
|
||||
return 0;
|
||||
return hleLogError(Log::sceNet, 0, "UNIMPL");
|
||||
}
|
||||
|
||||
// Abort a thread.
|
||||
static int sceNetThreadAbort(SceUID thid) {
|
||||
ERROR_LOG(Log::sceNet, "UNIMPL sceNetThreadAbort(%i)", thid);
|
||||
|
||||
return 0;
|
||||
return hleLogError(Log::sceNet, 0, "UNIMPL");
|
||||
}
|
||||
|
||||
static u32 sceWlanGetEtherAddr(u32 addrAddr) {
|
||||
|
@ -885,6 +880,8 @@ static void sceNetEtherNtostr(u32 macPtr, u32 bufferPtr) {
|
|||
|
||||
VERBOSE_LOG(Log::sceNet, "sceNetEtherNtostr - [%s]", buffer);
|
||||
}
|
||||
|
||||
hleNoLogVoid();
|
||||
}
|
||||
|
||||
static int hex_to_digit(int c) {
|
||||
|
@ -933,6 +930,7 @@ static void sceNetEtherStrton(u32 bufferPtr, u32 macPtr) {
|
|||
// Seems to maybe kinda return the last value. Probably returns void.
|
||||
//return value;
|
||||
}
|
||||
hleNoLogVoid();
|
||||
}
|
||||
|
||||
// Write static data since we don't actually manage any memory for sceNet* yet.
|
||||
|
|
|
@ -1996,8 +1996,7 @@ int sceNetAdhocSetSocketAlert(int id, int flag) {
|
|||
WARN_LOG_REPORT_ONCE(sceNetAdhocSetSocketAlert, Log::sceNet, "UNTESTED sceNetAdhocSetSocketAlert(%d, %08x) at %08x", id, flag, currentMIPS->pc);
|
||||
|
||||
int retval = NetAdhoc_SetSocketAlert(id, flag);
|
||||
hleDelayResult(retval, "set socket alert delay", 1000);
|
||||
return hleLogDebug(Log::sceNet, retval, "");
|
||||
return hleDelayResult(hleLogDebug(Log::sceNet, retval, ""), "set socket alert delay", 1000);
|
||||
}
|
||||
|
||||
int PollAdhocSocket(SceNetAdhocPollSd* sds, int count, int timeout, int nonblock) {
|
||||
|
@ -3482,12 +3481,14 @@ static int sceNetAdhocPtpOpen(const char *srcmac, int sport, const char *dstmac,
|
|||
NetAdhocPtp_Connect(i + 1, rexmt_int, 1, false);
|
||||
|
||||
// Workaround to give some time to get connected before returning from PtpOpen over high latency
|
||||
if (g_Config.bForcedFirstConnect && internal->attemptCount == 1)
|
||||
hleDelayResult(i + 1, "delayed ptpopen", rexmt_int);
|
||||
INFO_LOG(Log::sceNet, "sceNetAdhocPtpOpen - PSP Socket id: %i, Host Socket id: %i", i + 1, tcpsocket);
|
||||
|
||||
// Return PTP Socket id
|
||||
INFO_LOG(Log::sceNet, "sceNetAdhocPtpOpen - PSP Socket id: %i, Host Socket id: %i", i + 1, tcpsocket);
|
||||
return i + 1;
|
||||
if (g_Config.bForcedFirstConnect && internal->attemptCount == 1) {
|
||||
return hleDelayResult(hleLogDebug(Log::sceNet, i + 1), "delayed ptpopen", rexmt_int);
|
||||
} else {
|
||||
return hleLogDebug(Log::sceNet, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Free Memory
|
||||
|
@ -3613,10 +3614,8 @@ int AcceptPtpSocket(int ptpId, int newsocket, sockaddr_in& peeraddr, SceNetEther
|
|||
// Switch to non-blocking for futher usage
|
||||
changeBlockingMode(newsocket, 1);
|
||||
|
||||
INFO_LOG(Log::sceNet, "sceNetAdhocPtpAccept[%i->%i(%i):%u]: Established (%s:%u) - state: %d", ptpId, i + 1, newsocket, internal->data.ptp.lport, ip2str(peeraddr.sin_addr).c_str(), internal->data.ptp.pport, internal->data.ptp.state);
|
||||
|
||||
// Return Socket
|
||||
return i + 1;
|
||||
return hleLogSuccessI(Log::sceNet, i + 1, "Established (%s:%u) - state: %d", ip2str(peeraddr.sin_addr).c_str(), internal->data.ptp.pport, internal->data.ptp.state);
|
||||
}
|
||||
|
||||
// Free Memory
|
||||
|
@ -3628,8 +3627,7 @@ int AcceptPtpSocket(int ptpId, int newsocket, sockaddr_in& peeraddr, SceNetEther
|
|||
// Close Socket
|
||||
closesocket(newsocket);
|
||||
|
||||
ERROR_LOG(Log::sceNet, "sceNetAdhocPtpAccept[%i]: Failed (Socket Closed)", ptpId);
|
||||
return -1;
|
||||
return hleLogError(Log::sceNet, -1, "sceNetAdhocPtpAccept[%i]: Failed (Socket Closed)", ptpId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3798,9 +3796,7 @@ int NetAdhocPtp_Connect(int id, int timeout, int flag, bool allowForcedConnect)
|
|||
// Set Connected State
|
||||
ptpsocket.state = ADHOC_PTP_STATE_ESTABLISHED;
|
||||
|
||||
INFO_LOG(Log::sceNet, "sceNetAdhocPtpConnect[%i:%u]: Already Connected to %s:%u", id, ptpsocket.lport, ip2str(sin.sin_addr).c_str(), ptpsocket.pport);
|
||||
// Success
|
||||
return 0;
|
||||
return hleLogDebug(Log::sceNet, 0, "sceNetAdhocPtpConnect[%i:%u]: Already Connected to %s:%u", id, ptpsocket.lport, ip2str(sin.sin_addr).c_str(), ptpsocket.pport);
|
||||
}
|
||||
|
||||
// Error handling
|
||||
|
@ -3829,8 +3825,7 @@ int NetAdhocPtp_Connect(int id, int timeout, int flag, bool allowForcedConnect)
|
|||
// Simulate blocking behaviour with non-blocking socket
|
||||
u64 threadSocketId = ((u64)__KernelGetCurThread()) << 32 | ptpsocket.id;
|
||||
if (sendTargetPeers.find(threadSocketId) != sendTargetPeers.end()) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetAdhocPtpConnect[%i:%u]: Socket(%d) is Busy!", id, ptpsocket.lport, ptpsocket.id);
|
||||
return hleLogError(Log::sceNet, ERROR_NET_ADHOC_BUSY, "busy?");
|
||||
return hleLogError(Log::sceNet, ERROR_NET_ADHOC_BUSY, "Socket %d is busy!", ptpsocket.id);
|
||||
}
|
||||
|
||||
AdhocSendTargets dest = { 0, {}, false };
|
||||
|
@ -4082,8 +4077,7 @@ static int sceNetAdhocPtpListen(const char *srcmac, int sport, int bufsize, int
|
|||
changeBlockingMode(tcpsocket, 1);
|
||||
|
||||
// Return PTP Socket id
|
||||
INFO_LOG(Log::sceNet, "sceNetAdhocPtpListen - PSP Socket id: %i, Host Socket id: %i", i + 1, tcpsocket);
|
||||
return i + 1;
|
||||
return hleLogDebug(Log::sceNet, i + 1, "sceNetAdhocPtpListen - PSP Socket id: %i, Host Socket id: %i", i + 1, tcpsocket);
|
||||
}
|
||||
|
||||
// Free Memory
|
||||
|
|
|
@ -35,7 +35,7 @@ int g_inetLastErrno = 0;
|
|||
static int UpdateErrnoFromHost(int hostErrno, const char *func) {
|
||||
int newErrno = convertInetErrnoHost2PSP(hostErrno);
|
||||
if (g_inetLastErrno == 0 && newErrno == 0) {
|
||||
WARN_LOG(Log::sceNet, "BAD: errno set to 0 in %s. Functions should not clear errno.", convertInetErrno2str(g_inetLastErrno), func);
|
||||
WARN_LOG(Log::sceNet, "BAD: errno set to 0 in %s. Functions should not clear errno.", func);
|
||||
} else if (g_inetLastErrno != 0 && newErrno == 0) {
|
||||
ERROR_LOG(Log::sceNet, "BAD: errno cleared (previously %s) in %s. Functions should not clear errno.", convertInetErrno2str(g_inetLastErrno), func);
|
||||
g_inetLastErrno = 0;
|
||||
|
@ -390,9 +390,9 @@ static int sceNetInetRecv(int socket, u32 bufPtr, u32 bufLen, u32 flags) {
|
|||
int retval = recv(inetSock->sock, (char*)Memory::GetPointer(bufPtr), bufLen, flgs | MSG_NOSIGNAL);
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
retval = hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
} else {
|
||||
hleLogError(Log::sceNet, retval);
|
||||
retval = hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
return hleDelayResult(retval, "workaround until blocking-socket", 500);
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ static int sceNetInetSetsockopt(int socket, int level, int optname, u32 optvalPt
|
|||
}
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
hleLogError(Log::sceNet, retval);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
return hleLogSuccessI(Log::sceNet, retval);
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ static int sceNetInetGetsockopt(int socket, int level, int optname, u32 optvalPt
|
|||
}
|
||||
if (retval < 0) {
|
||||
UpdateErrnoFromHost(socket_errno, __FUNCTION__);
|
||||
hleLogError(Log::sceNet, retval);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
DEBUG_LOG(Log::sceNet, "SockOpt: OptValue = %d", *optval);
|
||||
return hleLogSuccessI(Log::sceNet, retval);
|
||||
|
@ -667,9 +667,9 @@ static int sceNetInetConnect(int socket, u32 sockAddrPtr, int sockAddrLen) {
|
|||
int hostErrno = socket_errno;
|
||||
UpdateErrnoFromHost(hostErrno, __FUNCTION__);
|
||||
if (connectInProgress(hostErrno))
|
||||
hleLogDebug(Log::sceNet, retval, "errno = %s Address = %s, Port = %d", convertInetErrno2str(g_inetLastErrno), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
retval = hleLogDebug(Log::sceNet, retval, "errno = %s Address = %s, Port = %d", convertInetErrno2str(g_inetLastErrno), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
else
|
||||
hleLogError(Log::sceNet, retval, "errno = %s Address = %s, Port = %d", convertInetErrno2str(g_inetLastErrno), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
retval = hleLogError(Log::sceNet, retval, "errno = %s Address = %s, Port = %d", convertInetErrno2str(g_inetLastErrno), ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
changeBlockingMode(inetSock->sock, 1);
|
||||
// TODO: Since we're temporarily forcing blocking-mode we'll need to change errno from ETIMEDOUT to EAGAIN
|
||||
/*if (inetLastErrno == ETIMEDOUT)
|
||||
|
@ -712,11 +712,10 @@ static int sceNetInetAccept(int socket, u32 addrPtr, u32 addrLenPtr) {
|
|||
int newHostSocket = accept(inetSock->sock, (struct sockaddr*)&saddr.addr, srclen);
|
||||
if (newHostSocket < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
hleLogDebug(Log::sceNet, newHostSocket, "EAGAIN");
|
||||
return hleLogDebug(Log::sceNet, -1, "EAGAIN");
|
||||
} else {
|
||||
hleLogError(Log::sceNet, newHostSocket);
|
||||
return hleLogError(Log::sceNet, -1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int newSocketId;
|
||||
|
@ -773,7 +772,6 @@ static int sceNetInetClose(int socket) {
|
|||
}
|
||||
|
||||
g_socketManager.Close(inetSock);
|
||||
|
||||
return hleLogSuccessInfoI(Log::sceNet, 0);
|
||||
}
|
||||
|
||||
|
@ -809,9 +807,9 @@ static int sceNetInetRecvfrom(int socket, u32 bufferPtr, int len, int flags, u32
|
|||
int retval = recvfrom(inetSock->sock, (char*)Memory::GetPointer(bufferPtr), len, flgs | MSG_NOSIGNAL, (struct sockaddr*)&saddr.addr, srclen);
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
retval = hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
} else {
|
||||
hleLogError(Log::sceNet, retval);
|
||||
retval = hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
// Using hleDelayResult as a workaround for games that need blocking-socket to be implemented (ie. Coded Arms Contagion)
|
||||
return hleDelayResult(retval, "workaround until blocking-socket", 500);
|
||||
|
@ -904,11 +902,10 @@ static int sceNetInetSendto(int socket, u32 bufferPtr, int len, int flags, u32 t
|
|||
}
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
return hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
} else {
|
||||
hleLogError(Log::sceNet, retval);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
return hleLogSuccessInfoI(Log::sceNet, retval, "SendTo: Address = %s, Port = %d", ip2str(saddr.in.sin_addr).c_str(), ntohs(saddr.in.sin_port));
|
||||
|
@ -917,7 +914,6 @@ static int sceNetInetSendto(int socket, u32 bufferPtr, int len, int flags, u32 t
|
|||
// Similar to POSIX's sendmsg or Winsock2's WSASendMsg? Are their packets compatible one another?
|
||||
// Games using this: The Warrior's Code
|
||||
static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
||||
DEBUG_LOG(Log::sceNet, "sceNetInetSendmsg(%i, %08x, %08x) at %08x", __FUNCTION__, socket, msghdrPtr, flags, currentMIPS->pc);
|
||||
// Note: sendmsg is concatenating iovec buffers before sending it, and send/sendto is just a wrapper for sendmsg according to https://stackoverflow.com/questions/4258834/how-sendmsg-works
|
||||
int retval = -1;
|
||||
if (!Memory::IsValidAddress(msghdrPtr)) {
|
||||
|
@ -1105,11 +1101,10 @@ static int sceNetInetSendmsg(int socket, u32 msghdrPtr, int flags) {
|
|||
*/
|
||||
if (retval < 0) {
|
||||
if (UpdateErrnoFromHost(socket_errno, __FUNCTION__) == ERROR_INET_EAGAIN) {
|
||||
hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
return hleLogDebug(Log::sceNet, retval, "EAGAIN");
|
||||
} else {
|
||||
hleLogError(Log::sceNet, retval);
|
||||
return hleLogError(Log::sceNet, retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
return hleLogSuccessInfoI(Log::sceNet, retval); // returns number of bytes sent?
|
||||
}
|
||||
|
|
|
@ -157,25 +157,23 @@ static int sceParseHttpStatusLine(u32 headerAddr, u32 headerLength, u32 httpVers
|
|||
}
|
||||
}
|
||||
catch (const std::runtime_error& ex) {
|
||||
hleLogError(Log::sceNet, -1, "Runtime error: %s", ex.what());
|
||||
return hleLogError(Log::sceNet, -1, "Runtime error: %s", ex.what());
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
hleLogError(Log::sceNet, -1, "Error occurred: %s", ex.what()); // SCE_HTTP_ERROR_PARSE_HTTP_INVALID_VALUE
|
||||
return hleLogError(Log::sceNet, -1, "Error occurred: %s", ex.what()); // SCE_HTTP_ERROR_PARSE_HTTP_INVALID_VALUE
|
||||
}
|
||||
catch (...) {
|
||||
hleLogError(Log::sceNet, -1, "Unknown error");
|
||||
return hleLogError(Log::sceNet, -1, "Unknown error");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return hleLogSuccessI(Log::sceNet, 0);
|
||||
}
|
||||
|
||||
const HLEFunction sceParseHttp [] =
|
||||
{
|
||||
const HLEFunction sceParseHttp[] = {
|
||||
{0X8077A433, &WrapI_UUUUUUU<sceParseHttpStatusLine>, "sceParseHttpStatusLine", 'i', "xxxxxxx"},
|
||||
{0XAD7BFDEF, &WrapI_UICUU<sceParseHttpResponseHeader>, "sceParseHttpResponseHeader", 'i', "xisxx" },
|
||||
};
|
||||
|
||||
void Register_sceParseHttp()
|
||||
{
|
||||
void Register_sceParseHttp() {
|
||||
RegisterModule("sceParseHttp", ARRAY_SIZE(sceParseHttp), sceParseHttp);
|
||||
}
|
||||
|
|
|
@ -920,14 +920,12 @@ static u32 scePsmfGetStreamSize(u32 psmfStruct, u32 sizeAddr)
|
|||
{
|
||||
Psmf *psmf = getPsmf(psmfStruct);
|
||||
if (!psmf) {
|
||||
ERROR_LOG(Log::ME, "scePsmfGetStreamSize(%08x, %08x): invalid psmf", psmfStruct, sizeAddr);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return hleLogError(Log::ME, ERROR_PSMF_NOT_FOUND, "invalid psmf");
|
||||
}
|
||||
DEBUG_LOG(Log::ME, "scePsmfGetStreamSize(%08x, %08x)", psmfStruct, sizeAddr);
|
||||
if (Memory::IsValidAddress(sizeAddr)) {
|
||||
Memory::Write_U32(psmf->streamSize, sizeAddr);
|
||||
}
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfQueryStreamOffset(u32 bufferAddr, u32 offsetAddr)
|
||||
|
@ -952,69 +950,58 @@ static u32 scePsmfGetHeaderSize(u32 psmfStruct, u32 sizeAddr)
|
|||
{
|
||||
Psmf *psmf = getPsmf(psmfStruct);
|
||||
if (!psmf) {
|
||||
ERROR_LOG(Log::ME, "scePsmfGetHeaderSize(%08x, %08x): invalid psmf", psmfStruct, sizeAddr);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return hleLogError(Log::ME, ERROR_PSMF_NOT_FOUND, "invalid psmf");
|
||||
}
|
||||
DEBUG_LOG(Log::ME, "scePsmfGetHeaderSize(%08x, %08x)", psmfStruct, sizeAddr);
|
||||
if (Memory::IsValidAddress(sizeAddr)) {
|
||||
Memory::Write_U32(psmf->headerSize, sizeAddr);
|
||||
}
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfGetPsmfVersion(u32 psmfStruct)
|
||||
{
|
||||
Psmf *psmf = getPsmf(psmfStruct);
|
||||
if (!psmf) {
|
||||
ERROR_LOG(Log::ME, "scePsmfGetPsmfVersion(%08x): invalid psmf", psmfStruct);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return hleLogError(Log::ME, ERROR_PSMF_NOT_FOUND, "invalid psmf");
|
||||
}
|
||||
DEBUG_LOG(Log::ME, "scePsmfGetPsmfVersion(%08x)", psmfStruct);
|
||||
return psmf->version;
|
||||
return hleLogDebug(Log::ME, psmf->version);
|
||||
}
|
||||
|
||||
static u32 scePsmfVerifyPsmf(u32 psmfAddr)
|
||||
{
|
||||
u32 magic = Memory::Read_U32(psmfAddr);
|
||||
if (magic != PSMF_MAGIC) {
|
||||
ERROR_LOG(Log::ME, "scePsmfVerifyPsmf(%08x): bad magic %08x", psmfAddr, magic);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return hleLogError(Log::ME, ERROR_PSMF_NOT_FOUND, "bad magic %08x", magic);
|
||||
}
|
||||
int version = Memory::Read_U32(psmfAddr + PSMF_STREAM_VERSION_OFFSET);
|
||||
if (version < 0) {
|
||||
ERROR_LOG(Log::ME, "scePsmfVerifyPsmf(%08x): bad version %08x", psmfAddr, version);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return hleLogError(Log::ME, ERROR_PSMF_NOT_FOUND, "bad version %08x", psmfAddr, version);
|
||||
}
|
||||
// Kurohyou 2 (at least the demo) uses an uninitialized value that happens to be zero on the PSP.
|
||||
// It appears to be written by scePsmfVerifyPsmf(), so we write some bytes into the stack here.
|
||||
Memory::Memset(currentMIPS->r[MIPS_REG_SP] - 0x20, 0, 0x20, "PsmfStack");
|
||||
DEBUG_LOG(Log::ME, "scePsmfVerifyPsmf(%08x)", psmfAddr);
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfGetNumberOfEPentries(u32 psmfStruct)
|
||||
{
|
||||
Psmf *psmf = getPsmf(psmfStruct);
|
||||
if (!psmf) {
|
||||
ERROR_LOG(Log::ME, "scePsmfGetNumberOfEPentries(%08x): invalid psmf", psmfStruct);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return hleLogError(Log::ME, ERROR_PSMF_NOT_FOUND, "invalid psmf");
|
||||
}
|
||||
DEBUG_LOG(Log::ME, "scePsmfGetNumberOfEPentries(%08x)", psmfStruct);
|
||||
return psmf->EPMapEntriesNum;
|
||||
return hleLogDebug(Log::ME, psmf->EPMapEntriesNum);
|
||||
}
|
||||
|
||||
static u32 scePsmfGetPresentationStartTime(u32 psmfStruct, u32 startTimeAddr)
|
||||
{
|
||||
Psmf *psmf = getPsmf(psmfStruct);
|
||||
if (!psmf) {
|
||||
ERROR_LOG(Log::ME, "scePsmfGetPresentationStartTime(%08x, %08x): invalid psmf", psmfStruct, startTimeAddr);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return hleLogError(Log::ME, ERROR_PSMF_NOT_FOUND, "invalid psmf");
|
||||
}
|
||||
DEBUG_LOG(Log::ME, "scePsmfGetPresentationStartTime(%08x, %08x)", psmfStruct, startTimeAddr);
|
||||
if (Memory::IsValidAddress(startTimeAddr)) {
|
||||
Memory::Write_U32(psmf->presentationStartTime, startTimeAddr);
|
||||
}
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfGetPresentationEndTime(u32 psmfStruct, u32 endTimeAddr)
|
||||
|
@ -1101,8 +1088,7 @@ static u32 scePsmfGetEPidWithTimestamp(u32 psmfStruct, u32 ts)
|
|||
{
|
||||
Psmf *psmf = getPsmf(psmfStruct);
|
||||
if (!psmf) {
|
||||
ERROR_LOG(Log::ME, "scePsmfGetEPidWithTimestamp(%08x, %i): invalid psmf", psmfStruct, ts);
|
||||
return ERROR_PSMF_NOT_FOUND;
|
||||
return hleLogError(Log::ME, ERROR_PSMF_NOT_FOUND, "invalid psmf");
|
||||
}
|
||||
DEBUG_LOG(Log::ME, "scePsmfGetEPidWithTimestamp(%08x, %i)", psmfStruct, ts);
|
||||
|
||||
|
@ -1190,7 +1176,7 @@ static int scePsmfPlayerStop(u32 psmfPlayer) {
|
|||
static int scePsmfPlayerBreak(u32 psmfPlayer) {
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "invalid psmf player", psmfPlayer);
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "invalid psmf player");
|
||||
}
|
||||
|
||||
psmfplayer->AbortFinish();
|
||||
|
@ -1234,7 +1220,7 @@ static int _PsmfPlayerFillRingbuffer(PsmfPlayer *psmfplayer) {
|
|||
static int _PsmfPlayerSetPsmfOffset(u32 psmfPlayer, const char *filename, int offset, bool docallback) {
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer || psmfplayer->status != PSMF_PLAYER_STATUS_INIT) {
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "invalid psmf player or status");
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "invalid psmf player or status");
|
||||
}
|
||||
if (!filename) {
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_PARAM, "invalid filename");
|
||||
|
@ -1361,27 +1347,22 @@ static int scePsmfPlayerStart(u32 psmfPlayer, u32 psmfPlayerData, int initPts)
|
|||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerStart(%08x, %08x, %d): invalid psmf player", psmfPlayer, psmfPlayerData, initPts);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status == PSMF_PLAYER_STATUS_INIT) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerStart(%08x, %08x, %d): psmf not yet set", psmfPlayer, psmfPlayerData, initPts);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "psmf not yet set");
|
||||
}
|
||||
|
||||
auto playerData = PSPPointer<PsmfPlayerData>::Create(psmfPlayerData);
|
||||
if (!playerData.IsValid()) {
|
||||
// Crashes on a PSP.
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerStart(%08x, %08x, %d): bad data address", psmfPlayer, psmfPlayerData, initPts);
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ADDRESS;
|
||||
return hleLogError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDRESS, "bad data address");
|
||||
}
|
||||
if (playerData->playMode < 0 || playerData->playMode > (int)PSMF_PLAYER_MODE_REWIND) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerStart(%08x, %08x, %d): invalid mode", psmfPlayer, psmfPlayerData, initPts);
|
||||
return ERROR_PSMFPLAYER_INVALID_PARAM;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_PARAM, "invalid mode");
|
||||
}
|
||||
if (initPts >= psmfplayer->mediaengine->getLastTimeStamp()) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerStart(%08x, %08x, %d): pts is outside video", psmfPlayer, psmfPlayerData, initPts);
|
||||
return ERROR_PSMFPLAYER_INVALID_PARAM;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_PARAM, "pts is outside video");
|
||||
}
|
||||
|
||||
if (psmfplayer->totalAudioStreams > 0) {
|
||||
|
@ -1423,8 +1404,7 @@ static int scePsmfPlayerStart(u32 psmfPlayer, u32 psmfPlayerData, int initPts)
|
|||
}
|
||||
|
||||
if (psmfplayer->playerVersion == PSMF_PLAYER_VERSION_BASIC && initPts != 0) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerStart(%08x, %08x, %d): unable to seek without EPmap", psmfPlayer, psmfPlayerData, initPts);
|
||||
return ERROR_PSMFPLAYER_INVALID_PARAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_PARAM, "unable to seek without EPmap");
|
||||
}
|
||||
|
||||
psmfplayer->AbortFinish();
|
||||
|
@ -1490,31 +1470,26 @@ static int scePsmfPlayerDelete(u32 psmfPlayer)
|
|||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerDelete(%08x): invalid psmf player", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
|
||||
INFO_LOG(Log::ME, "scePsmfPlayerDelete(%08x)", psmfPlayer);
|
||||
delete psmfplayer;
|
||||
psmfPlayerMap.erase(Memory::Read_U32(psmfPlayer));
|
||||
Memory::Write_U32(0, psmfPlayer);
|
||||
|
||||
return hleDelayResult(0, "psmfplayer deleted", 20000);
|
||||
return hleDelayResult(hleLogDebug(Log::ME, 0), "psmfplayer deleted", 20000);
|
||||
}
|
||||
|
||||
static int scePsmfPlayerUpdate(u32 psmfPlayer)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerUpdate(%08x): invalid psmf player", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status < PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerUpdate(%08x): not playing yet", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not playing yet");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::ME, "scePsmfPlayerUpdate(%08x)", psmfPlayer);
|
||||
if (psmfplayer->HasReachedEnd()) {
|
||||
if (videoLoopStatus == PSMF_PLAYER_CONFIG_NO_LOOP && psmfplayer->videoStep >= 1) {
|
||||
if (psmfplayer->status != PSMF_PLAYER_STATUS_PLAYING_FINISHED) {
|
||||
|
@ -1525,24 +1500,21 @@ static int scePsmfPlayerUpdate(u32 psmfPlayer)
|
|||
}
|
||||
psmfplayer->videoStep++;
|
||||
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static int scePsmfPlayerReleasePsmf(u32 psmfPlayer)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerReleasePsmf(%08x): invalid psmf player", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status < PSMF_PLAYER_STATUS_STANDBY) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerReleasePsmf(%08x): not set yet", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not set yet");
|
||||
}
|
||||
|
||||
WARN_LOG(Log::ME, "scePsmfPlayerReleasePsmf(%08x)", psmfPlayer);
|
||||
psmfplayer->status = PSMF_PLAYER_STATUS_INIT;
|
||||
return 0;
|
||||
return hleLogWarning(Log::ME, 0);
|
||||
}
|
||||
|
||||
static void __PsmfUpdatePts(PsmfPlayer *psmfplayer, PsmfVideoData *videoData) {
|
||||
|
@ -1557,50 +1529,42 @@ static int scePsmfPlayerGetVideoData(u32 psmfPlayer, u32 videoDataAddr)
|
|||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetVideoData(%08x, %08x): invalid psmf player", psmfPlayer, videoDataAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status < PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetVideoData(%08x, %08x): psmf not playing", psmfPlayer, videoDataAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "psmf not playing");
|
||||
}
|
||||
auto videoData = PSPPointer<PsmfVideoData>::Create(videoDataAddr);
|
||||
if (!videoData.IsValid()) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetVideoData(%08x, %08x): invalid data pointer", psmfPlayer, videoDataAddr);
|
||||
// Technically just crashes if videoData is not valid.
|
||||
return SCE_KERNEL_ERROR_INVALID_POINTER;
|
||||
return hleLogError(Log::ME, SCE_KERNEL_ERROR_INVALID_POINTER, "invalid data pointer");
|
||||
}
|
||||
if (videoData->frameWidth < 0) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetVideoData(%08x, %08x): illegal bufw %d", psmfPlayer, videoDataAddr, videoData->frameWidth);
|
||||
return SCE_KERNEL_ERROR_PRIV_REQUIRED;
|
||||
return hleLogError(Log::ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "illegal bufw %d", videoData->frameWidth);
|
||||
}
|
||||
if (videoData->frameWidth != 0 && videoData->frameWidth < psmfplayer->mediaengine->VideoWidth()) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetVideoData(%08x, %08x): bufw %d smaller than width %d", psmfPlayer, videoDataAddr, videoData->frameWidth, psmfplayer->mediaengine->VideoWidth());
|
||||
return SCE_KERNEL_ERROR_INVALID_VALUE;
|
||||
return hleLogError(Log::ME, SCE_KERNEL_ERROR_INVALID_VALUE, "bufw %d smaller than width %d", videoData->frameWidth, psmfplayer->mediaengine->VideoWidth());
|
||||
}
|
||||
|
||||
hleEatCycles(20000);
|
||||
|
||||
if (!__PsmfPlayerContinueSeek(psmfplayer)) {
|
||||
DEBUG_LOG(Log::HLE, "scePsmfPlayerGetVideoData(%08x, %08x): still seeking", psmfPlayer, videoDataAddr);
|
||||
return ERROR_PSMFPLAYER_NO_MORE_DATA;
|
||||
return hleLogDebug(Log::HLE, ERROR_PSMFPLAYER_NO_MORE_DATA, "still seeking");
|
||||
}
|
||||
|
||||
// On a real PSP, this takes a potentially variable amount of time.
|
||||
// Normally a minimum of 3 without audio, 5 with. But if you don't delay sufficiently between, hundreds.
|
||||
// It should be okay if we start videos quicker, but some games expect the first couple to fail.
|
||||
if (psmfplayer->warmUp < PSMF_PLAYER_WARMUP_FRAMES) {
|
||||
DEBUG_LOG(Log::ME, "scePsmfPlayerGetVideoData(%08x, %08x): warming up", psmfPlayer, videoDataAddr);
|
||||
++psmfplayer->warmUp;
|
||||
return ERROR_PSMFPLAYER_NO_MORE_DATA;
|
||||
return hleLogDebug(Log::ME, ERROR_PSMFPLAYER_NO_MORE_DATA, "warming up");
|
||||
}
|
||||
// In case we change warm up later, save a high value in savestates - video started.
|
||||
psmfplayer->warmUp = 10000;
|
||||
|
||||
// It's fine to pass an invalid value here if it's still warming up, but after that it's not okay.
|
||||
if (!Memory::IsValidAddress(videoData->displaybuf)) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetVideoData(%08x, %08x): invalid buffer pointer %08x", psmfPlayer, videoDataAddr, videoData->displaybuf);
|
||||
return SCE_KERNEL_ERROR_INVALID_POINTER;
|
||||
return hleLogError(Log::ME, SCE_KERNEL_ERROR_INVALID_POINTER, "invalid buffer pointer %08x", videoData->displaybuf);
|
||||
}
|
||||
|
||||
bool doVideoStep = true;
|
||||
|
@ -1642,35 +1606,29 @@ static int scePsmfPlayerGetVideoData(u32 psmfPlayer, u32 videoDataAddr)
|
|||
|
||||
_PsmfPlayerFillRingbuffer(psmfplayer);
|
||||
|
||||
DEBUG_LOG(Log::ME, "%08x=scePsmfPlayerGetVideoData(%08x, %08x)", 0, psmfPlayer, videoDataAddr);
|
||||
return hleDelayResult(0, "psmfPlayer video decode", 3000);
|
||||
return hleDelayResult(hleLogDebug(Log::ME, 0), "psmfPlayer video decode", 3000);
|
||||
}
|
||||
|
||||
static int scePsmfPlayerGetAudioData(u32 psmfPlayer, u32 audioDataAddr)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetAudioData(%08x, %08x): invalid psmf player", psmfPlayer, audioDataAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status < PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetAudioData(%08x, %08x): not yet playing", psmfPlayer, audioDataAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not yet playing");
|
||||
}
|
||||
if (!Memory::IsValidAddress(audioDataAddr)) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetAudioData(%08x, %08x): invalid audio pointer", psmfPlayer, audioDataAddr);
|
||||
return SCE_KERNEL_ERROR_INVALID_POINTER;
|
||||
return hleLogError(Log::ME, SCE_KERNEL_ERROR_INVALID_POINTER, "invalid audio pointer");
|
||||
}
|
||||
|
||||
// Don't return audio frames before we would return video frames.
|
||||
if (psmfplayer->warmUp < PSMF_PLAYER_WARMUP_FRAMES) {
|
||||
DEBUG_LOG(Log::ME, "scePsmfPlayerGetAudioData(%08x, %08x): warming up", psmfPlayer, audioDataAddr);
|
||||
return ERROR_PSMFPLAYER_NO_MORE_DATA;
|
||||
return hleLogDebug(Log::ME, ERROR_PSMFPLAYER_NO_MORE_DATA, "warming up");
|
||||
}
|
||||
|
||||
if (psmfplayer->playMode == PSMF_PLAYER_MODE_PAUSE) {
|
||||
INFO_LOG(Log::HLE, "scePsmfPlayerGetAudioData(%08x): paused mode", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_NO_MORE_DATA;
|
||||
return hleLogSuccessInfoI(Log::HLE, ERROR_PSMFPLAYER_NO_MORE_DATA, "paused mode");
|
||||
}
|
||||
|
||||
int ret = 0;
|
||||
|
@ -1683,14 +1641,13 @@ static int scePsmfPlayerGetAudioData(u32 psmfPlayer, u32 audioDataAddr)
|
|||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::ME, "%08x=scePsmfPlayerGetAudioData(%08x, %08x)", ret, psmfPlayer, audioDataAddr);
|
||||
if (ret != 0) {
|
||||
hleEatCycles(10000);
|
||||
} else {
|
||||
hleEatCycles(30000);
|
||||
}
|
||||
hleReSchedule("psmfplayer audio decode");
|
||||
return ret;
|
||||
return hleLogDebug(Log::ME, ret);
|
||||
}
|
||||
|
||||
static int scePsmfPlayerGetCurrentStatus(u32 psmfPlayer)
|
||||
|
@ -1699,60 +1656,49 @@ static int scePsmfPlayerGetCurrentStatus(u32 psmfPlayer)
|
|||
if (!psmfplayer) {
|
||||
// Mana Khemia and other games call this even when not necessary.
|
||||
// It's annoying so the logging is verbose'd out.
|
||||
VERBOSE_LOG(Log::ME, "scePsmfPlayerGetCurrentStatus(%08x): invalid psmf player", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogVerbose(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "invalid psmf player");
|
||||
}
|
||||
if (psmfplayer->status == PSMF_PLAYER_STATUS_NONE) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetCurrentStatus(%08x): not initialized", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not initialized");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::ME, "%d=scePsmfPlayerGetCurrentStatus(%08x)", psmfplayer->status, psmfPlayer);
|
||||
return psmfplayer->status;
|
||||
return hleLogDebug(Log::ME, psmfplayer->status);
|
||||
}
|
||||
|
||||
static u32 scePsmfPlayerGetCurrentPts(u32 psmfPlayer, u32 currentPtsAddr)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetCurrentPts(%08x, %08x): invalid psmf player", psmfPlayer, currentPtsAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status < PSMF_PLAYER_STATUS_STANDBY) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetCurrentPts(%08x, %08x): not initialized", psmfPlayer, currentPtsAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not initialized");
|
||||
}
|
||||
if (psmfplayer->psmfPlayerAvcAu.pts < 0) {
|
||||
VERBOSE_LOG(Log::ME, "scePsmfPlayerGetCurrentPts(%08x, %08x): no frame yet", psmfPlayer, currentPtsAddr);
|
||||
return ERROR_PSMFPLAYER_NO_MORE_DATA;
|
||||
return hleLogVerbose(Log::ME, ERROR_PSMFPLAYER_NO_MORE_DATA, "no frame yet");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::ME, "scePsmfPlayerGetCurrentPts(%08x, %08x)", psmfPlayer, currentPtsAddr);
|
||||
if (Memory::IsValidAddress(currentPtsAddr)) {
|
||||
Memory::Write_U32(psmfplayer->psmfPlayerAvcAu.pts, currentPtsAddr);
|
||||
}
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfPlayerGetPsmfInfo(u32 psmfPlayer, u32 psmfInfoAddr, u32 widthAddr, u32 heightAddr) {
|
||||
auto info = PSPPointer<PsmfInfo>::Create(psmfInfoAddr);
|
||||
if (!Memory::IsValidAddress(psmfPlayer) || !info.IsValid()) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetPsmfInfo(%08x, %08x): invalid addresses", psmfPlayer, psmfInfoAddr);
|
||||
// PSP would crash.
|
||||
return SCE_KERNEL_ERROR_ILLEGAL_ADDRESS;
|
||||
return hleLogError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDRESS, "invalid addresses");
|
||||
}
|
||||
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetPsmfInfo(%08x, %08x): invalid psmf player", psmfPlayer, psmfInfoAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status < PSMF_PLAYER_STATUS_STANDBY) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetPsmfInfo(%08x): psmf not set yet", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "psmf not set yet");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::ME, "scePsmfPlayerGetPsmfInfo(%08x, %08x)", psmfPlayer, psmfInfoAddr);
|
||||
// The first frame is at 0, so subtract one frame's duration to get the last frame's timestamp.
|
||||
info->lastFrameTS = psmfplayer->totalDurationTimestamp - VIDEO_FRAME_DURATION_TS;
|
||||
info->numVideoStreams = psmfplayer->totalVideoStreams;
|
||||
|
@ -1773,109 +1719,93 @@ static u32 scePsmfPlayerGetPsmfInfo(u32 psmfPlayer, u32 psmfInfoAddr, u32 widthA
|
|||
Memory::Write_U32(psmfplayer->videoHeight, heightAddr);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfPlayerGetCurrentPlayMode(u32 psmfPlayer, u32 playModeAddr, u32 playSpeedAddr)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetCurrentPlayMode(%08x, %08x, %08x): invalid psmf player", psmfPlayer, playModeAddr, playSpeedAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::ME, "scePsmfPlayerGetCurrentPlayMode(%08x, %08x, %08x)", psmfPlayer, playModeAddr, playSpeedAddr);
|
||||
if (Memory::IsValidAddress(playModeAddr)) {
|
||||
Memory::Write_U32(psmfplayer->playMode, playModeAddr);
|
||||
}
|
||||
if (Memory::IsValidAddress(playSpeedAddr)) {
|
||||
Memory::Write_U32(psmfplayer->playSpeed, playSpeedAddr);
|
||||
}
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfPlayerGetCurrentVideoStream(u32 psmfPlayer, u32 videoCodecAddr, u32 videoStreamNumAddr)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetCurrentVideoStream(%08x, %08x, %08x): invalid psmf player", psmfPlayer, videoCodecAddr, videoStreamNumAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status == PSMF_PLAYER_STATUS_INIT) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetCurrentVideoStream(%08x): psmf not yet set", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "psmf not yet set");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::ME, "scePsmfPlayerGetCurrentVideoStream(%08x, %08x, %08x)", psmfPlayer, videoCodecAddr, videoStreamNumAddr);
|
||||
if (Memory::IsValidAddress(videoCodecAddr)) {
|
||||
Memory::Write_U32(psmfplayer->videoCodec == 0x0E ? 0 : psmfplayer->videoCodec, videoCodecAddr);
|
||||
}
|
||||
if (Memory::IsValidAddress(videoStreamNumAddr)) {
|
||||
Memory::Write_U32(psmfplayer->videoStreamNum, videoStreamNumAddr);
|
||||
}
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfPlayerGetCurrentAudioStream(u32 psmfPlayer, u32 audioCodecAddr, u32 audioStreamNumAddr)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetCurrentAudioStream(%08x, %08x, %08x): invalid psmf player", psmfPlayer, audioCodecAddr, audioStreamNumAddr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status == PSMF_PLAYER_STATUS_INIT) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerGetCurrentVideoStream(%08x): psmf not yet set", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "psmf not yet set");
|
||||
}
|
||||
|
||||
DEBUG_LOG(Log::ME, "scePsmfPlayerGetCurrentAudioStream(%08x, %08x, %08x)", psmfPlayer, audioCodecAddr, audioStreamNumAddr);
|
||||
if (Memory::IsValidAddress(audioCodecAddr)) {
|
||||
Memory::Write_U32(psmfplayer->audioCodec == 0x0F ? 1 : psmfplayer->audioCodec, audioCodecAddr);
|
||||
}
|
||||
if (Memory::IsValidAddress(audioStreamNumAddr)) {
|
||||
Memory::Write_U32(psmfplayer->audioStreamNum, audioStreamNumAddr);
|
||||
}
|
||||
return 0;
|
||||
return hleLogSuccessInfoI(Log::ME, 0);
|
||||
}
|
||||
|
||||
static int scePsmfPlayerSetTempBuf(u32 psmfPlayer, u32 tempBufAddr, u32 tempBufSize)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerSetTempBuf(%08x, %08x, %08x): invalid psmf player", psmfPlayer, tempBufAddr, tempBufSize);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status != PSMF_PLAYER_STATUS_INIT) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSetTempBuf(%08x, %08x, %08x): invalid status %x", psmfPlayer, tempBufAddr, tempBufSize, psmfplayer->status);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "invalid status %x", psmfplayer->status);
|
||||
}
|
||||
if (tempBufSize < 0x00010000) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSetTempBuf(%08x, %08x, %08x): buffer too small", psmfPlayer, tempBufAddr, tempBufSize);
|
||||
return ERROR_PSMFPLAYER_INVALID_PARAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_PARAM, "buffer too small");
|
||||
}
|
||||
|
||||
INFO_LOG(Log::ME, "scePsmfPlayerSetTempBuf(%08x, %08x, %08x)", psmfPlayer, tempBufAddr, tempBufSize);
|
||||
// fake it right now, use tempbuf from memory directly
|
||||
//psmfplayer->tempbuf = tempBufAddr;
|
||||
//psmfplayer->tempbufSize = tempBufSize;
|
||||
|
||||
return 0;
|
||||
return hleLogSuccessInfoI(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfPlayerChangePlayMode(u32 psmfPlayer, int playMode, int playSpeed)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerChangePlayMode(%08x, %i, %i): invalid psmf player", psmfPlayer, playMode, playSpeed);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status < PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerChangePlayMode(%08x, %i, %i): not playing yet", psmfPlayer, playMode, playSpeed);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not playing yet");
|
||||
}
|
||||
if (playMode < 0 || playMode > (int)PSMF_PLAYER_MODE_REWIND) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerChangePlayMode(%08x, %i, %i): invalid mode", psmfPlayer, playMode, playSpeed);
|
||||
return ERROR_PSMFPLAYER_INVALID_CONFIG;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_CONFIG, "invalid mode");
|
||||
}
|
||||
|
||||
switch (playMode) {
|
||||
|
@ -1907,19 +1837,17 @@ static u32 scePsmfPlayerChangePlayMode(u32 psmfPlayer, int playMode, int playSpe
|
|||
}
|
||||
|
||||
psmfplayer->playMode = playMode;
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static u32 scePsmfPlayerSelectAudio(u32 psmfPlayer)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerSelectAudio(%08x): invalid psmf player", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status != PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerSelectAudio(%08x): not playing", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not playing");
|
||||
}
|
||||
|
||||
int next = psmfplayer->audioStreamNum + 1;
|
||||
|
@ -1927,8 +1855,7 @@ static u32 scePsmfPlayerSelectAudio(u32 psmfPlayer)
|
|||
next = 0;
|
||||
|
||||
if (next == psmfplayer->audioStreamNum || !psmfplayer->mediaengine->setAudioStream(next)) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectAudio(%08x): no stream to switch to", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STREAM, "no stream to switch to");
|
||||
}
|
||||
|
||||
WARN_LOG_REPORT(Log::ME, "scePsmfPlayerSelectAudio(%08x)", psmfPlayer);
|
||||
|
@ -1940,12 +1867,10 @@ static u32 scePsmfPlayerSelectVideo(u32 psmfPlayer)
|
|||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerSelectVideo(%08x): invalid psmf player", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status != PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerSelectVideo(%08x): not playing", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not playing");
|
||||
}
|
||||
|
||||
int next = psmfplayer->videoStreamNum + 1;
|
||||
|
@ -1953,8 +1878,7 @@ static u32 scePsmfPlayerSelectVideo(u32 psmfPlayer)
|
|||
next = 0;
|
||||
|
||||
if (next == psmfplayer->videoStreamNum || !psmfplayer->mediaengine->setVideoStream(next)) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectVideo(%08x): no stream to switch to", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STREAM, "no stream to switch to");
|
||||
}
|
||||
|
||||
WARN_LOG_REPORT(Log::ME, "scePsmfPlayerSelectVideo(%08x)", psmfPlayer);
|
||||
|
@ -1962,41 +1886,39 @@ static u32 scePsmfPlayerSelectVideo(u32 psmfPlayer)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static u32 scePsmfPlayerSelectSpecificVideo(u32 psmfPlayer, int videoCodec, int videoStreamNum)
|
||||
static u32 scePsmfPlayerSelectSpecificVideo(u32 psmfPlayer, int videoCodec, int videoStreamNum)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerSelectSpecificVideo(%08x, %i, %i): invalid psmf player", psmfPlayer, videoCodec, videoStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status != PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerSelectSpecificVideo(%08x, %i, %i): not playing", psmfPlayer, videoCodec, videoStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not playing");
|
||||
}
|
||||
if (psmfplayer->totalVideoStreams < 2) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificVideo(%08x, %i, %i): unable to change stream", psmfPlayer, videoCodec, videoStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STREAM, "unable to change stream");
|
||||
}
|
||||
if (videoStreamNum < 0 || videoStreamNum >= psmfplayer->totalVideoStreams) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificVideo(%08x, %i, %i): bad stream num param", psmfPlayer, videoCodec, videoStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_CONFIG;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_CONFIG, "bad stream num param");
|
||||
}
|
||||
if (videoCodec != 0x0E && videoCodec != 0x00) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificVideo(%08x, %i, %i): invalid codec", psmfPlayer, videoCodec, videoStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STREAM, "invalid codec");
|
||||
}
|
||||
if (psmfplayer->totalVideoStreams < 2 || !psmfplayer->mediaengine->setVideoStream(videoStreamNum)) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificVideo(%08x, %i, %i): unable to change stream", psmfPlayer, videoCodec, videoStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STREAM, "unable to change stream");
|
||||
}
|
||||
|
||||
WARN_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificVideo(%08x, %i, %i)", psmfPlayer, videoCodec, videoStreamNum);
|
||||
bool delay = false;
|
||||
if (psmfplayer->videoStreamNum != videoStreamNum) {
|
||||
hleDelayResult(0, "psmf select video", 100);
|
||||
delay = true;
|
||||
}
|
||||
psmfplayer->videoCodec = videoCodec;
|
||||
psmfplayer->videoStreamNum = videoStreamNum;
|
||||
return 0;
|
||||
if (delay) {
|
||||
return hleDelayResult(hleLogWarning(Log::ME, 0), "psmf select video", 100);
|
||||
} else {
|
||||
return hleLogWarning(Log::ME, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// WARNING: This function appears to be buggy in most libraries.
|
||||
|
@ -2004,63 +1926,56 @@ static u32 scePsmfPlayerSelectSpecificAudio(u32 psmfPlayer, int audioCodec, int
|
|||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerSelectSpecificAudio(%08x, %i, %i): invalid psmf player", psmfPlayer, audioCodec, audioStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status != PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerSelectSpecificAudio(%08x, %i, %i): not playing", psmfPlayer, audioCodec, audioStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "not playing");
|
||||
}
|
||||
if (psmfplayer->totalAudioStreams < 2) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificAudio(%08x, %i, %i): unable to change stream", psmfPlayer, audioCodec, audioStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STREAM, "unable to change stream");
|
||||
}
|
||||
if (audioStreamNum < 0 || audioStreamNum >= psmfplayer->totalAudioStreams) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificAudio(%08x, %i, %i): bad stream num param", psmfPlayer, audioCodec, audioStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_CONFIG;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_CONFIG, "bad stream num param");
|
||||
}
|
||||
if (audioCodec != 0x0F && audioCodec != 0x01) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificAudio(%08x, %i, %i): invalid codec", psmfPlayer, audioCodec, audioStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STREAM, "invalid codec");
|
||||
}
|
||||
if (psmfplayer->totalAudioStreams < 2 || !psmfplayer->mediaengine->setAudioStream(audioStreamNum)) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificAudio(%08x, %i, %i): unable to change stream", psmfPlayer, audioCodec, audioStreamNum);
|
||||
return ERROR_PSMFPLAYER_INVALID_STREAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STREAM, "unable to change stream");
|
||||
}
|
||||
|
||||
WARN_LOG_REPORT(Log::ME, "scePsmfPlayerSelectSpecificAudio(%08x, %i, %i)", psmfPlayer, audioCodec, audioStreamNum);
|
||||
bool delay = false;
|
||||
if (psmfplayer->audioStreamNum != audioStreamNum) {
|
||||
hleDelayResult(0, "psmf select audio", 100);
|
||||
delay = true;
|
||||
}
|
||||
psmfplayer->audioCodec = audioCodec;
|
||||
psmfplayer->audioStreamNum = audioStreamNum;
|
||||
return 0;
|
||||
if (delay) {
|
||||
return hleDelayResult(hleLogWarning(Log::ME, 0), "psmf select audio", 100);
|
||||
} else {
|
||||
return hleLogWarning(Log::ME, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static u32 scePsmfPlayerConfigPlayer(u32 psmfPlayer, int configMode, int configAttr)
|
||||
{
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG(Log::ME, "scePsmfPlayerConfigPlayer(%08x, %i, %i): invalid psmf player", psmfPlayer, configMode, configAttr);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
// This one works in any status as long as it's created.
|
||||
|
||||
switch (configMode) {
|
||||
case PSMF_PLAYER_CONFIG_MODE_LOOP:
|
||||
if (configAttr != 0 && configAttr != 1) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerConfigPlayer(%08x, loop, %i): invalid value", psmfPlayer, configAttr);
|
||||
return ERROR_PSMFPLAYER_INVALID_PARAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_PARAM, "invalid value");
|
||||
}
|
||||
INFO_LOG(Log::ME, "scePsmfPlayerConfigPlayer(%08x, loop, %i)", psmfPlayer, configAttr);
|
||||
videoLoopStatus = configAttr;
|
||||
break;
|
||||
case PSMF_PLAYER_CONFIG_MODE_PIXEL_TYPE:
|
||||
if (configAttr < -1 || configAttr > 3) {
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerConfigPlayer(%08x, pixelType, %i): invalid value", psmfPlayer, configAttr);
|
||||
return ERROR_PSMFPLAYER_INVALID_PARAM;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_PARAM, "invalid configAttr value");
|
||||
}
|
||||
INFO_LOG(Log::ME, "scePsmfPlayerConfigPlayer(%08x, pixelType, %i)", psmfPlayer, configAttr);
|
||||
// Does -1 mean default or something?
|
||||
if (configAttr != -1) {
|
||||
videoPixelMode = configAttr;
|
||||
|
@ -2070,27 +1985,23 @@ static u32 scePsmfPlayerConfigPlayer(u32 psmfPlayer, int configMode, int configA
|
|||
}
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG_REPORT(Log::ME, "scePsmfPlayerConfigPlayer(%08x, %i, %i): unknown parameter", psmfPlayer, configMode, configAttr);
|
||||
return ERROR_PSMFPLAYER_INVALID_CONFIG;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_CONFIG, "unknown parameter");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0);
|
||||
}
|
||||
|
||||
static int __PsmfPlayerFinish(u32 psmfPlayer) {
|
||||
PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer);
|
||||
if (!psmfplayer) {
|
||||
ERROR_LOG_REPORT(Log::ME, "__PsmfPlayerFinish(%08x): invalid psmf player", psmfPlayer);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleLogError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS);
|
||||
}
|
||||
if (psmfplayer->status != PSMF_PLAYER_STATUS_PLAYING) {
|
||||
ERROR_LOG_REPORT(Log::ME, "__PsmfPlayerFinish(%08x): unexpected status %d", psmfPlayer, psmfplayer->status);
|
||||
return ERROR_PSMFPLAYER_INVALID_STATUS;
|
||||
return hleReportError(Log::ME, ERROR_PSMFPLAYER_INVALID_STATUS, "unexpected status %d", psmfPlayer, psmfplayer->status);
|
||||
}
|
||||
|
||||
INFO_LOG(Log::ME, "__PsmfPlayerFinish(%08x): video end reached", psmfPlayer);
|
||||
psmfplayer->status = PSMF_PLAYER_STATUS_PLAYING_FINISHED;
|
||||
return 0;
|
||||
return hleLogDebug(Log::ME, 0, "video end reached");
|
||||
}
|
||||
|
||||
const HLEFunction scePsmf[] = {
|
||||
|
|
|
@ -148,17 +148,15 @@ void __UsbDoState(PointerWrap &p) {
|
|||
}
|
||||
|
||||
static int sceUsbStart(const char* driverName, u32 argsSize, u32 argsPtr) {
|
||||
INFO_LOG(Log::HLE, "sceUsbStart(%s, %i, %08x)", driverName, argsSize, argsPtr);
|
||||
usbStarted = true;
|
||||
UsbUpdateState();
|
||||
return 0;
|
||||
return hleLogSuccessInfoI(Log::HLE, 0);
|
||||
}
|
||||
|
||||
static int sceUsbStop(const char* driverName, u32 argsSize, u32 argsPtr) {
|
||||
INFO_LOG(Log::HLE, "sceUsbStop(%s, %i, %08x)", driverName, argsSize, argsPtr);
|
||||
usbStarted = false;
|
||||
UsbUpdateState();
|
||||
return 0;
|
||||
return hleLogSuccessInfoI(Log::HLE, 0);
|
||||
}
|
||||
|
||||
static int sceUsbGetState() {
|
||||
|
@ -168,22 +166,19 @@ static int sceUsbGetState() {
|
|||
} else {
|
||||
state = UsbCurrentState();
|
||||
}
|
||||
DEBUG_LOG(Log::HLE, "sceUsbGetState: 0x%x", state);
|
||||
return state;
|
||||
return hleLogDebug(Log::HLE, state);
|
||||
}
|
||||
|
||||
static int sceUsbActivate(u32 pid) {
|
||||
INFO_LOG(Log::HLE, "sceUsbActivate(%i)", pid);
|
||||
usbActivated = true;
|
||||
UsbUpdateState();
|
||||
return 0;
|
||||
return hleLogDebug(Log::HLE, 0);
|
||||
}
|
||||
|
||||
static int sceUsbDeactivate(u32 pid) {
|
||||
INFO_LOG(Log::HLE, "sceUsbDeactivate(%i)", pid);
|
||||
usbActivated = false;
|
||||
UsbUpdateState();
|
||||
return 0;
|
||||
return hleLogDebug(Log::HLE, 0);
|
||||
}
|
||||
|
||||
static int sceUsbWaitState(int state, u32 waitMode, u32 timeoutPtr) {
|
||||
|
|
|
@ -115,7 +115,7 @@ void ImGui_ImplThin3d_RenderDrawData(ImDrawData* draw_data, Draw::DrawContext *d
|
|||
} else {
|
||||
size_t index = (size_t)pcmd->TextureId - TEX_ID_OFFSET;
|
||||
if (index >= bd->tempTextures.size()) {
|
||||
WARN_LOG(Log::System, "Missing temp texture %d (out of %d)", index, (int)bd->tempTextures.size());
|
||||
WARN_LOG(Log::System, "Missing temp texture %d (out of %d)", (int)index, (int)bd->tempTextures.size());
|
||||
continue;
|
||||
}
|
||||
_dbg_assert_(index < bd->tempTextures.size());
|
||||
|
|
Loading…
Add table
Reference in a new issue