am.cpp 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <algorithm>
  5. #include <array>
  6. #include <cinttypes>
  7. #include <cstring>
  8. #include "audio_core/audio_renderer.h"
  9. #include "core/core.h"
  10. #include "core/file_sys/control_metadata.h"
  11. #include "core/file_sys/patch_manager.h"
  12. #include "core/file_sys/savedata_factory.h"
  13. #include "core/hle/ipc_helpers.h"
  14. #include "core/hle/kernel/kernel.h"
  15. #include "core/hle/kernel/process.h"
  16. #include "core/hle/kernel/readable_event.h"
  17. #include "core/hle/kernel/transfer_memory.h"
  18. #include "core/hle/kernel/writable_event.h"
  19. #include "core/hle/service/acc/profile_manager.h"
  20. #include "core/hle/service/am/am.h"
  21. #include "core/hle/service/am/applet_ae.h"
  22. #include "core/hle/service/am/applet_oe.h"
  23. #include "core/hle/service/am/applets/applets.h"
  24. #include "core/hle/service/am/applets/profile_select.h"
  25. #include "core/hle/service/am/applets/software_keyboard.h"
  26. #include "core/hle/service/am/applets/web_browser.h"
  27. #include "core/hle/service/am/idle.h"
  28. #include "core/hle/service/am/omm.h"
  29. #include "core/hle/service/am/spsm.h"
  30. #include "core/hle/service/am/tcap.h"
  31. #include "core/hle/service/apm/controller.h"
  32. #include "core/hle/service/apm/interface.h"
  33. #include "core/hle/service/bcat/backend/backend.h"
  34. #include "core/hle/service/filesystem/filesystem.h"
  35. #include "core/hle/service/ns/ns.h"
  36. #include "core/hle/service/nvflinger/nvflinger.h"
  37. #include "core/hle/service/pm/pm.h"
  38. #include "core/hle/service/set/set.h"
  39. #include "core/hle/service/sm/sm.h"
  40. #include "core/hle/service/vi/vi.h"
  41. #include "core/settings.h"
  42. namespace Service::AM {
  43. constexpr ResultCode ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 0x2};
  44. constexpr ResultCode ERR_NO_MESSAGES{ErrorModule::AM, 0x3};
  45. constexpr ResultCode ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 0x1F7};
  46. enum class LaunchParameterKind : u32 {
  47. ApplicationSpecific = 1,
  48. AccountPreselectedUser = 2,
  49. };
  50. constexpr u32 LAUNCH_PARAMETER_ACCOUNT_PRESELECTED_USER_MAGIC = 0xC79497CA;
  51. struct LaunchParameterAccountPreselectedUser {
  52. u32_le magic;
  53. u32_le is_account_selected;
  54. u128 current_user;
  55. INSERT_PADDING_BYTES(0x70);
  56. };
  57. static_assert(sizeof(LaunchParameterAccountPreselectedUser) == 0x88);
  58. IWindowController::IWindowController(Core::System& system_)
  59. : ServiceFramework("IWindowController"), system{system_} {
  60. // clang-format off
  61. static const FunctionInfo functions[] = {
  62. {0, nullptr, "CreateWindow"},
  63. {1, &IWindowController::GetAppletResourceUserId, "GetAppletResourceUserId"},
  64. {10, &IWindowController::AcquireForegroundRights, "AcquireForegroundRights"},
  65. {11, nullptr, "ReleaseForegroundRights"},
  66. {12, nullptr, "RejectToChangeIntoBackground"},
  67. {20, nullptr, "SetAppletWindowVisibility"},
  68. {21, nullptr, "SetAppletGpuTimeSlice"},
  69. };
  70. // clang-format on
  71. RegisterHandlers(functions);
  72. }
  73. IWindowController::~IWindowController() = default;
  74. void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
  75. const u64 process_id = system.CurrentProcess()->GetProcessID();
  76. LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id);
  77. IPC::ResponseBuilder rb{ctx, 4};
  78. rb.Push(RESULT_SUCCESS);
  79. rb.Push<u64>(process_id);
  80. }
  81. void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) {
  82. LOG_WARNING(Service_AM, "(STUBBED) called");
  83. IPC::ResponseBuilder rb{ctx, 2};
  84. rb.Push(RESULT_SUCCESS);
  85. }
  86. IAudioController::IAudioController() : ServiceFramework("IAudioController") {
  87. // clang-format off
  88. static const FunctionInfo functions[] = {
  89. {0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"},
  90. {1, &IAudioController::GetMainAppletExpectedMasterVolume, "GetMainAppletExpectedMasterVolume"},
  91. {2, &IAudioController::GetLibraryAppletExpectedMasterVolume, "GetLibraryAppletExpectedMasterVolume"},
  92. {3, &IAudioController::ChangeMainAppletMasterVolume, "ChangeMainAppletMasterVolume"},
  93. {4, &IAudioController::SetTransparentAudioRate, "SetTransparentVolumeRate"},
  94. };
  95. // clang-format on
  96. RegisterHandlers(functions);
  97. }
  98. IAudioController::~IAudioController() = default;
  99. void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
  100. IPC::RequestParser rp{ctx};
  101. const float main_applet_volume_tmp = rp.Pop<float>();
  102. const float library_applet_volume_tmp = rp.Pop<float>();
  103. LOG_DEBUG(Service_AM, "called. main_applet_volume={}, library_applet_volume={}",
  104. main_applet_volume_tmp, library_applet_volume_tmp);
  105. // Ensure the volume values remain within the 0-100% range
  106. main_applet_volume = std::clamp(main_applet_volume_tmp, min_allowed_volume, max_allowed_volume);
  107. library_applet_volume =
  108. std::clamp(library_applet_volume_tmp, min_allowed_volume, max_allowed_volume);
  109. IPC::ResponseBuilder rb{ctx, 2};
  110. rb.Push(RESULT_SUCCESS);
  111. }
  112. void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
  113. LOG_DEBUG(Service_AM, "called. main_applet_volume={}", main_applet_volume);
  114. IPC::ResponseBuilder rb{ctx, 3};
  115. rb.Push(RESULT_SUCCESS);
  116. rb.Push(main_applet_volume);
  117. }
  118. void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
  119. LOG_DEBUG(Service_AM, "called. library_applet_volume={}", library_applet_volume);
  120. IPC::ResponseBuilder rb{ctx, 3};
  121. rb.Push(RESULT_SUCCESS);
  122. rb.Push(library_applet_volume);
  123. }
  124. void IAudioController::ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx) {
  125. struct Parameters {
  126. float volume;
  127. s64 fade_time_ns;
  128. };
  129. static_assert(sizeof(Parameters) == 16);
  130. IPC::RequestParser rp{ctx};
  131. const auto parameters = rp.PopRaw<Parameters>();
  132. LOG_DEBUG(Service_AM, "called. volume={}, fade_time_ns={}", parameters.volume,
  133. parameters.fade_time_ns);
  134. main_applet_volume = std::clamp(parameters.volume, min_allowed_volume, max_allowed_volume);
  135. fade_time_ns = std::chrono::nanoseconds{parameters.fade_time_ns};
  136. IPC::ResponseBuilder rb{ctx, 2};
  137. rb.Push(RESULT_SUCCESS);
  138. }
  139. void IAudioController::SetTransparentAudioRate(Kernel::HLERequestContext& ctx) {
  140. IPC::RequestParser rp{ctx};
  141. const float transparent_volume_rate_tmp = rp.Pop<float>();
  142. LOG_DEBUG(Service_AM, "called. transparent_volume_rate={}", transparent_volume_rate_tmp);
  143. // Clamp volume range to 0-100%.
  144. transparent_volume_rate =
  145. std::clamp(transparent_volume_rate_tmp, min_allowed_volume, max_allowed_volume);
  146. IPC::ResponseBuilder rb{ctx, 2};
  147. rb.Push(RESULT_SUCCESS);
  148. }
  149. IDisplayController::IDisplayController() : ServiceFramework("IDisplayController") {
  150. // clang-format off
  151. static const FunctionInfo functions[] = {
  152. {0, nullptr, "GetLastForegroundCaptureImage"},
  153. {1, nullptr, "UpdateLastForegroundCaptureImage"},
  154. {2, nullptr, "GetLastApplicationCaptureImage"},
  155. {3, nullptr, "GetCallerAppletCaptureImage"},
  156. {4, nullptr, "UpdateCallerAppletCaptureImage"},
  157. {5, nullptr, "GetLastForegroundCaptureImageEx"},
  158. {6, nullptr, "GetLastApplicationCaptureImageEx"},
  159. {7, nullptr, "GetCallerAppletCaptureImageEx"},
  160. {8, nullptr, "TakeScreenShotOfOwnLayer"}, // 2.0.0+
  161. {9, nullptr, "CopyBetweenCaptureBuffers"}, // 5.0.0+
  162. {10, nullptr, "AcquireLastApplicationCaptureBuffer"},
  163. {11, nullptr, "ReleaseLastApplicationCaptureBuffer"},
  164. {12, nullptr, "AcquireLastForegroundCaptureBuffer"},
  165. {13, nullptr, "ReleaseLastForegroundCaptureBuffer"},
  166. {14, nullptr, "AcquireCallerAppletCaptureBuffer"},
  167. {15, nullptr, "ReleaseCallerAppletCaptureBuffer"},
  168. {16, nullptr, "AcquireLastApplicationCaptureBufferEx"},
  169. {17, nullptr, "AcquireLastForegroundCaptureBufferEx"},
  170. {18, nullptr, "AcquireCallerAppletCaptureBufferEx"},
  171. // 2.0.0+
  172. {20, nullptr, "ClearCaptureBuffer"},
  173. {21, nullptr, "ClearAppletTransitionBuffer"},
  174. // 4.0.0+
  175. {22, nullptr, "AcquireLastApplicationCaptureSharedBuffer"},
  176. {23, nullptr, "ReleaseLastApplicationCaptureSharedBuffer"},
  177. {24, nullptr, "AcquireLastForegroundCaptureSharedBuffer"},
  178. {25, nullptr, "ReleaseLastForegroundCaptureSharedBuffer"},
  179. {26, nullptr, "AcquireCallerAppletCaptureSharedBuffer"},
  180. {27, nullptr, "ReleaseCallerAppletCaptureSharedBuffer"},
  181. // 6.0.0+
  182. {28, nullptr, "TakeScreenShotOfOwnLayerEx"},
  183. };
  184. // clang-format on
  185. RegisterHandlers(functions);
  186. }
  187. IDisplayController::~IDisplayController() = default;
  188. IDebugFunctions::IDebugFunctions() : ServiceFramework{"IDebugFunctions"} {
  189. // clang-format off
  190. static const FunctionInfo functions[] = {
  191. {0, nullptr, "NotifyMessageToHomeMenuForDebug"},
  192. {1, nullptr, "OpenMainApplication"},
  193. {10, nullptr, "EmulateButtonEvent"},
  194. {20, nullptr, "InvalidateTransitionLayer"},
  195. {30, nullptr, "RequestLaunchApplicationWithUserAndArgumentForDebug"},
  196. {40, nullptr, "GetAppletResourceUsageInfo"},
  197. {41, nullptr, "SetCpuBoostModeForApplet"},
  198. };
  199. // clang-format on
  200. RegisterHandlers(functions);
  201. }
  202. IDebugFunctions::~IDebugFunctions() = default;
  203. ISelfController::ISelfController(Core::System& system,
  204. std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
  205. : ServiceFramework("ISelfController"), system(system), nvflinger(std::move(nvflinger)) {
  206. // clang-format off
  207. static const FunctionInfo functions[] = {
  208. {0, &ISelfController::Exit, "Exit"},
  209. {1, &ISelfController::LockExit, "LockExit"},
  210. {2, &ISelfController::UnlockExit, "UnlockExit"},
  211. {3, &ISelfController::EnterFatalSection, "EnterFatalSection"},
  212. {4, &ISelfController::LeaveFatalSection, "LeaveFatalSection"},
  213. {9, &ISelfController::GetLibraryAppletLaunchableEvent, "GetLibraryAppletLaunchableEvent"},
  214. {10, &ISelfController::SetScreenShotPermission, "SetScreenShotPermission"},
  215. {11, &ISelfController::SetOperationModeChangedNotification, "SetOperationModeChangedNotification"},
  216. {12, &ISelfController::SetPerformanceModeChangedNotification, "SetPerformanceModeChangedNotification"},
  217. {13, &ISelfController::SetFocusHandlingMode, "SetFocusHandlingMode"},
  218. {14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"},
  219. {15, nullptr, "SetScreenShotAppletIdentityInfo"},
  220. {16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"},
  221. {17, nullptr, "SetControllerFirmwareUpdateSection"},
  222. {18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"},
  223. {19, &ISelfController::SetScreenShotImageOrientation, "SetScreenShotImageOrientation"},
  224. {20, nullptr, "SetDesirableKeyboardLayout"},
  225. {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"},
  226. {41, nullptr, "IsSystemBufferSharingEnabled"},
  227. {42, nullptr, "GetSystemSharedLayerHandle"},
  228. {43, nullptr, "GetSystemSharedBufferHandle"},
  229. {50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"},
  230. {51, nullptr, "ApproveToDisplay"},
  231. {60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"},
  232. {61, nullptr, "SetMediaPlaybackState"},
  233. {62, &ISelfController::SetIdleTimeDetectionExtension, "SetIdleTimeDetectionExtension"},
  234. {63, &ISelfController::GetIdleTimeDetectionExtension, "GetIdleTimeDetectionExtension"},
  235. {64, nullptr, "SetInputDetectionSourceSet"},
  236. {65, nullptr, "ReportUserIsActive"},
  237. {66, nullptr, "GetCurrentIlluminance"},
  238. {67, nullptr, "IsIlluminanceAvailable"},
  239. {68, &ISelfController::SetAutoSleepDisabled, "SetAutoSleepDisabled"},
  240. {69, &ISelfController::IsAutoSleepDisabled, "IsAutoSleepDisabled"},
  241. {70, nullptr, "ReportMultimediaError"},
  242. {71, nullptr, "GetCurrentIlluminanceEx"},
  243. {80, nullptr, "SetWirelessPriorityMode"},
  244. {90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"},
  245. {91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"},
  246. {100, nullptr, "SetAlbumImageTakenNotificationEnabled"},
  247. {1000, nullptr, "GetDebugStorageChannel"},
  248. };
  249. // clang-format on
  250. RegisterHandlers(functions);
  251. auto& kernel = system.Kernel();
  252. launchable_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
  253. "ISelfController:LaunchableEvent");
  254. // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is
  255. // called. Yuzu can just create it unconditionally, since it doesn't need to support multiple
  256. // ISelfControllers. The event is signaled on creation, and on transition from suspended -> not
  257. // suspended if the event has previously been created by a call to
  258. // GetAccumulatedSuspendedTickChangedEvent.
  259. accumulated_suspended_tick_changed_event = Kernel::WritableEvent::CreateEventPair(
  260. kernel, Kernel::ResetType::Manual, "ISelfController:AccumulatedSuspendedTickChangedEvent");
  261. accumulated_suspended_tick_changed_event.writable->Signal();
  262. }
  263. ISelfController::~ISelfController() = default;
  264. void ISelfController::Exit(Kernel::HLERequestContext& ctx) {
  265. LOG_DEBUG(Service_AM, "called");
  266. system.Shutdown();
  267. IPC::ResponseBuilder rb{ctx, 2};
  268. rb.Push(RESULT_SUCCESS);
  269. }
  270. void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
  271. LOG_DEBUG(Service_AM, "called");
  272. system.SetExitLock(true);
  273. IPC::ResponseBuilder rb{ctx, 2};
  274. rb.Push(RESULT_SUCCESS);
  275. }
  276. void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
  277. LOG_DEBUG(Service_AM, "called");
  278. system.SetExitLock(false);
  279. IPC::ResponseBuilder rb{ctx, 2};
  280. rb.Push(RESULT_SUCCESS);
  281. }
  282. void ISelfController::EnterFatalSection(Kernel::HLERequestContext& ctx) {
  283. ++num_fatal_sections_entered;
  284. LOG_DEBUG(Service_AM, "called. Num fatal sections entered: {}", num_fatal_sections_entered);
  285. IPC::ResponseBuilder rb{ctx, 2};
  286. rb.Push(RESULT_SUCCESS);
  287. }
  288. void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) {
  289. LOG_DEBUG(Service_AM, "called.");
  290. // Entry and exit of fatal sections must be balanced.
  291. if (num_fatal_sections_entered == 0) {
  292. IPC::ResponseBuilder rb{ctx, 2};
  293. rb.Push(ResultCode{ErrorModule::AM, 512});
  294. return;
  295. }
  296. --num_fatal_sections_entered;
  297. IPC::ResponseBuilder rb{ctx, 2};
  298. rb.Push(RESULT_SUCCESS);
  299. }
  300. void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
  301. LOG_WARNING(Service_AM, "(STUBBED) called");
  302. launchable_event.writable->Signal();
  303. IPC::ResponseBuilder rb{ctx, 2, 1};
  304. rb.Push(RESULT_SUCCESS);
  305. rb.PushCopyObjects(launchable_event.readable);
  306. }
  307. void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
  308. LOG_WARNING(Service_AM, "(STUBBED) called");
  309. IPC::ResponseBuilder rb{ctx, 2};
  310. rb.Push(RESULT_SUCCESS);
  311. }
  312. void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) {
  313. IPC::RequestParser rp{ctx};
  314. bool flag = rp.Pop<bool>();
  315. LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
  316. IPC::ResponseBuilder rb{ctx, 2};
  317. rb.Push(RESULT_SUCCESS);
  318. }
  319. void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) {
  320. IPC::RequestParser rp{ctx};
  321. bool flag = rp.Pop<bool>();
  322. LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
  323. IPC::ResponseBuilder rb{ctx, 2};
  324. rb.Push(RESULT_SUCCESS);
  325. }
  326. void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) {
  327. // Takes 3 input u8s with each field located immediately after the previous
  328. // u8, these are bool flags. No output.
  329. IPC::RequestParser rp{ctx};
  330. struct FocusHandlingModeParams {
  331. u8 unknown0;
  332. u8 unknown1;
  333. u8 unknown2;
  334. };
  335. const auto flags = rp.PopRaw<FocusHandlingModeParams>();
  336. LOG_WARNING(Service_AM, "(STUBBED) called. unknown0={}, unknown1={}, unknown2={}",
  337. flags.unknown0, flags.unknown1, flags.unknown2);
  338. IPC::ResponseBuilder rb{ctx, 2};
  339. rb.Push(RESULT_SUCCESS);
  340. }
  341. void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
  342. LOG_WARNING(Service_AM, "(STUBBED) called");
  343. IPC::ResponseBuilder rb{ctx, 2};
  344. rb.Push(RESULT_SUCCESS);
  345. }
  346. void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) {
  347. // Takes 3 input u8s with each field located immediately after the previous
  348. // u8, these are bool flags. No output.
  349. IPC::RequestParser rp{ctx};
  350. bool enabled = rp.Pop<bool>();
  351. LOG_WARNING(Service_AM, "(STUBBED) called enabled={}", enabled);
  352. IPC::ResponseBuilder rb{ctx, 2};
  353. rb.Push(RESULT_SUCCESS);
  354. }
  355. void ISelfController::SetScreenShotImageOrientation(Kernel::HLERequestContext& ctx) {
  356. LOG_WARNING(Service_AM, "(STUBBED) called");
  357. IPC::ResponseBuilder rb{ctx, 2};
  358. rb.Push(RESULT_SUCCESS);
  359. }
  360. void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
  361. LOG_WARNING(Service_AM, "(STUBBED) called");
  362. // TODO(Subv): Find out how AM determines the display to use, for now just
  363. // create the layer in the Default display.
  364. const auto display_id = nvflinger->OpenDisplay("Default");
  365. const auto layer_id = nvflinger->CreateLayer(*display_id);
  366. IPC::ResponseBuilder rb{ctx, 4};
  367. rb.Push(RESULT_SUCCESS);
  368. rb.Push(*layer_id);
  369. }
  370. void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx) {
  371. LOG_WARNING(Service_AM, "(STUBBED) called");
  372. IPC::ResponseBuilder rb{ctx, 2};
  373. rb.Push(RESULT_SUCCESS);
  374. }
  375. void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
  376. IPC::RequestParser rp{ctx};
  377. idle_time_detection_extension = rp.Pop<u32>();
  378. LOG_WARNING(Service_AM, "(STUBBED) called idle_time_detection_extension={}",
  379. idle_time_detection_extension);
  380. IPC::ResponseBuilder rb{ctx, 2};
  381. rb.Push(RESULT_SUCCESS);
  382. }
  383. void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
  384. LOG_WARNING(Service_AM, "(STUBBED) called");
  385. IPC::ResponseBuilder rb{ctx, 3};
  386. rb.Push(RESULT_SUCCESS);
  387. rb.Push<u32>(idle_time_detection_extension);
  388. }
  389. void ISelfController::SetAutoSleepDisabled(Kernel::HLERequestContext& ctx) {
  390. IPC::RequestParser rp{ctx};
  391. is_auto_sleep_disabled = rp.Pop<bool>();
  392. // On the system itself, if the previous state of is_auto_sleep_disabled
  393. // differed from the current value passed in, it'd signify the internal
  394. // window manager to update (and also increment some statistics like update counts)
  395. //
  396. // It'd also indicate this change to an idle handling context.
  397. //
  398. // However, given we're emulating this behavior, most of this can be ignored
  399. // and it's sufficient to simply set the member variable for querying via
  400. // IsAutoSleepDisabled().
  401. LOG_DEBUG(Service_AM, "called. is_auto_sleep_disabled={}", is_auto_sleep_disabled);
  402. IPC::ResponseBuilder rb{ctx, 2};
  403. rb.Push(RESULT_SUCCESS);
  404. }
  405. void ISelfController::IsAutoSleepDisabled(Kernel::HLERequestContext& ctx) {
  406. LOG_DEBUG(Service_AM, "called.");
  407. IPC::ResponseBuilder rb{ctx, 3};
  408. rb.Push(RESULT_SUCCESS);
  409. rb.Push(is_auto_sleep_disabled);
  410. }
  411. void ISelfController::GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx) {
  412. LOG_DEBUG(Service_AM, "called.");
  413. // This command returns the total number of system ticks since ISelfController creation
  414. // where the game was suspended. Since Yuzu doesn't implement game suspension, this command
  415. // can just always return 0 ticks.
  416. IPC::ResponseBuilder rb{ctx, 4};
  417. rb.Push(RESULT_SUCCESS);
  418. rb.Push<u64>(0);
  419. }
  420. void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx) {
  421. LOG_DEBUG(Service_AM, "called.");
  422. IPC::ResponseBuilder rb{ctx, 2, 1};
  423. rb.Push(RESULT_SUCCESS);
  424. rb.PushCopyObjects(accumulated_suspended_tick_changed_event.readable);
  425. }
  426. AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) {
  427. on_new_message = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
  428. "AMMessageQueue:OnMessageRecieved");
  429. on_operation_mode_changed = Kernel::WritableEvent::CreateEventPair(
  430. kernel, Kernel::ResetType::Automatic, "AMMessageQueue:OperationModeChanged");
  431. }
  432. AppletMessageQueue::~AppletMessageQueue() = default;
  433. const Kernel::SharedPtr<Kernel::ReadableEvent>& AppletMessageQueue::GetMesssageRecieveEvent()
  434. const {
  435. return on_new_message.readable;
  436. }
  437. const Kernel::SharedPtr<Kernel::ReadableEvent>& AppletMessageQueue::GetOperationModeChangedEvent()
  438. const {
  439. return on_operation_mode_changed.readable;
  440. }
  441. void AppletMessageQueue::PushMessage(AppletMessage msg) {
  442. messages.push(msg);
  443. on_new_message.writable->Signal();
  444. }
  445. AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() {
  446. if (messages.empty()) {
  447. on_new_message.writable->Clear();
  448. return AppletMessage::NoMessage;
  449. }
  450. auto msg = messages.front();
  451. messages.pop();
  452. if (messages.empty()) {
  453. on_new_message.writable->Clear();
  454. }
  455. return msg;
  456. }
  457. std::size_t AppletMessageQueue::GetMessageCount() const {
  458. return messages.size();
  459. }
  460. void AppletMessageQueue::OperationModeChanged() {
  461. PushMessage(AppletMessage::OperationModeChanged);
  462. PushMessage(AppletMessage::PerformanceModeChanged);
  463. on_operation_mode_changed.writable->Signal();
  464. }
  465. void AppletMessageQueue::RequestExit() {
  466. PushMessage(AppletMessage::ExitRequested);
  467. }
  468. ICommonStateGetter::ICommonStateGetter(Core::System& system,
  469. std::shared_ptr<AppletMessageQueue> msg_queue)
  470. : ServiceFramework("ICommonStateGetter"), system(system), msg_queue(std::move(msg_queue)) {
  471. // clang-format off
  472. static const FunctionInfo functions[] = {
  473. {0, &ICommonStateGetter::GetEventHandle, "GetEventHandle"},
  474. {1, &ICommonStateGetter::ReceiveMessage, "ReceiveMessage"},
  475. {2, nullptr, "GetThisAppletKind"},
  476. {3, nullptr, "AllowToEnterSleep"},
  477. {4, nullptr, "DisallowToEnterSleep"},
  478. {5, &ICommonStateGetter::GetOperationMode, "GetOperationMode"},
  479. {6, &ICommonStateGetter::GetPerformanceMode, "GetPerformanceMode"},
  480. {7, nullptr, "GetCradleStatus"},
  481. {8, &ICommonStateGetter::GetBootMode, "GetBootMode"},
  482. {9, &ICommonStateGetter::GetCurrentFocusState, "GetCurrentFocusState"},
  483. {10, nullptr, "RequestToAcquireSleepLock"},
  484. {11, nullptr, "ReleaseSleepLock"},
  485. {12, nullptr, "ReleaseSleepLockTransiently"},
  486. {13, nullptr, "GetAcquiredSleepLockEvent"},
  487. {20, nullptr, "PushToGeneralChannel"},
  488. {30, nullptr, "GetHomeButtonReaderLockAccessor"},
  489. {31, nullptr, "GetReaderLockAccessorEx"},
  490. {40, nullptr, "GetCradleFwVersion"},
  491. {50, nullptr, "IsVrModeEnabled"},
  492. {51, nullptr, "SetVrModeEnabled"},
  493. {52, nullptr, "SwitchLcdBacklight"},
  494. {53, nullptr, "BeginVrModeEx"},
  495. {54, nullptr, "EndVrModeEx"},
  496. {55, nullptr, "IsInControllerFirmwareUpdateSection"},
  497. {60, &ICommonStateGetter::GetDefaultDisplayResolution, "GetDefaultDisplayResolution"},
  498. {61, &ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent, "GetDefaultDisplayResolutionChangeEvent"},
  499. {62, nullptr, "GetHdcpAuthenticationState"},
  500. {63, nullptr, "GetHdcpAuthenticationStateChangeEvent"},
  501. {64, nullptr, "SetTvPowerStateMatchingMode"},
  502. {65, nullptr, "GetApplicationIdByContentActionName"},
  503. {66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"},
  504. {80, nullptr, "PerformSystemButtonPressingIfInFocus"},
  505. {90, nullptr, "SetPerformanceConfigurationChangedNotification"},
  506. {91, nullptr, "GetCurrentPerformanceConfiguration"},
  507. {200, nullptr, "GetOperationModeSystemInfo"},
  508. };
  509. // clang-format on
  510. RegisterHandlers(functions);
  511. }
  512. ICommonStateGetter::~ICommonStateGetter() = default;
  513. void ICommonStateGetter::GetBootMode(Kernel::HLERequestContext& ctx) {
  514. LOG_DEBUG(Service_AM, "called");
  515. IPC::ResponseBuilder rb{ctx, 3};
  516. rb.Push(RESULT_SUCCESS);
  517. rb.Push<u8>(static_cast<u8>(Service::PM::SystemBootMode::Normal)); // Normal boot mode
  518. }
  519. void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) {
  520. LOG_DEBUG(Service_AM, "called");
  521. IPC::ResponseBuilder rb{ctx, 2, 1};
  522. rb.Push(RESULT_SUCCESS);
  523. rb.PushCopyObjects(msg_queue->GetMesssageRecieveEvent());
  524. }
  525. void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {
  526. LOG_DEBUG(Service_AM, "called");
  527. const auto message = msg_queue->PopMessage();
  528. IPC::ResponseBuilder rb{ctx, 3};
  529. if (message == AppletMessageQueue::AppletMessage::NoMessage) {
  530. LOG_ERROR(Service_AM, "Message queue is empty");
  531. rb.Push(ERR_NO_MESSAGES);
  532. rb.PushEnum<AppletMessageQueue::AppletMessage>(message);
  533. return;
  534. }
  535. rb.Push(RESULT_SUCCESS);
  536. rb.PushEnum<AppletMessageQueue::AppletMessage>(message);
  537. }
  538. void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
  539. LOG_WARNING(Service_AM, "(STUBBED) called");
  540. IPC::ResponseBuilder rb{ctx, 3};
  541. rb.Push(RESULT_SUCCESS);
  542. rb.Push(static_cast<u8>(FocusState::InFocus));
  543. }
  544. void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx) {
  545. LOG_DEBUG(Service_AM, "called");
  546. IPC::ResponseBuilder rb{ctx, 2, 1};
  547. rb.Push(RESULT_SUCCESS);
  548. rb.PushCopyObjects(msg_queue->GetOperationModeChangedEvent());
  549. }
  550. void ICommonStateGetter::GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx) {
  551. LOG_DEBUG(Service_AM, "called");
  552. IPC::ResponseBuilder rb{ctx, 4};
  553. rb.Push(RESULT_SUCCESS);
  554. if (Settings::values.use_docked_mode) {
  555. rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth) *
  556. static_cast<u32>(Settings::values.resolution_factor));
  557. rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight) *
  558. static_cast<u32>(Settings::values.resolution_factor));
  559. } else {
  560. rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth) *
  561. static_cast<u32>(Settings::values.resolution_factor));
  562. rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight) *
  563. static_cast<u32>(Settings::values.resolution_factor));
  564. }
  565. }
  566. void ICommonStateGetter::SetCpuBoostMode(Kernel::HLERequestContext& ctx) {
  567. LOG_DEBUG(Service_AM, "called, forwarding to APM:SYS");
  568. const auto& sm = system.ServiceManager();
  569. const auto apm_sys = sm.GetService<APM::APM_Sys>("apm:sys");
  570. ASSERT(apm_sys != nullptr);
  571. apm_sys->SetCpuBoostMode(ctx);
  572. }
  573. IStorage::IStorage(std::vector<u8> buffer)
  574. : ServiceFramework("IStorage"), buffer(std::move(buffer)) {
  575. // clang-format off
  576. static const FunctionInfo functions[] = {
  577. {0, &IStorage::Open, "Open"},
  578. {1, nullptr, "OpenTransferStorage"},
  579. };
  580. // clang-format on
  581. RegisterHandlers(functions);
  582. }
  583. IStorage::~IStorage() = default;
  584. const std::vector<u8>& IStorage::GetData() const {
  585. return buffer;
  586. }
  587. void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
  588. const bool use_docked_mode{Settings::values.use_docked_mode};
  589. LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode);
  590. IPC::ResponseBuilder rb{ctx, 3};
  591. rb.Push(RESULT_SUCCESS);
  592. rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld));
  593. }
  594. void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
  595. LOG_DEBUG(Service_AM, "called");
  596. IPC::ResponseBuilder rb{ctx, 3};
  597. rb.Push(RESULT_SUCCESS);
  598. rb.PushEnum(system.GetAPMController().GetCurrentPerformanceMode());
  599. }
  600. class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> {
  601. public:
  602. explicit ILibraryAppletAccessor(std::shared_ptr<Applets::Applet> applet)
  603. : ServiceFramework("ILibraryAppletAccessor"), applet(std::move(applet)) {
  604. // clang-format off
  605. static const FunctionInfo functions[] = {
  606. {0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
  607. {1, &ILibraryAppletAccessor::IsCompleted, "IsCompleted"},
  608. {10, &ILibraryAppletAccessor::Start, "Start"},
  609. {20, nullptr, "RequestExit"},
  610. {25, nullptr, "Terminate"},
  611. {30, &ILibraryAppletAccessor::GetResult, "GetResult"},
  612. {50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"},
  613. {100, &ILibraryAppletAccessor::PushInData, "PushInData"},
  614. {101, &ILibraryAppletAccessor::PopOutData, "PopOutData"},
  615. {102, nullptr, "PushExtraStorage"},
  616. {103, &ILibraryAppletAccessor::PushInteractiveInData, "PushInteractiveInData"},
  617. {104, &ILibraryAppletAccessor::PopInteractiveOutData, "PopInteractiveOutData"},
  618. {105, &ILibraryAppletAccessor::GetPopOutDataEvent, "GetPopOutDataEvent"},
  619. {106, &ILibraryAppletAccessor::GetPopInteractiveOutDataEvent, "GetPopInteractiveOutDataEvent"},
  620. {110, nullptr, "NeedsToExitProcess"},
  621. {120, nullptr, "GetLibraryAppletInfo"},
  622. {150, nullptr, "RequestForAppletToGetForeground"},
  623. {160, nullptr, "GetIndirectLayerConsumerHandle"},
  624. };
  625. // clang-format on
  626. RegisterHandlers(functions);
  627. }
  628. private:
  629. void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) {
  630. LOG_DEBUG(Service_AM, "called");
  631. const auto event = applet->GetBroker().GetStateChangedEvent();
  632. IPC::ResponseBuilder rb{ctx, 2, 1};
  633. rb.Push(RESULT_SUCCESS);
  634. rb.PushCopyObjects(event);
  635. }
  636. void IsCompleted(Kernel::HLERequestContext& ctx) {
  637. LOG_DEBUG(Service_AM, "called");
  638. IPC::ResponseBuilder rb{ctx, 3};
  639. rb.Push(RESULT_SUCCESS);
  640. rb.Push<u32>(applet->TransactionComplete());
  641. }
  642. void GetResult(Kernel::HLERequestContext& ctx) {
  643. LOG_DEBUG(Service_AM, "called");
  644. IPC::ResponseBuilder rb{ctx, 2};
  645. rb.Push(applet->GetStatus());
  646. }
  647. void Start(Kernel::HLERequestContext& ctx) {
  648. LOG_DEBUG(Service_AM, "called");
  649. ASSERT(applet != nullptr);
  650. applet->Initialize();
  651. applet->Execute();
  652. IPC::ResponseBuilder rb{ctx, 2};
  653. rb.Push(RESULT_SUCCESS);
  654. }
  655. void PushInData(Kernel::HLERequestContext& ctx) {
  656. LOG_DEBUG(Service_AM, "called");
  657. IPC::RequestParser rp{ctx};
  658. applet->GetBroker().PushNormalDataFromGame(*rp.PopIpcInterface<IStorage>());
  659. IPC::ResponseBuilder rb{ctx, 2};
  660. rb.Push(RESULT_SUCCESS);
  661. }
  662. void PopOutData(Kernel::HLERequestContext& ctx) {
  663. LOG_DEBUG(Service_AM, "called");
  664. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  665. const auto storage = applet->GetBroker().PopNormalDataToGame();
  666. if (storage == nullptr) {
  667. LOG_ERROR(Service_AM,
  668. "storage is a nullptr. There is no data in the current normal channel");
  669. rb.Push(ERR_NO_DATA_IN_CHANNEL);
  670. return;
  671. }
  672. rb.Push(RESULT_SUCCESS);
  673. rb.PushIpcInterface<IStorage>(std::move(*storage));
  674. }
  675. void PushInteractiveInData(Kernel::HLERequestContext& ctx) {
  676. LOG_DEBUG(Service_AM, "called");
  677. IPC::RequestParser rp{ctx};
  678. applet->GetBroker().PushInteractiveDataFromGame(*rp.PopIpcInterface<IStorage>());
  679. ASSERT(applet->IsInitialized());
  680. applet->ExecuteInteractive();
  681. applet->Execute();
  682. IPC::ResponseBuilder rb{ctx, 2};
  683. rb.Push(RESULT_SUCCESS);
  684. }
  685. void PopInteractiveOutData(Kernel::HLERequestContext& ctx) {
  686. LOG_DEBUG(Service_AM, "called");
  687. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  688. const auto storage = applet->GetBroker().PopInteractiveDataToGame();
  689. if (storage == nullptr) {
  690. LOG_ERROR(Service_AM,
  691. "storage is a nullptr. There is no data in the current interactive channel");
  692. rb.Push(ERR_NO_DATA_IN_CHANNEL);
  693. return;
  694. }
  695. rb.Push(RESULT_SUCCESS);
  696. rb.PushIpcInterface<IStorage>(std::move(*storage));
  697. }
  698. void GetPopOutDataEvent(Kernel::HLERequestContext& ctx) {
  699. LOG_DEBUG(Service_AM, "called");
  700. IPC::ResponseBuilder rb{ctx, 2, 1};
  701. rb.Push(RESULT_SUCCESS);
  702. rb.PushCopyObjects(applet->GetBroker().GetNormalDataEvent());
  703. }
  704. void GetPopInteractiveOutDataEvent(Kernel::HLERequestContext& ctx) {
  705. LOG_DEBUG(Service_AM, "called");
  706. IPC::ResponseBuilder rb{ctx, 2, 1};
  707. rb.Push(RESULT_SUCCESS);
  708. rb.PushCopyObjects(applet->GetBroker().GetInteractiveDataEvent());
  709. }
  710. std::shared_ptr<Applets::Applet> applet;
  711. };
  712. void IStorage::Open(Kernel::HLERequestContext& ctx) {
  713. LOG_DEBUG(Service_AM, "called");
  714. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  715. rb.Push(RESULT_SUCCESS);
  716. rb.PushIpcInterface<IStorageAccessor>(*this);
  717. }
  718. IStorageAccessor::IStorageAccessor(IStorage& storage)
  719. : ServiceFramework("IStorageAccessor"), backing(storage) {
  720. // clang-format off
  721. static const FunctionInfo functions[] = {
  722. {0, &IStorageAccessor::GetSize, "GetSize"},
  723. {10, &IStorageAccessor::Write, "Write"},
  724. {11, &IStorageAccessor::Read, "Read"},
  725. };
  726. // clang-format on
  727. RegisterHandlers(functions);
  728. }
  729. IStorageAccessor::~IStorageAccessor() = default;
  730. void IStorageAccessor::GetSize(Kernel::HLERequestContext& ctx) {
  731. LOG_DEBUG(Service_AM, "called");
  732. IPC::ResponseBuilder rb{ctx, 4};
  733. rb.Push(RESULT_SUCCESS);
  734. rb.Push(static_cast<u64>(backing.buffer.size()));
  735. }
  736. void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) {
  737. IPC::RequestParser rp{ctx};
  738. const u64 offset{rp.Pop<u64>()};
  739. const std::vector<u8> data{ctx.ReadBuffer()};
  740. LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, data.size());
  741. if (data.size() > backing.buffer.size() - offset) {
  742. LOG_ERROR(Service_AM,
  743. "offset is out of bounds, backing_buffer_sz={}, data_size={}, offset={}",
  744. backing.buffer.size(), data.size(), offset);
  745. IPC::ResponseBuilder rb{ctx, 2};
  746. rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
  747. return;
  748. }
  749. std::memcpy(backing.buffer.data() + offset, data.data(), data.size());
  750. IPC::ResponseBuilder rb{ctx, 2};
  751. rb.Push(RESULT_SUCCESS);
  752. }
  753. void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
  754. IPC::RequestParser rp{ctx};
  755. const u64 offset{rp.Pop<u64>()};
  756. const std::size_t size{ctx.GetWriteBufferSize()};
  757. LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
  758. if (size > backing.buffer.size() - offset) {
  759. LOG_ERROR(Service_AM, "offset is out of bounds, backing_buffer_sz={}, size={}, offset={}",
  760. backing.buffer.size(), size, offset);
  761. IPC::ResponseBuilder rb{ctx, 2};
  762. rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
  763. return;
  764. }
  765. ctx.WriteBuffer(backing.buffer.data() + offset, size);
  766. IPC::ResponseBuilder rb{ctx, 2};
  767. rb.Push(RESULT_SUCCESS);
  768. }
  769. ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_)
  770. : ServiceFramework("ILibraryAppletCreator"), system{system_} {
  771. static const FunctionInfo functions[] = {
  772. {0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"},
  773. {1, nullptr, "TerminateAllLibraryApplets"},
  774. {2, nullptr, "AreAnyLibraryAppletsLeft"},
  775. {10, &ILibraryAppletCreator::CreateStorage, "CreateStorage"},
  776. {11, &ILibraryAppletCreator::CreateTransferMemoryStorage, "CreateTransferMemoryStorage"},
  777. {12, nullptr, "CreateHandleStorage"},
  778. };
  779. RegisterHandlers(functions);
  780. }
  781. ILibraryAppletCreator::~ILibraryAppletCreator() = default;
  782. void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) {
  783. IPC::RequestParser rp{ctx};
  784. const auto applet_id = rp.PopRaw<Applets::AppletId>();
  785. const auto applet_mode = rp.PopRaw<u32>();
  786. LOG_DEBUG(Service_AM, "called with applet_id={:08X}, applet_mode={:08X}",
  787. static_cast<u32>(applet_id), applet_mode);
  788. const auto& applet_manager{system.GetAppletManager()};
  789. const auto applet = applet_manager.GetApplet(applet_id);
  790. if (applet == nullptr) {
  791. LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", static_cast<u32>(applet_id));
  792. IPC::ResponseBuilder rb{ctx, 2};
  793. rb.Push(ResultCode(-1));
  794. return;
  795. }
  796. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  797. rb.Push(RESULT_SUCCESS);
  798. rb.PushIpcInterface<AM::ILibraryAppletAccessor>(applet);
  799. }
  800. void ILibraryAppletCreator::CreateStorage(Kernel::HLERequestContext& ctx) {
  801. IPC::RequestParser rp{ctx};
  802. const u64 size{rp.Pop<u64>()};
  803. LOG_DEBUG(Service_AM, "called, size={}", size);
  804. std::vector<u8> buffer(size);
  805. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  806. rb.Push(RESULT_SUCCESS);
  807. rb.PushIpcInterface<AM::IStorage>(std::move(buffer));
  808. }
  809. void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx) {
  810. LOG_DEBUG(Service_AM, "called");
  811. IPC::RequestParser rp{ctx};
  812. rp.SetCurrentOffset(3);
  813. const auto handle{rp.Pop<Kernel::Handle>()};
  814. const auto transfer_mem =
  815. system.CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(handle);
  816. if (transfer_mem == nullptr) {
  817. LOG_ERROR(Service_AM, "shared_mem is a nullpr for handle={:08X}", handle);
  818. IPC::ResponseBuilder rb{ctx, 2};
  819. rb.Push(ResultCode(-1));
  820. return;
  821. }
  822. const u8* const mem_begin = transfer_mem->GetPointer();
  823. const u8* const mem_end = mem_begin + transfer_mem->GetSize();
  824. std::vector<u8> memory{mem_begin, mem_end};
  825. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  826. rb.Push(RESULT_SUCCESS);
  827. rb.PushIpcInterface(std::make_shared<IStorage>(std::move(memory)));
  828. }
  829. IApplicationFunctions::IApplicationFunctions(Core::System& system_)
  830. : ServiceFramework("IApplicationFunctions"), system{system_} {
  831. // clang-format off
  832. static const FunctionInfo functions[] = {
  833. {1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
  834. {10, nullptr, "CreateApplicationAndPushAndRequestToStart"},
  835. {11, nullptr, "CreateApplicationAndPushAndRequestToStartForQuest"},
  836. {12, nullptr, "CreateApplicationAndRequestToStart"},
  837. {13, &IApplicationFunctions::CreateApplicationAndRequestToStartForQuest, "CreateApplicationAndRequestToStartForQuest"},
  838. {14, nullptr, "CreateApplicationWithAttributeAndPushAndRequestToStartForQuest"},
  839. {15, nullptr, "CreateApplicationWithAttributeAndRequestToStartForQuest"},
  840. {20, &IApplicationFunctions::EnsureSaveData, "EnsureSaveData"},
  841. {21, &IApplicationFunctions::GetDesiredLanguage, "GetDesiredLanguage"},
  842. {22, &IApplicationFunctions::SetTerminateResult, "SetTerminateResult"},
  843. {23, &IApplicationFunctions::GetDisplayVersion, "GetDisplayVersion"},
  844. {24, nullptr, "GetLaunchStorageInfoForDebug"},
  845. {25, &IApplicationFunctions::ExtendSaveData, "ExtendSaveData"},
  846. {26, &IApplicationFunctions::GetSaveDataSize, "GetSaveDataSize"},
  847. {30, &IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed, "BeginBlockingHomeButtonShortAndLongPressed"},
  848. {31, &IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed, "EndBlockingHomeButtonShortAndLongPressed"},
  849. {32, &IApplicationFunctions::BeginBlockingHomeButton, "BeginBlockingHomeButton"},
  850. {33, &IApplicationFunctions::EndBlockingHomeButton, "EndBlockingHomeButton"},
  851. {40, &IApplicationFunctions::NotifyRunning, "NotifyRunning"},
  852. {50, &IApplicationFunctions::GetPseudoDeviceId, "GetPseudoDeviceId"},
  853. {60, nullptr, "SetMediaPlaybackStateForApplication"},
  854. {65, nullptr, "IsGamePlayRecordingSupported"},
  855. {66, &IApplicationFunctions::InitializeGamePlayRecording, "InitializeGamePlayRecording"},
  856. {67, &IApplicationFunctions::SetGamePlayRecordingState, "SetGamePlayRecordingState"},
  857. {68, nullptr, "RequestFlushGamePlayingMovieForDebug"},
  858. {70, nullptr, "RequestToShutdown"},
  859. {71, nullptr, "RequestToReboot"},
  860. {80, nullptr, "ExitAndRequestToShowThanksMessage"},
  861. {90, &IApplicationFunctions::EnableApplicationCrashReport, "EnableApplicationCrashReport"},
  862. {100, nullptr, "InitializeApplicationCopyrightFrameBuffer"},
  863. {101, nullptr, "SetApplicationCopyrightImage"},
  864. {102, nullptr, "SetApplicationCopyrightVisibility"},
  865. {110, nullptr, "QueryApplicationPlayStatistics"},
  866. {120, nullptr, "ExecuteProgram"},
  867. {121, nullptr, "ClearUserChannel"},
  868. {122, nullptr, "UnpopToUserChannel"},
  869. {130, &IApplicationFunctions::GetGpuErrorDetectedSystemEvent, "GetGpuErrorDetectedSystemEvent"},
  870. {500, nullptr, "StartContinuousRecordingFlushForDebug"},
  871. {1000, nullptr, "CreateMovieMaker"},
  872. {1001, nullptr, "PrepareForJit"},
  873. };
  874. // clang-format on
  875. RegisterHandlers(functions);
  876. auto& kernel = system.Kernel();
  877. gpu_error_detected_event = Kernel::WritableEvent::CreateEventPair(
  878. kernel, Kernel::ResetType::Manual, "IApplicationFunctions:GpuErrorDetectedSystemEvent");
  879. }
  880. IApplicationFunctions::~IApplicationFunctions() = default;
  881. void IApplicationFunctions::EnableApplicationCrashReport(Kernel::HLERequestContext& ctx) {
  882. LOG_WARNING(Service_AM, "(STUBBED) called");
  883. IPC::ResponseBuilder rb{ctx, 2};
  884. rb.Push(RESULT_SUCCESS);
  885. }
  886. void IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed(
  887. Kernel::HLERequestContext& ctx) {
  888. LOG_WARNING(Service_AM, "(STUBBED) called");
  889. IPC::ResponseBuilder rb{ctx, 2};
  890. rb.Push(RESULT_SUCCESS);
  891. }
  892. void IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed(
  893. Kernel::HLERequestContext& ctx) {
  894. LOG_WARNING(Service_AM, "(STUBBED) called");
  895. IPC::ResponseBuilder rb{ctx, 2};
  896. rb.Push(RESULT_SUCCESS);
  897. }
  898. void IApplicationFunctions::BeginBlockingHomeButton(Kernel::HLERequestContext& ctx) {
  899. LOG_WARNING(Service_AM, "(STUBBED) called");
  900. IPC::ResponseBuilder rb{ctx, 2};
  901. rb.Push(RESULT_SUCCESS);
  902. }
  903. void IApplicationFunctions::EndBlockingHomeButton(Kernel::HLERequestContext& ctx) {
  904. LOG_WARNING(Service_AM, "(STUBBED) called");
  905. IPC::ResponseBuilder rb{ctx, 2};
  906. rb.Push(RESULT_SUCCESS);
  907. }
  908. void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
  909. IPC::RequestParser rp{ctx};
  910. const auto kind = rp.PopEnum<LaunchParameterKind>();
  911. LOG_DEBUG(Service_AM, "called, kind={:08X}", static_cast<u8>(kind));
  912. if (kind == LaunchParameterKind::ApplicationSpecific && !launch_popped_application_specific) {
  913. const auto backend = BCAT::CreateBackendFromSettings(
  914. [this](u64 tid) { return system.GetFileSystemController().GetBCATDirectory(tid); });
  915. const auto build_id_full = Core::System::GetInstance().GetCurrentProcessBuildID();
  916. u64 build_id{};
  917. std::memcpy(&build_id, build_id_full.data(), sizeof(u64));
  918. const auto data =
  919. backend->GetLaunchParameter({Core::CurrentProcess()->GetTitleID(), build_id});
  920. if (data.has_value()) {
  921. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  922. rb.Push(RESULT_SUCCESS);
  923. rb.PushIpcInterface<AM::IStorage>(*data);
  924. launch_popped_application_specific = true;
  925. return;
  926. }
  927. } else if (kind == LaunchParameterKind::AccountPreselectedUser &&
  928. !launch_popped_account_preselect) {
  929. LaunchParameterAccountPreselectedUser params{};
  930. params.magic = LAUNCH_PARAMETER_ACCOUNT_PRESELECTED_USER_MAGIC;
  931. params.is_account_selected = 1;
  932. Account::ProfileManager profile_manager{};
  933. const auto uuid = profile_manager.GetUser(Settings::values.current_user);
  934. ASSERT(uuid);
  935. params.current_user = uuid->uuid;
  936. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  937. rb.Push(RESULT_SUCCESS);
  938. std::vector<u8> buffer(sizeof(LaunchParameterAccountPreselectedUser));
  939. std::memcpy(buffer.data(), &params, buffer.size());
  940. rb.PushIpcInterface<AM::IStorage>(buffer);
  941. launch_popped_account_preselect = true;
  942. return;
  943. }
  944. LOG_ERROR(Service_AM, "Attempted to load launch parameter but none was found!");
  945. IPC::ResponseBuilder rb{ctx, 2};
  946. rb.Push(ERR_NO_DATA_IN_CHANNEL);
  947. }
  948. void IApplicationFunctions::CreateApplicationAndRequestToStartForQuest(
  949. Kernel::HLERequestContext& ctx) {
  950. LOG_WARNING(Service_AM, "(STUBBED) called");
  951. IPC::ResponseBuilder rb{ctx, 2};
  952. rb.Push(RESULT_SUCCESS);
  953. }
  954. void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
  955. IPC::RequestParser rp{ctx};
  956. u128 user_id = rp.PopRaw<u128>();
  957. LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]);
  958. FileSys::SaveDataDescriptor descriptor{};
  959. descriptor.title_id = Core::CurrentProcess()->GetTitleID();
  960. descriptor.user_id = user_id;
  961. descriptor.type = FileSys::SaveDataType::SaveData;
  962. const auto res = system.GetFileSystemController().CreateSaveData(
  963. FileSys::SaveDataSpaceId::NandUser, descriptor);
  964. IPC::ResponseBuilder rb{ctx, 4};
  965. rb.Push(res.Code());
  966. rb.Push<u64>(0);
  967. }
  968. void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) {
  969. // Takes an input u32 Result, no output.
  970. // For example, in some cases official apps use this with error 0x2A2 then
  971. // uses svcBreak.
  972. IPC::RequestParser rp{ctx};
  973. u32 result = rp.Pop<u32>();
  974. LOG_WARNING(Service_AM, "(STUBBED) called, result=0x{:08X}", result);
  975. IPC::ResponseBuilder rb{ctx, 2};
  976. rb.Push(RESULT_SUCCESS);
  977. }
  978. void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
  979. LOG_WARNING(Service_AM, "(STUBBED) called");
  980. IPC::ResponseBuilder rb{ctx, 6};
  981. rb.Push(RESULT_SUCCESS);
  982. rb.Push<u64>(1);
  983. rb.Push<u64>(0);
  984. }
  985. void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
  986. // TODO(bunnei): This should be configurable
  987. LOG_DEBUG(Service_AM, "called");
  988. // Get supported languages from NACP, if possible
  989. // Default to 0 (all languages supported)
  990. u32 supported_languages = 0;
  991. FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID()};
  992. const auto res = pm.GetControlMetadata();
  993. if (res.first != nullptr) {
  994. supported_languages = res.first->GetSupportedLanguages();
  995. }
  996. // Call IApplicationManagerInterface implementation.
  997. auto& service_manager = system.ServiceManager();
  998. auto ns_am2 = service_manager.GetService<NS::NS>("ns:am2");
  999. auto app_man = ns_am2->GetApplicationManagerInterface();
  1000. // Get desired application language
  1001. const auto res_lang = app_man->GetApplicationDesiredLanguage(supported_languages);
  1002. if (res_lang.Failed()) {
  1003. IPC::ResponseBuilder rb{ctx, 2};
  1004. rb.Push(res_lang.Code());
  1005. return;
  1006. }
  1007. // Convert to settings language code.
  1008. const auto res_code = app_man->ConvertApplicationLanguageToLanguageCode(*res_lang);
  1009. if (res_code.Failed()) {
  1010. IPC::ResponseBuilder rb{ctx, 2};
  1011. rb.Push(res_code.Code());
  1012. return;
  1013. }
  1014. LOG_DEBUG(Service_AM, "got desired_language={:016X}", *res_code);
  1015. IPC::ResponseBuilder rb{ctx, 4};
  1016. rb.Push(RESULT_SUCCESS);
  1017. rb.Push(*res_code);
  1018. }
  1019. void IApplicationFunctions::InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) {
  1020. LOG_WARNING(Service_AM, "(STUBBED) called");
  1021. IPC::ResponseBuilder rb{ctx, 2};
  1022. rb.Push(RESULT_SUCCESS);
  1023. }
  1024. void IApplicationFunctions::SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) {
  1025. LOG_WARNING(Service_AM, "(STUBBED) called");
  1026. IPC::ResponseBuilder rb{ctx, 2};
  1027. rb.Push(RESULT_SUCCESS);
  1028. }
  1029. void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) {
  1030. LOG_WARNING(Service_AM, "(STUBBED) called");
  1031. IPC::ResponseBuilder rb{ctx, 3};
  1032. rb.Push(RESULT_SUCCESS);
  1033. rb.Push<u8>(0); // Unknown, seems to be ignored by official processes
  1034. }
  1035. void IApplicationFunctions::GetPseudoDeviceId(Kernel::HLERequestContext& ctx) {
  1036. LOG_WARNING(Service_AM, "(STUBBED) called");
  1037. IPC::ResponseBuilder rb{ctx, 6};
  1038. rb.Push(RESULT_SUCCESS);
  1039. // Returns a 128-bit UUID
  1040. rb.Push<u64>(0);
  1041. rb.Push<u64>(0);
  1042. }
  1043. void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
  1044. IPC::RequestParser rp{ctx};
  1045. const auto type{rp.PopRaw<FileSys::SaveDataType>()};
  1046. rp.Skip(1, false);
  1047. const auto user_id{rp.PopRaw<u128>()};
  1048. const auto new_normal_size{rp.PopRaw<u64>()};
  1049. const auto new_journal_size{rp.PopRaw<u64>()};
  1050. LOG_DEBUG(Service_AM,
  1051. "called with type={:02X}, user_id={:016X}{:016X}, new_normal={:016X}, "
  1052. "new_journal={:016X}",
  1053. static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);
  1054. system.GetFileSystemController().WriteSaveDataSize(
  1055. type, system.CurrentProcess()->GetTitleID(), user_id, {new_normal_size, new_journal_size});
  1056. IPC::ResponseBuilder rb{ctx, 4};
  1057. rb.Push(RESULT_SUCCESS);
  1058. // The following value is used upon failure to help the system recover.
  1059. // Since we always succeed, this should be 0.
  1060. rb.Push<u64>(0);
  1061. }
  1062. void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
  1063. IPC::RequestParser rp{ctx};
  1064. const auto type{rp.PopRaw<FileSys::SaveDataType>()};
  1065. rp.Skip(1, false);
  1066. const auto user_id{rp.PopRaw<u128>()};
  1067. LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast<u8>(type),
  1068. user_id[1], user_id[0]);
  1069. const auto size = system.GetFileSystemController().ReadSaveDataSize(
  1070. type, system.CurrentProcess()->GetTitleID(), user_id);
  1071. IPC::ResponseBuilder rb{ctx, 6};
  1072. rb.Push(RESULT_SUCCESS);
  1073. rb.Push(size.normal);
  1074. rb.Push(size.journal);
  1075. }
  1076. void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx) {
  1077. LOG_WARNING(Service_AM, "(STUBBED) called");
  1078. IPC::ResponseBuilder rb{ctx, 2, 1};
  1079. rb.Push(RESULT_SUCCESS);
  1080. rb.PushCopyObjects(gpu_error_detected_event.readable);
  1081. }
  1082. void InstallInterfaces(SM::ServiceManager& service_manager,
  1083. std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system) {
  1084. auto message_queue = std::make_shared<AppletMessageQueue>(system.Kernel());
  1085. // Needed on game boot
  1086. message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
  1087. std::make_shared<AppletAE>(nvflinger, message_queue, system)->InstallAsService(service_manager);
  1088. std::make_shared<AppletOE>(nvflinger, message_queue, system)->InstallAsService(service_manager);
  1089. std::make_shared<IdleSys>()->InstallAsService(service_manager);
  1090. std::make_shared<OMM>()->InstallAsService(service_manager);
  1091. std::make_shared<SPSM>()->InstallAsService(service_manager);
  1092. std::make_shared<TCAP>()->InstallAsService(service_manager);
  1093. }
  1094. IHomeMenuFunctions::IHomeMenuFunctions() : ServiceFramework("IHomeMenuFunctions") {
  1095. // clang-format off
  1096. static const FunctionInfo functions[] = {
  1097. {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"},
  1098. {11, nullptr, "LockForeground"},
  1099. {12, nullptr, "UnlockForeground"},
  1100. {20, nullptr, "PopFromGeneralChannel"},
  1101. {21, nullptr, "GetPopFromGeneralChannelEvent"},
  1102. {30, nullptr, "GetHomeButtonWriterLockAccessor"},
  1103. {31, nullptr, "GetWriterLockAccessorEx"},
  1104. {100, nullptr, "PopRequestLaunchApplicationForDebug"},
  1105. };
  1106. // clang-format on
  1107. RegisterHandlers(functions);
  1108. }
  1109. IHomeMenuFunctions::~IHomeMenuFunctions() = default;
  1110. void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) {
  1111. LOG_WARNING(Service_AM, "(STUBBED) called");
  1112. IPC::ResponseBuilder rb{ctx, 2};
  1113. rb.Push(RESULT_SUCCESS);
  1114. }
  1115. IGlobalStateController::IGlobalStateController() : ServiceFramework("IGlobalStateController") {
  1116. // clang-format off
  1117. static const FunctionInfo functions[] = {
  1118. {0, nullptr, "RequestToEnterSleep"},
  1119. {1, nullptr, "EnterSleep"},
  1120. {2, nullptr, "StartSleepSequence"},
  1121. {3, nullptr, "StartShutdownSequence"},
  1122. {4, nullptr, "StartRebootSequence"},
  1123. {9, nullptr, "IsAutoPowerDownRequested"},
  1124. {10, nullptr, "LoadAndApplyIdlePolicySettings"},
  1125. {11, nullptr, "NotifyCecSettingsChanged"},
  1126. {12, nullptr, "SetDefaultHomeButtonLongPressTime"},
  1127. {13, nullptr, "UpdateDefaultDisplayResolution"},
  1128. {14, nullptr, "ShouldSleepOnBoot"},
  1129. {15, nullptr, "GetHdcpAuthenticationFailedEvent"},
  1130. };
  1131. // clang-format on
  1132. RegisterHandlers(functions);
  1133. }
  1134. IGlobalStateController::~IGlobalStateController() = default;
  1135. IApplicationCreator::IApplicationCreator() : ServiceFramework("IApplicationCreator") {
  1136. // clang-format off
  1137. static const FunctionInfo functions[] = {
  1138. {0, nullptr, "CreateApplication"},
  1139. {1, nullptr, "PopLaunchRequestedApplication"},
  1140. {10, nullptr, "CreateSystemApplication"},
  1141. {100, nullptr, "PopFloatingApplicationForDevelopment"},
  1142. };
  1143. // clang-format on
  1144. RegisterHandlers(functions);
  1145. }
  1146. IApplicationCreator::~IApplicationCreator() = default;
  1147. IProcessWindingController::IProcessWindingController()
  1148. : ServiceFramework("IProcessWindingController") {
  1149. // clang-format off
  1150. static const FunctionInfo functions[] = {
  1151. {0, nullptr, "GetLaunchReason"},
  1152. {11, nullptr, "OpenCallingLibraryApplet"},
  1153. {21, nullptr, "PushContext"},
  1154. {22, nullptr, "PopContext"},
  1155. {23, nullptr, "CancelWindingReservation"},
  1156. {30, nullptr, "WindAndDoReserved"},
  1157. {40, nullptr, "ReserveToStartAndWaitAndUnwindThis"},
  1158. {41, nullptr, "ReserveToStartAndWait"},
  1159. };
  1160. // clang-format on
  1161. RegisterHandlers(functions);
  1162. }
  1163. IProcessWindingController::~IProcessWindingController() = default;
  1164. } // namespace Service::AM