Support loading NSO/NRO without a MOD0 header, stub some functions, support more ids on SvcGetInfo

This commit is contained in:
gdkchan 2018-02-06 20:28:32 -03:00
parent 2347c44bbf
commit b99e808791
15 changed files with 153 additions and 41 deletions

View file

@ -20,6 +20,7 @@ namespace Ryujinx.OsHle.Ipc
{ ( "acc:u0", 100), Service.AccU0InitializeApplicationInfo },
{ ( "acc:u0", 101), Service.AccU0GetBaasAccountManagerForApplication },
{ ( "apm", 0), Service.ApmOpenSession },
{ ( "apm:p", 0), Service.ApmOpenSession },
{ ( "appletOE", 0), Service.AppletOpenApplicationProxy },
{ ( "audout:u", 0), Service.AudOutListAudioOuts },
{ ( "audout:u", 1), Service.AudOutOpenAudioOut },
@ -27,6 +28,7 @@ namespace Ryujinx.OsHle.Ipc
{ ( "audren:u", 1), Service.AudRenGetAudioRendererWorkBufferSize },
{ ( "friend:a", 0), Service.FriendCreateFriendService },
{ ( "fsp-srv", 1), Service.FspSrvInitialize },
{ ( "fsp-srv", 18), Service.FspSrvMountSdCard },
{ ( "fsp-srv", 51), Service.FspSrvMountSaveData },
{ ( "fsp-srv", 200), Service.FspSrvOpenDataStorageByCurrentProcess },
{ ( "fsp-srv", 203), Service.FspSrvOpenRomStorage },
@ -43,11 +45,13 @@ namespace Ryujinx.OsHle.Ipc
{ ( "nvdrv", 2), Service.NvDrvClose },
{ ( "nvdrv", 3), Service.NvDrvInitialize },
{ ( "nvdrv", 4), Service.NvDrvQueryEvent },
{ ( "nvdrv", 8), Service.NvDrvSetClientPid },
{ ( "nvdrv:a", 0), Service.NvDrvOpen },
{ ( "nvdrv:a", 1), Service.NvDrvIoctl },
{ ( "nvdrv:a", 2), Service.NvDrvClose },
{ ( "nvdrv:a", 3), Service.NvDrvInitialize },
{ ( "nvdrv:a", 4), Service.NvDrvQueryEvent },
{ ( "nvdrv:a", 8), Service.NvDrvSetClientPid },
{ ( "pctl:a", 0), Service.PctlCreateService },
{ ( "pl:u", 1), Service.PlGetLoadState },
{ ( "pl:u", 2), Service.PlGetFontSize },
@ -81,6 +85,7 @@ namespace Ryujinx.OsHle.Ipc
{ (typeof(AmIApplicationFunctions), 1), AmIApplicationFunctions.PopLaunchParameter },
{ (typeof(AmIApplicationFunctions), 20), AmIApplicationFunctions.EnsureSaveData },
{ (typeof(AmIApplicationFunctions), 21), AmIApplicationFunctions.GetDesiredLanguage },
{ (typeof(AmIApplicationFunctions), 40), AmIApplicationFunctions.NotifyRunning },
//IApplicationProxy
{ (typeof(AmIApplicationProxy), 0), AmIApplicationProxy.GetCommonStateGetter },
@ -103,6 +108,7 @@ namespace Ryujinx.OsHle.Ipc
{ (typeof(AmISelfController), 11), AmISelfController.SetOperationModeChangedNotification },
{ (typeof(AmISelfController), 12), AmISelfController.SetPerformanceModeChangedNotification },
{ (typeof(AmISelfController), 13), AmISelfController.SetFocusHandlingMode },
{ (typeof(AmISelfController), 16), AmISelfController.SetOutOfFocusSuspendingEnabled },
//IStorage
{ (typeof(AmIStorage), 0), AmIStorage.Open },
@ -142,14 +148,15 @@ namespace Ryujinx.OsHle.Ipc
{ (typeof(TimeISystemClock), 0), TimeISystemClock.GetCurrentTime },
//IApplicationDisplayService
{ (typeof(ViIApplicationDisplayService), 100), ViIApplicationDisplayService.GetRelayService },
{ (typeof(ViIApplicationDisplayService), 101), ViIApplicationDisplayService.GetSystemDisplayService },
{ (typeof(ViIApplicationDisplayService), 102), ViIApplicationDisplayService.GetManagerDisplayService },
{ (typeof(ViIApplicationDisplayService), 1010), ViIApplicationDisplayService.OpenDisplay },
{ (typeof(ViIApplicationDisplayService), 2020), ViIApplicationDisplayService.OpenLayer },
{ (typeof(ViIApplicationDisplayService), 2030), ViIApplicationDisplayService.CreateStrayLayer },
{ (typeof(ViIApplicationDisplayService), 2101), ViIApplicationDisplayService.SetLayerScalingMode },
{ (typeof(ViIApplicationDisplayService), 5202), ViIApplicationDisplayService.GetDisplayVSyncEvent },
{ (typeof(ViIApplicationDisplayService), 100), ViIApplicationDisplayService.GetRelayService },
{ (typeof(ViIApplicationDisplayService), 101), ViIApplicationDisplayService.GetSystemDisplayService },
{ (typeof(ViIApplicationDisplayService), 102), ViIApplicationDisplayService.GetManagerDisplayService },
{ (typeof(ViIApplicationDisplayService), 103), ViIApplicationDisplayService.GetIndirectDisplayTransactionService },
{ (typeof(ViIApplicationDisplayService), 1010), ViIApplicationDisplayService.OpenDisplay },
{ (typeof(ViIApplicationDisplayService), 2020), ViIApplicationDisplayService.OpenLayer },
{ (typeof(ViIApplicationDisplayService), 2030), ViIApplicationDisplayService.CreateStrayLayer },
{ (typeof(ViIApplicationDisplayService), 2101), ViIApplicationDisplayService.SetLayerScalingMode },
{ (typeof(ViIApplicationDisplayService), 5202), ViIApplicationDisplayService.GetDisplayVSyncEvent },
//IHOSBinderDriver
{ (typeof(ViIHOSBinderDriver), 0), ViIHOSBinderDriver.TransactParcel },
@ -189,6 +196,8 @@ namespace Ryujinx.OsHle.Ipc
bool IgnoreNullPR = false;
string DbgServiceName = string.Empty;
if (Session is HDomain Dom)
{
if (Request.DomCmd == IpcDomCmd.SendMsg)
@ -200,10 +209,14 @@ namespace Ryujinx.OsHle.Ipc
if (Obj is HDomain)
{
DbgServiceName = $"{ServiceName} {CmdId}";
ServiceCmds.TryGetValue((ServiceName, CmdId), out ProcReq);
}
else if (Obj != null)
{
DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {CmdId}";
ObjectCmds.TryGetValue((Obj.GetType(), CmdId), out ProcReq);
}
}
@ -225,12 +238,16 @@ namespace Ryujinx.OsHle.Ipc
{
object Obj = ((HSessionObj)Session).Obj;
DbgServiceName = $"{ServiceName} {Obj.GetType().Name} {CmdId}";
ObjectCmds.TryGetValue((Obj.GetType(), CmdId), out ProcReq);
}
else
{
DbgServiceName = $"{ServiceName} {CmdId}";
ServiceCmds.TryGetValue((ServiceName, CmdId), out ProcReq);
}
}
}
if (ProcReq != null)
@ -255,7 +272,7 @@ namespace Ryujinx.OsHle.Ipc
}
else if (!IgnoreNullPR)
{
throw new NotImplementedException(ServiceName);
throw new NotImplementedException(DbgServiceName);
}
}
else if (Request.Type == IpcMessageType.Control)

View file

@ -35,6 +35,13 @@ namespace Ryujinx.OsHle.Objects
return 0;
}
public static long NotifyRunning(ServiceCtx Context)
{
Context.ResponseData.Write(1);
return 0;
}
private static byte[] MakeLaunchParams()
{
//Size needs to be at least 0x88 bytes otherwise application errors.

View file

@ -24,5 +24,12 @@ namespace Ryujinx.OsHle.Objects
return 0;
}
public static long SetOutOfFocusSuspendingEnabled(ServiceCtx Context)
{
bool Enable = Context.RequestData.ReadByte() != 0 ? true : false;
return 0;
}
}
}

View file

@ -31,6 +31,13 @@ namespace Ryujinx.OsHle.Objects
return 0;
}
public static long GetIndirectDisplayTransactionService(ServiceCtx Context)
{
MakeObject(Context, new ViIHOSBinderDriver());
return 0;
}
public static long OpenDisplay(ServiceCtx Context)
{
string Name = GetDisplayName(Context);

View file

@ -54,7 +54,7 @@ namespace Ryujinx.OsHle
AMemoryPerm.RW);
}
public void LoadProgram(IElf Program)
public void LoadProgram(IExecutable Program)
{
Executable Executable = new Executable(Program, Memory, ImageBase);
@ -138,7 +138,7 @@ namespace Ryujinx.OsHle
Thread.Registers.SvcCall += SvcHandler.SvcCall;
Thread.Registers.ProcessId = ProcessId;
Thread.Registers.ThreadId = Ns.Os.IdGen.GenerateId();
Thread.Registers.Tpidr = TlsPageAddr + TlsSlot * TlsSize;
Thread.Registers.Tpidr = TlsPageAddr + TlsSlot * TlsSize;
Thread.Registers.X0 = (ulong)ArgsPtr;
Thread.Registers.X1 = (ulong)Handle;
Thread.Registers.X31 = (ulong)StackTop;

View file

@ -11,6 +11,13 @@ namespace Ryujinx.OsHle.Services
return 0;
}
public static long FspSrvMountSdCard(ServiceCtx Context)
{
MakeObject(Context, new FspSrvIFileSystem(Context.Ns.VFs.GetSdCardPath()));
return 0;
}
public static long FspSrvMountSaveData(ServiceCtx Context)
{
MakeObject(Context, new FspSrvIFileSystem(Context.Ns.VFs.GetGameSavesPath()));

View file

@ -110,6 +110,15 @@ namespace Ryujinx.OsHle.Services
return 0;
}
public static long NvDrvSetClientPid(ServiceCtx Context)
{
long Pid = Context.RequestData.ReadInt64();
Context.ResponseData.Write(0);
return 0;
}
private static long NvGpuAsIoctlBindChannel(ServiceCtx Context)
{
long Position = Context.Request.PtrBuff[0].Position;

View file

@ -43,7 +43,8 @@ namespace Ryujinx.OsHle.Svc
Success = 0,
ErrBadHandle = 0xe401,
ErrTimeout = 0xea01,
ErrBadIpcReq = 0xf601,
ErrBadInfo = 0xf001,
ErrBadIpcReq = 0xf601
}
private Switch Ns;

View file

@ -133,11 +133,28 @@ namespace Ryujinx.OsHle.Svc
long Handle = (long)Registers.X2;
int InfoId = (int)Registers.X3;
//Fail for info not available on older Kernel versions.
if (InfoType == 18 ||
InfoType == 19)
{
Registers.X0 = (int)SvcResult.ErrBadInfo;
return;
}
switch (InfoType)
{
case 6: Registers.X1 = GetTotalMem(Memory); break;
case 7: Registers.X1 = GetUsedMem(Memory); break;
case 11: Registers.X1 = GetRnd64(); break;
case 2: Registers.X1 = GetMapRegionBaseAddr(); break;
case 3: Registers.X1 = GetMapRegionSize(); break;
case 4: Registers.X1 = GetHeapRegionBaseAddr(); break;
case 5: Registers.X1 = GetHeapRegionSize(); break;
case 6: Registers.X1 = GetTotalMem(Memory); break;
case 7: Registers.X1 = GetUsedMem(Memory); break;
case 11: Registers.X1 = GetRnd64(); break;
case 12: Registers.X1 = GetAddrSpaceBaseAddr(); break;
case 13: Registers.X1 = GetAddrSpaceSize(); break;
case 14: Registers.X1 = GetMapRegionBaseAddr(); break;
case 15: Registers.X1 = GetMapRegionSize(); break;
default: throw new NotImplementedException($"SvcGetInfo: {InfoType} {Handle} {InfoId}");
}
@ -159,5 +176,35 @@ namespace Ryujinx.OsHle.Svc
{
return (ulong)Rng.Next() + ((ulong)Rng.Next() << 32);
}
private static ulong GetAddrSpaceBaseAddr()
{
return 0x08000000;
}
private static ulong GetAddrSpaceSize()
{
return AMemoryMgr.AddrSize - GetAddrSpaceBaseAddr();
}
private static ulong GetMapRegionBaseAddr()
{
return 0x80000000;
}
private static ulong GetMapRegionSize()
{
return 0x40000000;
}
private static ulong GetHeapRegionBaseAddr()
{
return GetMapRegionBaseAddr() + GetMapRegionSize();
}
private static ulong GetHeapRegionSize()
{
return 0x40000000;
}
}
}