aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-11-28 20:18:09 -0200
committerGitHub <noreply@github.com>2018-11-28 20:18:09 -0200
commit00579927e43bf55ee06ae02933c1e755fb4120eb (patch)
tree0fd06db7b28e0accf87b465ec6f4dc74691febab /Ryujinx.HLE/HOS/Services
parente7fe7d724778535f8eff390abef54274a343c0b7 (diff)
Better process implementation (#491)
* Initial implementation of KProcess * Some improvements to the memory manager, implement back guest stack trace printing * Better GetInfo implementation, improve checking in some places with information from process capabilities * Allow the cpu to read/write from the correct memory locations for accesses crossing a page boundary * Change long -> ulong for address/size on memory related methods to avoid unnecessary casts * Attempt at implementing ldr:ro with new KProcess * Allow BSS with size 0 on ldr:ro * Add checking for memory block slab heap usage, return errors if full, exit gracefully * Use KMemoryBlockSize const from KMemoryManager * Allow all methods to read from non-contiguous locations * Fix for TransactParcelAuto * Address PR feedback, additionally fix some small issues related to the KIP loader and implement SVCs GetProcessId, GetProcessList, GetSystemInfo, CreatePort and ManageNamedPort * Fix wrong check for source pages count from page list on MapPhysicalMemory * Fix some issues with UnloadNro on ldr:ro
Diffstat (limited to 'Ryujinx.HLE/HOS/Services')
-rw-r--r--Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs6
-rw-r--r--Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs226
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs7
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs7
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs7
-rw-r--r--Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs12
-rw-r--r--Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs3
8 files changed, 193 insertions, 77 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs b/Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs
index 6b012689..2feaf8fc 100644
--- a/Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs
+++ b/Ryujinx.HLE/HOS/Services/Am/ICommonStateGetter.cs
@@ -35,7 +35,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
public long GetEventHandle(ServiceCtx Context)
{
- KEvent Event = Context.Process.AppletState.MessageEvent;
+ KEvent Event = Context.Device.System.AppletState.MessageEvent;
if (Context.Process.HandleTable.GenerateHandle(Event.ReadableEvent, out int Handle) != KernelResult.Success)
{
@@ -49,7 +49,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
public long ReceiveMessage(ServiceCtx Context)
{
- if (!Context.Process.AppletState.TryDequeueMessage(out MessageInfo Message))
+ if (!Context.Device.System.AppletState.TryDequeueMessage(out MessageInfo Message))
{
return MakeError(ErrorModule.Am, AmErr.NoMessages);
}
@@ -92,7 +92,7 @@ namespace Ryujinx.HLE.HOS.Services.Am
public long GetCurrentFocusState(ServiceCtx Context)
{
- Context.ResponseData.Write((byte)Context.Process.AppletState.FocusState);
+ Context.ResponseData.Write((byte)Context.Device.System.AppletState.FocusState);
return 0;
}
diff --git a/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs b/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs
index 4d595fde..f0899bd4 100644
--- a/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs
+++ b/Ryujinx.HLE/HOS/Services/Ldr/IRoInterface.cs
@@ -1,4 +1,7 @@
-using Ryujinx.HLE.HOS.Ipc;
+using ChocolArm64.Memory;
+using Ryujinx.Common;
+using Ryujinx.HLE.HOS.Ipc;
+using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.Loaders.Executables;
using Ryujinx.HLE.Utilities;
using System;
@@ -62,17 +65,32 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
class NroInfo
{
- public Nro Executable { get; private set; }
- public byte[] Hash { get; private set; }
- public long NroAddress { get; private set; }
- public long TotalSize { get; private set; }
- public long NroMappedAddress { get; set; }
+ public NxRelocatableObject Executable { get; private set; }
- public NroInfo(Nro Executable, byte[] Hash, long TotalSize)
+ public byte[] Hash { get; private set; }
+ public ulong NroAddress { get; private set; }
+ public ulong NroSize { get; private set; }
+ public ulong BssAddress { get; private set; }
+ public ulong BssSize { get; private set; }
+ public ulong TotalSize { get; private set; }
+ public ulong NroMappedAddress { get; set; }
+
+ public NroInfo(
+ NxRelocatableObject Executable,
+ byte[] Hash,
+ ulong NroAddress,
+ ulong NroSize,
+ ulong BssAddress,
+ ulong BssSize,
+ ulong TotalSize)
{
this.Executable = Executable;
this.Hash = Hash;
- this.TotalSize = TotalSize;
+ this.NroAddress = NroAddress;
+ this.NroSize = NroSize;
+ this.BssAddress = BssAddress;
+ this.BssSize = BssSize;
+ this.TotalSize = TotalSize;
}
}
@@ -174,7 +192,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
return false;
}
- public long ParseNro(out NroInfo Res, ServiceCtx Context, long NroHeapAddress, long NroSize, long BssHeapAddress, long BssSize)
+ public long ParseNro(out NroInfo Res, ServiceCtx Context, ulong NroAddress, ulong NroSize, ulong BssAddress, ulong BssSize)
{
Res = null;
@@ -182,28 +200,28 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
{
return MakeError(ErrorModule.Loader, LoaderErr.MaxNro);
}
- else if (NroSize == 0 || NroHeapAddress + NroSize <= NroHeapAddress || (NroSize & 0xFFF) != 0)
+ else if (NroSize == 0 || NroAddress + NroSize <= NroAddress || (NroSize & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.BadSize);
}
- else if (BssSize != 0 && (BssHeapAddress + BssSize) <= BssHeapAddress)
+ else if (BssSize != 0 && BssAddress + BssSize <= BssAddress)
{
return MakeError(ErrorModule.Loader, LoaderErr.BadSize);
}
- else if ((NroHeapAddress & 0xFFF) != 0)
+ else if ((NroAddress & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress);
}
- uint Magic = Context.Memory.ReadUInt32(NroHeapAddress + 0x10);
- uint NroFileSize = Context.Memory.ReadUInt32(NroHeapAddress + 0x18);
+ uint Magic = Context.Memory.ReadUInt32((long)NroAddress + 0x10);
+ uint NroFileSize = Context.Memory.ReadUInt32((long)NroAddress + 0x18);
if (Magic != NroMagic || NroSize != NroFileSize)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro);
}
- byte[] NroData = Context.Memory.ReadBytes(NroHeapAddress, NroSize);
+ byte[] NroData = Context.Memory.ReadBytes((long)NroAddress, (long)NroSize);
byte[] NroHash = null;
MemoryStream Stream = new MemoryStream(NroData);
@@ -225,67 +243,106 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
Stream.Position = 0;
- Nro Executable = new Nro(Stream, "memory", NroHeapAddress, BssHeapAddress);
+ NxRelocatableObject Executable = new NxRelocatableObject(Stream, NroAddress, BssAddress);
// check if everything is page align.
- if ((Executable.Text.Length & 0xFFF) != 0 || (Executable.RO.Length & 0xFFF) != 0
- || (Executable.Data.Length & 0xFFF) != 0 || (Executable.BssSize & 0xFFF) != 0)
+ if ((Executable.Text.Length & 0xFFF) != 0 || (Executable.RO.Length & 0xFFF) != 0 ||
+ (Executable.Data.Length & 0xFFF) != 0 || (Executable.BssSize & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro);
}
// check if everything is contiguous.
- if (Executable.ROOffset != Executable.TextOffset + Executable.Text.Length
- || Executable.DataOffset != Executable.ROOffset + Executable.RO.Length
- || NroFileSize != Executable.DataOffset + Executable.Data.Length)
+ if (Executable.ROOffset != Executable.TextOffset + Executable.Text.Length ||
+ Executable.DataOffset != Executable.ROOffset + Executable.RO.Length ||
+ NroFileSize != Executable.DataOffset + Executable.Data.Length)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro);
}
// finally check the bss size match.
- if (Executable.BssSize != BssSize)
+ if ((ulong)Executable.BssSize != BssSize)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidNro);
}
- Res = new NroInfo(Executable, NroHash, Executable.Text.Length + Executable.RO.Length + Executable.Data.Length + Executable.BssSize);
+ int TotalSize = Executable.Text.Length + Executable.RO.Length + Executable.Data.Length + Executable.BssSize;
+
+ Res = new NroInfo(
+ Executable,
+ NroHash,
+ NroAddress,
+ NroSize,
+ BssAddress,
+ BssSize,
+ (ulong)TotalSize);
return 0;
}
- private long MapNro(ServiceCtx Context, NroInfo Info, out long NroMappedAddress)
+ private long MapNro(ServiceCtx Context, NroInfo Info, out ulong NroMappedAddress)
{
NroMappedAddress = 0;
- long TargetAddress = Context.Process.MemoryManager.AddrSpaceStart;
- long HeapRegionStart = Context.Process.MemoryManager.HeapRegionStart;
- long HeapRegionEnd = Context.Process.MemoryManager.HeapRegionEnd;
+ KMemoryManager MemMgr = Context.Process.MemoryManager;
- long MapRegionStart = Context.Process.MemoryManager.MapRegionStart;
- long MapRegionEnd = Context.Process.MemoryManager.MapRegionEnd;
+ ulong TargetAddress = MemMgr.GetAddrSpaceBaseAddr();
while (true)
{
- if (TargetAddress + Info.TotalSize >= Context.Process.MemoryManager.AddrSpaceEnd)
+ if (TargetAddress + Info.TotalSize >= MemMgr.AddrSpaceEnd)
{
return MakeError(ErrorModule.Loader, LoaderErr.InvalidMemoryState);
}
- bool IsValidAddress = !(HeapRegionStart > 0 && HeapRegionStart <= TargetAddress + Info.TotalSize - 1
- && TargetAddress <= HeapRegionEnd - 1)
- && !(MapRegionStart > 0
- && MapRegionStart <= TargetAddress + Info.TotalSize - 1
- && TargetAddress <= MapRegionEnd - 1);
+ KMemoryInfo MemInfo = MemMgr.QueryMemory(TargetAddress);
- if (IsValidAddress && Context.Process.MemoryManager.HleIsUnmapped(TargetAddress, Info.TotalSize))
+ if (MemInfo.State == MemoryState.Unmapped && MemInfo.Size >= Info.TotalSize)
{
- break;
+ if (!MemMgr.InsideHeapRegion (TargetAddress, Info.TotalSize) &&
+ !MemMgr.InsideAliasRegion(TargetAddress, Info.TotalSize))
+ {
+ break;
+ }
}
- TargetAddress += 0x1000;
+ TargetAddress += MemInfo.Size;
+ }
+
+ KernelResult Result = MemMgr.MapProcessCodeMemory(TargetAddress, Info.NroAddress, Info.NroSize);
+
+ if (Result != KernelResult.Success)
+ {
+ return MakeError(ErrorModule.Loader, LoaderErr.InvalidMemoryState);
+ }
+
+ ulong BssTargetAddress = TargetAddress + Info.NroSize;
+
+ if (Info.BssSize != 0)
+ {
+ Result = MemMgr.MapProcessCodeMemory(BssTargetAddress, Info.BssAddress, Info.BssSize);
+
+ if (Result != KernelResult.Success)
+ {
+ MemMgr.UnmapProcessCodeMemory(TargetAddress, Info.NroAddress, Info.NroSize);
+
+ return MakeError(ErrorModule.Loader, LoaderErr.InvalidMemoryState);
+ }
}
- Context.Process.LoadProgram(Info.Executable, TargetAddress);
+ Result = LoadNroIntoMemory(Context.Process, Info.Executable, TargetAddress);
+
+ if (Result != KernelResult.Success)
+ {
+ MemMgr.UnmapProcessCodeMemory(TargetAddress, Info.NroAddress, Info.NroSize);
+
+ if (Info.BssSize != 0)
+ {
+ MemMgr.UnmapProcessCodeMemory(BssTargetAddress, Info.BssAddress, Info.BssSize);
+ }
+
+ return 0;
+ }
Info.NroMappedAddress = TargetAddress;
NroMappedAddress = TargetAddress;
@@ -293,6 +350,41 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
return 0;
}
+ private KernelResult LoadNroIntoMemory(KProcess Process, IExecutable RelocatableObject, ulong BaseAddress)
+ {
+ ulong TextStart = BaseAddress + (ulong)RelocatableObject.TextOffset;
+ ulong ROStart = BaseAddress + (ulong)RelocatableObject.ROOffset;
+ ulong DataStart = BaseAddress + (ulong)RelocatableObject.DataOffset;
+
+ ulong BssStart = DataStart + (ulong)RelocatableObject.Data.Length;
+
+ ulong BssEnd = BitUtils.AlignUp(BssStart + (ulong)RelocatableObject.BssSize, KMemoryManager.PageSize);
+
+ Process.CpuMemory.WriteBytes((long)TextStart, RelocatableObject.Text);
+ Process.CpuMemory.WriteBytes((long)ROStart, RelocatableObject.RO);
+ Process.CpuMemory.WriteBytes((long)DataStart, RelocatableObject.Data);
+
+ MemoryHelper.FillWithZeros(Process.CpuMemory, (long)BssStart, (int)(BssEnd - BssStart));
+
+ KernelResult Result;
+
+ Result = Process.MemoryManager.SetProcessMemoryPermission(TextStart, ROStart - TextStart, MemoryPermission.ReadAndExecute);
+
+ if (Result != KernelResult.Success)
+ {
+ return Result;
+ }
+
+ Result = Process.MemoryManager.SetProcessMemoryPermission(ROStart, DataStart - ROStart, MemoryPermission.Read);
+
+ if (Result != KernelResult.Success)
+ {
+ return Result;
+ }
+
+ return Process.MemoryManager.SetProcessMemoryPermission(DataStart, BssEnd - DataStart, MemoryPermission.ReadAndWrite);
+ }
+
private long RemoveNrrInfo(long NrrAddress)
{
foreach (NrrInfo Info in NrrInfos)
@@ -308,24 +400,46 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
return MakeError(ErrorModule.Loader, LoaderErr.BadNrrAddress);
}
- private long RemoveNroInfo(ServiceCtx Context, long NroMappedAddress, long NroHeapAddress)
+ private long RemoveNroInfo(ServiceCtx Context, ulong NroMappedAddress)
{
foreach (NroInfo Info in NroInfos)
{
- if (Info.NroMappedAddress == NroMappedAddress && Info.Executable.SourceAddress == NroHeapAddress)
+ if (Info.NroMappedAddress == NroMappedAddress)
{
NroInfos.Remove(Info);
- Context.Process.RemoveProgram(Info.NroMappedAddress);
+ ulong TextSize = (ulong)Info.Executable.Text.Length;
+ ulong ROSize = (ulong)Info.Executable.RO.Length;
+ ulong DataSize = (ulong)Info.Executable.Data.Length;
+ ulong BssSize = (ulong)Info.Executable.BssSize;
- long Result = Context.Process.MemoryManager.UnmapProcessCodeMemory(Info.NroMappedAddress, Info.Executable.SourceAddress, Info.TotalSize - Info.Executable.BssSize);
+ KernelResult Result = KernelResult.Success;
- if (Result == 0 && Info.Executable.BssSize != 0)
+ if (Info.Executable.BssSize != 0)
{
- Result = Context.Process.MemoryManager.UnmapProcessCodeMemory(Info.NroMappedAddress + Info.TotalSize - Info.Executable.BssSize, Info.Executable.BssAddress, Info.Executable.BssSize);
+ Result = Context.Process.MemoryManager.UnmapProcessCodeMemory(
+ Info.NroMappedAddress + TextSize + ROSize + DataSize,
+ Info.Executable.BssAddress,
+ BssSize);
}
- return Result;
+ if (Result == KernelResult.Success)
+ {
+ Result = Context.Process.MemoryManager.UnmapProcessCodeMemory(
+ Info.NroMappedAddress + TextSize + ROSize,
+ Info.Executable.SourceAddress + TextSize + ROSize,
+ DataSize);
+
+ if (Result == KernelResult.Success)
+ {
+ Result = Context.Process.MemoryManager.UnmapProcessCodeMemory(
+ Info.NroMappedAddress,
+ Info.Executable.SourceAddress,
+ TextSize + ROSize);
+ }
+ }
+
+ return (long)Result;
}
}
@@ -340,12 +454,12 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
// Zero
Context.RequestData.ReadUInt64();
- long NroHeapAddress = Context.RequestData.ReadInt64();
- long NroSize = Context.RequestData.ReadInt64();
- long BssHeapAddress = Context.RequestData.ReadInt64();
- long BssSize = Context.RequestData.ReadInt64();
+ ulong NroHeapAddress = Context.RequestData.ReadUInt64();
+ ulong NroSize = Context.RequestData.ReadUInt64();
+ ulong BssHeapAddress = Context.RequestData.ReadUInt64();
+ ulong BssSize = Context.RequestData.ReadUInt64();
- long NroMappedAddress = 0;
+ ulong NroMappedAddress = 0;
if (IsInitialized)
{
@@ -374,17 +488,19 @@ namespace Ryujinx.HLE.HOS.Services.Ldr
{
long Result = MakeError(ErrorModule.Loader, LoaderErr.BadInitialization);
- long NroMappedAddress = Context.RequestData.ReadInt64();
- long NroHeapAddress = Context.RequestData.ReadInt64();
+ // Zero
+ Context.RequestData.ReadUInt64();
+
+ ulong NroMappedAddress = Context.RequestData.ReadUInt64();
if (IsInitialized)
{
- if ((NroMappedAddress & 0xFFF) != 0 || (NroHeapAddress & 0xFFF) != 0)
+ if ((NroMappedAddress & 0xFFF) != 0)
{
return MakeError(ErrorModule.Loader, LoaderErr.UnalignedAddress);
}
- Result = RemoveNroInfo(Context, NroMappedAddress, NroHeapAddress);
+ Result = RemoveNroInfo(Context, NroMappedAddress);
}
return Result;
diff --git a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
index b8ae11ce..6786d0e2 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/INvDrvServices.cs
@@ -205,7 +205,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
return ((Cmd >> 31) & 1) != 0;
}
- public static void UnloadProcess(Process Process)
+ public static void UnloadProcess(KProcess Process)
{
Fds.DeleteProcess(Process);
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs
index fed41042..7fe3bbed 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvGpuAS/NvGpuASIoctl.cs
@@ -1,6 +1,7 @@
using ChocolArm64.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Memory;
+using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.HOS.Services.Nv.NvMap;
using System;
using System.Collections.Concurrent;
@@ -13,11 +14,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS
private const int FlagRemapSubRange = 0x100;
- private static ConcurrentDictionary<Process, NvGpuASCtx> ASCtxs;
+ private static ConcurrentDictionary<KProcess, NvGpuASCtx> ASCtxs;
static NvGpuASIoctl()
{
- ASCtxs = new ConcurrentDictionary<Process, NvGpuASCtx>();
+ ASCtxs = new ConcurrentDictionary<KProcess, NvGpuASCtx>();
}
public static int ProcessIoctl(ServiceCtx Context, int Cmd)
@@ -321,7 +322,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvGpuAS
return ASCtxs.GetOrAdd(Context.Process, (Key) => new NvGpuASCtx(Context));
}
- public static void UnloadProcess(Process Process)
+ public static void UnloadProcess(KProcess Process)
{
ASCtxs.TryRemove(Process, out _);
}
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
index 39f39d45..d9f5602b 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostChannel/NvHostChannelIoctl.cs
@@ -1,6 +1,7 @@
using ChocolArm64.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Memory;
+using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.HOS.Services.Nv.NvGpuAS;
using System;
using System.Collections.Concurrent;
@@ -21,11 +22,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostChannel
}
}
- private static ConcurrentDictionary<Process, ChannelsPerProcess> Channels;
+ private static ConcurrentDictionary<KProcess, ChannelsPerProcess> Channels;
static NvHostChannelIoctl()
{
- Channels = new ConcurrentDictionary<Process, ChannelsPerProcess>();
+ Channels = new ConcurrentDictionary<KProcess, ChannelsPerProcess>();
}
public static int ProcessIoctlGpu(ServiceCtx Context, int Cmd)
@@ -194,7 +195,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostChannel
return Cpp.Channels[Channel];
}
- public static void UnloadProcess(Process Process)
+ public static void UnloadProcess(KProcess Process)
{
Channels.TryRemove(Process, out _);
}
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs
index 6cb14741..bf92afb4 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvHostCtrl/NvHostCtrlIoctl.cs
@@ -1,5 +1,6 @@
using ChocolArm64.Memory;
using Ryujinx.Common.Logging;
+using Ryujinx.HLE.HOS.Kernel;
using System;
using System.Collections.Concurrent;
using System.Text;
@@ -9,13 +10,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl
{
class NvHostCtrlIoctl
{
- private static ConcurrentDictionary<Process, NvHostCtrlUserCtx> UserCtxs;
+ private static ConcurrentDictionary<KProcess, NvHostCtrlUserCtx> UserCtxs;
private static bool IsProductionMode = true;
static NvHostCtrlIoctl()
{
- UserCtxs = new ConcurrentDictionary<Process, NvHostCtrlUserCtx>();
+ UserCtxs = new ConcurrentDictionary<KProcess, NvHostCtrlUserCtx>();
if (Set.NxSettings.Settings.TryGetValue("nv!rmos_set_production_mode", out object ProductionModeSetting))
{
@@ -390,7 +391,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvHostCtrl
return UserCtxs.GetOrAdd(Context.Process, (Key) => new NvHostCtrlUserCtx());
}
- public static void UnloadProcess(Process Process)
+ public static void UnloadProcess(KProcess Process)
{
UserCtxs.TryRemove(Process, out _);
}
diff --git a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs
index f5378ef7..adc523e5 100644
--- a/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs
+++ b/Ryujinx.HLE/HOS/Services/Nv/NvMap/NvMapIoctl.cs
@@ -1,6 +1,7 @@
using ChocolArm64.Memory;
using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Memory;
+using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.Utilities;
using System.Collections.Concurrent;
@@ -10,11 +11,11 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvMap
{
private const int FlagNotFreedYet = 1;
- private static ConcurrentDictionary<Process, IdDictionary> Maps;
+ private static ConcurrentDictionary<KProcess, IdDictionary> Maps;
static NvMapIoctl()
{
- Maps = new ConcurrentDictionary<Process, IdDictionary>();
+ Maps = new ConcurrentDictionary<KProcess, IdDictionary>();
}
public static int ProcessIoctl(ServiceCtx Context, int Cmd)
@@ -130,10 +131,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvMap
//When the address is zero, we need to allocate
//our own backing memory for the NvMap.
//TODO: Is this allocation inside the transfer memory?
- if (!Context.Device.Memory.Allocator.TryAllocate((uint)Size, out Address))
- {
- Result = NvResult.OutOfMemory;
- }
+ Result = NvResult.OutOfMemory;
}
if (Result == NvResult.Success)
@@ -294,7 +292,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvMap
return null;
}
- public static void UnloadProcess(Process Process)
+ public static void UnloadProcess(KProcess Process)
{
Maps.TryRemove(Process, out _);
}
diff --git a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs
index 64e0b4a9..facfbe60 100644
--- a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs
+++ b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs
@@ -275,8 +275,7 @@ namespace Ryujinx.HLE.HOS.Services.Android
private long MakeReplyParcel(ServiceCtx Context, byte[] Data)
{
- long ReplyPos = Context.Request.ReceiveBuff[0].Position;
- long ReplySize = Context.Request.ReceiveBuff[0].Size;
+ (long ReplyPos, long ReplySize) = Context.Request.GetBufferType0x22();
byte[] Reply = MakeParcel(Data, new byte[0]);