Horizon: Implement arp:r and arp:w services (#5802)

* Horizon: Implement arp:r and arp:w services

* Fix formatting

* Remove HLE arp services

* Revert "Remove HLE arp services"

This reverts commit c576fcccadb963db56b96bacabd1c1ac7abfb1ab.

* Keep LibHac impl since it's used in bcat

* Addresses gdkchan's feedback

* ArpApi in PrepoIpcServer and remove LmApi

* Fix 2

* Fixes ArpApi init

* Fix encoding

* Update PrepoService.cs

* Fix prepo
This commit is contained in:
Ac_K 2024-01-25 23:06:53 +01:00 committed by GitHub
parent 43705c2320
commit cd37c75b82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 1415 additions and 37 deletions

View file

@ -1,8 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Arp
{
[Service("arp:r")]
class IReader : IpcService
{
public IReader(ServiceCtx context) { }
}
}

View file

@ -1,8 +0,0 @@
namespace Ryujinx.HLE.HOS.Services.Arp
{
[Service("arp:w")]
class IWriter : IpcService
{
public IWriter(ServiceCtx context) { }
}
}

View file

@ -159,9 +159,7 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
}
else
{
#pragma warning disable CS0162 // Unreachable code
return ResultCode.StereoVisionRestrictionConfigurableDisabled;
#pragma warning restore CS0162
}
}

View file

@ -34,7 +34,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
return metaLoader;
}
public static ProcessResult Load(this IFileSystem exeFs, Switch device, BlitStruct<ApplicationControlProperty> nacpData, MetaLoader metaLoader, bool isHomebrew = false)
public static ProcessResult Load(this IFileSystem exeFs, Switch device, BlitStruct<ApplicationControlProperty> nacpData, MetaLoader metaLoader, byte programIndex, bool isHomebrew = false)
{
ulong programId = metaLoader.GetProgramId();
@ -119,6 +119,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
true,
programName,
metaLoader.GetProgramId(),
programIndex,
null,
nsoExecutables);

View file

@ -26,7 +26,7 @@ namespace Ryujinx.HLE.Loaders.Processes
ProcessLoaderHelper.EnsureSaveData(device, new ApplicationId(programId), nacpData);
}
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader);
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader, 0);
// Load RomFS.
if (!string.IsNullOrEmpty(romFsPath))

View file

@ -61,7 +61,7 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
*/
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader);
ProcessResult processResult = exeFs.Load(device, nacpData, metaLoader, (byte)nca.GetProgramIndex());
// Load RomFS.
if (romFs == null)

View file

@ -77,7 +77,7 @@ namespace Ryujinx.HLE.Loaders.Processes
if (processResult.ProcessId == 0)
{
// This is not a normal NSP, it's actually a ExeFS as a NSP
processResult = partitionFileSystem.Load(_device, new BlitStruct<ApplicationControlProperty>(1), partitionFileSystem.GetNpdm(), true);
processResult = partitionFileSystem.Load(_device, new BlitStruct<ApplicationControlProperty>(1), partitionFileSystem.GetNpdm(), 0, true);
}
if (processResult.ProcessId != 0 && _processesByPid.TryAdd(processResult.ProcessId, processResult))
@ -198,7 +198,7 @@ namespace Ryujinx.HLE.Loaders.Processes
}
else
{
programName = System.IO.Path.GetFileNameWithoutExtension(path);
programName = Path.GetFileNameWithoutExtension(path);
executable = new NsoExecutable(new LocalStorage(path, FileAccess.Read), programName);
}
@ -215,6 +215,7 @@ namespace Ryujinx.HLE.Loaders.Processes
allowCodeMemoryForJit: true,
programName,
programId,
0,
null,
executable);

View file

@ -19,6 +19,7 @@ using Ryujinx.HLE.HOS.Kernel.Process;
using Ryujinx.HLE.Loaders.Executables;
using Ryujinx.HLE.Loaders.Processes.Extensions;
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Arp;
using System;
using System.Linq;
using System.Runtime.InteropServices;
@ -229,6 +230,7 @@ namespace Ryujinx.HLE.Loaders.Processes
bool allowCodeMemoryForJit,
string name,
ulong programId,
byte programIndex,
byte[] arguments = null,
params IExecutable[] executables)
{
@ -421,7 +423,7 @@ namespace Ryujinx.HLE.Loaders.Processes
// Once everything is loaded, we can load cheats.
device.Configuration.VirtualFileSystem.ModLoader.LoadCheats(programId, tamperInfo, device.TamperMachine);
return new ProcessResult(
ProcessResult processResult = new(
metaLoader,
applicationControlProperties,
diskCacheEnabled,
@ -431,6 +433,25 @@ namespace Ryujinx.HLE.Loaders.Processes
meta.MainThreadPriority,
meta.MainThreadStackSize,
device.System.State.DesiredTitleLanguage);
// Register everything in arp service.
device.System.ServiceTable.ArpWriter.AcquireRegistrar(out IRegistrar registrar);
registrar.SetApplicationControlProperty(MemoryMarshal.Cast<byte, Horizon.Sdk.Ns.ApplicationControlProperty>(applicationControlProperties.ByteSpan)[0]);
// TODO: Handle Version and StorageId when it will be needed.
registrar.SetApplicationLaunchProperty(new ApplicationLaunchProperty()
{
ApplicationId = new Horizon.Sdk.Ncm.ApplicationId(programId),
Version = 0x00,
Storage = Horizon.Sdk.Ncm.StorageId.BuiltInUser,
PatchStorage = Horizon.Sdk.Ncm.StorageId.None,
ApplicationKind = ApplicationKind.Application,
});
device.System.ServiceTable.ArpReader.GetApplicationInstanceId(out ulong applicationInstanceId, process.Pid);
device.System.ServiceTable.ArpWriter.AcquireApplicationProcessPropertyUpdater(out IUpdater updater, applicationInstanceId);
updater.SetApplicationProcessProperty(process.Pid, new ApplicationProcessProperty() { ProgramIndex = programIndex });
return processResult;
}
public static Result LoadIntoMemory(KProcess process, IExecutable image, ulong baseAddress)