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
This commit is contained in:
gdkchan 2018-11-28 20:18:09 -02:00 committed by GitHub
parent e7fe7d7247
commit 00579927e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
119 changed files with 7998 additions and 3232 deletions

View file

@ -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: