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
This commit is contained in:
parent
1758424208
commit
f77694e4f7
126 changed files with 2176 additions and 2092 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.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.WriteInt64((long)address + 0x100, thread.LastPc);
|
||||
memory.Write(address + 0x100, thread.LastPc);
|
||||
|
||||
memory.WriteUInt64((long)address + 0x108, (ulong)GetPsr(thread.Context));
|
||||
memory.Write(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.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.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 + 0x310, (int)thread.Context.Fpcr);
|
||||
memory.Write(address + 0x314, (int)thread.Context.Fpsr);
|
||||
memory.Write(address + 0x318, thread.Context.Tpidr);
|
||||
|
||||
return KernelResult.Success;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue