diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-11-28 20:18:09 -0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-28 20:18:09 -0200 |
| commit | 00579927e43bf55ee06ae02933c1e755fb4120eb (patch) | |
| tree | 0fd06db7b28e0accf87b465ec6f4dc74691febab /Ryujinx.HLE/Loaders/Npdm/KernelAccessControl.cs | |
| parent | e7fe7d724778535f8eff390abef54274a343c0b7 (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/Loaders/Npdm/KernelAccessControl.cs')
| -rw-r--r-- | Ryujinx.HLE/Loaders/Npdm/KernelAccessControl.cs | 162 |
1 files changed, 6 insertions, 156 deletions
diff --git a/Ryujinx.HLE/Loaders/Npdm/KernelAccessControl.cs b/Ryujinx.HLE/Loaders/Npdm/KernelAccessControl.cs index 0b45ebfb..cd3d3252 100644 --- a/Ryujinx.HLE/Loaders/Npdm/KernelAccessControl.cs +++ b/Ryujinx.HLE/Loaders/Npdm/KernelAccessControl.cs @@ -1,173 +1,23 @@ -using Ryujinx.HLE.Exceptions;
-using System;
-using System.Collections.ObjectModel;
-using System.IO;
+using System.IO;
namespace Ryujinx.HLE.Loaders.Npdm
{
class KernelAccessControl
{
- public ReadOnlyCollection<KernelAccessControlItem> Items;
+ public int[] Capabilities { get; private set; }
public KernelAccessControl(Stream Stream, int Offset, int Size)
{
Stream.Seek(Offset, SeekOrigin.Begin);
- BinaryReader Reader = new BinaryReader(Stream);
+ Capabilities = new int[Size / 4];
- KernelAccessControlItem[] Items = new KernelAccessControlItem[Size / 4];
+ BinaryReader Reader = new BinaryReader(Stream);
- for (int Index = 0; Index < Size / 4; Index++)
+ for (int Index = 0; Index < Capabilities.Length; Index++)
{
- uint Descriptor = Reader.ReadUInt32();
-
- //Ignore the descriptor.
- if (Descriptor == 0xffffffff)
- {
- continue;
- }
-
- Items[Index] = new KernelAccessControlItem();
-
- int LowBits = 0;
-
- while ((Descriptor & 1) != 0)
- {
- Descriptor >>= 1;
-
- LowBits++;
- }
-
- Descriptor >>= 1;
-
- switch (LowBits)
- {
- //Kernel flags.
- case 3:
- {
- Items[Index].HasKernelFlags = true;
-
- Items[Index].HighestThreadPriority = (Descriptor >> 0) & 0x3f;
- Items[Index].LowestThreadPriority = (Descriptor >> 6) & 0x3f;
- Items[Index].LowestCpuId = (Descriptor >> 12) & 0xff;
- Items[Index].HighestCpuId = (Descriptor >> 20) & 0xff;
-
- break;
- }
-
- //Syscall mask.
- case 4:
- {
- Items[Index].HasSvcFlags = true;
-
- Items[Index].AllowedSvcs = new bool[0x80];
-
- int SysCallBase = (int)(Descriptor >> 24) * 0x18;
-
- for (int SysCall = 0; SysCall < 0x18 && SysCallBase + SysCall < 0x80; SysCall++)
- {
- Items[Index].AllowedSvcs[SysCallBase + SysCall] = (Descriptor & 1) != 0;
-
- Descriptor >>= 1;
- }
-
- break;
- }
-
- //Map IO/Normal.
- case 6:
- {
- ulong Address = (Descriptor & 0xffffff) << 12;
- bool IsRo = (Descriptor >> 24) != 0;
-
- if (Index == Size / 4 - 1)
- {
- throw new InvalidNpdmException("Invalid Kernel Access Control Descriptors!");
- }
-
- Descriptor = Reader.ReadUInt32();
-
- if ((Descriptor & 0x7f) != 0x3f)
- {
- throw new InvalidNpdmException("Invalid Kernel Access Control Descriptors!");
- }
-
- Descriptor >>= 7;
-
- ulong MmioSize = (Descriptor & 0xffffff) << 12;
- bool IsNormal = (Descriptor >> 24) != 0;
-
- Items[Index].NormalMmio.Add(new KernelAccessControlMmio(Address, MmioSize, IsRo, IsNormal));
-
- Index++;
-
- break;
- }
-
- //Map Normal Page.
- case 7:
- {
- ulong Address = Descriptor << 12;
-
- Items[Index].PageMmio.Add(new KernelAccessControlMmio(Address, 0x1000, false, false));
-
- break;
- }
-
- //IRQ Pair.
- case 11:
- {
- Items[Index].Irq.Add(new KernelAccessControlIrq(
- (Descriptor >> 0) & 0x3ff,
- (Descriptor >> 10) & 0x3ff));
-
- break;
- }
-
- //Application Type.
- case 13:
- {
- Items[Index].HasApplicationType = true;
-
- Items[Index].ApplicationType = (int)Descriptor & 7;
-
- break;
- }
-
- //Kernel Release Version.
- case 14:
- {
- Items[Index].HasKernelVersion = true;
-
- Items[Index].KernelVersionRelease = (int)Descriptor;
-
- break;
- }
-
- //Handle Table Size.
- case 15:
- {
- Items[Index].HasHandleTableSize = true;
-
- Items[Index].HandleTableSize = (int)Descriptor;
-
- break;
- }
-
- //Debug Flags.
- case 16:
- {
- Items[Index].HasDebugFlags = true;
-
- Items[Index].AllowDebug = ((Descriptor >> 0) & 1) != 0;
- Items[Index].ForceDebug = ((Descriptor >> 1) & 1) != 0;
-
- break;
- }
- }
+ Capabilities[Index] = Reader.ReadInt32();
}
-
- this.Items = Array.AsReadOnly(Items);
}
}
}
|
