2018-01-13 13:22:39 -08:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-10-14 19:50:04 -07:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-08-21 07:59:37 -07:00
|
|
|
#include <array>
|
2018-03-04 10:03:58 -08:00
|
|
|
#include <cinttypes>
|
2018-10-10 18:49:20 -07:00
|
|
|
#include <cstring>
|
2018-06-03 11:23:44 -07:00
|
|
|
#include <stack>
|
2018-07-17 12:42:15 -07:00
|
|
|
#include "core/core.h"
|
2018-02-02 13:03:40 -08:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
|
|
|
#include "core/hle/kernel/event.h"
|
2018-07-17 12:42:15 -07:00
|
|
|
#include "core/hle/kernel/process.h"
|
2018-10-10 18:49:20 -07:00
|
|
|
#include "core/hle/service/acc/profile_manager.h"
|
2017-10-14 19:50:04 -07:00
|
|
|
#include "core/hle/service/am/am.h"
|
2018-02-02 13:03:40 -08:00
|
|
|
#include "core/hle/service/am/applet_ae.h"
|
2017-10-14 19:50:04 -07:00
|
|
|
#include "core/hle/service/am/applet_oe.h"
|
2018-07-31 04:01:49 -07:00
|
|
|
#include "core/hle/service/am/idle.h"
|
|
|
|
#include "core/hle/service/am/omm.h"
|
|
|
|
#include "core/hle/service/am/spsm.h"
|
2018-10-21 13:48:58 -07:00
|
|
|
#include "core/hle/service/am/tcap.h"
|
2018-02-02 13:03:40 -08:00
|
|
|
#include "core/hle/service/apm/apm.h"
|
2018-03-04 10:03:58 -08:00
|
|
|
#include "core/hle/service/filesystem/filesystem.h"
|
2018-02-02 13:03:40 -08:00
|
|
|
#include "core/hle/service/nvflinger/nvflinger.h"
|
2018-08-23 15:31:45 -07:00
|
|
|
#include "core/hle/service/pm/pm.h"
|
2018-04-28 17:30:53 -07:00
|
|
|
#include "core/hle/service/set/set.h"
|
2018-09-18 08:10:16 -07:00
|
|
|
#include "core/hle/service/vi/vi.h"
|
2018-03-26 19:24:31 -07:00
|
|
|
#include "core/settings.h"
|
2017-10-14 19:50:04 -07:00
|
|
|
|
2018-04-19 18:41:44 -07:00
|
|
|
namespace Service::AM {
|
2017-10-14 19:50:04 -07:00
|
|
|
|
2018-10-13 10:02:33 -07:00
|
|
|
constexpr u32 POP_LAUNCH_PARAMETER_MAGIC = 0xC79497CA;
|
|
|
|
|
|
|
|
struct LaunchParameters {
|
|
|
|
u32_le magic;
|
|
|
|
u32_le is_account_selected;
|
|
|
|
u128 current_user;
|
|
|
|
INSERT_PADDING_BYTES(0x70);
|
|
|
|
};
|
|
|
|
static_assert(sizeof(LaunchParameters) == 0x88);
|
2018-10-09 18:49:29 -07:00
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
IWindowController::IWindowController() : ServiceFramework("IWindowController") {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-02-02 13:03:40 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-04-10 08:36:00 -07:00
|
|
|
{0, nullptr, "CreateWindow"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{1, &IWindowController::GetAppletResourceUserId, "GetAppletResourceUserId"},
|
|
|
|
{10, &IWindowController::AcquireForegroundRights, "AcquireForegroundRights"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{11, nullptr, "ReleaseForegroundRights"},
|
|
|
|
{12, nullptr, "RejectToChangeIntoBackground"},
|
2018-10-21 13:40:17 -07:00
|
|
|
{20, nullptr, "SetAppletWindowVisibility"},
|
|
|
|
{21, nullptr, "SetAppletGpuTimeSlice"},
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
IWindowController::~IWindowController() = default;
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u64>(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-02-22 06:28:15 -08:00
|
|
|
IAudioController::IAudioController() : ServiceFramework("IAudioController") {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"},
|
|
|
|
{1, &IAudioController::GetMainAppletExpectedMasterVolume,
|
|
|
|
"GetMainAppletExpectedMasterVolume"},
|
|
|
|
{2, &IAudioController::GetLibraryAppletExpectedMasterVolume,
|
|
|
|
"GetLibraryAppletExpectedMasterVolume"},
|
|
|
|
{3, nullptr, "ChangeMainAppletMasterVolume"},
|
|
|
|
{4, nullptr, "SetTransparentVolumeRate"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
IAudioController::~IAudioController() = default;
|
|
|
|
|
2018-02-22 06:28:15 -08:00
|
|
|
void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-22 06:28:15 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-22 06:28:15 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-22 06:28:15 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(volume);
|
|
|
|
}
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2018-05-25 19:31:54 -07:00
|
|
|
IDisplayController::IDisplayController() : ServiceFramework("IDisplayController") {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-05-25 19:31:54 -07:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "GetLastForegroundCaptureImage"},
|
|
|
|
{1, nullptr, "UpdateLastForegroundCaptureImage"},
|
|
|
|
{2, nullptr, "GetLastApplicationCaptureImage"},
|
|
|
|
{3, nullptr, "GetCallerAppletCaptureImage"},
|
|
|
|
{4, nullptr, "UpdateCallerAppletCaptureImage"},
|
|
|
|
{5, nullptr, "GetLastForegroundCaptureImageEx"},
|
|
|
|
{6, nullptr, "GetLastApplicationCaptureImageEx"},
|
|
|
|
{7, nullptr, "GetCallerAppletCaptureImageEx"},
|
|
|
|
{8, nullptr, "TakeScreenShotOfOwnLayer"}, // 2.0.0+
|
|
|
|
{9, nullptr, "CopyBetweenCaptureBuffers"}, // 5.0.0+
|
|
|
|
{10, nullptr, "AcquireLastApplicationCaptureBuffer"},
|
|
|
|
{11, nullptr, "ReleaseLastApplicationCaptureBuffer"},
|
|
|
|
{12, nullptr, "AcquireLastForegroundCaptureBuffer"},
|
|
|
|
{13, nullptr, "ReleaseLastForegroundCaptureBuffer"},
|
|
|
|
{14, nullptr, "AcquireCallerAppletCaptureBuffer"},
|
|
|
|
{15, nullptr, "ReleaseCallerAppletCaptureBuffer"},
|
|
|
|
{16, nullptr, "AcquireLastApplicationCaptureBufferEx"},
|
|
|
|
{17, nullptr, "AcquireLastForegroundCaptureBufferEx"},
|
|
|
|
{18, nullptr, "AcquireCallerAppletCaptureBufferEx"},
|
|
|
|
// 2.0.0+
|
|
|
|
{20, nullptr, "ClearCaptureBuffer"},
|
|
|
|
{21, nullptr, "ClearAppletTransitionBuffer"},
|
|
|
|
// 4.0.0+
|
|
|
|
{22, nullptr, "AcquireLastApplicationCaptureSharedBuffer"},
|
|
|
|
{23, nullptr, "ReleaseLastApplicationCaptureSharedBuffer"},
|
|
|
|
{24, nullptr, "AcquireLastForegroundCaptureSharedBuffer"},
|
|
|
|
{25, nullptr, "ReleaseLastForegroundCaptureSharedBuffer"},
|
|
|
|
{26, nullptr, "AcquireCallerAppletCaptureSharedBuffer"},
|
|
|
|
{27, nullptr, "ReleaseCallerAppletCaptureSharedBuffer"},
|
2018-10-21 13:40:17 -07:00
|
|
|
// 6.0.0+
|
|
|
|
{28, nullptr, "TakeScreenShotOfOwnLayerEx"},
|
2018-05-25 19:31:54 -07:00
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-25 19:31:54 -07:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
2018-02-02 13:03:40 -08:00
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
IDisplayController::~IDisplayController() = default;
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
IDebugFunctions::IDebugFunctions() : ServiceFramework("IDebugFunctions") {}
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
IDebugFunctions::~IDebugFunctions() = default;
|
2018-02-02 13:03:40 -08:00
|
|
|
|
|
|
|
ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
|
|
|
|
: ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger)) {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-02-02 13:03:40 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
2018-04-10 08:36:00 -07:00
|
|
|
{0, nullptr, "Exit"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{1, &ISelfController::LockExit, "LockExit"},
|
|
|
|
{2, &ISelfController::UnlockExit, "UnlockExit"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{3, nullptr, "EnterFatalSection"},
|
|
|
|
{4, nullptr, "LeaveFatalSection"},
|
2018-02-07 04:11:17 -08:00
|
|
|
{9, &ISelfController::GetLibraryAppletLaunchableEvent, "GetLibraryAppletLaunchableEvent"},
|
2018-02-22 02:04:23 -08:00
|
|
|
{10, &ISelfController::SetScreenShotPermission, "SetScreenShotPermission"},
|
2018-10-21 13:40:17 -07:00
|
|
|
{11, &ISelfController::SetOperationModeChangedNotification, "SetOperationModeChangedNotification"},
|
|
|
|
{12, &ISelfController::SetPerformanceModeChangedNotification, "SetPerformanceModeChangedNotification"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{13, &ISelfController::SetFocusHandlingMode, "SetFocusHandlingMode"},
|
|
|
|
{14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{15, nullptr, "SetScreenShotAppletIdentityInfo"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{17, nullptr, "SetControllerFirmwareUpdateSection"},
|
|
|
|
{18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"},
|
2018-08-07 21:40:46 -07:00
|
|
|
{19, &ISelfController::SetScreenShotImageOrientation, "SetScreenShotImageOrientation"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{20, nullptr, "SetDesirableKeyboardLayout"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{41, nullptr, "IsSystemBufferSharingEnabled"},
|
|
|
|
{42, nullptr, "GetSystemSharedLayerHandle"},
|
2018-05-07 08:27:30 -07:00
|
|
|
{50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{51, nullptr, "ApproveToDisplay"},
|
|
|
|
{60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"},
|
|
|
|
{61, nullptr, "SetMediaPlaybackState"},
|
2018-08-16 21:23:08 -07:00
|
|
|
{62, &ISelfController::SetIdleTimeDetectionExtension, "SetIdleTimeDetectionExtension"},
|
|
|
|
{63, &ISelfController::GetIdleTimeDetectionExtension, "GetIdleTimeDetectionExtension"},
|
2018-04-11 04:48:56 -07:00
|
|
|
{64, nullptr, "SetInputDetectionSourceSet"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{65, nullptr, "ReportUserIsActive"},
|
|
|
|
{66, nullptr, "GetCurrentIlluminance"},
|
|
|
|
{67, nullptr, "IsIlluminanceAvailable"},
|
|
|
|
{68, nullptr, "SetAutoSleepDisabled"},
|
|
|
|
{69, nullptr, "IsAutoSleepDisabled"},
|
|
|
|
{70, nullptr, "ReportMultimediaError"},
|
|
|
|
{80, nullptr, "SetWirelessPriorityMode"},
|
2018-10-21 13:40:17 -07:00
|
|
|
{90, nullptr, "GetAccumulatedSuspendedTickValue"},
|
|
|
|
{91, nullptr, "GetAccumulatedSuspendedTickChangedEvent"},
|
|
|
|
{1000, nullptr, "GetDebugStorageChannel"},
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
RegisterHandlers(functions);
|
2018-02-07 04:11:17 -08:00
|
|
|
|
2018-08-28 09:30:33 -07:00
|
|
|
auto& kernel = Core::System::GetInstance().Kernel();
|
2018-02-07 04:11:17 -08:00
|
|
|
launchable_event =
|
2018-08-28 09:30:33 -07:00
|
|
|
Kernel::Event::Create(kernel, Kernel::ResetType::Sticky, "ISelfController:LaunchableEvent");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
ISelfController::~ISelfController() = default;
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) {
|
|
|
|
// Takes 3 input u8s with each field located immediately after the previous u8, these are
|
|
|
|
// bool flags. No output.
|
|
|
|
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
struct FocusHandlingModeParams {
|
|
|
|
u8 unknown0;
|
|
|
|
u8 unknown1;
|
|
|
|
u8 unknown2;
|
|
|
|
};
|
|
|
|
auto flags = rp.PopRaw<FocusHandlingModeParams>();
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
bool flag = rp.Pop<bool>();
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
2018-02-22 02:04:23 -08:00
|
|
|
void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-22 02:04:23 -08:00
|
|
|
}
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
bool flag = rp.Pop<bool>();
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) {
|
|
|
|
// Takes 3 input u8s with each field located immediately after the previous u8, these are
|
|
|
|
// bool flags. No output.
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
bool enabled = rp.Pop<bool>();
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called enabled={}", enabled);
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
2018-02-07 04:11:17 -08:00
|
|
|
void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
launchable_event->Signal();
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(launchable_event);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-07 04:11:17 -08:00
|
|
|
}
|
|
|
|
|
2018-08-07 21:40:46 -07:00
|
|
|
void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
|
|
|
|
// TODO(Subv): Find out how AM determines the display to use, for now just create the layer
|
|
|
|
// in the Default display.
|
|
|
|
u64 display_id = nvflinger->OpenDisplay("Default");
|
|
|
|
u64 layer_id = nvflinger->CreateLayer(display_id);
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(layer_id);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-05-07 08:27:30 -07:00
|
|
|
}
|
|
|
|
|
2018-08-16 21:23:08 -07:00
|
|
|
void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
idle_time_detection_extension = rp.Pop<u32>();
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(idle_time_detection_extension);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2018-11-06 23:01:33 -08:00
|
|
|
AppletMessageQueue::AppletMessageQueue() {
|
|
|
|
auto& kernel = Core::System::GetInstance().Kernel();
|
|
|
|
on_new_message = Kernel::Event::Create(kernel, Kernel::ResetType::Sticky,
|
|
|
|
"AMMessageQueue:OnMessageRecieved");
|
|
|
|
on_operation_mode_changed = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot,
|
|
|
|
"AMMessageQueue:OperationModeChanged");
|
|
|
|
}
|
|
|
|
|
|
|
|
AppletMessageQueue::~AppletMessageQueue() = default;
|
|
|
|
|
|
|
|
const Kernel::SharedPtr<Kernel::Event>& AppletMessageQueue::GetMesssageRecieveEvent() const {
|
|
|
|
return on_new_message;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Kernel::SharedPtr<Kernel::Event>& AppletMessageQueue::GetOperationModeChangedEvent() const {
|
|
|
|
return on_operation_mode_changed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppletMessageQueue::PushMessage(AppletMessage msg) {
|
|
|
|
messages.push(msg);
|
|
|
|
on_new_message->Signal();
|
|
|
|
}
|
|
|
|
|
|
|
|
AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() {
|
|
|
|
if (messages.empty()) {
|
|
|
|
on_new_message->Clear();
|
|
|
|
return AppletMessage::NoMessage;
|
|
|
|
}
|
|
|
|
auto msg = messages.front();
|
|
|
|
messages.pop();
|
|
|
|
if (messages.empty()) {
|
|
|
|
on_new_message->Clear();
|
|
|
|
}
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t AppletMessageQueue::GetMessageCount() const {
|
|
|
|
return messages.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppletMessageQueue::OperationModeChanged() {
|
|
|
|
PushMessage(AppletMessage::OperationModeChanged);
|
|
|
|
PushMessage(AppletMessage::PerformanceModeChanged);
|
|
|
|
on_operation_mode_changed->Signal();
|
|
|
|
}
|
|
|
|
|
|
|
|
ICommonStateGetter::ICommonStateGetter(std::shared_ptr<AppletMessageQueue> msg_queue)
|
|
|
|
: ServiceFramework("ICommonStateGetter"), msg_queue(std::move(msg_queue)) {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-02-02 13:03:40 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &ICommonStateGetter::GetEventHandle, "GetEventHandle"},
|
|
|
|
{1, &ICommonStateGetter::ReceiveMessage, "ReceiveMessage"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{2, nullptr, "GetThisAppletKind"},
|
|
|
|
{3, nullptr, "AllowToEnterSleep"},
|
|
|
|
{4, nullptr, "DisallowToEnterSleep"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{5, &ICommonStateGetter::GetOperationMode, "GetOperationMode"},
|
|
|
|
{6, &ICommonStateGetter::GetPerformanceMode, "GetPerformanceMode"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{7, nullptr, "GetCradleStatus"},
|
2018-08-23 15:31:45 -07:00
|
|
|
{8, &ICommonStateGetter::GetBootMode, "GetBootMode"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{9, &ICommonStateGetter::GetCurrentFocusState, "GetCurrentFocusState"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{10, nullptr, "RequestToAcquireSleepLock"},
|
|
|
|
{11, nullptr, "ReleaseSleepLock"},
|
|
|
|
{12, nullptr, "ReleaseSleepLockTransiently"},
|
|
|
|
{13, nullptr, "GetAcquiredSleepLockEvent"},
|
|
|
|
{20, nullptr, "PushToGeneralChannel"},
|
|
|
|
{30, nullptr, "GetHomeButtonReaderLockAccessor"},
|
|
|
|
{31, nullptr, "GetReaderLockAccessorEx"},
|
|
|
|
{40, nullptr, "GetCradleFwVersion"},
|
|
|
|
{50, nullptr, "IsVrModeEnabled"},
|
|
|
|
{51, nullptr, "SetVrModeEnabled"},
|
|
|
|
{52, nullptr, "SwitchLcdBacklight"},
|
|
|
|
{55, nullptr, "IsInControllerFirmwareUpdateSection"},
|
2018-09-18 08:10:16 -07:00
|
|
|
{60, &ICommonStateGetter::GetDefaultDisplayResolution, "GetDefaultDisplayResolution"},
|
2018-10-21 13:40:17 -07:00
|
|
|
{61, &ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent, "GetDefaultDisplayResolutionChangeEvent"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{62, nullptr, "GetHdcpAuthenticationState"},
|
|
|
|
{63, nullptr, "GetHdcpAuthenticationStateChangeEvent"},
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
|
2018-08-28 09:30:33 -07:00
|
|
|
auto& kernel = Core::System::GetInstance().Kernel();
|
|
|
|
event = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, "ICommonStateGetter:Event");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
ICommonStateGetter::~ICommonStateGetter() = default;
|
|
|
|
|
2018-08-23 15:31:45 -07:00
|
|
|
void ICommonStateGetter::GetBootMode(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
rb.Push<u8>(static_cast<u8>(Service::PM::SystemBootMode::Normal)); // Normal boot mode
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
}
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-06 23:01:33 -08:00
|
|
|
rb.PushCopyObjects(msg_queue->GetMesssageRecieveEvent());
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2018-11-06 23:01:33 -08:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-06 23:01:33 -08:00
|
|
|
rb.PushEnum<AppletMessageQueue::AppletMessage>(msg_queue->PopMessage());
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2018-11-06 23:01:33 -08:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(static_cast<u8>(FocusState::InFocus));
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
2018-08-16 14:20:54 -07:00
|
|
|
void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-11-06 23:01:33 -08:00
|
|
|
rb.PushCopyObjects(msg_queue->GetOperationModeChangedEvent());
|
2018-08-16 14:20:54 -07:00
|
|
|
|
2018-11-06 23:01:33 -08:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-08-16 14:20:54 -07:00
|
|
|
}
|
|
|
|
|
2018-09-18 08:10:16 -07:00
|
|
|
void ICommonStateGetter::GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
if (Settings::values.use_docked_mode) {
|
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth));
|
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight));
|
|
|
|
} else {
|
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth));
|
|
|
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight));
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
}
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
|
2018-03-26 19:59:18 -07:00
|
|
|
const bool use_docked_mode{Settings::values.use_docked_mode};
|
2018-02-02 13:03:40 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-03-26 19:59:18 -07:00
|
|
|
rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld));
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2018-11-06 23:01:33 -08:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
|
2018-03-26 19:59:18 -07:00
|
|
|
const bool use_docked_mode{Settings::values.use_docked_mode};
|
2018-02-02 13:03:40 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-03-26 19:59:18 -07:00
|
|
|
rb.Push(static_cast<u32>(use_docked_mode ? APM::PerformanceMode::Docked
|
|
|
|
: APM::PerformanceMode::Handheld));
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2018-11-06 23:01:33 -08:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
class IStorageAccessor final : public ServiceFramework<IStorageAccessor> {
|
|
|
|
public:
|
|
|
|
explicit IStorageAccessor(std::vector<u8> buffer)
|
|
|
|
: ServiceFramework("IStorageAccessor"), buffer(std::move(buffer)) {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-02-02 13:03:40 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IStorageAccessor::GetSize, "GetSize"},
|
2018-06-03 11:21:45 -07:00
|
|
|
{10, &IStorageAccessor::Write, "Write"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{11, &IStorageAccessor::Read, "Read"},
|
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<u8> buffer;
|
|
|
|
|
|
|
|
void GetSize(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(static_cast<u64>(buffer.size()));
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
2018-06-03 11:21:45 -07:00
|
|
|
void Write(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
const u64 offset{rp.Pop<u64>()};
|
|
|
|
const std::vector<u8> data{ctx.ReadBuffer()};
|
|
|
|
|
|
|
|
ASSERT(offset + data.size() <= buffer.size());
|
|
|
|
|
|
|
|
std::memcpy(&buffer[offset], data.data(), data.size());
|
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-06-03 11:21:45 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called, offset={}", offset);
|
2018-06-03 11:21:45 -07:00
|
|
|
}
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void Read(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
2018-06-03 11:21:05 -07:00
|
|
|
const u64 offset{rp.Pop<u64>()};
|
2018-09-15 06:21:06 -07:00
|
|
|
const std::size_t size{ctx.GetWriteBufferSize()};
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2018-02-13 20:16:19 -08:00
|
|
|
ASSERT(offset + size <= buffer.size());
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2018-02-13 20:16:19 -08:00
|
|
|
ctx.WriteBuffer(buffer.data() + offset, size);
|
2018-02-02 13:03:40 -08:00
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-02-02 13:03:40 -08:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called, offset={}", offset);
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class IStorage final : public ServiceFramework<IStorage> {
|
|
|
|
public:
|
|
|
|
explicit IStorage(std::vector<u8> buffer)
|
|
|
|
: ServiceFramework("IStorage"), buffer(std::move(buffer)) {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-02-02 13:03:40 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IStorage::Open, "Open"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{1, nullptr, "OpenTransferStorage"},
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<u8> buffer;
|
|
|
|
|
|
|
|
void Open(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<AM::IStorageAccessor>(buffer);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-06-03 11:23:44 -07:00
|
|
|
class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> {
|
|
|
|
public:
|
|
|
|
explicit ILibraryAppletAccessor() : ServiceFramework("ILibraryAppletAccessor") {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-06-03 11:23:44 -07:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
|
|
|
|
{1, nullptr, "IsCompleted"},
|
2018-06-03 20:37:17 -07:00
|
|
|
{10, &ILibraryAppletAccessor::Start, "Start"},
|
2018-06-03 11:23:44 -07:00
|
|
|
{20, nullptr, "RequestExit"},
|
|
|
|
{25, nullptr, "Terminate"},
|
2018-06-03 20:37:17 -07:00
|
|
|
{30, &ILibraryAppletAccessor::GetResult, "GetResult"},
|
2018-06-03 11:23:44 -07:00
|
|
|
{50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"},
|
|
|
|
{100, &ILibraryAppletAccessor::PushInData, "PushInData"},
|
2018-06-03 20:43:31 -07:00
|
|
|
{101, &ILibraryAppletAccessor::PopOutData, "PopOutData"},
|
2018-06-03 11:23:44 -07:00
|
|
|
{102, nullptr, "PushExtraStorage"},
|
|
|
|
{103, nullptr, "PushInteractiveInData"},
|
|
|
|
{104, nullptr, "PopInteractiveOutData"},
|
|
|
|
{105, nullptr, "GetPopOutDataEvent"},
|
|
|
|
{106, nullptr, "GetPopInteractiveOutDataEvent"},
|
|
|
|
{110, nullptr, "NeedsToExitProcess"},
|
|
|
|
{120, nullptr, "GetLibraryAppletInfo"},
|
|
|
|
{150, nullptr, "RequestForAppletToGetForeground"},
|
|
|
|
{160, nullptr, "GetIndirectLayerConsumerHandle"},
|
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-06-03 11:23:44 -07:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
|
2018-08-28 09:30:33 -07:00
|
|
|
auto& kernel = Core::System::GetInstance().Kernel();
|
|
|
|
state_changed_event = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot,
|
2018-06-03 11:23:44 -07:00
|
|
|
"ILibraryAppletAccessor:StateChangedEvent");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
state_changed_event->Signal();
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(state_changed_event);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-06-03 11:23:44 -07:00
|
|
|
}
|
|
|
|
|
2018-06-03 20:37:17 -07:00
|
|
|
void GetResult(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-06-03 20:37:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void Start(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-06-03 20:37:17 -07:00
|
|
|
}
|
|
|
|
|
2018-06-03 11:23:44 -07:00
|
|
|
void PushInData(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
storage_stack.push(rp.PopIpcInterface<AM::IStorage>());
|
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-06-03 11:23:44 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-06-03 11:23:44 -07:00
|
|
|
}
|
|
|
|
|
2018-06-03 20:43:31 -07:00
|
|
|
void PopOutData(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<AM::IStorage>(std::move(storage_stack.top()));
|
|
|
|
|
|
|
|
storage_stack.pop();
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-06-03 20:43:31 -07:00
|
|
|
}
|
|
|
|
|
2018-06-03 11:23:44 -07:00
|
|
|
std::stack<std::shared_ptr<AM::IStorage>> storage_stack;
|
|
|
|
Kernel::SharedPtr<Kernel::Event> state_changed_event;
|
|
|
|
};
|
|
|
|
|
2018-06-03 11:19:24 -07:00
|
|
|
ILibraryAppletCreator::ILibraryAppletCreator() : ServiceFramework("ILibraryAppletCreator") {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"},
|
|
|
|
{1, nullptr, "TerminateAllLibraryApplets"},
|
|
|
|
{2, nullptr, "AreAnyLibraryAppletsLeft"},
|
|
|
|
{10, &ILibraryAppletCreator::CreateStorage, "CreateStorage"},
|
|
|
|
{11, nullptr, "CreateTransferMemoryStorage"},
|
|
|
|
{12, nullptr, "CreateHandleStorage"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
ILibraryAppletCreator::~ILibraryAppletCreator() = default;
|
|
|
|
|
2018-06-03 11:19:24 -07:00
|
|
|
void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<AM::ILibraryAppletAccessor>();
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-06-03 11:19:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void ILibraryAppletCreator::CreateStorage(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u64 size{rp.Pop<u64>()};
|
|
|
|
std::vector<u8> buffer(size);
|
|
|
|
|
2018-09-18 22:09:59 -07:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2018-06-03 11:19:24 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<AM::IStorage>(std::move(buffer));
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called, size={}", size);
|
2018-06-03 11:19:24 -07:00
|
|
|
}
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
IApplicationFunctions::IApplicationFunctions() : ServiceFramework("IApplicationFunctions") {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-02-02 13:03:40 -08:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{10, nullptr, "CreateApplicationAndPushAndRequestToStart"},
|
|
|
|
{11, nullptr, "CreateApplicationAndPushAndRequestToStartForQuest"},
|
|
|
|
{12, nullptr, "CreateApplicationAndRequestToStart"},
|
2018-10-21 13:40:17 -07:00
|
|
|
{13, &IApplicationFunctions::CreateApplicationAndRequestToStartForQuest, "CreateApplicationAndRequestToStartForQuest"},
|
2018-02-05 17:58:11 -08:00
|
|
|
{20, &IApplicationFunctions::EnsureSaveData, "EnsureSaveData"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{21, &IApplicationFunctions::GetDesiredLanguage, "GetDesiredLanguage"},
|
|
|
|
{22, &IApplicationFunctions::SetTerminateResult, "SetTerminateResult"},
|
2018-05-25 21:21:03 -07:00
|
|
|
{23, &IApplicationFunctions::GetDisplayVersion, "GetDisplayVersion"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{24, nullptr, "GetLaunchStorageInfoForDebug"},
|
|
|
|
{25, nullptr, "ExtendSaveData"},
|
|
|
|
{26, nullptr, "GetSaveDataSize"},
|
2018-10-21 13:40:17 -07:00
|
|
|
{30, &IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed, "BeginBlockingHomeButtonShortAndLongPressed"},
|
|
|
|
{31, &IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed, "EndBlockingHomeButtonShortAndLongPressed"},
|
2018-10-19 06:01:10 -07:00
|
|
|
{32, &IApplicationFunctions::BeginBlockingHomeButton, "BeginBlockingHomeButton"},
|
|
|
|
{33, &IApplicationFunctions::EndBlockingHomeButton, "EndBlockingHomeButton"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{40, &IApplicationFunctions::NotifyRunning, "NotifyRunning"},
|
2018-06-05 15:44:01 -07:00
|
|
|
{50, &IApplicationFunctions::GetPseudoDeviceId, "GetPseudoDeviceId"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{60, nullptr, "SetMediaPlaybackStateForApplication"},
|
|
|
|
{65, nullptr, "IsGamePlayRecordingSupported"},
|
2018-02-02 13:03:40 -08:00
|
|
|
{66, &IApplicationFunctions::InitializeGamePlayRecording, "InitializeGamePlayRecording"},
|
|
|
|
{67, &IApplicationFunctions::SetGamePlayRecordingState, "SetGamePlayRecordingState"},
|
2018-04-10 08:36:00 -07:00
|
|
|
{68, nullptr, "RequestFlushGamePlayingMovieForDebug"},
|
|
|
|
{70, nullptr, "RequestToShutdown"},
|
|
|
|
{71, nullptr, "RequestToReboot"},
|
|
|
|
{80, nullptr, "ExitAndRequestToShowThanksMessage"},
|
|
|
|
{90, nullptr, "EnableApplicationCrashReport"},
|
|
|
|
{100, nullptr, "InitializeApplicationCopyrightFrameBuffer"},
|
|
|
|
{101, nullptr, "SetApplicationCopyrightImage"},
|
|
|
|
{102, nullptr, "SetApplicationCopyrightVisibility"},
|
|
|
|
{110, nullptr, "QueryApplicationPlayStatistics"},
|
|
|
|
{120, nullptr, "ExecuteProgram"},
|
|
|
|
{121, nullptr, "ClearUserChannel"},
|
|
|
|
{122, nullptr, "UnpopToUserChannel"},
|
|
|
|
{500, nullptr, "StartContinuousRecordingFlushForDebug"},
|
|
|
|
{1000, nullptr, "CreateMovieMaker"},
|
|
|
|
{1001, nullptr, "PrepareForJit"},
|
2018-02-02 13:03:40 -08:00
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
IApplicationFunctions::~IApplicationFunctions() = default;
|
|
|
|
|
2018-10-19 06:01:10 -07:00
|
|
|
void IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed(
|
|
|
|
Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed(
|
|
|
|
Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::BeginBlockingHomeButton(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::EndBlockingHomeButton(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
|
2018-10-13 10:02:33 -07:00
|
|
|
LaunchParameters params{};
|
2018-10-09 18:49:29 -07:00
|
|
|
|
2018-10-13 10:02:33 -07:00
|
|
|
params.magic = POP_LAUNCH_PARAMETER_MAGIC;
|
|
|
|
params.is_account_selected = 1;
|
2018-10-10 18:49:20 -07:00
|
|
|
|
|
|
|
Account::ProfileManager profile_manager{};
|
2018-10-13 10:02:33 -07:00
|
|
|
const auto uuid = profile_manager.GetUser(Settings::values.current_user);
|
2018-10-29 21:03:25 -07:00
|
|
|
ASSERT(uuid);
|
2018-10-13 10:02:33 -07:00
|
|
|
params.current_user = uuid->uuid;
|
2018-02-02 13:03:40 -08:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-10-13 10:02:33 -07:00
|
|
|
|
|
|
|
std::vector<u8> buffer(sizeof(LaunchParameters));
|
|
|
|
std::memcpy(buffer.data(), ¶ms, buffer.size());
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
rb.PushIpcInterface<AM::IStorage>(buffer);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
void IApplicationFunctions::CreateApplicationAndRequestToStartForQuest(
|
|
|
|
Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-05-07 08:27:30 -07:00
|
|
|
}
|
|
|
|
|
2018-02-05 17:58:11 -08:00
|
|
|
void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
|
2018-03-04 10:03:58 -08:00
|
|
|
IPC::RequestParser rp{ctx};
|
2018-07-17 12:42:15 -07:00
|
|
|
u128 uid = rp.PopRaw<u128>(); // What does this do?
|
2018-03-04 10:03:58 -08:00
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service, "(STUBBED) called uid = {:016X}{:016X}", uid[1], uid[0]);
|
2018-03-04 10:03:58 -08:00
|
|
|
|
2018-02-18 15:09:52 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-07-17 12:42:15 -07:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-02-18 15:09:52 -08:00
|
|
|
rb.Push<u64>(0);
|
2018-07-17 12:42:15 -07:00
|
|
|
} // namespace Service::AM
|
2018-02-05 17:58:11 -08:00
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) {
|
|
|
|
// Takes an input u32 Result, no output.
|
|
|
|
// For example, in some cases official apps use this with error 0x2A2 then uses svcBreak.
|
|
|
|
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
u32 result = rp.Pop<u32>();
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called, result=0x{:08X}", result);
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
2018-05-25 21:21:03 -07:00
|
|
|
void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 6};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u64>(1);
|
|
|
|
rb.Push<u64>(0);
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-05-25 21:21:03 -07:00
|
|
|
}
|
|
|
|
|
2018-02-02 13:03:40 -08:00
|
|
|
void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
|
2018-04-28 17:30:53 -07:00
|
|
|
// TODO(bunnei): This should be configurable
|
2018-02-02 13:03:40 -08:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-08-03 08:02:55 -07:00
|
|
|
rb.Push(
|
|
|
|
static_cast<u64>(Service::Set::GetLanguageCodeFromIndex(Settings::values.language_index)));
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u8>(0); // Unknown, seems to be ignored by official processes
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 13:03:40 -08:00
|
|
|
}
|
|
|
|
|
2018-06-05 15:44:01 -07:00
|
|
|
void IApplicationFunctions::GetPseudoDeviceId(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 6};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
// Returns a 128-bit UUID
|
|
|
|
rb.Push<u64>(0);
|
|
|
|
rb.Push<u64>(0);
|
|
|
|
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-06-05 15:44:01 -07:00
|
|
|
}
|
|
|
|
|
2018-01-22 10:46:36 -08:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager,
|
|
|
|
std::shared_ptr<NVFlinger::NVFlinger> nvflinger) {
|
2018-11-06 23:01:33 -08:00
|
|
|
auto message_queue = std::make_shared<AppletMessageQueue>();
|
|
|
|
message_queue->PushMessage(
|
|
|
|
AppletMessageQueue::AppletMessage::FocusStateChanged); // Needed on game boot
|
|
|
|
|
|
|
|
std::make_shared<AppletAE>(nvflinger, message_queue)->InstallAsService(service_manager);
|
|
|
|
std::make_shared<AppletOE>(nvflinger, message_queue)->InstallAsService(service_manager);
|
2018-07-31 04:01:49 -07:00
|
|
|
std::make_shared<IdleSys>()->InstallAsService(service_manager);
|
|
|
|
std::make_shared<OMM>()->InstallAsService(service_manager);
|
|
|
|
std::make_shared<SPSM>()->InstallAsService(service_manager);
|
2018-10-21 13:48:58 -07:00
|
|
|
std::make_shared<TCAP>()->InstallAsService(service_manager);
|
2017-10-14 19:50:04 -07:00
|
|
|
}
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
IHomeMenuFunctions::IHomeMenuFunctions() : ServiceFramework("IHomeMenuFunctions") {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-05-07 08:27:30 -07:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"},
|
|
|
|
{11, nullptr, "LockForeground"},
|
|
|
|
{12, nullptr, "UnlockForeground"},
|
|
|
|
{20, nullptr, "PopFromGeneralChannel"},
|
|
|
|
{21, nullptr, "GetPopFromGeneralChannelEvent"},
|
|
|
|
{30, nullptr, "GetHomeButtonWriterLockAccessor"},
|
|
|
|
{31, nullptr, "GetWriterLockAccessorEx"},
|
2018-10-21 13:40:17 -07:00
|
|
|
{100, nullptr, "PopRequestLaunchApplicationForDebug"},
|
2018-05-07 08:27:30 -07:00
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
IHomeMenuFunctions::~IHomeMenuFunctions() = default;
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-07-02 09:13:26 -07:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-05-07 08:27:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
IGlobalStateController::IGlobalStateController() : ServiceFramework("IGlobalStateController") {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-05-07 08:27:30 -07:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "RequestToEnterSleep"},
|
|
|
|
{1, nullptr, "EnterSleep"},
|
|
|
|
{2, nullptr, "StartSleepSequence"},
|
|
|
|
{3, nullptr, "StartShutdownSequence"},
|
|
|
|
{4, nullptr, "StartRebootSequence"},
|
|
|
|
{10, nullptr, "LoadAndApplyIdlePolicySettings"},
|
|
|
|
{11, nullptr, "NotifyCecSettingsChanged"},
|
|
|
|
{12, nullptr, "SetDefaultHomeButtonLongPressTime"},
|
|
|
|
{13, nullptr, "UpdateDefaultDisplayResolution"},
|
|
|
|
{14, nullptr, "ShouldSleepOnBoot"},
|
|
|
|
{15, nullptr, "GetHdcpAuthenticationFailedEvent"},
|
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
IGlobalStateController::~IGlobalStateController() = default;
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
IApplicationCreator::IApplicationCreator() : ServiceFramework("IApplicationCreator") {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-05-07 08:27:30 -07:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "CreateApplication"},
|
|
|
|
{1, nullptr, "PopLaunchRequestedApplication"},
|
|
|
|
{10, nullptr, "CreateSystemApplication"},
|
|
|
|
{100, nullptr, "PopFloatingApplicationForDevelopment"},
|
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
IApplicationCreator::~IApplicationCreator() = default;
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
IProcessWindingController::IProcessWindingController()
|
|
|
|
: ServiceFramework("IProcessWindingController") {
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format off
|
2018-05-07 08:27:30 -07:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, nullptr, "GetLaunchReason"},
|
|
|
|
{11, nullptr, "OpenCallingLibraryApplet"},
|
|
|
|
{21, nullptr, "PushContext"},
|
|
|
|
{22, nullptr, "PopContext"},
|
|
|
|
{23, nullptr, "CancelWindingReservation"},
|
|
|
|
{30, nullptr, "WindAndDoReserved"},
|
|
|
|
{40, nullptr, "ReserveToStartAndWaitAndUnwindThis"},
|
|
|
|
{41, nullptr, "ReserveToStartAndWait"},
|
|
|
|
};
|
2018-10-21 13:40:17 -07:00
|
|
|
// clang-format on
|
|
|
|
|
2018-05-07 08:27:30 -07:00
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-10 18:20:52 -07:00
|
|
|
|
|
|
|
IProcessWindingController::~IProcessWindingController() = default;
|
2018-04-19 18:41:44 -07:00
|
|
|
} // namespace Service::AM
|