Merge branch 'am-add-new-functions-services' into 'master'

core/hle: Implement all missing AM (Applet Manager) service functions

See merge request citron/rewrite!29
This commit is contained in:
Zephyron
2025-07-01 07:54:43 +00:00
14 changed files with 704 additions and 23 deletions

View File

@@ -489,6 +489,8 @@ add_library(core STATIC
hle/service/am/service/library_applet_self_accessor.h
hle/service/am/service/lock_accessor.cpp
hle/service/am/service/lock_accessor.h
hle/service/am/service/overlay_applet_proxy.cpp
hle/service/am/service/overlay_applet_proxy.h
hle/service/am/service/process_winding_controller.cpp
hle/service/am/service/process_winding_controller.h
hle/service/am/service/self_controller.cpp
@@ -499,6 +501,8 @@ add_library(core STATIC
hle/service/am/service/storage_accessor.h
hle/service/am/service/system_applet_proxy.cpp
hle/service/am/service/system_applet_proxy.h
hle/service/am/service/system_application_proxy.cpp
hle/service/am/service/system_application_proxy.h
hle/service/am/service/window_controller.cpp
hle/service/am/service/window_controller.h
hle/service/am/window_system.cpp

View File

@@ -1,11 +1,16 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/core.h"
#include "core/hle/service/am/applet_manager.h"
#include "core/hle/service/am/service/all_system_applet_proxies_service.h"
#include "core/hle/service/am/service/debug_functions.h"
#include "core/hle/service/am/service/library_applet_creator.h"
#include "core/hle/service/am/service/library_applet_proxy.h"
#include "core/hle/service/am/service/overlay_applet_proxy.h"
#include "core/hle/service/am/service/system_applet_proxy.h"
#include "core/hle/service/am/service/system_application_proxy.h"
#include "core/hle/service/am/window_system.h"
#include "core/hle/service/cmif_serialization.h"
@@ -19,11 +24,11 @@ IAllSystemAppletProxiesService::IAllSystemAppletProxiesService(Core::System& sys
{100, D<&IAllSystemAppletProxiesService::OpenSystemAppletProxy>, "OpenSystemAppletProxy"},
{200, D<&IAllSystemAppletProxiesService::OpenLibraryAppletProxyOld>, "OpenLibraryAppletProxyOld"},
{201, D<&IAllSystemAppletProxiesService::OpenLibraryAppletProxy>, "OpenLibraryAppletProxy"},
{300, nullptr, "OpenOverlayAppletProxy"},
{350, nullptr, "OpenSystemApplicationProxy"},
{400, nullptr, "CreateSelfLibraryAppletCreatorForDevelop"},
{410, nullptr, "GetSystemAppletControllerForDebug"},
{1000, nullptr, "GetDebugFunctions"},
{300, D<&IAllSystemAppletProxiesService::OpenOverlayAppletProxy>, "OpenOverlayAppletProxy"},
{350, D<&IAllSystemAppletProxiesService::OpenSystemApplicationProxy>, "OpenSystemApplicationProxy"},
{400, D<&IAllSystemAppletProxiesService::CreateSelfLibraryAppletCreatorForDevelop>, "CreateSelfLibraryAppletCreatorForDevelop"},
{410, D<&IAllSystemAppletProxiesService::GetSystemAppletControllerForDebug>, "GetSystemAppletControllerForDebug"},
{1000, D<&IAllSystemAppletProxiesService::GetDebugFunctions>, "GetDebugFunctions"},
};
// clang-format on
@@ -78,4 +83,58 @@ std::shared_ptr<Applet> IAllSystemAppletProxiesService::GetAppletFromProcessId(
return m_window_system.GetByAppletResourceUserId(process_id.pid);
}
Result IAllSystemAppletProxiesService::OpenOverlayAppletProxy(
Out<SharedPointer<IOverlayAppletProxy>> out_overlay_applet_proxy, ClientProcessId pid,
InCopyHandle<Kernel::KProcess> process_handle,
InLargeData<AppletAttribute, BufferAttr_HipcMapAlias> attribute) {
LOG_DEBUG(Service_AM, "called");
if (const auto applet = GetAppletFromProcessId(pid)) {
*out_overlay_applet_proxy = std::make_shared<IOverlayAppletProxy>(
system, applet, process_handle.Get(), m_window_system);
R_SUCCEED();
} else {
LOG_ERROR(Service_AM, "Applet doesn't exist for process_id={}", pid.pid);
R_THROW(ResultUnknown);
}
}
Result IAllSystemAppletProxiesService::OpenSystemApplicationProxy(
Out<SharedPointer<ISystemApplicationProxy>> out_system_application_proxy, ClientProcessId pid,
InCopyHandle<Kernel::KProcess> process_handle) {
LOG_DEBUG(Service_AM, "called");
if (const auto applet = GetAppletFromProcessId(pid)) {
*out_system_application_proxy = std::make_shared<ISystemApplicationProxy>(
system, applet, process_handle.Get(), m_window_system);
R_SUCCEED();
} else {
LOG_ERROR(Service_AM, "Applet doesn't exist for process_id={}", pid.pid);
R_THROW(ResultUnknown);
}
}
Result IAllSystemAppletProxiesService::CreateSelfLibraryAppletCreatorForDevelop(
Out<SharedPointer<ILibraryAppletCreator>> out_library_applet_creator, ClientProcessId pid,
InCopyHandle<Kernel::KProcess> process_handle) {
LOG_WARNING(Service_AM, "(STUBBED) called");
if (const auto applet = this->GetAppletFromProcessId(pid); applet) {
*out_library_applet_creator = std::make_shared<ILibraryAppletCreator>(system, applet, m_window_system);
R_SUCCEED();
} else {
R_THROW(ResultUnknown);
}
}
Result IAllSystemAppletProxiesService::GetSystemAppletControllerForDebug() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_THROW(ResultUnknown);
}
Result IAllSystemAppletProxiesService::GetDebugFunctions(
Out<SharedPointer<IDebugFunctions>> out_debug_functions) {
LOG_DEBUG(Service_AM, "called");
*out_debug_functions = std::make_shared<IDebugFunctions>(system);
R_SUCCEED();
}
} // namespace Service::AM

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -12,8 +13,12 @@ namespace AM {
struct Applet;
struct AppletAttribute;
class IDebugFunctions;
class ILibraryAppletCreator;
class ILibraryAppletProxy;
class IOverlayAppletProxy;
class ISystemAppletProxy;
class ISystemApplicationProxy;
class WindowSystem;
class IAllSystemAppletProxiesService final
@@ -33,6 +38,18 @@ private:
Result OpenLibraryAppletProxyOld(
Out<SharedPointer<ILibraryAppletProxy>> out_library_applet_proxy, ClientProcessId pid,
InCopyHandle<Kernel::KProcess> process_handle);
Result OpenOverlayAppletProxy(Out<SharedPointer<IOverlayAppletProxy>> out_overlay_applet_proxy,
ClientProcessId pid,
InCopyHandle<Kernel::KProcess> process_handle,
InLargeData<AppletAttribute, BufferAttr_HipcMapAlias> attribute);
Result OpenSystemApplicationProxy(Out<SharedPointer<ISystemApplicationProxy>> out_system_application_proxy,
ClientProcessId pid,
InCopyHandle<Kernel::KProcess> process_handle);
Result CreateSelfLibraryAppletCreatorForDevelop(Out<SharedPointer<ILibraryAppletCreator>> out_library_applet_creator,
ClientProcessId pid,
InCopyHandle<Kernel::KProcess> process_handle);
Result GetSystemAppletControllerForDebug();
Result GetDebugFunctions(Out<SharedPointer<IDebugFunctions>> out_debug_functions);
private:
std::shared_ptr<Applet> GetAppletFromProcessId(ProcessId pid);

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/settings.h"
@@ -85,7 +86,31 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_, std::shared_
{181, nullptr, "UpgradeLaunchRequiredVersion"},
{190, nullptr, "SendServerMaintenanceOverlayNotification"},
{200, nullptr, "GetLastApplicationExitReason"},
{210, nullptr, "GetLaunchRequiredVersionUpgrade"},
{211, nullptr, "GetLaunchRequiredVersionUpgradeStatus"},
{300, nullptr, "RequestToLaunchApplication"},
{301, nullptr, "RequestToLaunchApplicationWithUserAndArguments"},
{310, nullptr, "RequestToLaunchApplicationWithArgumentsAndUserSelectionAndError"},
{350, nullptr, "DeclareApplicationAlive"},
{400, nullptr, "CreateApplicationResourceUsageSystemReportForDebug"},
{401, nullptr, "WriteApplicationResourceUsageSystemReportForDebug"},
{410, nullptr, "SetApplicationMemoryReservation"},
{450, nullptr, "CreateApplicationForDevelop"},
{460, nullptr, "GetApplicationControlProperty"},
{461, nullptr, "GetApplicationDesiredLanguage"},
{470, nullptr, "SetApplicationTerminateResult"},
{480, nullptr, "GetApplicationRightsOnClient"},
{490, nullptr, "GetApplicationCertificate"},
{500, nullptr, "StartContinuousRecordingFlushForDebug"},
{510, nullptr, "SetApplicationAliveCheckTimeoutEnabled"},
{600, nullptr, "CreateApplicationAliveChecker"},
{700, nullptr, "QueryApplicationPlayStatisticsForSystem"},
{701, nullptr, "QueryApplicationPlayStatisticsByUidForSystem"},
{702, nullptr, "QueryApplicationPlayStatisticsByPidForSystem"},
{900, nullptr, "CreateApplicationAttributeUpdater"},
{997, nullptr, "GetApplicationViewWithPromotionInfo"},
{998, nullptr, "GetApplicationView"},
{999, nullptr, "GetApplicationViewDeprecated"},
{1000, nullptr, "CreateMovieMaker"},
{1001, D<&IApplicationFunctions::PrepareForJit>, "PrepareForJit"},
};

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/settings.h"
@@ -69,7 +70,29 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
{501, nullptr, "SuppressDisablingSleepTemporarily"},
{502, nullptr, "IsSleepEnabled"},
{503, nullptr, "IsDisablingSleepSuppressed"},
{600, nullptr, "GetLaunchStorageInfoForDebug"},
{700, nullptr, "ExtendSaveData"},
{701, nullptr, "GetSaveDataSize"},
{800, nullptr, "CreateCacheStorage"},
{801, nullptr, "GetCacheStorageMax"},
{810, nullptr, "GetSaveDataSizeMax"},
{900, D<&ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled>, "SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled"},
{901, nullptr, "GetRequestExitToLibraryAppletAtExecuteNextProgramEnabled"},
{1000, nullptr, "GetRestartMessageEnabled"},
{1001, nullptr, "GetScreenShotPermission"},
{1010, nullptr, "GetNextProgramArgumentInfo"},
{1011, nullptr, "GetPreviousProgramArgumentInfo"},
{1020, nullptr, "GetGpuErrorDetectedSystemEvent"},
{1021, nullptr, "SetDelayTimeToAbortOnGpuError"},
{1030, nullptr, "GetFriendInvitationStorageChannelEvent"},
{1031, nullptr, "TryPopFromFriendInvitationStorageChannel"},
{1040, nullptr, "GetNotificationStorageChannelEvent"},
{1041, nullptr, "TryPopFromNotificationStorageChannel"},
{1050, nullptr, "GetHealthWarningDisappearedSystemEvent"},
{1060, nullptr, "SetHdcpAuthenticationActivated"},
{1061, nullptr, "GetLastForegroundCaptureImageEx"},
{1062, nullptr, "GetLastApplicationCaptureImageEx"},
{1063, nullptr, "GetLastApplicationCaptureImage"},
};
// clang-format on

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/service/cradle_firmware_updater.h"
@@ -12,19 +13,44 @@ IGlobalStateController::IGlobalStateController(Core::System& system_)
m_context{system_, "IGlobalStateController"}, m_hdcp_authentication_failed_event{m_context} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "RequestToEnterSleep"},
{1, nullptr, "EnterSleep"},
{2, nullptr, "StartSleepSequence"},
{3, nullptr, "StartShutdownSequence"},
{4, nullptr, "StartRebootSequence"},
{9, nullptr, "IsAutoPowerDownRequested"},
{0, D<&IGlobalStateController::RequestToEnterSleep>, "RequestToEnterSleep"},
{1, D<&IGlobalStateController::EnterSleep>, "EnterSleep"},
{2, D<&IGlobalStateController::StartSleepSequence>, "StartSleepSequence"},
{3, D<&IGlobalStateController::StartShutdownSequence>, "StartShutdownSequence"},
{4, D<&IGlobalStateController::StartRebootSequence>, "StartRebootSequence"},
{9, D<&IGlobalStateController::IsAutoPowerDownRequested>, "IsAutoPowerDownRequested"},
{10, D<&IGlobalStateController::LoadAndApplyIdlePolicySettings>, "LoadAndApplyIdlePolicySettings"},
{11, nullptr, "NotifyCecSettingsChanged"},
{12, nullptr, "SetDefaultHomeButtonLongPressTime"},
{13, nullptr, "UpdateDefaultDisplayResolution"},
{11, D<&IGlobalStateController::NotifyCecSettingsChanged>, "NotifyCecSettingsChanged"},
{12, D<&IGlobalStateController::SetDefaultHomeButtonLongPressTime>, "SetDefaultHomeButtonLongPressTime"},
{13, D<&IGlobalStateController::UpdateDefaultDisplayResolution>, "UpdateDefaultDisplayResolution"},
{14, D<&IGlobalStateController::ShouldSleepOnBoot>, "ShouldSleepOnBoot"},
{15, D<&IGlobalStateController::GetHdcpAuthenticationFailedEvent>, "GetHdcpAuthenticationFailedEvent"},
{30, D<&IGlobalStateController::OpenCradleFirmwareUpdater>, "OpenCradleFirmwareUpdater"},
{50, nullptr, "IsVrModeEnabled"},
{51, nullptr, "SetVrModeEnabled"},
{52, nullptr, "SetLcdBacklighOffEnabled"},
{53, nullptr, "BeginVrModeEx"},
{54, nullptr, "EndVrModeEx"},
{55, nullptr, "IsInControllerFirmwareUpdateSection"},
{60, nullptr, "SetWirelessPriorityMode"},
{61, nullptr, "GetWirelessPriorityMode"},
{62, nullptr, "GetAccumulatedSuspendedTickValue"},
{63, nullptr, "GetAccumulatedSuspendedTickChangedEvent"},
{64, nullptr, "SetAlarmTimeChangeEvent"},
{65, nullptr, "GetWakeupCount"},
{66, nullptr, "GetHomeButtonInputProtectionStartTime"},
{67, nullptr, "IsHomeButtonInputProtectionEnabled"},
{68, nullptr, "GetHomeButtonInputProtectionRemainingTime"},
{80, nullptr, "IsForceRebootDisabledOnBoot"},
{81, nullptr, "GetLastSleepReason"},
{82, nullptr, "GetLastWakeupReason"},
{90, nullptr, "GetRebootlessSystemUpdateVersion"},
{91, nullptr, "GetLastSystemButtonPressedTime"},
{100, nullptr, "GetAppletLaunchedCount"},
{110, nullptr, "GetSystemButtonPressedHistory"},
{200, nullptr, "GetOperationModeChangeHistory"},
{300, nullptr, "GetSleepRequiredVersion"},
{400, nullptr, "IsQuestRebootRequiredForFirmware"},
};
// clang-format on
@@ -58,4 +84,50 @@ Result IGlobalStateController::OpenCradleFirmwareUpdater(
R_SUCCEED();
}
Result IGlobalStateController::RequestToEnterSleep() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}
Result IGlobalStateController::EnterSleep() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}
Result IGlobalStateController::StartSleepSequence(bool sleep_requested) {
LOG_WARNING(Service_AM, "(STUBBED) called, sleep_requested={}", sleep_requested);
R_SUCCEED();
}
Result IGlobalStateController::StartShutdownSequence() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}
Result IGlobalStateController::StartRebootSequence() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}
Result IGlobalStateController::IsAutoPowerDownRequested(Out<bool> out_is_auto_power_down_requested) {
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_is_auto_power_down_requested = false;
R_SUCCEED();
}
Result IGlobalStateController::NotifyCecSettingsChanged() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}
Result IGlobalStateController::SetDefaultHomeButtonLongPressTime(s64 time) {
LOG_WARNING(Service_AM, "(STUBBED) called, time={}", time);
R_SUCCEED();
}
Result IGlobalStateController::UpdateDefaultDisplayResolution() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}
} // namespace Service::AM

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -18,7 +19,16 @@ public:
~IGlobalStateController() override;
private:
Result RequestToEnterSleep();
Result EnterSleep();
Result StartSleepSequence(bool sleep_requested);
Result StartShutdownSequence();
Result StartRebootSequence();
Result IsAutoPowerDownRequested(Out<bool> out_is_auto_power_down_requested);
Result LoadAndApplyIdlePolicySettings();
Result NotifyCecSettingsChanged();
Result SetDefaultHomeButtonLongPressTime(s64 time);
Result UpdateDefaultDisplayResolution();
Result ShouldSleepOnBoot(Out<bool> out_should_sleep_on_boot);
Result GetHdcpAuthenticationFailedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result OpenCradleFirmwareUpdater(

View File

@@ -1,9 +1,13 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/result.h"
#include "core/hle/service/am/am_results.h"
#include "core/hle/service/am/applet_manager.h"
#include "core/hle/service/am/service/home_menu_functions.h"
#include "core/hle/service/am/service/lock_accessor.h"
#include "core/hle/service/am/service/storage.h"
#include "core/hle/service/am/window_system.h"
#include "core/hle/service/cmif_serialization.h"
@@ -19,18 +23,35 @@ IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_, std::shared_ptr<Ap
{10, D<&IHomeMenuFunctions::RequestToGetForeground>, "RequestToGetForeground"},
{11, D<&IHomeMenuFunctions::LockForeground>, "LockForeground"},
{12, D<&IHomeMenuFunctions::UnlockForeground>, "UnlockForeground"},
{20, nullptr, "PopFromGeneralChannel"},
{20, D<&IHomeMenuFunctions::PopFromGeneralChannel>, "PopFromGeneralChannel"},
{21, D<&IHomeMenuFunctions::GetPopFromGeneralChannelEvent>, "GetPopFromGeneralChannelEvent"},
{30, nullptr, "GetHomeButtonWriterLockAccessor"},
{31, nullptr, "GetWriterLockAccessorEx"},
{40, nullptr, "IsSleepEnabled"},
{30, D<&IHomeMenuFunctions::GetHomeButtonWriterLockAccessor>, "GetHomeButtonWriterLockAccessor"},
{31, D<&IHomeMenuFunctions::GetWriterLockAccessorEx>, "GetWriterLockAccessorEx"},
{40, D<&IHomeMenuFunctions::IsSleepEnabled>, "IsSleepEnabled"},
{41, D<&IHomeMenuFunctions::IsRebootEnabled>, "IsRebootEnabled"},
{50, nullptr, "LaunchSystemApplet"},
{51, nullptr, "LaunchStarter"},
{100, nullptr, "PopRequestLaunchApplicationForDebug"},
{50, D<&IHomeMenuFunctions::LaunchSystemApplet>, "LaunchSystemApplet"},
{51, D<&IHomeMenuFunctions::LaunchStarter>, "LaunchStarter"},
{100, D<&IHomeMenuFunctions::PopRequestLaunchApplicationForDebug>, "PopRequestLaunchApplicationForDebug"},
{110, D<&IHomeMenuFunctions::IsForceTerminateApplicationDisabledForDebug>, "IsForceTerminateApplicationDisabledForDebug"},
{200, nullptr, "LaunchDevMenu"},
{1000, nullptr, "SetLastApplicationExitReason"},
{200, D<&IHomeMenuFunctions::LaunchDevMenu>, "LaunchDevMenu"},
{300, nullptr, "RebootSystem"},
{301, nullptr, "LaunchApplication"},
{310, nullptr, "LaunchApplicationWithStorageId"},
{400, nullptr, "GetLastFrontDockedTime"},
{401, nullptr, "GetLastFrontUndockedTime"},
{500, nullptr, "GetAppletLaunchedHistory"},
{501, nullptr, "ClearAppletLaunchedHistory"},
{502, nullptr, "ReloadHomeMenuAssets"},
{510, nullptr, "LaunchApplicationFromStorageManager"},
{600, nullptr, "GetScreenShotPermission"},
{610, nullptr, "UpdateLastForegroundCaptureImage"},
{611, nullptr, "UpdateLastApplicationCaptureImage"},
{700, nullptr, "ClearLastApplicationCaptureImageWithUserId"},
{800, nullptr, "TakeScreenShotOfOwnLayerEx"},
{810, nullptr, "OpenMyGpuErrorHandler"},
{900, nullptr, "GetAppletLaunchedHistoryForDebug"},
{910, nullptr, "CreateFloatingLibraryApplet"},
{1000, D<&IHomeMenuFunctions::SetLastApplicationExitReason>, "SetLastApplicationExitReason"},
};
// clang-format on
@@ -77,4 +98,55 @@ Result IHomeMenuFunctions::IsForceTerminateApplicationDisabledForDebug(
R_SUCCEED();
}
Result IHomeMenuFunctions::PopFromGeneralChannel(Out<SharedPointer<IStorage>> out_storage) {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_THROW(ResultNoDataInChannel);
}
Result IHomeMenuFunctions::GetHomeButtonWriterLockAccessor(
Out<SharedPointer<ILockAccessor>> out_lock_accessor) {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_THROW(ResultUnknown);
}
Result IHomeMenuFunctions::GetWriterLockAccessorEx(
Out<SharedPointer<ILockAccessor>> out_lock_accessor, u32 button_type) {
LOG_WARNING(Service_AM, "(STUBBED) called, button_type={}", button_type);
R_THROW(ResultUnknown);
}
Result IHomeMenuFunctions::IsSleepEnabled(Out<bool> out_is_sleep_enabled) {
LOG_INFO(Service_AM, "called");
*out_is_sleep_enabled = true;
R_SUCCEED();
}
Result IHomeMenuFunctions::LaunchSystemApplet(AppletId applet_id, u32 launch_mode,
SharedPointer<IStorage> storage) {
LOG_WARNING(Service_AM, "(STUBBED) called, applet_id={}, launch_mode={}", applet_id, launch_mode);
R_SUCCEED();
}
Result IHomeMenuFunctions::LaunchStarter() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}
Result IHomeMenuFunctions::PopRequestLaunchApplicationForDebug(
Out<u64> out_application_id, Out<SharedPointer<IStorage>> out_storage) {
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_application_id = 0;
R_THROW(ResultNoDataInChannel);
}
Result IHomeMenuFunctions::LaunchDevMenu() {
LOG_WARNING(Service_AM, "(STUBBED) called");
R_SUCCEED();
}
Result IHomeMenuFunctions::SetLastApplicationExitReason(s32 exit_reason) {
LOG_WARNING(Service_AM, "(STUBBED) called, exit_reason={}", exit_reason);
R_SUCCEED();
}
} // namespace Service::AM

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
@@ -11,6 +12,8 @@
namespace Service::AM {
struct Applet;
class ILockAccessor;
class IStorage;
class WindowSystem;
class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {
@@ -23,10 +26,19 @@ private:
Result RequestToGetForeground();
Result LockForeground();
Result UnlockForeground();
Result PopFromGeneralChannel(Out<SharedPointer<IStorage>> out_storage);
Result GetPopFromGeneralChannelEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result GetHomeButtonWriterLockAccessor(Out<SharedPointer<ILockAccessor>> out_lock_accessor);
Result GetWriterLockAccessorEx(Out<SharedPointer<ILockAccessor>> out_lock_accessor, u32 button_type);
Result IsSleepEnabled(Out<bool> out_is_sleep_enabled);
Result IsRebootEnabled(Out<bool> out_is_reboot_enbaled);
Result LaunchSystemApplet(AppletId applet_id, u32 launch_mode, SharedPointer<IStorage> storage);
Result LaunchStarter();
Result PopRequestLaunchApplicationForDebug(Out<u64> out_application_id, Out<SharedPointer<IStorage>> out_storage);
Result IsForceTerminateApplicationDisabledForDebug(
Out<bool> out_is_force_terminate_application_disabled_for_debug);
Result LaunchDevMenu();
Result SetLastApplicationExitReason(s32 exit_reason);
WindowSystem& m_window_system;
const std::shared_ptr<Applet> m_applet;

View File

@@ -0,0 +1,147 @@
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/service/audio_controller.h"
#include "core/hle/service/am/service/common_state_getter.h"
#include "core/hle/service/am/service/debug_functions.h"
#include "core/hle/service/am/service/display_controller.h"
#include "core/hle/service/am/service/global_state_controller.h"
#include "core/hle/service/am/service/home_menu_functions.h"
#include "core/hle/service/am/service/library_applet_creator.h"
#include "core/hle/service/am/service/overlay_applet_proxy.h"
#include "core/hle/service/am/service/process_winding_controller.h"
#include "core/hle/service/am/service/self_controller.h"
#include "core/hle/service/am/service/window_controller.h"
#include "core/hle/service/cmif_serialization.h"
namespace Service::AM {
// Forward declaration for IOverlayAppletFunctions
class IOverlayAppletFunctions final : public ServiceFramework<IOverlayAppletFunctions> {
public:
explicit IOverlayAppletFunctions(Core::System& system_) : ServiceFramework{system_, "IOverlayAppletFunctions"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "BeginToWatchShortHomeButtonMessage"},
{1, nullptr, "EndToWatchShortHomeButtonMessage"},
{2, nullptr, "GetApplicationIdForLogo"},
{3, nullptr, "SetGpuTimeSliceBoost"},
{4, nullptr, "SetAutoSleepTimeAndDimmingTimeEnabled"},
{5, nullptr, "SetHandlingHomeButtonShortPressedEnabled"},
{6, nullptr, "SetHandlingCaptureButtonShortPressedEnabledForOverlayApplet"},
{7, nullptr, "SetHandlingCaptureButtonLongPressedEnabledForOverlayApplet"},
{8, nullptr, "GetShortHomeButtonMessage"},
{9, nullptr, "IsHomeButtonShortPressedBlocked"},
{10, nullptr, "IsVrModeCurtainRequired"},
{11, nullptr, "SetInputDetectionPolicy"},
{20, nullptr, "SetCpuBoostRequestPriority"},
};
// clang-format on
RegisterHandlers(functions);
}
};
IOverlayAppletProxy::IOverlayAppletProxy(Core::System& system_, std::shared_ptr<Applet> applet,
Kernel::KProcess* process, WindowSystem& window_system)
: ServiceFramework{system_, "IOverlayAppletProxy"},
m_window_system{window_system}, m_process{process}, m_applet{std::move(applet)} {
// clang-format off
static const FunctionInfo functions[] = {
{0, D<&IOverlayAppletProxy::GetCommonStateGetter>, "GetCommonStateGetter"},
{1, D<&IOverlayAppletProxy::GetSelfController>, "GetSelfController"},
{2, D<&IOverlayAppletProxy::GetWindowController>, "GetWindowController"},
{3, D<&IOverlayAppletProxy::GetAudioController>, "GetAudioController"},
{4, D<&IOverlayAppletProxy::GetDisplayController>, "GetDisplayController"},
{11, D<&IOverlayAppletProxy::GetLibraryAppletCreator>, "GetLibraryAppletCreator"},
{20, D<&IOverlayAppletProxy::GetOverlayAppletFunctions>, "GetOverlayAppletFunctions"},
{21, D<&IOverlayAppletProxy::GetHomeMenuFunctions>, "GetHomeMenuFunctions"},
{22, D<&IOverlayAppletProxy::GetGlobalStateController>, "GetGlobalStateController"},
{1000, D<&IOverlayAppletProxy::GetDebugFunctions>, "GetDebugFunctions"},
};
// clang-format on
RegisterHandlers(functions);
}
IOverlayAppletProxy::~IOverlayAppletProxy() = default;
Result IOverlayAppletProxy::GetCommonStateGetter(
Out<SharedPointer<ICommonStateGetter>> out_common_state_getter) {
LOG_DEBUG(Service_AM, "called");
*out_common_state_getter = std::make_shared<ICommonStateGetter>(system, m_applet);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetSelfController(
Out<SharedPointer<ISelfController>> out_self_controller) {
LOG_DEBUG(Service_AM, "called");
*out_self_controller = std::make_shared<ISelfController>(system, m_applet, m_process);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetWindowController(
Out<SharedPointer<IWindowController>> out_window_controller) {
LOG_DEBUG(Service_AM, "called");
*out_window_controller = std::make_shared<IWindowController>(system, m_applet, m_window_system);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetAudioController(
Out<SharedPointer<IAudioController>> out_audio_controller) {
LOG_DEBUG(Service_AM, "called");
*out_audio_controller = std::make_shared<IAudioController>(system);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetDisplayController(
Out<SharedPointer<IDisplayController>> out_display_controller) {
LOG_DEBUG(Service_AM, "called");
*out_display_controller = std::make_shared<IDisplayController>(system, m_applet);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetProcessWindingController(
Out<SharedPointer<IProcessWindingController>> out_process_winding_controller) {
LOG_DEBUG(Service_AM, "called");
*out_process_winding_controller = std::make_shared<IProcessWindingController>(system, m_applet);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetLibraryAppletCreator(
Out<SharedPointer<ILibraryAppletCreator>> out_library_applet_creator) {
LOG_DEBUG(Service_AM, "called");
*out_library_applet_creator =
std::make_shared<ILibraryAppletCreator>(system, m_applet, m_window_system);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetOverlayAppletFunctions(
Out<SharedPointer<IOverlayAppletFunctions>> out_overlay_applet_functions) {
LOG_DEBUG(Service_AM, "called");
*out_overlay_applet_functions = std::make_shared<IOverlayAppletFunctions>(system);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetHomeMenuFunctions(
Out<SharedPointer<IHomeMenuFunctions>> out_home_menu_functions) {
LOG_DEBUG(Service_AM, "called");
*out_home_menu_functions =
std::make_shared<IHomeMenuFunctions>(system, m_applet, m_window_system);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetGlobalStateController(
Out<SharedPointer<IGlobalStateController>> out_global_state_controller) {
LOG_DEBUG(Service_AM, "called");
*out_global_state_controller = std::make_shared<IGlobalStateController>(system);
R_SUCCEED();
}
Result IOverlayAppletProxy::GetDebugFunctions(
Out<SharedPointer<IDebugFunctions>> out_debug_functions) {
LOG_DEBUG(Service_AM, "called");
*out_debug_functions = std::make_shared<IDebugFunctions>(system);
R_SUCCEED();
}
} // namespace Service::AM

View File

@@ -0,0 +1,53 @@
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Kernel {
class KProcess;
}
namespace Service::AM {
struct Applet;
class IAudioController;
class ICommonStateGetter;
class IDebugFunctions;
class IDisplayController;
class IGlobalStateController;
class IHomeMenuFunctions;
class ILibraryAppletCreator;
class IOverlayAppletFunctions;
class IProcessWindingController;
class ISelfController;
class IWindowController;
class WindowSystem;
class IOverlayAppletProxy final : public ServiceFramework<IOverlayAppletProxy> {
public:
explicit IOverlayAppletProxy(Core::System& system_, std::shared_ptr<Applet> applet,
Kernel::KProcess* process, WindowSystem& window_system);
~IOverlayAppletProxy() override;
private:
Result GetCommonStateGetter(Out<SharedPointer<ICommonStateGetter>> out_common_state_getter);
Result GetSelfController(Out<SharedPointer<ISelfController>> out_self_controller);
Result GetWindowController(Out<SharedPointer<IWindowController>> out_window_controller);
Result GetAudioController(Out<SharedPointer<IAudioController>> out_audio_controller);
Result GetDisplayController(Out<SharedPointer<IDisplayController>> out_display_controller);
Result GetProcessWindingController(Out<SharedPointer<IProcessWindingController>> out_process_winding_controller);
Result GetLibraryAppletCreator(Out<SharedPointer<ILibraryAppletCreator>> out_library_applet_creator);
Result GetOverlayAppletFunctions(Out<SharedPointer<IOverlayAppletFunctions>> out_overlay_applet_functions);
Result GetHomeMenuFunctions(Out<SharedPointer<IHomeMenuFunctions>> out_home_menu_functions);
Result GetGlobalStateController(Out<SharedPointer<IGlobalStateController>> out_global_state_controller);
Result GetDebugFunctions(Out<SharedPointer<IDebugFunctions>> out_debug_functions);
WindowSystem& m_window_system;
Kernel::KProcess* const m_process;
const std::shared_ptr<Applet> m_applet;
};
} // namespace Service::AM

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/logging/log.h"
@@ -67,6 +68,25 @@ ISelfController::ISelfController(Core::System& system_, std::shared_ptr<Applet>
{110, nullptr, "SetApplicationAlbumUserData"},
{120, D<&ISelfController::SaveCurrentScreenshot>, "SaveCurrentScreenshot"},
{130, D<&ISelfController::SetRecordVolumeMuted>, "SetRecordVolumeMuted"},
{140, nullptr, "SetRecordingVolumeMuted"},
{141, nullptr, "GetRecordingVolumeMuted"},
{150, nullptr, "SetRecordingEncryptionEnabled"},
{160, nullptr, "SetCpuBoostRequestPriority"},
{170, nullptr, "GetCurrentPerformanceConfiguration"},
{180, nullptr, "GetOperationModeSystemInfo"},
{200, nullptr, "GetSettingsPlatformRegion"},
{210, nullptr, "ActivateMigrationService"},
{211, nullptr, "DeactivateMigrationService"},
{300, nullptr, "SendMessage"},
{301, nullptr, "ReceiveMessage"},
{400, nullptr, "CreateAlbumAccessorApplicationAlbumEntry"},
{401, nullptr, "CreateAlbumAccessorApplicationAlbumArchivedEntry"},
{500, nullptr, "OpenAccessorSession"},
{600, nullptr, "CreateAccessorInterface"},
{700, nullptr, "CreateCacheStorageInterface"},
{800, nullptr, "OpenDataStorageByApplicationId"},
{900, nullptr, "CreateUserInterface"},
{950, nullptr, "CreateSystemUpdateInterface"},
{1000, nullptr, "GetDebugStorageChannel"},
};
// clang-format on

View File

@@ -0,0 +1,115 @@
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/service/application_functions.h"
#include "core/hle/service/am/service/audio_controller.h"
#include "core/hle/service/am/service/common_state_getter.h"
#include "core/hle/service/am/service/debug_functions.h"
#include "core/hle/service/am/service/display_controller.h"
#include "core/hle/service/am/service/global_state_controller.h"
#include "core/hle/service/am/service/home_menu_functions.h"
#include "core/hle/service/am/service/library_applet_creator.h"
#include "core/hle/service/am/service/self_controller.h"
#include "core/hle/service/am/service/system_application_proxy.h"
#include "core/hle/service/am/service/window_controller.h"
#include "core/hle/service/cmif_serialization.h"
namespace Service::AM {
ISystemApplicationProxy::ISystemApplicationProxy(Core::System& system_, std::shared_ptr<Applet> applet,
Kernel::KProcess* process, WindowSystem& window_system)
: ServiceFramework{system_, "ISystemApplicationProxy"},
m_window_system{window_system}, m_process{process}, m_applet{std::move(applet)} {
// clang-format off
static const FunctionInfo functions[] = {
{0, D<&ISystemApplicationProxy::GetCommonStateGetter>, "GetCommonStateGetter"},
{1, D<&ISystemApplicationProxy::GetSelfController>, "GetSelfController"},
{2, D<&ISystemApplicationProxy::GetWindowController>, "GetWindowController"},
{3, D<&ISystemApplicationProxy::GetAudioController>, "GetAudioController"},
{4, D<&ISystemApplicationProxy::GetDisplayController>, "GetDisplayController"},
{11, D<&ISystemApplicationProxy::GetLibraryAppletCreator>, "GetLibraryAppletCreator"},
{20, D<&ISystemApplicationProxy::GetHomeMenuFunctions>, "GetHomeMenuFunctions"},
{21, D<&ISystemApplicationProxy::GetGlobalStateController>, "GetGlobalStateController"},
{22, D<&ISystemApplicationProxy::GetApplicationFunctions>, "GetApplicationFunctions"},
{1000, D<&ISystemApplicationProxy::GetDebugFunctions>, "GetDebugFunctions"},
};
// clang-format on
RegisterHandlers(functions);
}
ISystemApplicationProxy::~ISystemApplicationProxy() = default;
Result ISystemApplicationProxy::GetCommonStateGetter(
Out<SharedPointer<ICommonStateGetter>> out_common_state_getter) {
LOG_DEBUG(Service_AM, "called");
*out_common_state_getter = std::make_shared<ICommonStateGetter>(system, m_applet);
R_SUCCEED();
}
Result ISystemApplicationProxy::GetSelfController(
Out<SharedPointer<ISelfController>> out_self_controller) {
LOG_DEBUG(Service_AM, "called");
*out_self_controller = std::make_shared<ISelfController>(system, m_applet, m_process);
R_SUCCEED();
}
Result ISystemApplicationProxy::GetWindowController(
Out<SharedPointer<IWindowController>> out_window_controller) {
LOG_DEBUG(Service_AM, "called");
*out_window_controller = std::make_shared<IWindowController>(system, m_applet, m_window_system);
R_SUCCEED();
}
Result ISystemApplicationProxy::GetAudioController(
Out<SharedPointer<IAudioController>> out_audio_controller) {
LOG_DEBUG(Service_AM, "called");
*out_audio_controller = std::make_shared<IAudioController>(system);
R_SUCCEED();
}
Result ISystemApplicationProxy::GetDisplayController(
Out<SharedPointer<IDisplayController>> out_display_controller) {
LOG_DEBUG(Service_AM, "called");
*out_display_controller = std::make_shared<IDisplayController>(system, m_applet);
R_SUCCEED();
}
Result ISystemApplicationProxy::GetLibraryAppletCreator(
Out<SharedPointer<ILibraryAppletCreator>> out_library_applet_creator) {
LOG_DEBUG(Service_AM, "called");
*out_library_applet_creator =
std::make_shared<ILibraryAppletCreator>(system, m_applet, m_window_system);
R_SUCCEED();
}
Result ISystemApplicationProxy::GetHomeMenuFunctions(
Out<SharedPointer<IHomeMenuFunctions>> out_home_menu_functions) {
LOG_DEBUG(Service_AM, "called");
*out_home_menu_functions =
std::make_shared<IHomeMenuFunctions>(system, m_applet, m_window_system);
R_SUCCEED();
}
Result ISystemApplicationProxy::GetGlobalStateController(
Out<SharedPointer<IGlobalStateController>> out_global_state_controller) {
LOG_DEBUG(Service_AM, "called");
*out_global_state_controller = std::make_shared<IGlobalStateController>(system);
R_SUCCEED();
}
Result ISystemApplicationProxy::GetApplicationFunctions(
Out<SharedPointer<IApplicationFunctions>> out_application_functions) {
LOG_DEBUG(Service_AM, "called");
*out_application_functions = std::make_shared<IApplicationFunctions>(system, m_applet);
R_SUCCEED();
}
Result ISystemApplicationProxy::GetDebugFunctions(
Out<SharedPointer<IDebugFunctions>> out_debug_functions) {
LOG_DEBUG(Service_AM, "called");
*out_debug_functions = std::make_shared<IDebugFunctions>(system);
R_SUCCEED();
}
} // namespace Service::AM

View File

@@ -0,0 +1,52 @@
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "core/hle/service/cmif_types.h"
#include "core/hle/service/service.h"
namespace Kernel {
class KProcess;
}
namespace Service::AM {
struct Applet;
class IApplicationFunctions;
class IAudioController;
class ICommonStateGetter;
class IDebugFunctions;
class IDisplayController;
class IGlobalStateController;
class IHomeMenuFunctions;
class ILibraryAppletCreator;
class IProcessWindingController;
class ISelfController;
class IWindowController;
class WindowSystem;
class ISystemApplicationProxy final : public ServiceFramework<ISystemApplicationProxy> {
public:
explicit ISystemApplicationProxy(Core::System& system_, std::shared_ptr<Applet> applet,
Kernel::KProcess* process, WindowSystem& window_system);
~ISystemApplicationProxy() override;
private:
Result GetCommonStateGetter(Out<SharedPointer<ICommonStateGetter>> out_common_state_getter);
Result GetSelfController(Out<SharedPointer<ISelfController>> out_self_controller);
Result GetWindowController(Out<SharedPointer<IWindowController>> out_window_controller);
Result GetAudioController(Out<SharedPointer<IAudioController>> out_audio_controller);
Result GetDisplayController(Out<SharedPointer<IDisplayController>> out_display_controller);
Result GetLibraryAppletCreator(Out<SharedPointer<ILibraryAppletCreator>> out_library_applet_creator);
Result GetHomeMenuFunctions(Out<SharedPointer<IHomeMenuFunctions>> out_home_menu_functions);
Result GetGlobalStateController(Out<SharedPointer<IGlobalStateController>> out_global_state_controller);
Result GetApplicationFunctions(Out<SharedPointer<IApplicationFunctions>> out_application_functions);
Result GetDebugFunctions(Out<SharedPointer<IDebugFunctions>> out_debug_functions);
WindowSystem& m_window_system;
Kernel::KProcess* const m_process;
const std::shared_ptr<Applet> m_applet;
};
} // namespace Service::AM