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,4 +1,5 @@
using Ryujinx.HLE.OsHle.Utilities;
using Ryujinx.HLE.Exceptions;
using Ryujinx.HLE.Utilities;
using System.IO;
using System.Text;
@ -9,77 +10,69 @@ namespace Ryujinx.HLE.Loaders.Npdm
//http://switchbrew.org/index.php?title=NPDM
class Npdm
{
public bool Is64Bits;
public int AddressSpaceWidth;
public byte MainThreadPriority;
public byte DefaultCpuId;
public int SystemResourceSize;
public int ProcessCategory;
public int MainEntrypointStackSize;
public string TitleName;
public byte[] ProductCode;
public ulong FSPerms;
private const int MetaMagic = 'M' << 0 | 'E' << 8 | 'T' << 16 | 'A' << 24;
private int ACI0Offset;
private int ACI0Size;
private int ACIDOffset;
private int ACIDSize;
public bool Is64Bits { get; private set; }
public int AddressSpaceWidth { get; private set; }
public byte MainThreadPriority { get; private set; }
public byte DefaultCpuId { get; private set; }
public int SystemResourceSize { get; private set; }
public int ProcessCategory { get; private set; }
public int MainEntrypointStackSize { get; private set; }
public string TitleName { get; private set; }
public byte[] ProductCode { get; private set; }
public ACI0 ACI0;
public ACID ACID;
public ACI0 ACI0 { get; private set; }
public ACID ACID { get; private set; }
public const long NpdmMagic = 'M' << 0 | 'E' << 8 | 'T' << 16 | 'A' << 24;
public Npdm(Stream NPDMStream)
public Npdm(Stream Stream)
{
BinaryReader Reader = new BinaryReader(NPDMStream);
BinaryReader Reader = new BinaryReader(Stream);
if (Reader.ReadInt32() != NpdmMagic)
if (Reader.ReadInt32() != MetaMagic)
{
throw new InvalidNpdmException("NPDM Stream doesn't contain NPDM file!");
}
Reader.ReadInt64(); // Padding / Unused
Reader.ReadInt64();
//MmuFlags, bit0: 64-bit instructions, bits1-3: address space width (1=64-bit, 2=32-bit). Needs to be <= 0xF.
byte MmuFlags = Reader.ReadByte();
// MmuFlags, bit0: 64-bit instructions, bits1-3: address space width (1=64-bit, 2=32-bit). Needs to be <= 0xF
byte MmuFlags = Reader.ReadByte();
Is64Bits = (MmuFlags & 1) != 0;
AddressSpaceWidth = (MmuFlags >> 1) & 7;
Reader.ReadByte(); // Padding / Unused
Reader.ReadByte();
MainThreadPriority = Reader.ReadByte(); // (0-63)
MainThreadPriority = Reader.ReadByte(); //(0-63).
DefaultCpuId = Reader.ReadByte();
Reader.ReadInt32(); // Padding / Unused
Reader.ReadInt32();
// System resource size (max size as of 5.x: 534773760). Unknown usage.
//System resource size (max size as of 5.x: 534773760).
SystemResourceSize = EndianSwap.Swap32(Reader.ReadInt32());
// ProcessCategory (0: regular title, 1: kernel built-in). Should be 0 here.
//ProcessCategory (0: regular title, 1: kernel built-in). Should be 0 here.
ProcessCategory = EndianSwap.Swap32(Reader.ReadInt32());
// Main entrypoint stack size
// (Should(?) be page-aligned. In non-nspwn scenarios, values of 0 can also rarely break in Horizon.
// This might be something auto-adapting or a security feature of some sort ?)
//Main entrypoint stack size.
MainEntrypointStackSize = Reader.ReadInt32();
byte[] TempTitleName = Reader.ReadBytes(0x10);
TitleName = Encoding.UTF8.GetString(TempTitleName, 0, TempTitleName.Length).Trim('\0');
ProductCode = Reader.ReadBytes(0x10); // Unknown value
TitleName = Encoding.UTF8.GetString(TempTitleName, 0, TempTitleName.Length).Trim('\0');
NPDMStream.Seek(0x30, SeekOrigin.Current); // Skip reserved bytes
ProductCode = Reader.ReadBytes(0x10);
ACI0Offset = Reader.ReadInt32();
ACI0Size = Reader.ReadInt32();
ACIDOffset = Reader.ReadInt32();
ACIDSize = Reader.ReadInt32();
Stream.Seek(0x30, SeekOrigin.Current);
ACI0 = new ACI0(NPDMStream, ACI0Offset);
ACID = new ACID(NPDMStream, ACIDOffset);
int ACI0Offset = Reader.ReadInt32();
int ACI0Size = Reader.ReadInt32();
int ACIDOffset = Reader.ReadInt32();
int ACIDSize = Reader.ReadInt32();
FSPerms = ACI0.FSAccessHeader.PermissionsBitmask & ACID.FSAccessControl.PermissionsBitmask;
ACI0 = new ACI0(Stream, ACI0Offset);
ACID = new ACID(Stream, ACIDOffset);
}
}
}