aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Core/OsHle
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-02-23 21:59:38 -0300
committergdkchan <gab.dark.100@gmail.com>2018-02-23 21:59:38 -0300
commit3936c934482a587635bc5a1e47962551aeb53aeb (patch)
tree7df4ab78fe30ea27edcda9e54a32a8d132717225 /Ryujinx.Core/OsHle
parent2ed733b1d5addad027f48acfdd407e64b71427fc (diff)
Map heap on heap base region, fix for thread start on homebrew, add FCVTMU and FCVTPU (general) instructions, fix FMOV (higher 64 bits) encodings, improve emit code for FCVT* (general) instructions
Diffstat (limited to 'Ryujinx.Core/OsHle')
-rw-r--r--Ryujinx.Core/OsHle/Horizon.cs16
-rw-r--r--Ryujinx.Core/OsHle/MemoryRegions.cs13
-rw-r--r--Ryujinx.Core/OsHle/Objects/Android/NvFlinger.cs2
-rw-r--r--Ryujinx.Core/OsHle/Objects/FspSrv/IFileSystem.cs13
-rw-r--r--Ryujinx.Core/OsHle/Process.cs19
-rw-r--r--Ryujinx.Core/OsHle/Svc/SvcSystem.cs8
6 files changed, 46 insertions, 25 deletions
diff --git a/Ryujinx.Core/OsHle/Horizon.cs b/Ryujinx.Core/OsHle/Horizon.cs
index e2d38d52..9929102d 100644
--- a/Ryujinx.Core/OsHle/Horizon.cs
+++ b/Ryujinx.Core/OsHle/Horizon.cs
@@ -114,25 +114,22 @@ namespace Ryujinx.Core.OsHle
public void LoadProgram(string FileName)
{
+ bool IsNro = Path.GetExtension(FileName).ToLower() == ".nro";
+
int ProcessId = IdGen.GenerateId();
Process MainProcess = new Process(Ns, Allocator, ProcessId);
using (FileStream Input = new FileStream(FileName, FileMode.Open))
{
- if (Path.GetExtension(FileName).ToLower() == ".nro")
- {
- MainProcess.LoadProgram(new Nro(Input));
- }
- else
- {
- MainProcess.LoadProgram(new Nso(Input));
- }
+ MainProcess.LoadProgram(IsNro
+ ? (IExecutable)new Nro(Input)
+ : (IExecutable)new Nso(Input));
}
MainProcess.SetEmptyArgs();
MainProcess.InitializeHeap();
- MainProcess.Run();
+ MainProcess.Run(IsNro);
Processes.TryAdd(ProcessId, MainProcess);
}
@@ -190,6 +187,7 @@ namespace Ryujinx.Core.OsHle
if (SharedMem.TryGetLastVirtualPosition(out long Position))
{
Logging.Info($"HID shared memory successfully mapped to {Position:x16}!");
+
Ns.Hid.Init(Position);
}
}
diff --git a/Ryujinx.Core/OsHle/MemoryRegions.cs b/Ryujinx.Core/OsHle/MemoryRegions.cs
new file mode 100644
index 00000000..e8ededc8
--- /dev/null
+++ b/Ryujinx.Core/OsHle/MemoryRegions.cs
@@ -0,0 +1,13 @@
+using ChocolArm64.Memory;
+
+namespace Ryujinx.Core.OsHle
+{
+ static class MemoryRegions
+ {
+ public const long MapRegionAddress = 0x80000000;
+ public const long MapRegionSize = 0x40000000;
+
+ public const long HeapRegionAddress = MapRegionAddress + MapRegionSize;
+ public const long HeapRegionSize = 0x40000000;
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.Core/OsHle/Objects/Android/NvFlinger.cs b/Ryujinx.Core/OsHle/Objects/Android/NvFlinger.cs
index 23863099..54588383 100644
--- a/Ryujinx.Core/OsHle/Objects/Android/NvFlinger.cs
+++ b/Ryujinx.Core/OsHle/Objects/Android/NvFlinger.cs
@@ -245,7 +245,7 @@ namespace Ryujinx.Core.OsHle.Objects.Android
HNvMap NvMap = GetNvMap(Context, Slot);
- if (NvMap.Address < 0 || NvMap.Address + FbSize > AMemoryMgr.AddrSize)
+ if (FbSize < 0 || NvMap.Address < 0 || NvMap.Address + FbSize > AMemoryMgr.AddrSize)
{
Logging.Error($"Frame buffer address {NvMap.Address:x16} is invalid!");
diff --git a/Ryujinx.Core/OsHle/Objects/FspSrv/IFileSystem.cs b/Ryujinx.Core/OsHle/Objects/FspSrv/IFileSystem.cs
index e18c1daf..6b86a473 100644
--- a/Ryujinx.Core/OsHle/Objects/FspSrv/IFileSystem.cs
+++ b/Ryujinx.Core/OsHle/Objects/FspSrv/IFileSystem.cs
@@ -273,7 +273,16 @@ namespace Ryujinx.Core.OsHle.Objects.FspSrv
FileStream Stream = new FileStream(FileName, FileMode.Open);
- MakeObject(Context, new IFile(Stream, FileName));
+ IFile FileInterface = new IFile(Stream, FileName);
+
+ FileInterface.Disposed += RemoveFileInUse;
+
+ lock (OpenPaths)
+ {
+ OpenPaths.Add(FileName);
+ }
+
+ MakeObject(Context, FileInterface);
return 0;
}
@@ -353,7 +362,7 @@ namespace Ryujinx.Core.OsHle.Objects.FspSrv
lock (OpenPaths)
{
- FileInterface.Disposed -= RemoveDirectoryInUse;
+ FileInterface.Disposed -= RemoveFileInUse;
OpenPaths.Remove(FileInterface.HostPath);
}
diff --git a/Ryujinx.Core/OsHle/Process.cs b/Ryujinx.Core/OsHle/Process.cs
index 022dc0f9..3e265ed3 100644
--- a/Ryujinx.Core/OsHle/Process.cs
+++ b/Ryujinx.Core/OsHle/Process.cs
@@ -86,10 +86,10 @@ namespace Ryujinx.Core.OsHle
public void InitializeHeap()
{
- Memory.Manager.SetHeapAddr((ImageBase + 0x3fffffff) & ~0x3fffffff);
+ Memory.Manager.SetHeapAddr(MemoryRegions.HeapRegionAddress);
}
- public bool Run()
+ public bool Run(bool UseHbAbi = false)
{
if (Executables.Count == 0)
{
@@ -109,6 +109,14 @@ namespace Ryujinx.Core.OsHle
MainThread = Ns.Os.Handles.GetData<HThread>(Handle);
+ if (UseHbAbi)
+ {
+ Homebrew Homebrew_ABI = new Homebrew(Memory, Executables[0].ImageEnd, (long)Handle);
+
+ MainThread.Thread.ThreadState.X0 = (ulong)Executables[0].ImageEnd;
+ MainThread.Thread.ThreadState.X1 = ulong.MaxValue;
+ }
+
Scheduler.StartThread(MainThread);
return true;
@@ -186,13 +194,6 @@ namespace Ryujinx.Core.OsHle
Thread.ThreadState.X1 = (ulong)Handle;
Thread.ThreadState.X31 = (ulong)StackTop;
- if (Executables[0].Extension == Extensions.NRO)
- {
- Homebrew Homebrew_ABI = new Homebrew(Memory, Executables[0].ImageEnd, (long)Handle);
- Thread.ThreadState.X0 = (ulong)Executables[0].ImageEnd;
- Thread.ThreadState.X1 = 0xFFFFFFFFFFFFFFFF;
- }
-
Thread.WorkFinished += ThreadFinished;
ThreadsByTpidr.TryAdd(Thread.ThreadState.Tpidr, ThreadHnd);
diff --git a/Ryujinx.Core/OsHle/Svc/SvcSystem.cs b/Ryujinx.Core/OsHle/Svc/SvcSystem.cs
index f33d2ac8..71edfbd6 100644
--- a/Ryujinx.Core/OsHle/Svc/SvcSystem.cs
+++ b/Ryujinx.Core/OsHle/Svc/SvcSystem.cs
@@ -182,22 +182,22 @@ namespace Ryujinx.Core.OsHle.Svc
private ulong GetMapRegionBaseAddr()
{
- return 0x80000000;
+ return MemoryRegions.MapRegionAddress;
}
private ulong GetMapRegionSize()
{
- return 0x40000000;
+ return MemoryRegions.MapRegionSize;
}
private ulong GetHeapRegionBaseAddr()
{
- return GetMapRegionBaseAddr() + GetMapRegionSize();
+ return MemoryRegions.HeapRegionAddress;
}
private ulong GetHeapRegionSize()
{
- return 0x40000000;
+ return MemoryRegions.HeapRegionSize;
}
private ulong GetTotalMem()