service: Implement GPU error handling IPC commands for AM

Implements several IPC commands in IApplicationFunctions related to GPU error
handling and system events:

- EnableApplicationAllThreadDumpOnCrash (cmd 124)
- SetDelayTimeToAbortOnGpuError (cmd 131)
- TryPopFromNotificationStorageChannel (cmd 151)
- SetHdcpAuthenticationActivated (cmd 170)
- GetLaunchRequiredVersion (cmd 180)
- UpgradeLaunchRequiredVersion (cmd 181)

Also adds the LaunchRequiredVersion struct definition to the header file.
These are currently stubbed implementations that log warnings when called.

REFS: switchbrew.org/wiki/Applet_Manager_services#GetGpuErrorDetectedSystemEvent
This commit is contained in:
Zephyron 2025-01-27 00:45:27 +10:00
parent be191f740a
commit b7e11d3724
3 changed files with 53 additions and 7 deletions

View file

@ -72,17 +72,17 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_, std::shared_
{121, D<&IApplicationFunctions::ClearUserChannel>, "ClearUserChannel"}, {121, D<&IApplicationFunctions::ClearUserChannel>, "ClearUserChannel"},
{122, D<&IApplicationFunctions::UnpopToUserChannel>, "UnpopToUserChannel"}, {122, D<&IApplicationFunctions::UnpopToUserChannel>, "UnpopToUserChannel"},
{123, D<&IApplicationFunctions::GetPreviousProgramIndex>, "GetPreviousProgramIndex"}, {123, D<&IApplicationFunctions::GetPreviousProgramIndex>, "GetPreviousProgramIndex"},
{124, nullptr, "EnableApplicationAllThreadDumpOnCrash"}, {124, D<&IApplicationFunctions::EnableApplicationAllThreadDumpOnCrash>, "EnableApplicationAllThreadDumpOnCrash"},
{130, D<&IApplicationFunctions::GetGpuErrorDetectedSystemEvent>, "GetGpuErrorDetectedSystemEvent"}, {130, D<&IApplicationFunctions::GetGpuErrorDetectedSystemEvent>, "GetGpuErrorDetectedSystemEvent"},
{131, nullptr, "SetDelayTimeToAbortOnGpuError"}, {131, D<&IApplicationFunctions::SetDelayTimeToAbortOnGpuError>, "SetDelayTimeToAbortOnGpuError"},
{140, D<&IApplicationFunctions::GetFriendInvitationStorageChannelEvent>, "GetFriendInvitationStorageChannelEvent"}, {140, D<&IApplicationFunctions::GetFriendInvitationStorageChannelEvent>, "GetFriendInvitationStorageChannelEvent"},
{141, D<&IApplicationFunctions::TryPopFromFriendInvitationStorageChannel>, "TryPopFromFriendInvitationStorageChannel"}, {141, D<&IApplicationFunctions::TryPopFromFriendInvitationStorageChannel>, "TryPopFromFriendInvitationStorageChannel"},
{150, D<&IApplicationFunctions::GetNotificationStorageChannelEvent>, "GetNotificationStorageChannelEvent"}, {150, D<&IApplicationFunctions::GetNotificationStorageChannelEvent>, "GetNotificationStorageChannelEvent"},
{151, nullptr, "TryPopFromNotificationStorageChannel"}, {151, D<&IApplicationFunctions::TryPopFromNotificationStorageChannel>, "TryPopFromNotificationStorageChannel"},
{160, D<&IApplicationFunctions::GetHealthWarningDisappearedSystemEvent>, "GetHealthWarningDisappearedSystemEvent"}, {160, D<&IApplicationFunctions::GetHealthWarningDisappearedSystemEvent>, "GetHealthWarningDisappearedSystemEvent"},
{170, nullptr, "SetHdcpAuthenticationActivated"}, {170, D<&IApplicationFunctions::SetHdcpAuthenticationActivated>, "SetHdcpAuthenticationActivated"},
{180, nullptr, "GetLaunchRequiredVersion"}, {180, D<&IApplicationFunctions::GetLaunchRequiredVersion>, "GetLaunchRequiredVersion"},
{181, nullptr, "UpgradeLaunchRequiredVersion"}, {181, D<&IApplicationFunctions::UpgradeLaunchRequiredVersion>, "UpgradeLaunchRequiredVersion"},
{190, nullptr, "SendServerMaintenanceOverlayNotification"}, {190, nullptr, "SendServerMaintenanceOverlayNotification"},
{200, nullptr, "GetLastApplicationExitReason"}, {200, nullptr, "GetLastApplicationExitReason"},
{500, nullptr, "StartContinuousRecordingFlushForDebug"}, {500, nullptr, "StartContinuousRecordingFlushForDebug"},
@ -500,4 +500,37 @@ Result IApplicationFunctions::PrepareForJit() {
R_SUCCEED(); R_SUCCEED();
} }
Result IApplicationFunctions::EnableApplicationAllThreadDumpOnCrash() {
LOG_WARNING(Service_AM, "(STUBBED) called");
return ResultSuccess;
}
Result IApplicationFunctions::SetDelayTimeToAbortOnGpuError(u64 delay_time_ns) {
LOG_WARNING(Service_AM, "(STUBBED) called, delay_time_ns={}", delay_time_ns);
return ResultSuccess;
}
Result IApplicationFunctions::TryPopFromNotificationStorageChannel(Out<bool> out_success,
OutBuffer<BufferAttr_HipcMapAlias> out_buffer) {
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_success = false;
return ResultSuccess;
}
Result IApplicationFunctions::SetHdcpAuthenticationActivated(bool activated) {
LOG_WARNING(Service_AM, "(STUBBED) called, activated={}", activated);
return ResultSuccess;
}
Result IApplicationFunctions::GetLaunchRequiredVersion(Out<LaunchRequiredVersion> out_version) {
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_version = {}; // Zero-initialize the struct
return ResultSuccess;
}
Result IApplicationFunctions::UpgradeLaunchRequiredVersion(const LaunchRequiredVersion& version) {
LOG_WARNING(Service_AM, "(STUBBED) called");
return ResultSuccess;
}
} // namespace Service::AM } // namespace Service::AM

