aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Kernel/SupervisorCall
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-05-03 19:54:50 -0300
committerGitHub <noreply@github.com>2020-05-04 08:54:50 +1000
commitf77694e4f774c9391aad5344e70a7c8721cfedc6 (patch)
tree36bccaeb153bd5d921c751966b8a734a7b4b6ae1 /Ryujinx.HLE/HOS/Kernel/SupervisorCall
parent1758424208335d1f4ff7c27c554e517c81bf72f6 (diff)
Implement a new physical memory manager and replace DeviceMemory (#856)
* Implement a new physical memory manager and replace DeviceMemory * Proper generic constraints * Fix debug build * Add memory tests * New CPU memory manager and general code cleanup * Remove host memory management from CPU project, use Ryujinx.Memory instead * Fix tests * Document exceptions on MemoryBlock * Fix leak on unix memory allocation * Proper disposal of some objects on tests * Fix JitCache not being set as initialized * GetRef without checks for 8-bits and 16-bits CAS * Add MemoryBlock destructor * Throw in separate method to improve codegen * Address PR feedback * QueryModified improvements * Fix memory write tracking not marking all pages as modified in some cases * Simplify MarkRegionAsModified * Remove XML doc for ghost param * Add back optimization to avoid useless buffer updates * Add Ryujinx.Cpu project, move MemoryManager there and remove MemoryBlockWrapper * Some nits * Do not perform address translation when size is 0 * Address PR feedback and format NativeInterface class * Remove ghost parameter description * Update Ryujinx.Cpu to .NET Core 3.1 * Address PR feedback * Fix build * Return a well defined value for GetPhysicalAddress with invalid VA, and do not return unmapped ranges as modified * Typo
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/SupervisorCall')
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs4
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcMemory.cs16
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs2
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs148
-rw-r--r--Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThreadSync.cs2
5 files changed, 87 insertions, 85 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs
index bcecf86a..7188ead0 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcIpc.cs
@@ -108,7 +108,9 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
private KernelResult SendSyncRequest(ulong messagePtr, ulong size, int handle)
{
- byte[] messageData = _process.CpuMemory.ReadBytes((long)messagePtr, (long)size);
+ byte[] messageData = new byte[size];
+
+ _process.CpuMemory.Read(messagePtr, messageData);
KClientSession clientSession = _process.HandleTable.GetObject<KClientSession>(handle);
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcMemory.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcMemory.cs
index b69ce03a..a6d06986 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcMemory.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcMemory.cs
@@ -191,14 +191,14 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
{
KMemoryInfo blkInfo = _process.MemoryManager.QueryMemory(position);
- _process.CpuMemory.WriteUInt64((long)infoPtr + 0x00, blkInfo.Address);
- _process.CpuMemory.WriteUInt64((long)infoPtr + 0x08, blkInfo.Size);
- _process.CpuMemory.WriteInt32 ((long)infoPtr + 0x10, (int)blkInfo.State & 0xff);
- _process.CpuMemory.WriteInt32 ((long)infoPtr + 0x14, (int)blkInfo.Attribute);
- _process.CpuMemory.WriteInt32 ((long)infoPtr + 0x18, (int)blkInfo.Permission);
- _process.CpuMemory.WriteInt32 ((long)infoPtr + 0x1c, blkInfo.IpcRefCount);
- _process.CpuMemory.WriteInt32 ((long)infoPtr + 0x20, blkInfo.DeviceRefCount);
- _process.CpuMemory.WriteInt32 ((long)infoPtr + 0x24, 0);
+ _process.CpuMemory.Write(infoPtr + 0x00, blkInfo.Address);
+ _process.CpuMemory.Write(infoPtr + 0x08, blkInfo.Size);
+ _process.CpuMemory.Write(infoPtr + 0x10, (int)blkInfo.State & 0xff);
+ _process.CpuMemory.Write(infoPtr + 0x14, (int)blkInfo.Attribute);
+ _process.CpuMemory.Write(infoPtr + 0x18, (int)blkInfo.Permission);
+ _process.CpuMemory.Write(infoPtr + 0x1c, blkInfo.IpcRefCount);
+ _process.CpuMemory.Write(infoPtr + 0x20, blkInfo.DeviceRefCount);
+ _process.CpuMemory.Write(infoPtr + 0x24, 0);
pageInfo = 0;
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs
index 82c30cb5..f654630c 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcSystem.cs
@@ -1,6 +1,6 @@
-using ARMeilleure.Memory;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
+using Ryujinx.Cpu;
using Ryujinx.HLE.Exceptions;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Ipc;
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs
index 101fb192..f1ac3ded 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThread.cs
@@ -1,5 +1,5 @@
-using ARMeilleure.Memory;
using ARMeilleure.State;
+using Ryujinx.Cpu;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Process;
using Ryujinx.HLE.HOS.Kernel.Threading;
@@ -432,79 +432,79 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
MemoryManager memory = currentProcess.CpuMemory;
- memory.WriteUInt64((long)address + 0x0, thread.Context.GetX(0));
- memory.WriteUInt64((long)address + 0x8, thread.Context.GetX(1));
- memory.WriteUInt64((long)address + 0x10, thread.Context.GetX(2));
- memory.WriteUInt64((long)address + 0x18, thread.Context.GetX(3));
- memory.WriteUInt64((long)address + 0x20, thread.Context.GetX(4));
- memory.WriteUInt64((long)address + 0x28, thread.Context.GetX(5));
- memory.WriteUInt64((long)address + 0x30, thread.Context.GetX(6));
- memory.WriteUInt64((long)address + 0x38, thread.Context.GetX(7));
- memory.WriteUInt64((long)address + 0x40, thread.Context.GetX(8));
- memory.WriteUInt64((long)address + 0x48, thread.Context.GetX(9));
- memory.WriteUInt64((long)address + 0x50, thread.Context.GetX(10));
- memory.WriteUInt64((long)address + 0x58, thread.Context.GetX(11));
- memory.WriteUInt64((long)address + 0x60, thread.Context.GetX(12));
- memory.WriteUInt64((long)address + 0x68, thread.Context.GetX(13));
- memory.WriteUInt64((long)address + 0x70, thread.Context.GetX(14));
- memory.WriteUInt64((long)address + 0x78, thread.Context.GetX(15));
- memory.WriteUInt64((long)address + 0x80, thread.Context.GetX(16));
- memory.WriteUInt64((long)address + 0x88, thread.Context.GetX(17));
- memory.WriteUInt64((long)address + 0x90, thread.Context.GetX(18));
- memory.WriteUInt64((long)address + 0x98, thread.Context.GetX(19));
- memory.WriteUInt64((long)address + 0xa0, thread.Context.GetX(20));
- memory.WriteUInt64((long)address + 0xa8, thread.Context.GetX(21));
- memory.WriteUInt64((long)address + 0xb0, thread.Context.GetX(22));
- memory.WriteUInt64((long)address + 0xb8, thread.Context.GetX(23));
- memory.WriteUInt64((long)address + 0xc0, thread.Context.GetX(24));
- memory.WriteUInt64((long)address + 0xc8, thread.Context.GetX(25));
- memory.WriteUInt64((long)address + 0xd0, thread.Context.GetX(26));
- memory.WriteUInt64((long)address + 0xd8, thread.Context.GetX(27));
- memory.WriteUInt64((long)address + 0xe0, thread.Context.GetX(28));
- memory.WriteUInt64((long)address + 0xe8, thread.Context.GetX(29));
- memory.WriteUInt64((long)address + 0xf0, thread.Context.GetX(30));
- memory.WriteUInt64((long)address + 0xf8, thread.Context.GetX(31));
-
- memory.WriteInt64((long)address + 0x100, thread.LastPc);
-
- memory.WriteUInt64((long)address + 0x108, (ulong)GetPsr(thread.Context));
-
- memory.WriteVector128((long)address + 0x110, thread.Context.GetV(0));
- memory.WriteVector128((long)address + 0x120, thread.Context.GetV(1));
- memory.WriteVector128((long)address + 0x130, thread.Context.GetV(2));
- memory.WriteVector128((long)address + 0x140, thread.Context.GetV(3));
- memory.WriteVector128((long)address + 0x150, thread.Context.GetV(4));
- memory.WriteVector128((long)address + 0x160, thread.Context.GetV(5));
- memory.WriteVector128((long)address + 0x170, thread.Context.GetV(6));
- memory.WriteVector128((long)address + 0x180, thread.Context.GetV(7));
- memory.WriteVector128((long)address + 0x190, thread.Context.GetV(8));
- memory.WriteVector128((long)address + 0x1a0, thread.Context.GetV(9));
- memory.WriteVector128((long)address + 0x1b0, thread.Context.GetV(10));
- memory.WriteVector128((long)address + 0x1c0, thread.Context.GetV(11));
- memory.WriteVector128((long)address + 0x1d0, thread.Context.GetV(12));
- memory.WriteVector128((long)address + 0x1e0, thread.Context.GetV(13));
- memory.WriteVector128((long)address + 0x1f0, thread.Context.GetV(14));
- memory.WriteVector128((long)address + 0x200, thread.Context.GetV(15));
- memory.WriteVector128((long)address + 0x210, thread.Context.GetV(16));
- memory.WriteVector128((long)address + 0x220, thread.Context.GetV(17));
- memory.WriteVector128((long)address + 0x230, thread.Context.GetV(18));
- memory.WriteVector128((long)address + 0x240, thread.Context.GetV(19));
- memory.WriteVector128((long)address + 0x250, thread.Context.GetV(20));
- memory.WriteVector128((long)address + 0x260, thread.Context.GetV(21));
- memory.WriteVector128((long)address + 0x270, thread.Context.GetV(22));
- memory.WriteVector128((long)address + 0x280, thread.Context.GetV(23));
- memory.WriteVector128((long)address + 0x290, thread.Context.GetV(24));
- memory.WriteVector128((long)address + 0x2a0, thread.Context.GetV(25));
- memory.WriteVector128((long)address + 0x2b0, thread.Context.GetV(26));
- memory.WriteVector128((long)address + 0x2c0, thread.Context.GetV(27));
- memory.WriteVector128((long)address + 0x2d0, thread.Context.GetV(28));
- memory.WriteVector128((long)address + 0x2e0, thread.Context.GetV(29));
- memory.WriteVector128((long)address + 0x2f0, thread.Context.GetV(30));
- memory.WriteVector128((long)address + 0x300, thread.Context.GetV(31));
-
- memory.WriteInt32((long)address + 0x310, (int)thread.Context.Fpcr);
- memory.WriteInt32((long)address + 0x314, (int)thread.Context.Fpsr);
- memory.WriteInt64((long)address + 0x318, thread.Context.Tpidr);
+ memory.Write(address + 0x0, thread.Context.GetX(0));
+ memory.Write(address + 0x8, thread.Context.GetX(1));
+ memory.Write(address + 0x10, thread.Context.GetX(2));
+ memory.Write(address + 0x18, thread.Context.GetX(3));
+ memory.Write(address + 0x20, thread.Context.GetX(4));
+ memory.Write(address + 0x28, thread.Context.GetX(5));
+ memory.Write(address + 0x30, thread.Context.GetX(6));
+ memory.Write(address + 0x38, thread.Context.GetX(7));
+ memory.Write(address + 0x40, thread.Context.GetX(8));
+ memory.Write(address + 0x48, thread.Context.GetX(9));
+ memory.Write(address + 0x50, thread.Context.GetX(10));
+ memory.Write(address + 0x58, thread.Context.GetX(11));
+ memory.Write(address + 0x60, thread.Context.GetX(12));
+ memory.Write(address + 0x68, thread.Context.GetX(13));
+ memory.Write(address + 0x70, thread.Context.GetX(14));
+ memory.Write(address + 0x78, thread.Context.GetX(15));
+ memory.Write(address + 0x80, thread.Context.GetX(16));
+ memory.Write(address + 0x88, thread.Context.GetX(17));
+ memory.Write(address + 0x90, thread.Context.GetX(18));
+ memory.Write(address + 0x98, thread.Context.GetX(19));
+ memory.Write(address + 0xa0, thread.Context.GetX(20));
+ memory.Write(address + 0xa8, thread.Context.GetX(21));
+ memory.Write(address + 0xb0, thread.Context.GetX(22));
+ memory.Write(address + 0xb8, thread.Context.GetX(23));
+ memory.Write(address + 0xc0, thread.Context.GetX(24));
+ memory.Write(address + 0xc8, thread.Context.GetX(25));
+ memory.Write(address + 0xd0, thread.Context.GetX(26));
+ memory.Write(address + 0xd8, thread.Context.GetX(27));
+ memory.Write(address + 0xe0, thread.Context.GetX(28));
+ memory.Write(address + 0xe8, thread.Context.GetX(29));
+ memory.Write(address + 0xf0, thread.Context.GetX(30));
+ memory.Write(address + 0xf8, thread.Context.GetX(31));
+
+ memory.Write(address + 0x100, thread.LastPc);
+
+ memory.Write(address + 0x108, (ulong)GetPsr(thread.Context));
+
+ memory.Write(address + 0x110, thread.Context.GetV(0));
+ memory.Write(address + 0x120, thread.Context.GetV(1));
+ memory.Write(address + 0x130, thread.Context.GetV(2));
+ memory.Write(address + 0x140, thread.Context.GetV(3));
+ memory.Write(address + 0x150, thread.Context.GetV(4));
+ memory.Write(address + 0x160, thread.Context.GetV(5));
+ memory.Write(address + 0x170, thread.Context.GetV(6));
+ memory.Write(address + 0x180, thread.Context.GetV(7));
+ memory.Write(address + 0x190, thread.Context.GetV(8));
+ memory.Write(address + 0x1a0, thread.Context.GetV(9));
+ memory.Write(address + 0x1b0, thread.Context.GetV(10));
+ memory.Write(address + 0x1c0, thread.Context.GetV(11));
+ memory.Write(address + 0x1d0, thread.Context.GetV(12));
+ memory.Write(address + 0x1e0, thread.Context.GetV(13));
+ memory.Write(address + 0x1f0, thread.Context.GetV(14));
+ memory.Write(address + 0x200, thread.Context.GetV(15));
+ memory.Write(address + 0x210, thread.Context.GetV(16));
+ memory.Write(address + 0x220, thread.Context.GetV(17));
+ memory.Write(address + 0x230, thread.Context.GetV(18));
+ memory.Write(address + 0x240, thread.Context.GetV(19));
+ memory.Write(address + 0x250, thread.Context.GetV(20));
+ memory.Write(address + 0x260, thread.Context.GetV(21));
+ memory.Write(address + 0x270, thread.Context.GetV(22));
+ memory.Write(address + 0x280, thread.Context.GetV(23));
+ memory.Write(address + 0x290, thread.Context.GetV(24));
+ memory.Write(address + 0x2a0, thread.Context.GetV(25));
+ memory.Write(address + 0x2b0, thread.Context.GetV(26));
+ memory.Write(address + 0x2c0, thread.Context.GetV(27));
+ memory.Write(address + 0x2d0, thread.Context.GetV(28));
+ memory.Write(address + 0x2e0, thread.Context.GetV(29));
+ memory.Write(address + 0x2f0, thread.Context.GetV(30));
+ memory.Write(address + 0x300, thread.Context.GetV(31));
+
+ memory.Write(address + 0x310, (int)thread.Context.Fpcr);
+ memory.Write(address + 0x314, (int)thread.Context.Fpsr);
+ memory.Write(address + 0x318, thread.Context.Tpidr);
return KernelResult.Success;
}
diff --git a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThreadSync.cs b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThreadSync.cs
index 4adbdd62..eecafb0b 100644
--- a/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThreadSync.cs
+++ b/Ryujinx.HLE/HOS/Kernel/SupervisorCall/SvcThreadSync.cs
@@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
for (int index = 0; index < handlesCount; index++)
{
- int handle = _process.CpuMemory.ReadInt32((long)handlesPtr + index * 4);
+ int handle = _process.CpuMemory.Read<int>(handlesPtr + (ulong)index * 4);
KSynchronizationObject syncObj = _process.HandleTable.GetObject<KSynchronizationObject>(handle);