IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel (#1458)
* IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel * Fix for applet transfer memory + some nits * Keep handles if possible to avoid server handle table exhaustion * Fix IPC ZeroFill bug * am: Correctly implement CreateManagedDisplayLayer and implement CreateManagedDisplaySeparableLayer CreateManagedDisplaySeparableLayer is requires since 10.x+ when appletResourceUserId != 0 * Make it exit properly * Make ServiceNotImplementedException show the full message again * Allow yielding execution to avoid starving other threads * Only wait if active * Merge IVirtualMemoryManager and IAddressSpaceManager * Fix Ro loading data from the wrong process Co-authored-by: Thog <me@thog.eu>
This commit is contained in:
parent
461c24092a
commit
cf6cd71488
115 changed files with 2356 additions and 1088 deletions
|
@ -36,23 +36,23 @@ namespace Ryujinx.HLE.HOS
|
|||
|
||||
ulong codeAddress = codeBaseAddress + (ulong)kip.TextOffset;
|
||||
|
||||
int mmuFlags = 0;
|
||||
ProcessCreationFlags flags = 0;
|
||||
|
||||
if (AslrEnabled)
|
||||
{
|
||||
// TODO: Randomization.
|
||||
|
||||
mmuFlags |= 0x20;
|
||||
flags |= ProcessCreationFlags.EnableAslr;
|
||||
}
|
||||
|
||||
if (kip.Is64BitAddressSpace)
|
||||
{
|
||||
mmuFlags |= (int)AddressSpaceType.Addr39Bits << 1;
|
||||
flags |= ProcessCreationFlags.AddressSpace64Bit;
|
||||
}
|
||||
|
||||
if (kip.Is64Bit)
|
||||
{
|
||||
mmuFlags |= 1;
|
||||
flags |= ProcessCreationFlags.Is64Bit;
|
||||
}
|
||||
|
||||
ProcessCreationInfo creationInfo = new ProcessCreationInfo(
|
||||
|
@ -61,7 +61,7 @@ namespace Ryujinx.HLE.HOS
|
|||
kip.ProgramId,
|
||||
codeAddress,
|
||||
codePagesCount,
|
||||
mmuFlags,
|
||||
flags,
|
||||
0,
|
||||
0);
|
||||
|
||||
|
@ -82,12 +82,15 @@ namespace Ryujinx.HLE.HOS
|
|||
|
||||
KProcess process = new KProcess(context);
|
||||
|
||||
var processContextFactory = new ArmProcessContextFactory();
|
||||
|
||||
result = process.InitializeKip(
|
||||
creationInfo,
|
||||
kip.Capabilities,
|
||||
pageList,
|
||||
context.ResourceLimit,
|
||||
memoryRegion);
|
||||
memoryRegion,
|
||||
processContextFactory);
|
||||
|
||||
if (result != KernelResult.Success)
|
||||
{
|
||||
|
@ -183,7 +186,7 @@ namespace Ryujinx.HLE.HOS
|
|||
metaData.Aci0.TitleId,
|
||||
codeStart,
|
||||
codePagesCount,
|
||||
metaData.MmuFlags,
|
||||
(ProcessCreationFlags)metaData.ProcessFlags | ProcessCreationFlags.IsApplication,
|
||||
0,
|
||||
personalMmHeapPagesCount);
|
||||
|
||||
|
@ -217,11 +220,14 @@ namespace Ryujinx.HLE.HOS
|
|||
return false;
|
||||
}
|
||||
|
||||
var processContextFactory = new ArmProcessContextFactory();
|
||||
|
||||
result = process.Initialize(
|
||||
creationInfo,
|
||||
metaData.Aci0.KernelAccessControl.Capabilities,
|
||||
resourceLimit,
|
||||
memoryRegion);
|
||||
memoryRegion,
|
||||
processContextFactory);
|
||||
|
||||
if (result != KernelResult.Success)
|
||||
{
|
||||
|
@ -280,7 +286,7 @@ namespace Ryujinx.HLE.HOS
|
|||
|
||||
MemoryHelper.FillWithZeros(process.CpuMemory, (long)bssStart, image.BssSize);
|
||||
|
||||
KernelResult SetProcessMemoryPermission(ulong address, ulong size, MemoryPermission permission)
|
||||
KernelResult SetProcessMemoryPermission(ulong address, ulong size, KMemoryPermission permission)
|
||||
{
|
||||
if (size == 0)
|
||||
{
|
||||
|
@ -292,21 +298,21 @@ namespace Ryujinx.HLE.HOS
|
|||
return process.MemoryManager.SetProcessMemoryPermission(address, size, permission);
|
||||
}
|
||||
|
||||
KernelResult result = SetProcessMemoryPermission(textStart, (ulong)image.Text.Length, MemoryPermission.ReadAndExecute);
|
||||
KernelResult result = SetProcessMemoryPermission(textStart, (ulong)image.Text.Length, KMemoryPermission.ReadAndExecute);
|
||||
|
||||
if (result != KernelResult.Success)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SetProcessMemoryPermission(roStart, (ulong)image.Ro.Length, MemoryPermission.Read);
|
||||
result = SetProcessMemoryPermission(roStart, (ulong)image.Ro.Length, KMemoryPermission.Read);
|
||||
|
||||
if (result != KernelResult.Success)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return SetProcessMemoryPermission(dataStart, end - dataStart, MemoryPermission.ReadAndWrite);
|
||||
return SetProcessMemoryPermission(dataStart, end - dataStart, KMemoryPermission.ReadAndWrite);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue