Get rid of KernelErr

This commit is contained in:
gdkchan 2018-12-12 01:27:01 -03:00
commit 8f3f19260a
7 changed files with 25 additions and 52 deletions

View file

@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Ipc
{ {
static class IpcHandler static class IpcHandler
{ {
public static long IpcCall( public static KernelResult IpcCall(
Switch device, Switch device,
KProcess process, KProcess process,
MemoryManager memory, MemoryManager memory,
@ -100,7 +100,7 @@ namespace Ryujinx.HLE.HOS.Ipc
memory.WriteBytes(cmdPtr, response.GetBytes(cmdPtr)); memory.WriteBytes(cmdPtr, response.GetBytes(cmdPtr));
} }
return 0; return KernelResult.Success;
} }
private static IpcMessage FillResponse(IpcMessage response, long result, params int[] values) private static IpcMessage FillResponse(IpcMessage response, long result, params int[] values)

View file

@ -1,8 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Kernel namespace Ryujinx.HLE.HOS.Kernel
{ {
class KAddressArbiter class KAddressArbiter
@ -29,7 +27,7 @@ namespace Ryujinx.HLE.HOS.Kernel
_system.CriticalSection.Enter(); _system.CriticalSection.Enter();
currentThread.SignaledObj = null; currentThread.SignaledObj = null;
currentThread.ObjSyncResult = 0; currentThread.ObjSyncResult = KernelResult.Success;
KProcess currentProcess = _system.Scheduler.GetCurrentProcess(); KProcess currentProcess = _system.Scheduler.GetCurrentProcess();
@ -87,7 +85,7 @@ namespace Ryujinx.HLE.HOS.Kernel
if (result != KernelResult.Success && newOwnerThread != null) if (result != KernelResult.Success && newOwnerThread != null)
{ {
newOwnerThread.SignaledObj = null; newOwnerThread.SignaledObj = null;
newOwnerThread.ObjSyncResult = (int)result; newOwnerThread.ObjSyncResult = result;
} }
_system.CriticalSection.Leave(); _system.CriticalSection.Leave();
@ -106,7 +104,7 @@ namespace Ryujinx.HLE.HOS.Kernel
KThread currentThread = _system.Scheduler.GetCurrentThread(); KThread currentThread = _system.Scheduler.GetCurrentThread();
currentThread.SignaledObj = null; currentThread.SignaledObj = null;
currentThread.ObjSyncResult = (int)MakeError(ErrorModule.Kernel, KernelErr.Timeout); currentThread.ObjSyncResult = KernelResult.TimedOut;
if (currentThread.ShallBeTerminated || if (currentThread.ShallBeTerminated ||
currentThread.SchedFlags == ThreadSchedState.TerminationPending) currentThread.SchedFlags == ThreadSchedState.TerminationPending)
@ -178,7 +176,7 @@ namespace Ryujinx.HLE.HOS.Kernel
} }
newOwnerThread.SignaledObj = null; newOwnerThread.SignaledObj = null;
newOwnerThread.ObjSyncResult = 0; newOwnerThread.ObjSyncResult = KernelResult.Success;
newOwnerThread.ReleaseAndResume(); newOwnerThread.ReleaseAndResume();
} }
@ -236,7 +234,7 @@ namespace Ryujinx.HLE.HOS.Kernel
currentProcess.CpuMemory.ClearExclusive(0); currentProcess.CpuMemory.ClearExclusive(0);
requester.SignaledObj = null; requester.SignaledObj = null;
requester.ObjSyncResult = (int)MakeError(ErrorModule.Kernel, KernelErr.NoAccessPerm); requester.ObjSyncResult = KernelResult.InvalidMemState;
return null; return null;
} }
@ -270,7 +268,7 @@ namespace Ryujinx.HLE.HOS.Kernel
{ {
//We now own the mutex. //We now own the mutex.
requester.SignaledObj = null; requester.SignaledObj = null;
requester.ObjSyncResult = 0; requester.ObjSyncResult = KernelResult.Success;
requester.ReleaseAndResume(); requester.ReleaseAndResume();
@ -290,7 +288,7 @@ namespace Ryujinx.HLE.HOS.Kernel
{ {
//Invalid mutex owner. //Invalid mutex owner.
requester.SignaledObj = null; requester.SignaledObj = null;
requester.ObjSyncResult = (int)MakeError(ErrorModule.Kernel, KernelErr.InvalidHandle); requester.ObjSyncResult = KernelResult.InvalidHandle;
requester.ReleaseAndResume(); requester.ReleaseAndResume();
} }
@ -313,7 +311,7 @@ namespace Ryujinx.HLE.HOS.Kernel
} }
currentThread.SignaledObj = null; currentThread.SignaledObj = null;
currentThread.ObjSyncResult = (int)MakeError(ErrorModule.Kernel, KernelErr.Timeout); currentThread.ObjSyncResult = KernelResult.TimedOut;
if (!KernelTransfer.UserToKernelInt32(_system, address, out int currentValue)) if (!KernelTransfer.UserToKernelInt32(_system, address, out int currentValue))
{ {
@ -388,7 +386,7 @@ namespace Ryujinx.HLE.HOS.Kernel
} }
currentThread.SignaledObj = null; currentThread.SignaledObj = null;
currentThread.ObjSyncResult = (int)MakeError(ErrorModule.Kernel, KernelErr.Timeout); currentThread.ObjSyncResult = KernelResult.TimedOut;
KProcess currentProcess = _system.Scheduler.GetCurrentProcess(); KProcess currentProcess = _system.Scheduler.GetCurrentProcess();
@ -641,7 +639,7 @@ namespace Ryujinx.HLE.HOS.Kernel
while (signaledThreads.TryDequeue(out KThread thread)) while (signaledThreads.TryDequeue(out KThread thread))
{ {
thread.SignaledObj = null; thread.SignaledObj = null;
thread.ObjSyncResult = 0; thread.ObjSyncResult = KernelResult.Success;
thread.ReleaseAndResume(); thread.ReleaseAndResume();

View file

@ -65,7 +65,7 @@ namespace Ryujinx.HLE.HOS.Kernel
currentThread.WaitingSync = true; currentThread.WaitingSync = true;
currentThread.SignaledObj = null; currentThread.SignaledObj = null;
currentThread.ObjSyncResult = (int)result; currentThread.ObjSyncResult = result;
currentThread.Reschedule(ThreadSchedState.Paused); currentThread.Reschedule(ThreadSchedState.Paused);
@ -85,7 +85,7 @@ namespace Ryujinx.HLE.HOS.Kernel
_system.CriticalSection.Enter(); _system.CriticalSection.Enter();
result = (KernelResult)currentThread.ObjSyncResult; result = currentThread.ObjSyncResult;
handleIndex = -1; handleIndex = -1;
@ -120,7 +120,7 @@ namespace Ryujinx.HLE.HOS.Kernel
if ((thread.SchedFlags & ThreadSchedState.LowMask) == ThreadSchedState.Paused) if ((thread.SchedFlags & ThreadSchedState.LowMask) == ThreadSchedState.Paused)
{ {
thread.SignaledObj = syncObj; thread.SignaledObj = syncObj;
thread.ObjSyncResult = 0; thread.ObjSyncResult = KernelResult.Success;
thread.Reschedule(ThreadSchedState.Running); thread.Reschedule(ThreadSchedState.Running);
} }

View file

@ -4,8 +4,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Kernel namespace Ryujinx.HLE.HOS.Kernel
{ {
class KThread : KSynchronizationObject, IKFutureSchedulerObject class KThread : KSynchronizationObject, IKFutureSchedulerObject
@ -48,7 +46,7 @@ namespace Ryujinx.HLE.HOS.Kernel
private ThreadSchedState _forcePauseFlags; private ThreadSchedState _forcePauseFlags;
public int ObjSyncResult { get; set; } public KernelResult ObjSyncResult { get; set; }
public int DynamicPriority { get; set; } public int DynamicPriority { get; set; }
public int CurrentCore { get; set; } public int CurrentCore { get; set; }
@ -113,7 +111,7 @@ namespace Ryujinx.HLE.HOS.Kernel
DynamicPriority = priority; DynamicPriority = priority;
BasePriority = priority; BasePriority = priority;
ObjSyncResult = 0x7201; ObjSyncResult = KernelResult.ThreadNotStarted;
_entrypoint = entrypoint; _entrypoint = entrypoint;
@ -274,7 +272,7 @@ namespace Ryujinx.HLE.HOS.Kernel
System.CriticalSection.Leave(); System.CriticalSection.Leave();
} }
public long Sleep(long timeout) public KernelResult Sleep(long timeout)
{ {
System.CriticalSection.Enter(); System.CriticalSection.Enter();
@ -282,7 +280,7 @@ namespace Ryujinx.HLE.HOS.Kernel
{ {
System.CriticalSection.Leave(); System.CriticalSection.Leave();
return MakeError(ErrorModule.Kernel, KernelErr.ThreadTerminating); return KernelResult.ThreadTerminating;
} }
SetNewSchedFlags(ThreadSchedState.Paused); SetNewSchedFlags(ThreadSchedState.Paused);
@ -553,7 +551,7 @@ namespace Ryujinx.HLE.HOS.Kernel
else else
{ {
SignaledObj = null; SignaledObj = null;
ObjSyncResult = (int)MakeError(ErrorModule.Kernel, KernelErr.Cancelled); ObjSyncResult = KernelResult.Cancelled;
SetNewSchedFlags(ThreadSchedState.Running); SetNewSchedFlags(ThreadSchedState.Running);
@ -1017,7 +1015,7 @@ namespace Ryujinx.HLE.HOS.Kernel
{ {
thread.MutexOwner = null; thread.MutexOwner = null;
thread._preferredCoreOverride = 0; thread._preferredCoreOverride = 0;
thread.ObjSyncResult = 0xfa01; thread.ObjSyncResult = KernelResult.InvalidState;
thread.ReleaseAndResume(); thread.ReleaseAndResume();
} }

View file

@ -1,24 +0,0 @@
namespace Ryujinx.HLE.HOS.Kernel
{
static class KernelErr
{
public const int ThreadTerminating = 59;
public const int InvalidSize = 101;
public const int InvalidAddress = 102;
public const int OutOfMemory = 104;
public const int HandleTableFull = 105;
public const int NoAccessPerm = 106;
public const int InvalidPermission = 108;
public const int InvalidMemRange = 110;
public const int InvalidPriority = 112;
public const int InvalidCoreId = 113;
public const int InvalidHandle = 114;
public const int InvalidMaskValue = 116;
public const int Timeout = 117;
public const int Cancelled = 118;
public const int CountOutOfRange = 119;
public const int InvalidEnumValue = 120;
public const int InvalidThread = 122;
public const int InvalidState = 125;
}
}

View file

@ -4,6 +4,7 @@ namespace Ryujinx.HLE.HOS.Kernel
{ {
Success = 0, Success = 0,
InvalidCapability = 0x1c01, InvalidCapability = 0x1c01,
ThreadNotStarted = 0x7201,
ThreadTerminating = 0x7601, ThreadTerminating = 0x7601,
InvalidSize = 0xca01, InvalidSize = 0xca01,
InvalidAddress = 0xcc01, InvalidAddress = 0xcc01,

View file

@ -178,7 +178,7 @@ namespace Ryujinx.HLE.HOS.Kernel
KThread currentThread = _system.Scheduler.GetCurrentThread(); KThread currentThread = _system.Scheduler.GetCurrentThread();
currentThread.SignaledObj = null; currentThread.SignaledObj = null;
currentThread.ObjSyncResult = 0; currentThread.ObjSyncResult = KernelResult.Success;
currentThread.Reschedule(ThreadSchedState.Paused); currentThread.Reschedule(ThreadSchedState.Paused);
@ -194,7 +194,7 @@ namespace Ryujinx.HLE.HOS.Kernel
_system.CriticalSection.Leave(); _system.CriticalSection.Leave();
return (KernelResult)currentThread.ObjSyncResult; return currentThread.ObjSyncResult;
} }
else else
{ {
@ -208,7 +208,7 @@ namespace Ryujinx.HLE.HOS.Kernel
{ {
HleIpcMessage ipcMessage = (HleIpcMessage)state; HleIpcMessage ipcMessage = (HleIpcMessage)state;
ipcMessage.Thread.ObjSyncResult = (int)IpcHandler.IpcCall( ipcMessage.Thread.ObjSyncResult = IpcHandler.IpcCall(
_device, _device,
_process, _process,
_memory, _memory,