View file

@ -21,6 +21,12 @@ namespace Service::AM {
struct Applet; struct Applet;
class IStorage; class IStorage;
struct LaunchRequiredVersion {
u32 version;
INSERT_PADDING_WORDS(3); // Padding for IPC alignment
};
static_assert(sizeof(LaunchRequiredVersion) == 0x10);
class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> { class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> {
public: public:
explicit IApplicationFunctions(Core::System& system_, std::shared_ptr<Applet> applet); explicit IApplicationFunctions(Core::System& system_, std::shared_ptr<Applet> applet);
@ -77,6 +83,13 @@ private:
Result GetNotificationStorageChannelEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); Result GetNotificationStorageChannelEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result GetHealthWarningDisappearedSystemEvent(OutCopyHandle<Kernel::KReadableEvent> out_event); Result GetHealthWarningDisappearedSystemEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
Result PrepareForJit(); Result PrepareForJit();
Result EnableApplicationAllThreadDumpOnCrash();
Result SetDelayTimeToAbortOnGpuError(u64 delay_time_ns);
Result TryPopFromNotificationStorageChannel(Out<bool> out_success,
OutBuffer<BufferAttr_HipcMapAlias> out_buffer);
Result SetHdcpAuthenticationActivated(bool activated);
Result GetLaunchRequiredVersion(Out<LaunchRequiredVersion> out_version);
Result UpgradeLaunchRequiredVersion(const LaunchRequiredVersion& version);
const std::shared_ptr<Applet> m_applet; const std::shared_ptr<Applet> m_applet;
}; };

View file

@ -22,7 +22,7 @@ constexpr Result ResultInvalidClient(ErrorModule::SM, 2);
constexpr Result ResultAlreadyRegistered(ErrorModule::SM, 4); constexpr Result ResultAlreadyRegistered(ErrorModule::SM, 4);
constexpr Result ResultInvalidServiceName(ErrorModule::SM, 6); constexpr Result ResultInvalidServiceName(ErrorModule::SM, 6);
constexpr Result ResultNotRegistered(ErrorModule::SM, 7); constexpr Result ResultNotRegistered(ErrorModule::SM, 7);
constexpr Result ResultNotAllowed(ErrorModule::SM, 1); [[maybe_unused]] constexpr Result ResultNotAllowed(ErrorModule::SM, 1);
ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} { ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} {
controller_interface = std::make_unique<Controller>(kernel.System()); controller_interface = std::make_unique<Controller>(kernel.System());