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

This commit is contained in:
gdkchan 2018-02-23 21:59:38 -03:00
parent 2ed733b1d5
commit 3936c93448
14 changed files with 109 additions and 101 deletions

View file

@ -13,7 +13,6 @@ namespace Ryujinx.Core.Loaders
public long ImageBase { get; private set; }
public long ImageEnd { get; private set; }
public Extensions Extension { get; private set; }
public Executable(IExecutable Exe, AMemory Memory, long ImageBase)
{
@ -47,8 +46,6 @@ namespace Ryujinx.Core.Loaders
long EhHdrEndOffset = Memory.ReadInt32(Mod0Offset + 0x14) + Mod0Offset;
long ModObjOffset = Memory.ReadInt32(Mod0Offset + 0x18) + Mod0Offset;
Extension = Exe.Extension;
MapBss(BssStartOffset, BssEndOffset - BssStartOffset);
ImageEnd = BssEndOffset;

View file

@ -2,12 +2,6 @@ using System.Collections.ObjectModel;
namespace Ryujinx.Core.Loaders.Executables
{
public enum Extensions
{
NRO,
NSO
}
public interface IExecutable
{
ReadOnlyCollection<byte> Text { get; }
@ -19,7 +13,5 @@ namespace Ryujinx.Core.Loaders.Executables
int ROOffset { get; }
int DataOffset { get; }
int BssSize { get; }
Extensions Extension { get; }
}
}

View file

@ -20,8 +20,6 @@ namespace Ryujinx.Core.Loaders.Executables
public int DataOffset { get; private set; }
public int BssSize { get; private set; }
public Extensions Extension { get; private set; }
public Nro(Stream Input)
{
BinaryReader Reader = new BinaryReader(Input);
@ -49,8 +47,6 @@ namespace Ryujinx.Core.Loaders.Executables
this.DataOffset = DataOffset;
this.BssSize = BssSize;
this.Extension = Extensions.NRO;
byte[] Read(long Position, int Size)
{
Input.Seek(Position, SeekOrigin.Begin);

View file

@ -21,8 +21,6 @@ namespace Ryujinx.Core.Loaders.Executables
public int DataOffset { get; private set; }
public int BssSize { get; private set; }
public Extensions Extension { get; private set; }
[Flags]
private enum NsoFlags
{
@ -81,8 +79,6 @@ namespace Ryujinx.Core.Loaders.Executables
this.DataOffset = DataMemOffset;
this.BssSize = BssSize;
this.Extension = Extensions.NSO;
//Text segment
Input.Seek(TextOffset, SeekOrigin.Begin);

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -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!");

View file

@ -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);
}

View file

@ -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);

View file

@ -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()