Add pl:u stub, use higher precision on CNTPCT_EL0 register tick count
This commit is contained in:
parent
4d90d60119
commit
2ed24af756
5 changed files with 47 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
using ChocolArm64.Events;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ChocolArm64.State
|
||||
{
|
||||
|
@ -40,15 +41,34 @@ namespace ChocolArm64.State
|
|||
public uint CtrEl0 => 0x8444c004;
|
||||
public uint DczidEl0 => 0x00000004;
|
||||
|
||||
private const ulong TicksPerS = 19_200_000;
|
||||
private const ulong TicksPerMS = TicksPerS / 1_000;
|
||||
public ulong CntfrqEl0 { get; set; }
|
||||
public ulong CntpctEl0
|
||||
{
|
||||
get
|
||||
{
|
||||
double Ticks = TickCounter.ElapsedTicks * HostTickFreq;
|
||||
|
||||
public ulong CntpctEl0 => (ulong)Environment.TickCount * TicksPerMS;
|
||||
return (ulong)(Ticks * CntfrqEl0);
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<AInstExceptionEventArgs> Break;
|
||||
public event EventHandler<AInstExceptionEventArgs> SvcCall;
|
||||
public event EventHandler<AInstUndefinedEventArgs> Undefined;
|
||||
|
||||
private static Stopwatch TickCounter;
|
||||
|
||||
private static double HostTickFreq;
|
||||
|
||||
static AThreadState()
|
||||
{
|
||||
HostTickFreq = 1.0 / Stopwatch.Frequency;
|
||||
|
||||
TickCounter = new Stopwatch();
|
||||
|
||||
TickCounter.Start();
|
||||
}
|
||||
|
||||
internal void OnBreak(int Imm)
|
||||
{
|
||||
Break?.Invoke(this, new AInstExceptionEventArgs(Imm));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue