aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Core/OsHle/Process.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-02-27 20:45:07 -0300
committergdkchan <gab.dark.100@gmail.com>2018-02-27 20:45:07 -0300
commitf876bd2a805805d9e5dc350b65e8d02fbc5b88b5 (patch)
tree7a3af73448166b628526028cb35d09cc8a010eac /Ryujinx.Core/OsHle/Process.cs
parent708761963e09ceb4619f8f21fffc7af051a8f020 (diff)
Change SvcGetInfo 5 to return actual heap size, remove AMemoryAlloc since it is no longer needed with direct memory access, move some memory management logic out of AMemoryMgr, change default virtual filesystem path to AppData
Diffstat (limited to 'Ryujinx.Core/OsHle/Process.cs')
-rw-r--r--Ryujinx.Core/OsHle/Process.cs52
1 files changed, 26 insertions, 26 deletions
diff --git a/Ryujinx.Core/OsHle/Process.cs b/Ryujinx.Core/OsHle/Process.cs
index 9ca9a2bd..f0b568c8 100644
--- a/Ryujinx.Core/OsHle/Process.cs
+++ b/Ryujinx.Core/OsHle/Process.cs
@@ -15,19 +15,15 @@ namespace Ryujinx.Core.OsHle
{
public class Process : IDisposable
{
- private const int MaxStackSize = 8 * 1024 * 1024;
-
private const int TlsSize = 0x200;
private const int TotalTlsSlots = 32;
- private const int TlsTotalSize = TotalTlsSlots * TlsSize;
- private const long TlsPageAddr = (AMemoryMgr.AddrSize - TlsTotalSize) & ~AMemoryMgr.PageMask;
private Switch Ns;
- private ATranslator Translator;
-
public int ProcessId { get; private set; }
+ private ATranslator Translator;
+
public AMemory Memory { get; private set; }
public KProcessScheduler Scheduler { get; private set; }
@@ -44,12 +40,12 @@ namespace Ryujinx.Core.OsHle
private long ImageBase;
- public Process(Switch Ns, AMemoryAlloc Allocator, int ProcessId)
+ public Process(Switch Ns, int ProcessId)
{
this.Ns = Ns;
this.ProcessId = ProcessId;
- Memory = new AMemory(Ns.Ram, Allocator);
+ Memory = new AMemory(Ns.Ram);
Scheduler = new KProcessScheduler();
@@ -61,13 +57,12 @@ namespace Ryujinx.Core.OsHle
Executables = new List<Executable>();
- ImageBase = 0x8000000;
+ ImageBase = MemoryRegions.AddrSpaceStart;
- Memory.Manager.MapPhys(
- TlsPageAddr,
- TlsTotalSize,
- (int)MemoryType.ThreadLocal,
- AMemoryPerm.RW);
+ MapRWMemRegion(
+ MemoryRegions.TlsPagesAddress,
+ MemoryRegions.TlsPagesSize,
+ MemoryType.ThreadLocal);
}
public void LoadProgram(IExecutable Program)
@@ -86,11 +81,6 @@ namespace Ryujinx.Core.OsHle
ImageBase += AMemoryMgr.PageSize;
}
- public void InitializeHeap()
- {
- Memory.Manager.SetHeapAddr(MemoryRegions.HeapRegionAddress);
- }
-
public bool Run(bool UseHbAbi = false)
{
if (Executables.Count == 0)
@@ -98,11 +88,14 @@ namespace Ryujinx.Core.OsHle
return false;
}
- long StackBot = TlsPageAddr - MaxStackSize;
-
- Memory.Manager.MapPhys(StackBot, MaxStackSize, (int)MemoryType.Normal, AMemoryPerm.RW);
+ MapRWMemRegion(
+ MemoryRegions.MainStackAddress,
+ MemoryRegions.MainStackSize,
+ MemoryType.Normal);
+
+ long StackTop = MemoryRegions.MainStackAddress + MemoryRegions.MainStackSize;
- int Handle = MakeThread(Executables[0].ImageBase, TlsPageAddr, 0, 0, 0);
+ int Handle = MakeThread(Executables[0].ImageBase, StackTop, 0, 0, 0);
if (Handle == -1)
{
@@ -113,7 +106,7 @@ namespace Ryujinx.Core.OsHle
if (UseHbAbi)
{
- long HbAbiDataPosition = (Executables[0].ImageEnd + 0xfff) & ~0xfff;
+ long HbAbiDataPosition = AMemoryHelper.PageRoundUp(Executables[0].ImageEnd);
Homebrew.WriteHbAbiData(Memory, HbAbiDataPosition, Handle);
@@ -126,6 +119,11 @@ namespace Ryujinx.Core.OsHle
return true;
}
+ private void MapRWMemRegion(long Position, long Size, MemoryType Type)
+ {
+ Memory.Manager.Map(Position, Size, (int)Type, AMemoryPerm.RW);
+ }
+
public void StopAllThreads()
{
if (MainThread != null)
@@ -188,12 +186,14 @@ namespace Ryujinx.Core.OsHle
return -1;
}
+ long Tpidr = MemoryRegions.TlsPagesAddress + TlsSlot * TlsSize;
+
Thread.ThreadState.Break += BreakHandler;
Thread.ThreadState.SvcCall += SvcHandler.SvcCall;
Thread.ThreadState.Undefined += UndefinedHandler;
Thread.ThreadState.ProcessId = ProcessId;
Thread.ThreadState.ThreadId = Ns.Os.IdGen.GenerateId();
- Thread.ThreadState.Tpidr = TlsPageAddr + TlsSlot * TlsSize;
+ Thread.ThreadState.Tpidr = Tpidr;
Thread.ThreadState.X0 = (ulong)ArgsPtr;
Thread.ThreadState.X1 = (ulong)Handle;
Thread.ThreadState.X31 = (ulong)StackTop;
@@ -267,7 +267,7 @@ namespace Ryujinx.Core.OsHle
private int GetTlsSlot(long Position)
{
- return (int)((Position - TlsPageAddr) / TlsSize);
+ return (int)((Position - MemoryRegions.TlsPagesAddress) / TlsSize);
}
public HThread GetThread(long Tpidr)