Refactoring HOS folder structure (#771)

* Refactoring HOS folder structure

Refactoring HOS folder structure:

- Added some subfolders when needed (Following structure decided in private).
- Added some `Types` folders when needed.
- Little cleanup here and there.
- Add services placeholders for every HOS services (close #766 and #753).

* Remove Types namespaces
This commit is contained in:
Ac_K 2019-09-19 02:45:11 +02:00 committed by jduncanator
parent 4af3101b22
commit a0720b5681
393 changed files with 2540 additions and 1299 deletions

View file

@ -0,0 +1,7 @@
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class IApplicationCreator : IpcService
{
public IApplicationCreator() { }
}
}

View file

@ -0,0 +1,66 @@
using Ryujinx.Common.Logging;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class IAudioController : IpcService
{
public IAudioController() { }
[Command(0)]
// SetExpectedMasterVolume(f32, f32)
public ResultCode SetExpectedMasterVolume(ServiceCtx context)
{
float appletVolume = context.RequestData.ReadSingle();
float libraryAppletVolume = context.RequestData.ReadSingle();
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(1)]
// GetMainAppletExpectedMasterVolume() -> f32
public ResultCode GetMainAppletExpectedMasterVolume(ServiceCtx context)
{
context.ResponseData.Write(1f);
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(2)]
// GetLibraryAppletExpectedMasterVolume() -> f32
public ResultCode GetLibraryAppletExpectedMasterVolume(ServiceCtx context)
{
context.ResponseData.Write(1f);
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(3)]
// ChangeMainAppletMasterVolume(f32, u64)
public ResultCode ChangeMainAppletMasterVolume(ServiceCtx context)
{
float unknown0 = context.RequestData.ReadSingle();
long unknown1 = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(4)]
// SetTransparentVolumeRate(f32)
public ResultCode SetTransparentVolumeRate(ServiceCtx context)
{
float unknown0 = context.RequestData.ReadSingle();
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
}
}

View file

@ -0,0 +1,142 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Apm;
using System;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class ICommonStateGetter : IpcService
{
private KEvent _displayResolutionChangeEvent;
private CpuBoostMode _cpuBoostMode = CpuBoostMode.Disabled;
public ICommonStateGetter(Horizon system)
{
_displayResolutionChangeEvent = new KEvent(system);
}
[Command(0)]
// GetEventHandle() -> handle<copy>
public ResultCode GetEventHandle(ServiceCtx context)
{
KEvent Event = context.Device.System.AppletState.MessageEvent;
if (context.Process.HandleTable.GenerateHandle(Event.ReadableEvent, out int handle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
return ResultCode.Success;
}
[Command(1)]
// ReceiveMessage() -> nn::am::AppletMessage
public ResultCode ReceiveMessage(ServiceCtx context)
{
if (!context.Device.System.AppletState.TryDequeueMessage(out MessageInfo message))
{
return ResultCode.NoMessages;
}
context.ResponseData.Write((int)message);
return ResultCode.Success;
}
[Command(5)]
// GetOperationMode() -> u8
public ResultCode GetOperationMode(ServiceCtx context)
{
OperationMode mode = context.Device.System.State.DockedMode
? OperationMode.Docked
: OperationMode.Handheld;
context.ResponseData.Write((byte)mode);
return ResultCode.Success;
}
[Command(6)]
// GetPerformanceMode() -> u32
public ResultCode GetPerformanceMode(ServiceCtx context)
{
PerformanceMode mode = context.Device.System.State.DockedMode
? PerformanceMode.Docked
: PerformanceMode.Handheld;
context.ResponseData.Write((int)mode);
return ResultCode.Success;
}
[Command(8)]
// GetBootMode() -> u8
public ResultCode GetBootMode(ServiceCtx context)
{
context.ResponseData.Write((byte)0); //Unknown value.
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(9)]
// GetCurrentFocusState() -> u8
public ResultCode GetCurrentFocusState(ServiceCtx context)
{
context.ResponseData.Write((byte)context.Device.System.AppletState.FocusState);
return ResultCode.Success;
}
[Command(60)] // 3.0.0+
// GetDefaultDisplayResolution() -> (u32, u32)
public ResultCode GetDefaultDisplayResolution(ServiceCtx context)
{
context.ResponseData.Write(1280);
context.ResponseData.Write(720);
return ResultCode.Success;
}
[Command(61)] // 3.0.0+
// GetDefaultDisplayResolutionChangeEvent() -> handle<copy>
public ResultCode GetDefaultDisplayResolutionChangeEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_displayResolutionChangeEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(66)] // 6.0.0+
// SetCpuBoostMode(u32 cpu_boost_mode)
public ResultCode SetCpuBoostMode(ServiceCtx context)
{
uint cpuBoostMode = context.RequestData.ReadUInt32();
if (cpuBoostMode > 1)
{
return ResultCode.CpuBoostModeInvalid;
}
_cpuBoostMode = (CpuBoostMode)cpuBoostMode;
// NOTE: There is a condition variable after the assignment, probably waiting something with apm:sys service (SetCpuBoostMode call?).
// Since we will probably never support CPU boost things, it's not needed to implement more.
return ResultCode.Success;
}
}
}

View file

@ -0,0 +1,7 @@
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class IDebugFunctions : IpcService
{
public IDebugFunctions() { }
}
}

