Replace unicorn bindings with Nuget package (#4378)
* Replace unicorn bindings with Nuget package * Use nameof for ValueSource args * Remove redundant code from test projects * Fix wrong values for EmuStart() Add notes to address this later again * Improve formatting * Fix formatting/alignment issues
This commit is contained in:
parent
b3f0978869
commit
ec8d4f3af5
64 changed files with 2276 additions and 3576 deletions
|
@ -6,7 +6,6 @@ using Ryujinx.Cpu.Jit;
|
|||
using Ryujinx.Memory;
|
||||
using Ryujinx.Tests.Unicorn;
|
||||
using System;
|
||||
|
||||
using MemoryPermission = Ryujinx.Tests.Unicorn.MemoryPermission;
|
||||
|
||||
namespace Ryujinx.Tests.Cpu
|
||||
|
@ -33,18 +32,10 @@ namespace Ryujinx.Tests.Cpu
|
|||
|
||||
private CpuContext _cpuContext;
|
||||
|
||||
private static bool _unicornAvailable;
|
||||
private UnicornAArch64 _unicornEmu;
|
||||
|
||||
private bool _usingMemory;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void OneTimeSetup()
|
||||
{
|
||||
_unicornAvailable = UnicornAArch64.IsAvailable();
|
||||
Assume.That(_unicornAvailable, "Unicorn is not available");
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
@ -65,23 +56,17 @@ namespace Ryujinx.Tests.Cpu
|
|||
Optimizations.AllowLcqInFunctionTable = false;
|
||||
Optimizations.UseUnmanagedDispatchLoop = false;
|
||||
|
||||
if (_unicornAvailable)
|
||||
{
|
||||
_unicornEmu = new UnicornAArch64();
|
||||
_unicornEmu.MemoryMap(CodeBaseAddress, Size, MemoryPermission.READ | MemoryPermission.EXEC);
|
||||
_unicornEmu.MemoryMap(DataBaseAddress, Size, MemoryPermission.READ | MemoryPermission.WRITE);
|
||||
_unicornEmu.PC = CodeBaseAddress;
|
||||
}
|
||||
_unicornEmu = new UnicornAArch64();
|
||||
_unicornEmu.MemoryMap(CodeBaseAddress, Size, MemoryPermission.Read | MemoryPermission.Exec);
|
||||
_unicornEmu.MemoryMap(DataBaseAddress, Size, MemoryPermission.Read | MemoryPermission.Write);
|
||||
_unicornEmu.PC = CodeBaseAddress;
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
if (_unicornAvailable)
|
||||
{
|
||||
_unicornEmu.Dispose();
|
||||
_unicornEmu = null;
|
||||
}
|
||||
_unicornEmu.Dispose();
|
||||
_unicornEmu = null;
|
||||
|
||||
_memory.DecrementReferenceCount();
|
||||
_context.Dispose();
|
||||
|
@ -105,10 +90,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
{
|
||||
_memory.Write(_currAddress, opcode);
|
||||
|
||||
if (_unicornAvailable)
|
||||
{
|
||||
_unicornEmu.MemoryWrite32(_currAddress, opcode);
|
||||
}
|
||||
_unicornEmu.MemoryWrite32(_currAddress, opcode);
|
||||
|
||||
_currAddress += 4;
|
||||
}
|
||||
|
@ -158,38 +140,35 @@ namespace Ryujinx.Tests.Cpu
|
|||
_context.Fpcr = (FPCR)fpcr;
|
||||
_context.Fpsr = (FPSR)fpsr;
|
||||
|
||||
if (_unicornAvailable)
|
||||
{
|
||||
_unicornEmu.X[0] = x0;
|
||||
_unicornEmu.X[1] = x1;
|
||||
_unicornEmu.X[2] = x2;
|
||||
_unicornEmu.X[3] = x3;
|
||||
_unicornEmu.SP = x31;
|
||||
_unicornEmu.X[0] = x0;
|
||||
_unicornEmu.X[1] = x1;
|
||||
_unicornEmu.X[2] = x2;
|
||||
_unicornEmu.X[3] = x3;
|
||||
_unicornEmu.SP = x31;
|
||||
|
||||
_unicornEmu.Q[0] = V128ToSimdValue(v0);
|
||||
_unicornEmu.Q[1] = V128ToSimdValue(v1);
|
||||
_unicornEmu.Q[2] = V128ToSimdValue(v2);
|
||||
_unicornEmu.Q[3] = V128ToSimdValue(v3);
|
||||
_unicornEmu.Q[4] = V128ToSimdValue(v4);
|
||||
_unicornEmu.Q[5] = V128ToSimdValue(v5);
|
||||
_unicornEmu.Q[30] = V128ToSimdValue(v30);
|
||||
_unicornEmu.Q[31] = V128ToSimdValue(v31);
|
||||
_unicornEmu.Q[0] = V128ToSimdValue(v0);
|
||||
_unicornEmu.Q[1] = V128ToSimdValue(v1);
|
||||
_unicornEmu.Q[2] = V128ToSimdValue(v2);
|
||||
_unicornEmu.Q[3] = V128ToSimdValue(v3);
|
||||
_unicornEmu.Q[4] = V128ToSimdValue(v4);
|
||||
_unicornEmu.Q[5] = V128ToSimdValue(v5);
|
||||
_unicornEmu.Q[30] = V128ToSimdValue(v30);
|
||||
_unicornEmu.Q[31] = V128ToSimdValue(v31);
|
||||
|
||||
_unicornEmu.OverflowFlag = overflow;
|
||||
_unicornEmu.CarryFlag = carry;
|
||||
_unicornEmu.ZeroFlag = zero;
|
||||
_unicornEmu.NegativeFlag = negative;
|
||||
_unicornEmu.OverflowFlag = overflow;
|
||||
_unicornEmu.CarryFlag = carry;
|
||||
_unicornEmu.ZeroFlag = zero;
|
||||
_unicornEmu.NegativeFlag = negative;
|
||||
|
||||
_unicornEmu.Fpcr = fpcr;
|
||||
_unicornEmu.Fpsr = fpsr;
|
||||
}
|
||||
_unicornEmu.Fpcr = fpcr;
|
||||
_unicornEmu.Fpsr = fpsr;
|
||||
}
|
||||
|
||||
protected void ExecuteOpcodes(bool runUnicorn = true)
|
||||
{
|
||||
_cpuContext.Execute(_context, CodeBaseAddress);
|
||||
|
||||
if (_unicornAvailable && runUnicorn)
|
||||
if (runUnicorn)
|
||||
{
|
||||
_unicornEmu.RunForCount((_currAddress - CodeBaseAddress - 4) / 4);
|
||||
}
|
||||
|
@ -239,10 +218,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
{
|
||||
_memory.Write(DataBaseAddress + offset, data);
|
||||
|
||||
if (_unicornAvailable)
|
||||
{
|
||||
_unicornEmu.MemoryWrite(DataBaseAddress + offset, data);
|
||||
}
|
||||
_unicornEmu.MemoryWrite(DataBaseAddress + offset, data);
|
||||
|
||||
_usingMemory = true; // When true, CompareAgainstUnicorn checks the working memory for equality too.
|
||||
}
|
||||
|
@ -251,10 +227,7 @@ namespace Ryujinx.Tests.Cpu
|
|||
{
|
||||
_memory.Write(DataBaseAddress + offset, data);
|
||||
|
||||
if (_unicornAvailable)
|
||||
{
|
||||
_unicornEmu.MemoryWrite8(DataBaseAddress + offset, data);
|
||||
}
|
||||
_unicornEmu.MemoryWrite8(DataBaseAddress + offset, data);
|
||||
|
||||
_usingMemory = true; // When true, CompareAgainstUnicorn checks the working memory for equality too.
|
||||
}
|
||||
|
@ -331,11 +304,6 @@ namespace Ryujinx.Tests.Cpu
|
|||
FpSkips fpSkips = FpSkips.None,
|
||||
FpTolerances fpTolerances = FpTolerances.None)
|
||||
{
|
||||
if (!_unicornAvailable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IgnoreAllExcept_FpsrQc)
|
||||
{
|
||||
fpsrMask &= Fpsr.Qc;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue