Fix compilation warnings and use new LibHac APIs for executable loading (#1350)

* Fix compilation warnings and use new LibHac APIs for executable loading

* Migrate NSO loader to the new reader and fix kip loader

* Fix CS0162 restore

* Remove extra return lines

* Address Moose's comment
This commit is contained in:
Mary 2020-07-04 01:58:01 +02:00 committed by GitHub
parent e13154c83d
commit 2c48750ff0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 102 additions and 43 deletions

View file

@ -415,13 +415,13 @@ namespace Ryujinx.HLE.HOS
bool isNro = Path.GetExtension(filePath).ToLower() == ".nro";
IExecutable nro;
IExecutable executable;
if (isNro)
{
FileStream input = new FileStream(filePath, FileMode.Open);
NroExecutable obj = new NroExecutable(input);
nro = obj;
executable = obj;
// homebrew NRO can actually have some data after the actual NRO
if (input.Length > obj.FileSize)
@ -493,7 +493,7 @@ namespace Ryujinx.HLE.HOS
}
else
{
nro = new NsoExecutable(new LocalStorage(filePath, FileAccess.Read));
executable = new NsoExecutable(new LocalStorage(filePath, FileAccess.Read));
}
_contentManager.LoadEntries(_device);
@ -502,7 +502,7 @@ namespace Ryujinx.HLE.HOS
TitleId = metaData.Aci0.TitleId;
TitleIs64Bit = metaData.Is64Bit;
ProgramLoader.LoadNsos(_device.System.KernelContext, metaData, executables: nro);
ProgramLoader.LoadNsos(_device.System.KernelContext, metaData, executables: executable);
}
private Npdm GetDefaultNpdm()

View file

@ -32,7 +32,7 @@ namespace Ryujinx.HLE.HOS
int codePagesCount = codeSize / KMemoryManager.PageSize;
ulong codeBaseAddress = (kip.Header.Flags & 0x10) != 0 ? 0x8000000UL : 0x200000UL;
ulong codeBaseAddress = kip.Is64BitAddressSpace ? 0x8000000UL : 0x200000UL;
ulong codeAddress = codeBaseAddress + (ulong)kip.TextOffset;
@ -45,27 +45,27 @@ namespace Ryujinx.HLE.HOS
mmuFlags |= 0x20;
}
if ((kip.Header.Flags & 0x10) != 0)
if (kip.Is64BitAddressSpace)
{
mmuFlags |= (int)AddressSpaceType.Addr39Bits << 1;
}
if ((kip.Header.Flags & 0x08) != 0)
if (kip.Is64Bit)
{
mmuFlags |= 1;
}
ProcessCreationInfo creationInfo = new ProcessCreationInfo(
kip.Header.Name,
kip.Header.ProcessCategory,
kip.Header.TitleId,
kip.Name,
kip.Version,
kip.ProgramId,
codeAddress,
codePagesCount,
mmuFlags,
0,
0);
MemoryRegion memoryRegion = (kip.Header.Flags & 0x20) != 0
MemoryRegion memoryRegion = kip.UsesSecureMemory
? MemoryRegion.Service
: MemoryRegion.Application;
@ -105,9 +105,9 @@ namespace Ryujinx.HLE.HOS
return false;
}
process.DefaultCpuCore = kip.Header.DefaultCore;
process.DefaultCpuCore = kip.IdealCoreId;
result = process.Start(kip.Header.MainThreadPriority, (ulong)kip.Header.Sections[1].Attribute);
result = process.Start(kip.Priority, (ulong)kip.StackSize);
if (result != KernelResult.Success)
{

View file

@ -9,9 +9,9 @@ namespace Ryujinx.HLE.HOS.Services.Bluetooth
[Service("btdrv")]
class IBluetoothDriver : IpcService
{
#pragma warning disable CS0169
#pragma warning disable CS0414
private string _unknownLowEnergy;
#pragma warning restore CS0169
#pragma warning restore CS0414
public IBluetoothDriver(ServiceCtx context) { }

View file

@ -32,7 +32,9 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Nsd.Manager
return ResultCode.Success;
}
#pragma warning disable CS0162
return ResultCode.NullOutputObject;
#pragma warning restore CS0162
}
}