View file

@ -0,0 +1,7 @@
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class IDisplayController : IpcService
{
public IDisplayController() { }
}
}

View file

@ -0,0 +1,7 @@
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class IGlobalStateController : IpcService
{
public IGlobalStateController() { }
}
}

View file

@ -0,0 +1,44 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
using System;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class IHomeMenuFunctions : IpcService
{
private KEvent _channelEvent;
public IHomeMenuFunctions(Horizon system)
{
// TODO: Signal this Event somewhere in future.
_channelEvent = new KEvent(system);
}
[Command(10)]
// RequestToGetForeground()
public ResultCode RequestToGetForeground(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(21)]
// GetPopFromGeneralChannelEvent() -> handle<copy>
public ResultCode GetPopFromGeneralChannelEvent(ServiceCtx context)
{
if (context.Process.HandleTable.GenerateHandle(_channelEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
}
}

View file

@ -0,0 +1,29 @@
using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.LibraryAppletCreator;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class ILibraryAppletCreator : IpcService
{
public ILibraryAppletCreator() { }
[Command(0)]
// CreateLibraryApplet(u32, u32) -> object<nn::am::service::ILibraryAppletAccessor>
public ResultCode CreateLibraryApplet(ServiceCtx context)
{
MakeObject(context, new ILibraryAppletAccessor(context.Device.System));
return ResultCode.Success;
}
[Command(10)]
// CreateStorage(u64) -> object<nn::am::service::IStorage>
public ResultCode CreateStorage(ServiceCtx context)
{
long size = context.RequestData.ReadInt64();
MakeObject(context, new IStorage(new byte[size]));
return ResultCode.Success;
}
}
}

View file

@ -0,0 +1,200 @@
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
using System;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class ISelfController : IpcService
{
private KEvent _libraryAppletLaunchableEvent;
private KEvent _accumulatedSuspendedTickChangedEvent;
private int _accumulatedSuspendedTickChangedEventHandle = 0;
private int _idleTimeDetectionExtension;
public ISelfController(Horizon system)
{
_libraryAppletLaunchableEvent = new KEvent(system);
}
[Command(0)]
// Exit()
public ResultCode Exit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(1)]
// LockExit()
public ResultCode LockExit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(2)]
// UnlockExit()
public ResultCode UnlockExit(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(9)]
// GetLibraryAppletLaunchableEvent() -> handle<copy>
public ResultCode GetLibraryAppletLaunchableEvent(ServiceCtx context)
{
_libraryAppletLaunchableEvent.ReadableEvent.Signal();
if (context.Process.HandleTable.GenerateHandle(_libraryAppletLaunchableEvent.ReadableEvent, out int handle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(10)]
// SetScreenShotPermission(u32)
public ResultCode SetScreenShotPermission(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(11)]
// SetOperationModeChangedNotification(b8)
public ResultCode SetOperationModeChangedNotification(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(12)]
// SetPerformanceModeChangedNotification(b8)
public ResultCode SetPerformanceModeChangedNotification(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(13)]
// SetFocusHandlingMode(b8, b8, b8)
public ResultCode SetFocusHandlingMode(ServiceCtx context)
{
bool flag1 = context.RequestData.ReadByte() != 0;
bool flag2 = context.RequestData.ReadByte() != 0;
bool flag3 = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(14)]
// SetRestartMessageEnabled(b8)
public ResultCode SetRestartMessageEnabled(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(16)] // 2.0.0+
// SetOutOfFocusSuspendingEnabled(b8)
public ResultCode SetOutOfFocusSuspendingEnabled(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(19)] // 3.0.0+
public ResultCode SetScreenShotImageOrientation(ServiceCtx context)
{
int orientation = context.RequestData.ReadInt32();
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(50)]
// SetHandlesRequestToDisplay(b8)
public ResultCode SetHandlesRequestToDisplay(ServiceCtx context)
{
bool enable = context.RequestData.ReadByte() != 0;
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
[Command(62)]
// SetIdleTimeDetectionExtension(u32)
public ResultCode SetIdleTimeDetectionExtension(ServiceCtx context)
{
_idleTimeDetectionExtension = context.RequestData.ReadInt32();
Logger.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
return ResultCode.Success;
}
[Command(63)]
// GetIdleTimeDetectionExtension() -> u32
public ResultCode GetIdleTimeDetectionExtension(ServiceCtx context)
{
context.ResponseData.Write(_idleTimeDetectionExtension);
Logger.PrintStub(LogClass.ServiceAm, new { _idleTimeDetectionExtension });
return ResultCode.Success;
}
[Command(91)] // 6.0.0+
// GetAccumulatedSuspendedTickChangedEvent() -> handle<copy>
public ResultCode GetAccumulatedSuspendedTickChangedEvent(ServiceCtx context)
{
if (_accumulatedSuspendedTickChangedEventHandle == 0)
{
_accumulatedSuspendedTickChangedEvent = new KEvent(context.Device.System);
_accumulatedSuspendedTickChangedEvent.ReadableEvent.Signal();
if (context.Process.HandleTable.GenerateHandle(_accumulatedSuspendedTickChangedEvent.ReadableEvent, out _accumulatedSuspendedTickChangedEventHandle) != KernelResult.Success)
{
throw new InvalidOperationException("Out of handles!");
}
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_accumulatedSuspendedTickChangedEventHandle);
return ResultCode.Success;
}
}
}

View file

@ -0,0 +1,29 @@
using Ryujinx.Common.Logging;
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
class IWindowController : IpcService
{
public IWindowController() { }
[Command(1)]
// GetAppletResourceUserId() -> nn::applet::AppletResourceUserId
public ResultCode GetAppletResourceUserId(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
context.ResponseData.Write(0L);
return ResultCode.Success;
}
[Command(10)]
// AcquireForegroundRights()
public ResultCode AcquireForegroundRights(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAm);
return ResultCode.Success;
}
}
}

View file

@ -0,0 +1,8 @@
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
enum FocusState
{
InFocus = 1,
OutOfFocus = 2
}
}

View file

@ -0,0 +1,9 @@
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
enum MessageInfo
{
FocusStateChanged = 0xf,
OperationModeChanged = 0x1e,
PerformanceModeChanged = 0x1f
}
}

View file

@ -0,0 +1,8 @@
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
{
enum OperationMode
{
Handheld = 0,
Docked = 1
}
}