Code style fixes and nits on the HLE project (#355)

* Some style fixes and nits on ITimeZoneService

* Remove some unneeded usings

* Remove the Ryujinx.HLE.OsHle.Handles namespace

* Remove hbmenu automatic load on process exit

* Rename Ns to Device, rename Os to System, rename SystemState to State

* Move Exceptions and Utilities out of OsHle

* Rename OsHle to HOS

* Rename OsHle folder to HOS

* IManagerDisplayService and ISystemDisplayService style fixes

* BsdError shouldn't be public

* Add a empty new line before using static

* Remove unused file

* Some style fixes on NPDM

* Exit gracefully when the application is closed

* Code style fixes on IGeneralService

* Add 0x prefix on values printed as hex

* Small improvements on finalization code

* Move ProcessId and ThreadId out of AThreadState

* Rename VFs to FileSystem

* FsAccessHeader shouldn't be public. Also fix file names casing

* More case changes on NPDM

* Remove unused files

* Move using to the correct place on NPDM

* Use properties on KernelAccessControlMmio

* Address PR feedback
This commit is contained in:
gdkchan 2018-08-16 20:47:36 -03:00 committed by GitHub
parent 182d716867
commit 521751795a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
258 changed files with 1574 additions and 1546 deletions

View file

@ -1,79 +1,40 @@
using System.Collections.Generic;
using Ryujinx.HLE.Exceptions;
using System;
using System.Collections.ObjectModel;
using System.IO;
namespace Ryujinx.HLE.Loaders.Npdm
{
public class KernelAccessControlIRQ
class KernelAccessControl
{
public uint IRQ0;
public uint IRQ1;
}
public ReadOnlyCollection<KernelAccessControlItem> Items;
public class KernelAccessControlMMIO
{
public ulong Address;
public ulong Size;
public bool IsRO;
public bool IsNormal;
}
public class KernelAccessControlItems
{
public bool HasKernelFlags;
public uint LowestThreadPriority;
public uint HighestThreadPriority;
public uint LowestCpuId;
public uint HighestCpuId;
public bool HasSVCFlags;
public int[] SVCsAllowed;
public List<KernelAccessControlMMIO> NormalMMIO;
public List<KernelAccessControlMMIO> PageMMIO;
public List<KernelAccessControlIRQ> IRQ;
public bool HasApplicationType;
public int ApplicationType;
public bool HasKernelVersion;
public int KernelVersionRelease;
public bool HasHandleTableSize;
public int HandleTableSize;
public bool HasDebugFlags;
public bool AllowDebug;
public bool ForceDebug;
}
public class KernelAccessControl
{
public KernelAccessControlItems[] Items;
public KernelAccessControl(Stream FSAccessControlsStream, int Offset, int Size)
public KernelAccessControl(Stream Stream, int Offset, int Size)
{
FSAccessControlsStream.Seek(Offset, SeekOrigin.Begin);
Stream.Seek(Offset, SeekOrigin.Begin);
BinaryReader Reader = new BinaryReader(FSAccessControlsStream);
BinaryReader Reader = new BinaryReader(Stream);
Items = new KernelAccessControlItems[Size / 4];
KernelAccessControlItem[] Items = new KernelAccessControlItem[Size / 4];
for (int i = 0; i < Size / 4; i++)
for (int Index = 0; Index < Size / 4; Index++)
{
uint Descriptor = Reader.ReadUInt32();
if (Descriptor == 0xFFFFFFFF) //Ignore the descriptor
//Ignore the descriptor.
if (Descriptor == 0xffffffff)
{
continue;
}
Items[i] = new KernelAccessControlItems();
Items[Index] = new KernelAccessControlItem();
int LowBits = 0;
while ((Descriptor & 1) != 0)
{
Descriptor >>= 1;
LowBits++;
}
@ -81,128 +42,132 @@ namespace Ryujinx.HLE.Loaders.Npdm
switch (LowBits)
{
case 3: // Kernel flags
//Kernel flags.
case 3:
{
Items[i].HasKernelFlags = true;
Items[Index].HasKernelFlags = true;
Items[i].HighestThreadPriority = Descriptor & 0x3F;
Items[i].LowestThreadPriority = (Descriptor >> 6) & 0x3F;
Items[i].LowestCpuId = (Descriptor >> 12) & 0xFF;
Items[i].HighestCpuId = (Descriptor >> 20) & 0xFF;
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;
}
case 4: // Syscall mask
//Syscall mask.
case 4:
{
Items[i].HasSVCFlags = true;
Items[Index].HasSvcFlags = true;
Items[i].SVCsAllowed = new int[0x80];
Items[Index].AllowedSvcs = new bool[0x80];
int SysCallBase = (int)(Descriptor >> 24) * 0x18;
for (int SysCall = 0; SysCall < 0x18 && SysCallBase + SysCall < 0x80; SysCall++)
{
Items[i].SVCsAllowed[SysCallBase + SysCall] = (int)Descriptor & 1;
Items[Index].AllowedSvcs[SysCallBase + SysCall] = (Descriptor & 1) != 0;
Descriptor >>= 1;
}
break;
}
case 6: // Map IO/Normal - Never tested.
//Map IO/Normal.
case 6:
{
KernelAccessControlMMIO TempNormalMMIO = new KernelAccessControlMMIO
{
Address = (Descriptor & 0xFFFFFF) << 12,
IsRO = (Descriptor >> 24) != 0
};
ulong Address = (Descriptor & 0xffffff) << 12;
bool IsRo = (Descriptor >> 24) != 0;
if (i == Size / 4 - 1)
if (Index == Size / 4 - 1)
{
throw new InvalidNpdmException("Invalid Kernel Access Control Descriptors!");
}
Descriptor = Reader.ReadUInt32();
if ((Descriptor & 0x7F) != 0x3F)
if ((Descriptor & 0x7f) != 0x3f)
{
throw new InvalidNpdmException("Invalid Kernel Access Control Descriptors!");
}
Descriptor >>= 7;
TempNormalMMIO.Size = (Descriptor & 0xFFFFFF) << 12;
TempNormalMMIO.IsNormal = (Descriptor >> 24) != 0;
Items[i].NormalMMIO.Add(TempNormalMMIO);
i++;
ulong MmioSize = (Descriptor & 0xffffff) << 12;
bool IsNormal = (Descriptor >> 24) != 0;
Items[Index].NormalMmio.Add(new KernelAccessControlMmio(Address, MmioSize, IsRo, IsNormal));
Index++;
break;
}
case 7: // Map Normal Page - Never tested.
//Map Normal Page.
case 7:
{
KernelAccessControlMMIO TempPageMMIO = new KernelAccessControlMMIO
{
Address = Descriptor << 12,
Size = 0x1000,
IsRO = false,
IsNormal = false
};
ulong Address = Descriptor << 12;
Items[i].PageMMIO.Add(TempPageMMIO);
Items[Index].PageMmio.Add(new KernelAccessControlMmio(Address, 0x1000, false, false));
break;
}
case 11: // IRQ Pair - Never tested.
//IRQ Pair.
case 11:
{
KernelAccessControlIRQ TempIRQ = new KernelAccessControlIRQ
{
IRQ0 = Descriptor & 0x3FF,
IRQ1 = (Descriptor >> 10) & 0x3FF
};
Items[Index].Irq.Add(new KernelAccessControlIrq(
(Descriptor >> 0) & 0x3ff,
(Descriptor >> 10) & 0x3ff));
break;
}
case 13: // App Type
//Application Type.
case 13:
{
Items[i].HasApplicationType = true;
Items[i].ApplicationType = (int)Descriptor & 7;
Items[Index].HasApplicationType = true;
Items[Index].ApplicationType = (int)Descriptor & 7;
break;
}
case 14: // Kernel Release Version
//Kernel Release Version.
case 14:
{
Items[i].HasKernelVersion = true;
Items[Index].HasKernelVersion = true;
Items[i].KernelVersionRelease = (int)Descriptor;
Items[Index].KernelVersionRelease = (int)Descriptor;
break;
}
case 15: // Handle Table Size
//Handle Table Size.
case 15:
{
Items[i].HasHandleTableSize = true;
Items[Index].HasHandleTableSize = true;
Items[i].HandleTableSize = (int)Descriptor;
Items[Index].HandleTableSize = (int)Descriptor;
break;
}
case 16: // Debug Flags
//Debug Flags.
case 16:
{
Items[i].HasDebugFlags = true;
Items[Index].HasDebugFlags = true;
Items[i].AllowDebug = (Descriptor & 1) != 0;
Items[i].ForceDebug = ((Descriptor >> 1) & 1) != 0;
Items[Index].AllowDebug = ((Descriptor >> 0) & 1) != 0;
Items[Index].ForceDebug = ((Descriptor >> 1) & 1) != 0;
break;
}
}
}
this.Items = Array.AsReadOnly(Items);
}
}
}