Move ProcessId and ThreadId out of AThreadState
This commit is contained in:
parent
7fa094f137
commit
4f05b53121
6 changed files with 18 additions and 23 deletions
|
@ -18,8 +18,6 @@ namespace ChocolArm64
|
||||||
|
|
||||||
public event EventHandler WorkFinished;
|
public event EventHandler WorkFinished;
|
||||||
|
|
||||||
public int ThreadId => ThreadState.ThreadId;
|
|
||||||
|
|
||||||
private int IsExecuting;
|
private int IsExecuting;
|
||||||
|
|
||||||
public AThread(ATranslator Translator, AMemory Memory, long EntryPoint)
|
public AThread(ATranslator Translator, AMemory Memory, long EntryPoint)
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace ChocolArm64.Memory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<int, ArmMonitor> Monitors;
|
private Dictionary<AThreadState, ArmMonitor> Monitors;
|
||||||
|
|
||||||
private ConcurrentDictionary<long, IntPtr> ObservedPages;
|
private ConcurrentDictionary<long, IntPtr> ObservedPages;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace ChocolArm64.Memory
|
||||||
|
|
||||||
public AMemory(IntPtr Ram)
|
public AMemory(IntPtr Ram)
|
||||||
{
|
{
|
||||||
Monitors = new Dictionary<int, ArmMonitor>();
|
Monitors = new Dictionary<AThreadState, ArmMonitor>();
|
||||||
|
|
||||||
ObservedPages = new ConcurrentDictionary<long, IntPtr>();
|
ObservedPages = new ConcurrentDictionary<long, IntPtr>();
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
ClearExclusive(State);
|
ClearExclusive(State);
|
||||||
|
|
||||||
Monitors.Remove(State.ThreadId);
|
Monitors.Remove(State);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,11 +93,11 @@ namespace ChocolArm64.Memory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
|
if (!Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
|
||||||
{
|
{
|
||||||
ThreadMon = new ArmMonitor();
|
ThreadMon = new ArmMonitor();
|
||||||
|
|
||||||
Monitors.Add(ThreadState.ThreadId, ThreadMon);
|
Monitors.Add(ThreadState, ThreadMon);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadMon.Position = Position;
|
ThreadMon.Position = Position;
|
||||||
|
@ -113,7 +113,7 @@ namespace ChocolArm64.Memory
|
||||||
|
|
||||||
Monitor.Enter(Monitors);
|
Monitor.Enter(Monitors);
|
||||||
|
|
||||||
if (!Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
|
if (!Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ namespace ChocolArm64.Memory
|
||||||
|
|
||||||
public void ClearExclusiveForStore(AThreadState ThreadState)
|
public void ClearExclusiveForStore(AThreadState ThreadState)
|
||||||
{
|
{
|
||||||
if (Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
|
if (Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
|
||||||
{
|
{
|
||||||
ThreadMon.ExState = false;
|
ThreadMon.ExState = false;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ namespace ChocolArm64.Memory
|
||||||
{
|
{
|
||||||
lock (Monitors)
|
lock (Monitors)
|
||||||
{
|
{
|
||||||
if (Monitors.TryGetValue(ThreadState.ThreadId, out ArmMonitor ThreadMon))
|
if (Monitors.TryGetValue(ThreadState, out ArmMonitor ThreadMon))
|
||||||
{
|
{
|
||||||
ThreadMon.ExState = false;
|
ThreadMon.ExState = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,6 @@ namespace ChocolArm64.State
|
||||||
public bool Zero;
|
public bool Zero;
|
||||||
public bool Negative;
|
public bool Negative;
|
||||||
|
|
||||||
public int ProcessId;
|
|
||||||
public int ThreadId;
|
|
||||||
|
|
||||||
public bool Running { get; set; }
|
public bool Running { get; set; }
|
||||||
|
|
||||||
public long TpidrEl0 { get; set; }
|
public long TpidrEl0 { get; set; }
|
||||||
|
|
|
@ -33,18 +33,20 @@ namespace Ryujinx.HLE.HOS.Kernel
|
||||||
|
|
||||||
public long LastPc { get; set; }
|
public long LastPc { get; set; }
|
||||||
|
|
||||||
public int ThreadId => Thread.ThreadId;
|
public int ThreadId { get; private set; }
|
||||||
|
|
||||||
public KThread(
|
public KThread(
|
||||||
AThread Thread,
|
AThread Thread,
|
||||||
Process Process,
|
Process Process,
|
||||||
int ProcessorId,
|
int ProcessorId,
|
||||||
int Priority)
|
int Priority,
|
||||||
|
int ThreadId)
|
||||||
{
|
{
|
||||||
this.Thread = Thread;
|
this.Thread = Thread;
|
||||||
this.Process = Process;
|
this.Process = Process;
|
||||||
this.ProcessorId = ProcessorId;
|
this.ProcessorId = ProcessorId;
|
||||||
this.IdealCore = ProcessorId;
|
this.IdealCore = ProcessorId;
|
||||||
|
this.ThreadId = ThreadId;
|
||||||
|
|
||||||
MutexWaiters = new List<KThread>();
|
MutexWaiters = new List<KThread>();
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Kernel
|
||||||
|
|
||||||
private void SvcExitProcess(AThreadState ThreadState)
|
private void SvcExitProcess(AThreadState ThreadState)
|
||||||
{
|
{
|
||||||
Device.System.ExitProcess(ThreadState.ProcessId);
|
Device.System.ExitProcess(Process.ProcessId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SvcClearEvent(AThreadState ThreadState)
|
private void SvcClearEvent(AThreadState ThreadState)
|
||||||
|
|
|
@ -194,18 +194,16 @@ namespace Ryujinx.HLE.HOS
|
||||||
|
|
||||||
AThread CpuThread = new AThread(GetTranslator(), Memory, EntryPoint);
|
AThread CpuThread = new AThread(GetTranslator(), Memory, EntryPoint);
|
||||||
|
|
||||||
KThread Thread = new KThread(CpuThread, this, ProcessorId, Priority);
|
long Tpidr = GetFreeTls();
|
||||||
|
|
||||||
|
int ThreadId = (int)((Tpidr - MemoryManager.TlsIoRegionStart) / 0x200) + 1;
|
||||||
|
|
||||||
|
KThread Thread = new KThread(CpuThread, this, ProcessorId, Priority, ThreadId);
|
||||||
|
|
||||||
Thread.LastPc = EntryPoint;
|
Thread.LastPc = EntryPoint;
|
||||||
|
|
||||||
int Handle = HandleTable.OpenHandle(Thread);
|
int Handle = HandleTable.OpenHandle(Thread);
|
||||||
|
|
||||||
long Tpidr = GetFreeTls();
|
|
||||||
|
|
||||||
int ThreadId = (int)((Tpidr - MemoryManager.TlsIoRegionStart) / 0x200) + 1;
|
|
||||||
|
|
||||||
CpuThread.ThreadState.ProcessId = ProcessId;
|
|
||||||
CpuThread.ThreadState.ThreadId = ThreadId;
|
|
||||||
CpuThread.ThreadState.CntfrqEl0 = TickFreq;
|
CpuThread.ThreadState.CntfrqEl0 = TickFreq;
|
||||||
CpuThread.ThreadState.Tpidr = Tpidr;
|
CpuThread.ThreadState.Tpidr = Tpidr;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue