aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-11-28 20:18:09 -0200
committerGitHub <noreply@github.com>2018-11-28 20:18:09 -0200
commit00579927e43bf55ee06ae02933c1e755fb4120eb (patch)
tree0fd06db7b28e0accf87b465ec6f4dc74691febab /Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs
parente7fe7d724778535f8eff390abef54274a343c0b7 (diff)
Better process implementation (#491)
* Initial implementation of KProcess * Some improvements to the memory manager, implement back guest stack trace printing * Better GetInfo implementation, improve checking in some places with information from process capabilities * Allow the cpu to read/write from the correct memory locations for accesses crossing a page boundary * Change long -> ulong for address/size on memory related methods to avoid unnecessary casts * Attempt at implementing ldr:ro with new KProcess * Allow BSS with size 0 on ldr:ro * Add checking for memory block slab heap usage, return errors if full, exit gracefully * Use KMemoryBlockSize const from KMemoryManager * Allow all methods to read from non-contiguous locations * Fix for TransactParcelAuto * Address PR feedback, additionally fix some small issues related to the KIP loader and implement SVCs GetProcessId, GetProcessList, GetSystemInfo, CreatePort and ManageNamedPort * Fix wrong check for source pages count from page list on MapPhysicalMemory * Fix some issues with UnloadNro on ldr:ro
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs')
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs40
1 files changed, 24 insertions, 16 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs b/Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs
index 318bd290..3935df5d 100644
--- a/Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SvcThreadSync.cs
@@ -32,6 +32,8 @@ namespace Ryujinx.HLE.HOS.Kernel
{
int Handle = Memory.ReadInt32(HandlesPtr + Index * 4);
+ Logger.PrintDebug(LogClass.KernelSvc, $"Sync handle 0x{Handle:x8}");
+
KSynchronizationObject SyncObj = Process.HandleTable.GetObject<KSynchronizationObject>(Handle);
if (SyncObj == null)
@@ -116,12 +118,9 @@ namespace Ryujinx.HLE.HOS.Kernel
return;
}
- long Result = System.AddressArbiter.ArbitrateLock(
- Process,
- Memory,
- OwnerHandle,
- MutexAddress,
- RequesterHandle);
+ KProcess CurrentProcess = System.Scheduler.GetCurrentProcess();
+
+ long Result = CurrentProcess.AddressArbiter.ArbitrateLock(OwnerHandle, MutexAddress, RequesterHandle);
if (Result != 0)
{
@@ -155,7 +154,9 @@ namespace Ryujinx.HLE.HOS.Kernel
return;
}
- long Result = System.AddressArbiter.ArbitrateUnlock(Memory, MutexAddress);
+ KProcess CurrentProcess = System.Scheduler.GetCurrentProcess();
+
+ long Result = CurrentProcess.AddressArbiter.ArbitrateUnlock(MutexAddress);
if (Result != 0)
{
@@ -196,8 +197,9 @@ namespace Ryujinx.HLE.HOS.Kernel
return;
}
- long Result = System.AddressArbiter.WaitProcessWideKeyAtomic(
- Memory,
+ KProcess CurrentProcess = System.Scheduler.GetCurrentProcess();
+
+ long Result = CurrentProcess.AddressArbiter.WaitProcessWideKeyAtomic(
MutexAddress,
CondVarAddress,
ThreadHandle,
@@ -227,7 +229,9 @@ namespace Ryujinx.HLE.HOS.Kernel
"Address = 0x" + Address.ToString("x16") + ", " +
"Count = 0x" + Count .ToString("x8"));
- System.AddressArbiter.SignalProcessWideKey(Process, Memory, Address, Count);
+ KProcess CurrentProcess = System.Scheduler.GetCurrentProcess();
+
+ CurrentProcess.AddressArbiter.SignalProcessWideKey(Address, Count);
ThreadState.X0 = 0;
}
@@ -263,20 +267,22 @@ namespace Ryujinx.HLE.HOS.Kernel
return;
}
+ KProcess CurrentProcess = System.Scheduler.GetCurrentProcess();
+
long Result;
switch (Type)
{
case ArbitrationType.WaitIfLessThan:
- Result = System.AddressArbiter.WaitForAddressIfLessThan(Memory, Address, Value, false, Timeout);
+ Result = CurrentProcess.AddressArbiter.WaitForAddressIfLessThan(Address, Value, false, Timeout);
break;
case ArbitrationType.DecrementAndWaitIfLessThan:
- Result = System.AddressArbiter.WaitForAddressIfLessThan(Memory, Address, Value, true, Timeout);
+ Result = CurrentProcess.AddressArbiter.WaitForAddressIfLessThan(Address, Value, true, Timeout);
break;
case ArbitrationType.WaitIfEqual:
- Result = System.AddressArbiter.WaitForAddressIfEqual(Memory, Address, Value, Timeout);
+ Result = CurrentProcess.AddressArbiter.WaitForAddressIfEqual(Address, Value, Timeout);
break;
default:
@@ -323,20 +329,22 @@ namespace Ryujinx.HLE.HOS.Kernel
return;
}
+ KProcess CurrentProcess = System.Scheduler.GetCurrentProcess();
+
long Result;
switch (Type)
{
case SignalType.Signal:
- Result = System.AddressArbiter.Signal(Address, Count);
+ Result = CurrentProcess.AddressArbiter.Signal(Address, Count);
break;
case SignalType.SignalAndIncrementIfEqual:
- Result = System.AddressArbiter.SignalAndIncrementIfEqual(Memory, Address, Value, Count);
+ Result = CurrentProcess.AddressArbiter.SignalAndIncrementIfEqual(Address, Value, Count);
break;
case SignalType.SignalAndModifyIfEqual:
- Result = System.AddressArbiter.SignalAndModifyIfEqual(Memory, Address, Value, Count);
+ Result = CurrentProcess.AddressArbiter.SignalAndModifyIfEqual(Address, Value, Count);
break;
default: