[Kernel] Fix spontaneous r0 corruption

This commit is contained in:
wheremyfoodat 2023-04-24 23:10:04 +03:00
parent 0add6b7d7a
commit 3529c9bf67
2 changed files with 12 additions and 7 deletions

View file

@ -111,12 +111,15 @@ void Kernel::svcClearEvent() {
void Kernel::svcSignalEvent() {
const Handle handle = regs[0];
logSVC("SignalEvent(event handle = %X)\n", handle);
if (!signalEvent(handle)) {
KernelObject* object = getObject(handle, KernelObjectType::Event);
if (object == nullptr) {
Helpers::panic("Signalled non-existent event: %X\n", handle);
regs[0] = SVCResult::BadHandle;
} else {
// We must signalEvent after setting r0, otherwise the r0 of the new thread will ne corrupted
regs[0] = SVCResult::Success;
signalEvent(handle);
}
}