2018-01-13 21:22:39 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-10-15 02:50:04 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-03-04 18:03:58 +00:00
|
|
|
#include <cinttypes>
|
|
|
|
#include "core/file_sys/filesystem.h"
|
2018-02-02 21:03:40 +00:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
|
|
|
#include "core/hle/kernel/event.h"
|
2017-10-15 02:50:04 +00:00
|
|
|
#include "core/hle/service/am/am.h"
|
2018-02-02 21:03:40 +00:00
|
|
|
#include "core/hle/service/am/applet_ae.h"
|
2017-10-15 02:50:04 +00:00
|
|
|
#include "core/hle/service/am/applet_oe.h"
|
2018-02-02 21:03:40 +00:00
|
|
|
#include "core/hle/service/apm/apm.h"
|
2018-03-04 18:03:58 +00:00
|
|
|
#include "core/hle/service/filesystem/filesystem.h"
|
2018-02-02 21:03:40 +00:00
|
|
|
#include "core/hle/service/nvflinger/nvflinger.h"
|
2018-03-27 02:24:31 +00:00
|
|
|
#include "core/settings.h"
|
2017-10-15 02:50:04 +00:00
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
namespace Service::AM {
|
2017-10-15 02:50:04 +00:00
|
|
|
|
2018-02-02 21:03:40 +00:00
|
|
|
IWindowController::IWindowController() : ServiceFramework("IWindowController") {
|
|
|
|
static const FunctionInfo functions[] = {
|
2018-04-10 15:36:00 +00:00
|
|
|
{0, nullptr, "CreateWindow"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{1, &IWindowController::GetAppletResourceUserId, "GetAppletResourceUserId"},
|
|
|
|
{10, &IWindowController::AcquireForegroundRights, "AcquireForegroundRights"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{11, nullptr, "ReleaseForegroundRights"},
|
|
|
|
{12, nullptr, "RejectToChangeIntoBackground"},
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u64>(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) {
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-02-22 14:28:15 +00: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(volume);
|
|
|
|
}
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
IDisplayController::IDisplayController() : ServiceFramework("IDisplayController") {}
|
|
|
|
|
|
|
|
IDebugFunctions::IDebugFunctions() : ServiceFramework("IDebugFunctions") {}
|
|
|
|
|
|
|
|
ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
|
|
|
|
: ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger)) {
|
|
|
|
static const FunctionInfo functions[] = {
|
2018-04-10 15:36:00 +00:00
|
|
|
{0, nullptr, "Exit"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{1, &ISelfController::LockExit, "LockExit"},
|
|
|
|
{2, &ISelfController::UnlockExit, "UnlockExit"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{3, nullptr, "EnterFatalSection"},
|
|
|
|
{4, nullptr, "LeaveFatalSection"},
|
2018-02-07 12:11:17 +00:00
|
|
|
{9, &ISelfController::GetLibraryAppletLaunchableEvent, "GetLibraryAppletLaunchableEvent"},
|
2018-02-22 10:04:23 +00:00
|
|
|
{10, &ISelfController::SetScreenShotPermission, "SetScreenShotPermission"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{11, &ISelfController::SetOperationModeChangedNotification,
|
|
|
|
"SetOperationModeChangedNotification"},
|
|
|
|
{12, &ISelfController::SetPerformanceModeChangedNotification,
|
|
|
|
"SetPerformanceModeChangedNotification"},
|
|
|
|
{13, &ISelfController::SetFocusHandlingMode, "SetFocusHandlingMode"},
|
|
|
|
{14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{15, nullptr, "SetScreenShotAppletIdentityInfo"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{17, nullptr, "SetControllerFirmwareUpdateSection"},
|
|
|
|
{18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"},
|
|
|
|
{19, nullptr, "SetScreenShotImageOrientation"},
|
|
|
|
{20, nullptr, "SetDesirableKeyboardLayout"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{41, nullptr, "IsSystemBufferSharingEnabled"},
|
|
|
|
{42, nullptr, "GetSystemSharedLayerHandle"},
|
|
|
|
{50, nullptr, "SetHandlesRequestToDisplay"},
|
|
|
|
{51, nullptr, "ApproveToDisplay"},
|
|
|
|
{60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"},
|
|
|
|
{61, nullptr, "SetMediaPlaybackState"},
|
|
|
|
{62, nullptr, "SetIdleTimeDetectionExtension"},
|
|
|
|
{63, nullptr, "GetIdleTimeDetectionExtension"},
|
2018-04-11 11:48:56 +00:00
|
|
|
{64, nullptr, "SetInputDetectionSourceSet"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{65, nullptr, "ReportUserIsActive"},
|
|
|
|
{66, nullptr, "GetCurrentIlluminance"},
|
|
|
|
{67, nullptr, "IsIlluminanceAvailable"},
|
|
|
|
{68, nullptr, "SetAutoSleepDisabled"},
|
|
|
|
{69, nullptr, "IsAutoSleepDisabled"},
|
|
|
|
{70, nullptr, "ReportMultimediaError"},
|
|
|
|
{80, nullptr, "SetWirelessPriorityMode"},
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
2018-02-07 12:11:17 +00:00
|
|
|
|
|
|
|
launchable_event =
|
|
|
|
Kernel::Event::Create(Kernel::ResetType::OneShot, "ISelfController:LaunchableEvent");
|
2018-02-02 21:03:40 +00: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-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00: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-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called flag=%u", static_cast<u32>(flag));
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 10:04:23 +00:00
|
|
|
void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00: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-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called flag=%u", static_cast<u32>(flag));
|
2018-02-02 21:03:40 +00: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-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called enabled=%u", static_cast<u32>(enabled));
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 12:11:17 +00:00
|
|
|
void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
launchable_event->Signal();
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(launchable_event);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00: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-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ICommonStateGetter::ICommonStateGetter() : ServiceFramework("ICommonStateGetter") {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &ICommonStateGetter::GetEventHandle, "GetEventHandle"},
|
|
|
|
{1, &ICommonStateGetter::ReceiveMessage, "ReceiveMessage"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{2, nullptr, "GetThisAppletKind"},
|
|
|
|
{3, nullptr, "AllowToEnterSleep"},
|
|
|
|
{4, nullptr, "DisallowToEnterSleep"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{5, &ICommonStateGetter::GetOperationMode, "GetOperationMode"},
|
|
|
|
{6, &ICommonStateGetter::GetPerformanceMode, "GetPerformanceMode"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{7, nullptr, "GetCradleStatus"},
|
|
|
|
{8, nullptr, "GetBootMode"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{9, &ICommonStateGetter::GetCurrentFocusState, "GetCurrentFocusState"},
|
2018-04-10 15:36:00 +00: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"},
|
|
|
|
{60, nullptr, "GetDefaultDisplayResolution"},
|
|
|
|
{61, nullptr, "GetDefaultDisplayResolutionChangeEvent"},
|
|
|
|
{62, nullptr, "GetHdcpAuthenticationState"},
|
|
|
|
{63, nullptr, "GetHdcpAuthenticationStateChangeEvent"},
|
2018-02-02 21:03:40 +00:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
|
|
|
|
event = Kernel::Event::Create(Kernel::ResetType::OneShot, "ICommonStateGetter:Event");
|
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) {
|
|
|
|
event->Signal();
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushCopyObjects(event);
|
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(15);
|
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push(static_cast<u8>(FocusState::InFocus));
|
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
|
2018-03-27 02:59:18 +00:00
|
|
|
const bool use_docked_mode{Settings::values.use_docked_mode};
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-03-27 02:59:18 +00:00
|
|
|
rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld));
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
|
2018-03-27 02:59:18 +00:00
|
|
|
const bool use_docked_mode{Settings::values.use_docked_mode};
|
2018-02-02 21:03:40 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-03-27 02:59:18 +00:00
|
|
|
rb.Push(static_cast<u32>(use_docked_mode ? APM::PerformanceMode::Docked
|
|
|
|
: APM::PerformanceMode::Handheld));
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-07 12:11:17 +00:00
|
|
|
class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> {
|
|
|
|
public:
|
|
|
|
explicit ILibraryAppletAccessor() : ServiceFramework("ILibraryAppletAccessor") {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
|
|
|
|
{1, nullptr, "IsCompleted"},
|
|
|
|
{10, nullptr, "Start"},
|
|
|
|
{20, nullptr, "RequestExit"},
|
|
|
|
{25, nullptr, "Terminate"},
|
|
|
|
{30, nullptr, "GetResult"},
|
|
|
|
{50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"},
|
|
|
|
{100, nullptr, "PushInData"},
|
|
|
|
{101, nullptr, "PopOutData"},
|
|
|
|
{102, nullptr, "PushExtraStorage"},
|
|
|
|
{103, nullptr, "PushInteractiveInData"},
|
|
|
|
{104, nullptr, "PopInteractiveOutData"},
|
|
|
|
{105, nullptr, "GetPopOutDataEvent"},
|
|
|
|
{106, nullptr, "GetPopInteractiveOutDataEvent"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{110, nullptr, "NeedsToExitProcess"},
|
2018-02-07 12:11:17 +00:00
|
|
|
{120, nullptr, "GetLibraryAppletInfo"},
|
|
|
|
{150, nullptr, "RequestForAppletToGetForeground"},
|
|
|
|
{160, nullptr, "GetIndirectLayerConsumerHandle"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
|
|
|
|
state_changed_event = Kernel::Event::Create(Kernel::ResetType::OneShot,
|
|
|
|
"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);
|
|
|
|
|
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
|
|
|
}
|
|
|
|
|
|
|
|
Kernel::SharedPtr<Kernel::Event> state_changed_event;
|
|
|
|
};
|
|
|
|
|
|
|
|
ILibraryAppletCreator::ILibraryAppletCreator() : ServiceFramework("ILibraryAppletCreator") {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"},
|
|
|
|
{1, nullptr, "TerminateAllLibraryApplets"},
|
|
|
|
{2, nullptr, "AreAnyLibraryAppletsLeft"},
|
|
|
|
{10, nullptr, "CreateStorage"},
|
|
|
|
{11, nullptr, "CreateTransferMemoryStorage"},
|
|
|
|
{12, nullptr, "CreateHandleStorage"},
|
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<AM::ILibraryAppletAccessor>();
|
|
|
|
|
|
|
|
LOG_DEBUG(Service_AM, "called");
|
|
|
|
}
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
class IStorageAccessor final : public ServiceFramework<IStorageAccessor> {
|
|
|
|
public:
|
|
|
|
explicit IStorageAccessor(std::vector<u8> buffer)
|
|
|
|
: ServiceFramework("IStorageAccessor"), buffer(std::move(buffer)) {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IStorageAccessor::GetSize, "GetSize"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{10, nullptr, "Write"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{11, &IStorageAccessor::Read, "Read"},
|
|
|
|
};
|
|
|
|
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-02-04 21:58:12 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Read(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
|
|
|
|
u64 offset = rp.Pop<u64>();
|
|
|
|
|
2018-02-14 04:16:19 +00:00
|
|
|
const size_t size{ctx.GetWriteBufferSize()};
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-02-14 04:16:19 +00:00
|
|
|
ASSERT(offset + size <= buffer.size());
|
2018-02-02 21:03:40 +00:00
|
|
|
|
2018-02-14 04:16:19 +00:00
|
|
|
ctx.WriteBuffer(buffer.data() + offset, size);
|
2018-02-02 21:03:40 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class IStorage final : public ServiceFramework<IStorage> {
|
|
|
|
public:
|
|
|
|
explicit IStorage(std::vector<u8> buffer)
|
|
|
|
: ServiceFramework("IStorage"), buffer(std::move(buffer)) {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IStorage::Open, "Open"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{1, nullptr, "OpenTransferStorage"},
|
2018-02-02 21:03:40 +00: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-02-04 21:58:12 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
IApplicationFunctions::IApplicationFunctions() : ServiceFramework("IApplicationFunctions") {
|
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{10, nullptr, "CreateApplicationAndPushAndRequestToStart"},
|
|
|
|
{11, nullptr, "CreateApplicationAndPushAndRequestToStartForQuest"},
|
|
|
|
{12, nullptr, "CreateApplicationAndRequestToStart"},
|
|
|
|
{13, nullptr, "CreateApplicationAndRequestToStartForQuest"},
|
2018-02-06 01:58:11 +00:00
|
|
|
{20, &IApplicationFunctions::EnsureSaveData, "EnsureSaveData"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{21, &IApplicationFunctions::GetDesiredLanguage, "GetDesiredLanguage"},
|
|
|
|
{22, &IApplicationFunctions::SetTerminateResult, "SetTerminateResult"},
|
2018-04-10 15:36:00 +00:00
|
|
|
{23, nullptr, "GetDisplayVersion"},
|
|
|
|
{24, nullptr, "GetLaunchStorageInfoForDebug"},
|
|
|
|
{25, nullptr, "ExtendSaveData"},
|
|
|
|
{26, nullptr, "GetSaveDataSize"},
|
|
|
|
{30, nullptr, "BeginBlockingHomeButtonShortAndLongPressed"},
|
|
|
|
{31, nullptr, "EndBlockingHomeButtonShortAndLongPressed"},
|
|
|
|
{32, nullptr, "BeginBlockingHomeButton"},
|
|
|
|
{33, nullptr, "EndBlockingHomeButton"},
|
|
|
|
{40, &IApplicationFunctions::NotifyRunning, "NotifyRunning"},
|
|
|
|
{50, nullptr, "GetPseudoDeviceId"},
|
|
|
|
{60, nullptr, "SetMediaPlaybackStateForApplication"},
|
|
|
|
{65, nullptr, "IsGamePlayRecordingSupported"},
|
2018-02-02 21:03:40 +00:00
|
|
|
{66, &IApplicationFunctions::InitializeGamePlayRecording, "InitializeGamePlayRecording"},
|
|
|
|
{67, &IApplicationFunctions::SetGamePlayRecordingState, "SetGamePlayRecordingState"},
|
2018-04-10 15:36:00 +00: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 21:03:40 +00:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
|
|
|
|
constexpr u8 data[0x88] = {
|
|
|
|
0xca, 0x97, 0x94, 0xc7, // Magic
|
|
|
|
1, 0, 0, 0, // IsAccountSelected (bool)
|
|
|
|
1, 0, 0, 0, // User Id (word 0)
|
|
|
|
0, 0, 0, 0, // User Id (word 1)
|
|
|
|
0, 0, 0, 0, // User Id (word 2)
|
|
|
|
0, 0, 0, 0 // User Id (word 3)
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<u8> buffer(data, data + sizeof(data));
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
|
|
|
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushIpcInterface<AM::IStorage>(buffer);
|
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_DEBUG(Service_AM, "called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-06 01:58:11 +00:00
|
|
|
void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
|
2018-03-04 18:03:58 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
u128 uid = rp.PopRaw<u128>();
|
|
|
|
|
|
|
|
LOG_WARNING(Service, "(STUBBED) called uid = %016" PRIX64 "%016" PRIX64, uid[1], uid[0]);
|
|
|
|
|
2018-02-18 23:09:52 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
2018-03-04 18:03:58 +00:00
|
|
|
|
|
|
|
FileSys::Path unused;
|
|
|
|
auto savedata = FileSystem::OpenFileSystem(FileSystem::Type::SaveData, unused);
|
|
|
|
if (savedata.Failed()) {
|
|
|
|
// Create the save data and return an error indicating that the operation was performed.
|
|
|
|
FileSystem::FormatFileSystem(FileSystem::Type::SaveData);
|
|
|
|
// TODO(Subv): Find out the correct error code for this.
|
|
|
|
rb.Push(ResultCode(ErrorModule::FS, 40));
|
|
|
|
} else {
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-02-18 23:09:52 +00:00
|
|
|
rb.Push<u64>(0);
|
2018-02-06 01:58:11 +00:00
|
|
|
}
|
|
|
|
|
2018-02-02 21:03:40 +00: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-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called, result=0x%08X", result);
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 4};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u64>(SystemLanguage::English);
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IApplicationFunctions::SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
|
2018-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00: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-02-04 21:58:12 +00:00
|
|
|
LOG_WARNING(Service_AM, "(STUBBED) called");
|
2018-02-02 21:03:40 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 18:46:36 +00:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager,
|
|
|
|
std::shared_ptr<NVFlinger::NVFlinger> nvflinger) {
|
2018-02-02 21:03:40 +00:00
|
|
|
std::make_shared<AppletAE>(nvflinger)->InstallAsService(service_manager);
|
2018-01-22 18:46:36 +00:00
|
|
|
std::make_shared<AppletOE>(nvflinger)->InstallAsService(service_manager);
|
2017-10-15 02:50:04 +00:00
|
|
|
}
|
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
} // namespace Service::AM
|