am.cpp 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include <algorithm>
  4. #include <array>
  5. #include <cinttypes>
  6. #include <cstring>
  7. #include "common/settings.h"
  8. #include "core/core.h"
  9. #include "core/file_sys/control_metadata.h"
  10. #include "core/file_sys/patch_manager.h"
  11. #include "core/file_sys/registered_cache.h"
  12. #include "core/file_sys/savedata_factory.h"
  13. #include "core/hle/ipc_helpers.h"
  14. #include "core/hle/kernel/k_event.h"
  15. #include "core/hle/kernel/k_transfer_memory.h"
  16. #include "core/hle/service/acc/profile_manager.h"
  17. #include "core/hle/service/am/am.h"
  18. #include "core/hle/service/am/applet_ae.h"
  19. #include "core/hle/service/am/applet_oe.h"
  20. #include "core/hle/service/am/applets/applet_profile_select.h"
  21. #include "core/hle/service/am/applets/applet_web_browser.h"
  22. #include "core/hle/service/am/applets/applets.h"
  23. #include "core/hle/service/am/idle.h"
  24. #include "core/hle/service/am/omm.h"
  25. #include "core/hle/service/am/spsm.h"
  26. #include "core/hle/service/apm/apm_controller.h"
  27. #include "core/hle/service/apm/apm_interface.h"
  28. #include "core/hle/service/bcat/backend/backend.h"
  29. #include "core/hle/service/caps/caps.h"
  30. #include "core/hle/service/filesystem/filesystem.h"
  31. #include "core/hle/service/ns/ns.h"
  32. #include "core/hle/service/nvflinger/nvflinger.h"
  33. #include "core/hle/service/pm/pm.h"
  34. #include "core/hle/service/server_manager.h"
  35. #include "core/hle/service/sm/sm.h"
  36. #include "core/hle/service/vi/vi.h"
  37. #include "core/memory.h"
  38. namespace Service::AM {
  39. constexpr Result ERR_NO_DATA_IN_CHANNEL{ErrorModule::AM, 2};
  40. constexpr Result ERR_NO_MESSAGES{ErrorModule::AM, 3};
  41. constexpr Result ERR_SIZE_OUT_OF_BOUNDS{ErrorModule::AM, 503};
  42. enum class LaunchParameterKind : u32 {
  43. ApplicationSpecific = 1,
  44. AccountPreselectedUser = 2,
  45. };
  46. constexpr u32 LAUNCH_PARAMETER_ACCOUNT_PRESELECTED_USER_MAGIC = 0xC79497CA;
  47. struct LaunchParameterAccountPreselectedUser {
  48. u32_le magic;
  49. u32_le is_account_selected;
  50. Common::UUID current_user;
  51. INSERT_PADDING_BYTES(0x70);
  52. };
  53. static_assert(sizeof(LaunchParameterAccountPreselectedUser) == 0x88);
  54. IWindowController::IWindowController(Core::System& system_)
  55. : ServiceFramework{system_, "IWindowController"} {
  56. // clang-format off
  57. static const FunctionInfo functions[] = {
  58. {0, nullptr, "CreateWindow"},
  59. {1, &IWindowController::GetAppletResourceUserId, "GetAppletResourceUserId"},
  60. {2, nullptr, "GetAppletResourceUserIdOfCallerApplet"},
  61. {10, &IWindowController::AcquireForegroundRights, "AcquireForegroundRights"},
  62. {11, nullptr, "ReleaseForegroundRights"},
  63. {12, nullptr, "RejectToChangeIntoBackground"},
  64. {20, nullptr, "SetAppletWindowVisibility"},
  65. {21, nullptr, "SetAppletGpuTimeSlice"},
  66. };
  67. // clang-format on
  68. RegisterHandlers(functions);
  69. }
  70. IWindowController::~IWindowController() = default;
  71. void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
  72. const u64 process_id = system.ApplicationProcess()->GetProcessID();
  73. LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id);
  74. IPC::ResponseBuilder rb{ctx, 4};
  75. rb.Push(ResultSuccess);
  76. rb.Push<u64>(process_id);
  77. }
  78. void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx) {
  79. LOG_WARNING(Service_AM, "(STUBBED) called");
  80. IPC::ResponseBuilder rb{ctx, 2};
  81. rb.Push(ResultSuccess);
  82. }
  83. IAudioController::IAudioController(Core::System& system_)
  84. : ServiceFramework{system_, "IAudioController"} {
  85. // clang-format off
  86. static const FunctionInfo functions[] = {
  87. {0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"},
  88. {1, &IAudioController::GetMainAppletExpectedMasterVolume, "GetMainAppletExpectedMasterVolume"},
  89. {2, &IAudioController::GetLibraryAppletExpectedMasterVolume, "GetLibraryAppletExpectedMasterVolume"},
  90. {3, &IAudioController::ChangeMainAppletMasterVolume, "ChangeMainAppletMasterVolume"},
  91. {4, &IAudioController::SetTransparentAudioRate, "SetTransparentVolumeRate"},
  92. };
  93. // clang-format on
  94. RegisterHandlers(functions);
  95. }
  96. IAudioController::~IAudioController() = default;
  97. void IAudioController::SetExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
  98. IPC::RequestParser rp{ctx};
  99. const float main_applet_volume_tmp = rp.Pop<float>();
  100. const float library_applet_volume_tmp = rp.Pop<float>();
  101. LOG_DEBUG(Service_AM, "called. main_applet_volume={}, library_applet_volume={}",
  102. main_applet_volume_tmp, library_applet_volume_tmp);
  103. // Ensure the volume values remain within the 0-100% range
  104. main_applet_volume = std::clamp(main_applet_volume_tmp, min_allowed_volume, max_allowed_volume);
  105. library_applet_volume =
  106. std::clamp(library_applet_volume_tmp, min_allowed_volume, max_allowed_volume);
  107. IPC::ResponseBuilder rb{ctx, 2};
  108. rb.Push(ResultSuccess);
  109. }
  110. void IAudioController::GetMainAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
  111. LOG_DEBUG(Service_AM, "called. main_applet_volume={}", main_applet_volume);
  112. IPC::ResponseBuilder rb{ctx, 3};
  113. rb.Push(ResultSuccess);
  114. rb.Push(main_applet_volume);
  115. }
  116. void IAudioController::GetLibraryAppletExpectedMasterVolume(Kernel::HLERequestContext& ctx) {
  117. LOG_DEBUG(Service_AM, "called. library_applet_volume={}", library_applet_volume);
  118. IPC::ResponseBuilder rb{ctx, 3};
  119. rb.Push(ResultSuccess);
  120. rb.Push(library_applet_volume);
  121. }
  122. void IAudioController::ChangeMainAppletMasterVolume(Kernel::HLERequestContext& ctx) {
  123. struct Parameters {
  124. float volume;
  125. s64 fade_time_ns;
  126. };
  127. static_assert(sizeof(Parameters) == 16);
  128. IPC::RequestParser rp{ctx};
  129. const auto parameters = rp.PopRaw<Parameters>();
  130. LOG_DEBUG(Service_AM, "called. volume={}, fade_time_ns={}", parameters.volume,
  131. parameters.fade_time_ns);
  132. main_applet_volume = std::clamp(parameters.volume, min_allowed_volume, max_allowed_volume);
  133. fade_time_ns = std::chrono::nanoseconds{parameters.fade_time_ns};
  134. IPC::ResponseBuilder rb{ctx, 2};
  135. rb.Push(ResultSuccess);
  136. }
  137. void IAudioController::SetTransparentAudioRate(Kernel::HLERequestContext& ctx) {
  138. IPC::RequestParser rp{ctx};
  139. const float transparent_volume_rate_tmp = rp.Pop<float>();
  140. LOG_DEBUG(Service_AM, "called. transparent_volume_rate={}", transparent_volume_rate_tmp);
  141. // Clamp volume range to 0-100%.
  142. transparent_volume_rate =
  143. std::clamp(transparent_volume_rate_tmp, min_allowed_volume, max_allowed_volume);
  144. IPC::ResponseBuilder rb{ctx, 2};
  145. rb.Push(ResultSuccess);
  146. }
  147. IDisplayController::IDisplayController(Core::System& system_)
  148. : ServiceFramework{system_, "IDisplayController"} {
  149. // clang-format off
  150. static const FunctionInfo functions[] = {
  151. {0, nullptr, "GetLastForegroundCaptureImage"},
  152. {1, nullptr, "UpdateLastForegroundCaptureImage"},
  153. {2, nullptr, "GetLastApplicationCaptureImage"},
  154. {3, nullptr, "GetCallerAppletCaptureImage"},
  155. {4, nullptr, "UpdateCallerAppletCaptureImage"},
  156. {5, nullptr, "GetLastForegroundCaptureImageEx"},
  157. {6, nullptr, "GetLastApplicationCaptureImageEx"},
  158. {7, nullptr, "GetCallerAppletCaptureImageEx"},
  159. {8, nullptr, "TakeScreenShotOfOwnLayer"},
  160. {9, nullptr, "CopyBetweenCaptureBuffers"},
  161. {10, nullptr, "AcquireLastApplicationCaptureBuffer"},
  162. {11, nullptr, "ReleaseLastApplicationCaptureBuffer"},
  163. {12, nullptr, "AcquireLastForegroundCaptureBuffer"},
  164. {13, nullptr, "ReleaseLastForegroundCaptureBuffer"},
  165. {14, nullptr, "AcquireCallerAppletCaptureBuffer"},
  166. {15, nullptr, "ReleaseCallerAppletCaptureBuffer"},
  167. {16, nullptr, "AcquireLastApplicationCaptureBufferEx"},
  168. {17, nullptr, "AcquireLastForegroundCaptureBufferEx"},
  169. {18, nullptr, "AcquireCallerAppletCaptureBufferEx"},
  170. {20, nullptr, "ClearCaptureBuffer"},
  171. {21, nullptr, "ClearAppletTransitionBuffer"},
  172. {22, nullptr, "AcquireLastApplicationCaptureSharedBuffer"},
  173. {23, nullptr, "ReleaseLastApplicationCaptureSharedBuffer"},
  174. {24, nullptr, "AcquireLastForegroundCaptureSharedBuffer"},
  175. {25, nullptr, "ReleaseLastForegroundCaptureSharedBuffer"},
  176. {26, nullptr, "AcquireCallerAppletCaptureSharedBuffer"},
  177. {27, nullptr, "ReleaseCallerAppletCaptureSharedBuffer"},
  178. {28, nullptr, "TakeScreenShotOfOwnLayerEx"},
  179. };
  180. // clang-format on
  181. RegisterHandlers(functions);
  182. }
  183. IDisplayController::~IDisplayController() = default;
  184. IDebugFunctions::IDebugFunctions(Core::System& system_)
  185. : ServiceFramework{system_, "IDebugFunctions"} {
  186. // clang-format off
  187. static const FunctionInfo functions[] = {
  188. {0, nullptr, "NotifyMessageToHomeMenuForDebug"},
  189. {1, nullptr, "OpenMainApplication"},
  190. {10, nullptr, "PerformSystemButtonPressing"},
  191. {20, nullptr, "InvalidateTransitionLayer"},
  192. {30, nullptr, "RequestLaunchApplicationWithUserAndArgumentForDebug"},
  193. {31, nullptr, "RequestLaunchApplicationByApplicationLaunchInfoForDebug"},
  194. {40, nullptr, "GetAppletResourceUsageInfo"},
  195. {100, nullptr, "SetCpuBoostModeForApplet"},
  196. {101, nullptr, "CancelCpuBoostModeForApplet"},
  197. {110, nullptr, "PushToAppletBoundChannelForDebug"},
  198. {111, nullptr, "TryPopFromAppletBoundChannelForDebug"},
  199. {120, nullptr, "AlarmSettingNotificationEnableAppEventReserve"},
  200. {121, nullptr, "AlarmSettingNotificationDisableAppEventReserve"},
  201. {122, nullptr, "AlarmSettingNotificationPushAppEventNotify"},
  202. {130, nullptr, "FriendInvitationSetApplicationParameter"},
  203. {131, nullptr, "FriendInvitationClearApplicationParameter"},
  204. {132, nullptr, "FriendInvitationPushApplicationParameter"},
  205. {140, nullptr, "RestrictPowerOperationForSecureLaunchModeForDebug"},
  206. {900, nullptr, "GetGrcProcessLaunchedSystemEvent"},
  207. };
  208. // clang-format on
  209. RegisterHandlers(functions);
  210. }
  211. IDebugFunctions::~IDebugFunctions() = default;
  212. ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_)
  213. : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_}, service_context{
  214. system,
  215. "ISelfController"} {
  216. // clang-format off
  217. static const FunctionInfo functions[] = {
  218. {0, &ISelfController::Exit, "Exit"},
  219. {1, &ISelfController::LockExit, "LockExit"},
  220. {2, &ISelfController::UnlockExit, "UnlockExit"},
  221. {3, &ISelfController::EnterFatalSection, "EnterFatalSection"},
  222. {4, &ISelfController::LeaveFatalSection, "LeaveFatalSection"},
  223. {9, &ISelfController::GetLibraryAppletLaunchableEvent, "GetLibraryAppletLaunchableEvent"},
  224. {10, &ISelfController::SetScreenShotPermission, "SetScreenShotPermission"},
  225. {11, &ISelfController::SetOperationModeChangedNotification, "SetOperationModeChangedNotification"},
  226. {12, &ISelfController::SetPerformanceModeChangedNotification, "SetPerformanceModeChangedNotification"},
  227. {13, &ISelfController::SetFocusHandlingMode, "SetFocusHandlingMode"},
  228. {14, &ISelfController::SetRestartMessageEnabled, "SetRestartMessageEnabled"},
  229. {15, nullptr, "SetScreenShotAppletIdentityInfo"},
  230. {16, &ISelfController::SetOutOfFocusSuspendingEnabled, "SetOutOfFocusSuspendingEnabled"},
  231. {17, nullptr, "SetControllerFirmwareUpdateSection"},
  232. {18, nullptr, "SetRequiresCaptureButtonShortPressedMessage"},
  233. {19, &ISelfController::SetAlbumImageOrientation, "SetAlbumImageOrientation"},
  234. {20, nullptr, "SetDesirableKeyboardLayout"},
  235. {21, nullptr, "GetScreenShotProgramId"},
  236. {40, &ISelfController::CreateManagedDisplayLayer, "CreateManagedDisplayLayer"},
  237. {41, nullptr, "IsSystemBufferSharingEnabled"},
  238. {42, nullptr, "GetSystemSharedLayerHandle"},
  239. {43, nullptr, "GetSystemSharedBufferHandle"},
  240. {44, &ISelfController::CreateManagedDisplaySeparableLayer, "CreateManagedDisplaySeparableLayer"},
  241. {45, nullptr, "SetManagedDisplayLayerSeparationMode"},
  242. {46, nullptr, "SetRecordingLayerCompositionEnabled"},
  243. {50, &ISelfController::SetHandlesRequestToDisplay, "SetHandlesRequestToDisplay"},
  244. {51, nullptr, "ApproveToDisplay"},
  245. {60, nullptr, "OverrideAutoSleepTimeAndDimmingTime"},
  246. {61, nullptr, "SetMediaPlaybackState"},
  247. {62, &ISelfController::SetIdleTimeDetectionExtension, "SetIdleTimeDetectionExtension"},
  248. {63, &ISelfController::GetIdleTimeDetectionExtension, "GetIdleTimeDetectionExtension"},
  249. {64, nullptr, "SetInputDetectionSourceSet"},
  250. {65, &ISelfController::ReportUserIsActive, "ReportUserIsActive"},
  251. {66, nullptr, "GetCurrentIlluminance"},
  252. {67, nullptr, "IsIlluminanceAvailable"},
  253. {68, &ISelfController::SetAutoSleepDisabled, "SetAutoSleepDisabled"},
  254. {69, &ISelfController::IsAutoSleepDisabled, "IsAutoSleepDisabled"},
  255. {70, nullptr, "ReportMultimediaError"},
  256. {71, nullptr, "GetCurrentIlluminanceEx"},
  257. {72, nullptr, "SetInputDetectionPolicy"},
  258. {80, nullptr, "SetWirelessPriorityMode"},
  259. {90, &ISelfController::GetAccumulatedSuspendedTickValue, "GetAccumulatedSuspendedTickValue"},
  260. {91, &ISelfController::GetAccumulatedSuspendedTickChangedEvent, "GetAccumulatedSuspendedTickChangedEvent"},
  261. {100, &ISelfController::SetAlbumImageTakenNotificationEnabled, "SetAlbumImageTakenNotificationEnabled"},
  262. {110, nullptr, "SetApplicationAlbumUserData"},
  263. {120, &ISelfController::SaveCurrentScreenshot, "SaveCurrentScreenshot"},
  264. {130, &ISelfController::SetRecordVolumeMuted, "SetRecordVolumeMuted"},
  265. {1000, nullptr, "GetDebugStorageChannel"},
  266. };
  267. // clang-format on
  268. RegisterHandlers(functions);
  269. launchable_event = service_context.CreateEvent("ISelfController:LaunchableEvent");
  270. // This event is created by AM on the first time GetAccumulatedSuspendedTickChangedEvent() is
  271. // called. Yuzu can just create it unconditionally, since it doesn't need to support multiple
  272. // ISelfControllers. The event is signaled on creation, and on transition from suspended -> not
  273. // suspended if the event has previously been created by a call to
  274. // GetAccumulatedSuspendedTickChangedEvent.
  275. accumulated_suspended_tick_changed_event =
  276. service_context.CreateEvent("ISelfController:AccumulatedSuspendedTickChangedEvent");
  277. accumulated_suspended_tick_changed_event->Signal();
  278. }
  279. ISelfController::~ISelfController() {
  280. service_context.CloseEvent(launchable_event);
  281. service_context.CloseEvent(accumulated_suspended_tick_changed_event);
  282. }
  283. void ISelfController::Exit(Kernel::HLERequestContext& ctx) {
  284. LOG_DEBUG(Service_AM, "called");
  285. IPC::ResponseBuilder rb{ctx, 2};
  286. rb.Push(ResultSuccess);
  287. system.Exit();
  288. }
  289. void ISelfController::LockExit(Kernel::HLERequestContext& ctx) {
  290. LOG_DEBUG(Service_AM, "called");
  291. system.SetExitLock(true);
  292. IPC::ResponseBuilder rb{ctx, 2};
  293. rb.Push(ResultSuccess);
  294. }
  295. void ISelfController::UnlockExit(Kernel::HLERequestContext& ctx) {
  296. LOG_DEBUG(Service_AM, "called");
  297. system.SetExitLock(false);
  298. IPC::ResponseBuilder rb{ctx, 2};
  299. rb.Push(ResultSuccess);
  300. }
  301. void ISelfController::EnterFatalSection(Kernel::HLERequestContext& ctx) {
  302. ++num_fatal_sections_entered;
  303. LOG_DEBUG(Service_AM, "called. Num fatal sections entered: {}", num_fatal_sections_entered);
  304. IPC::ResponseBuilder rb{ctx, 2};
  305. rb.Push(ResultSuccess);
  306. }
  307. void ISelfController::LeaveFatalSection(Kernel::HLERequestContext& ctx) {
  308. LOG_DEBUG(Service_AM, "called.");
  309. // Entry and exit of fatal sections must be balanced.
  310. if (num_fatal_sections_entered == 0) {
  311. IPC::ResponseBuilder rb{ctx, 2};
  312. rb.Push(Result{ErrorModule::AM, 512});
  313. return;
  314. }
  315. --num_fatal_sections_entered;
  316. IPC::ResponseBuilder rb{ctx, 2};
  317. rb.Push(ResultSuccess);
  318. }
  319. void ISelfController::GetLibraryAppletLaunchableEvent(Kernel::HLERequestContext& ctx) {
  320. LOG_WARNING(Service_AM, "(STUBBED) called");
  321. launchable_event->Signal();
  322. IPC::ResponseBuilder rb{ctx, 2, 1};
  323. rb.Push(ResultSuccess);
  324. rb.PushCopyObjects(launchable_event->GetReadableEvent());
  325. }
  326. void ISelfController::SetScreenShotPermission(Kernel::HLERequestContext& ctx) {
  327. IPC::RequestParser rp{ctx};
  328. const auto permission = rp.PopEnum<ScreenshotPermission>();
  329. LOG_DEBUG(Service_AM, "called, permission={}", permission);
  330. screenshot_permission = permission;
  331. IPC::ResponseBuilder rb{ctx, 2};
  332. rb.Push(ResultSuccess);
  333. }
  334. void ISelfController::SetOperationModeChangedNotification(Kernel::HLERequestContext& ctx) {
  335. IPC::RequestParser rp{ctx};
  336. bool flag = rp.Pop<bool>();
  337. LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
  338. IPC::ResponseBuilder rb{ctx, 2};
  339. rb.Push(ResultSuccess);
  340. }
  341. void ISelfController::SetPerformanceModeChangedNotification(Kernel::HLERequestContext& ctx) {
  342. IPC::RequestParser rp{ctx};
  343. bool flag = rp.Pop<bool>();
  344. LOG_WARNING(Service_AM, "(STUBBED) called flag={}", flag);
  345. IPC::ResponseBuilder rb{ctx, 2};
  346. rb.Push(ResultSuccess);
  347. }
  348. void ISelfController::SetFocusHandlingMode(Kernel::HLERequestContext& ctx) {
  349. // Takes 3 input u8s with each field located immediately after the previous
  350. // u8, these are bool flags. No output.
  351. IPC::RequestParser rp{ctx};
  352. struct FocusHandlingModeParams {
  353. u8 unknown0;
  354. u8 unknown1;
  355. u8 unknown2;
  356. };
  357. const auto flags = rp.PopRaw<FocusHandlingModeParams>();
  358. LOG_WARNING(Service_AM, "(STUBBED) called. unknown0={}, unknown1={}, unknown2={}",
  359. flags.unknown0, flags.unknown1, flags.unknown2);
  360. IPC::ResponseBuilder rb{ctx, 2};
  361. rb.Push(ResultSuccess);
  362. }
  363. void ISelfController::SetRestartMessageEnabled(Kernel::HLERequestContext& ctx) {
  364. LOG_WARNING(Service_AM, "(STUBBED) called");
  365. IPC::ResponseBuilder rb{ctx, 2};
  366. rb.Push(ResultSuccess);
  367. }
  368. void ISelfController::SetOutOfFocusSuspendingEnabled(Kernel::HLERequestContext& ctx) {
  369. // Takes 3 input u8s with each field located immediately after the previous
  370. // u8, these are bool flags. No output.
  371. IPC::RequestParser rp{ctx};
  372. bool enabled = rp.Pop<bool>();
  373. LOG_WARNING(Service_AM, "(STUBBED) called enabled={}", enabled);
  374. IPC::ResponseBuilder rb{ctx, 2};
  375. rb.Push(ResultSuccess);
  376. }
  377. void ISelfController::SetAlbumImageOrientation(Kernel::HLERequestContext& ctx) {
  378. LOG_WARNING(Service_AM, "(STUBBED) called");
  379. IPC::ResponseBuilder rb{ctx, 2};
  380. rb.Push(ResultSuccess);
  381. }
  382. void ISelfController::CreateManagedDisplayLayer(Kernel::HLERequestContext& ctx) {
  383. LOG_WARNING(Service_AM, "(STUBBED) called");
  384. // TODO(Subv): Find out how AM determines the display to use, for now just
  385. // create the layer in the Default display.
  386. const auto display_id = nvflinger.OpenDisplay("Default");
  387. const auto layer_id = nvflinger.CreateLayer(*display_id);
  388. IPC::ResponseBuilder rb{ctx, 4};
  389. rb.Push(ResultSuccess);
  390. rb.Push(*layer_id);
  391. }
  392. void ISelfController::CreateManagedDisplaySeparableLayer(Kernel::HLERequestContext& ctx) {
  393. LOG_WARNING(Service_AM, "(STUBBED) called");
  394. // TODO(Subv): Find out how AM determines the display to use, for now just
  395. // create the layer in the Default display.
  396. // This calls nn::vi::CreateRecordingLayer() which creates another layer.
  397. // Currently we do not support more than 1 layer per display, output 1 layer id for now.
  398. // Outputting 1 layer id instead of the expected 2 has not been observed to cause any adverse
  399. // side effects.
  400. // TODO: Support multiple layers
  401. const auto display_id = nvflinger.OpenDisplay("Default");
  402. const auto layer_id = nvflinger.CreateLayer(*display_id);
  403. IPC::ResponseBuilder rb{ctx, 4};
  404. rb.Push(ResultSuccess);
  405. rb.Push(*layer_id);
  406. }
  407. void ISelfController::SetHandlesRequestToDisplay(Kernel::HLERequestContext& ctx) {
  408. LOG_WARNING(Service_AM, "(STUBBED) called");
  409. IPC::ResponseBuilder rb{ctx, 2};
  410. rb.Push(ResultSuccess);
  411. }
  412. void ISelfController::SetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
  413. IPC::RequestParser rp{ctx};
  414. idle_time_detection_extension = rp.Pop<u32>();
  415. LOG_WARNING(Service_AM, "(STUBBED) called idle_time_detection_extension={}",
  416. idle_time_detection_extension);
  417. IPC::ResponseBuilder rb{ctx, 2};
  418. rb.Push(ResultSuccess);
  419. }
  420. void ISelfController::GetIdleTimeDetectionExtension(Kernel::HLERequestContext& ctx) {
  421. LOG_WARNING(Service_AM, "(STUBBED) called");
  422. IPC::ResponseBuilder rb{ctx, 3};
  423. rb.Push(ResultSuccess);
  424. rb.Push<u32>(idle_time_detection_extension);
  425. }
  426. void ISelfController::ReportUserIsActive(Kernel::HLERequestContext& ctx) {
  427. LOG_WARNING(Service_AM, "(STUBBED) called");
  428. IPC::ResponseBuilder rb{ctx, 2};
  429. rb.Push(ResultSuccess);
  430. }
  431. void ISelfController::SetAutoSleepDisabled(Kernel::HLERequestContext& ctx) {
  432. IPC::RequestParser rp{ctx};
  433. is_auto_sleep_disabled = rp.Pop<bool>();
  434. // On the system itself, if the previous state of is_auto_sleep_disabled
  435. // differed from the current value passed in, it'd signify the internal
  436. // window manager to update (and also increment some statistics like update counts)
  437. //
  438. // It'd also indicate this change to an idle handling context.
  439. //
  440. // However, given we're emulating this behavior, most of this can be ignored
  441. // and it's sufficient to simply set the member variable for querying via
  442. // IsAutoSleepDisabled().
  443. LOG_DEBUG(Service_AM, "called. is_auto_sleep_disabled={}", is_auto_sleep_disabled);
  444. IPC::ResponseBuilder rb{ctx, 2};
  445. rb.Push(ResultSuccess);
  446. }
  447. void ISelfController::IsAutoSleepDisabled(Kernel::HLERequestContext& ctx) {
  448. LOG_DEBUG(Service_AM, "called.");
  449. IPC::ResponseBuilder rb{ctx, 3};
  450. rb.Push(ResultSuccess);
  451. rb.Push(is_auto_sleep_disabled);
  452. }
  453. void ISelfController::GetAccumulatedSuspendedTickValue(Kernel::HLERequestContext& ctx) {
  454. LOG_DEBUG(Service_AM, "called.");
  455. // This command returns the total number of system ticks since ISelfController creation
  456. // where the game was suspended. Since Yuzu doesn't implement game suspension, this command
  457. // can just always return 0 ticks.
  458. IPC::ResponseBuilder rb{ctx, 4};
  459. rb.Push(ResultSuccess);
  460. rb.Push<u64>(0);
  461. }
  462. void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequestContext& ctx) {
  463. LOG_DEBUG(Service_AM, "called.");
  464. IPC::ResponseBuilder rb{ctx, 2, 1};
  465. rb.Push(ResultSuccess);
  466. rb.PushCopyObjects(accumulated_suspended_tick_changed_event->GetReadableEvent());
  467. }
  468. void ISelfController::SetAlbumImageTakenNotificationEnabled(Kernel::HLERequestContext& ctx) {
  469. IPC::RequestParser rp{ctx};
  470. // This service call sets an internal flag whether a notification is shown when an image is
  471. // captured. Currently we do not support capturing images via the capture button, so this can be
  472. // stubbed for now.
  473. const bool album_image_taken_notification_enabled = rp.Pop<bool>();
  474. LOG_WARNING(Service_AM, "(STUBBED) called. album_image_taken_notification_enabled={}",
  475. album_image_taken_notification_enabled);
  476. IPC::ResponseBuilder rb{ctx, 2};
  477. rb.Push(ResultSuccess);
  478. }
  479. void ISelfController::SaveCurrentScreenshot(Kernel::HLERequestContext& ctx) {
  480. IPC::RequestParser rp{ctx};
  481. const auto album_report_option = rp.PopEnum<Capture::AlbumReportOption>();
  482. LOG_WARNING(Service_AM, "(STUBBED) called. album_report_option={}", album_report_option);
  483. IPC::ResponseBuilder rb{ctx, 2};
  484. rb.Push(ResultSuccess);
  485. }
  486. void ISelfController::SetRecordVolumeMuted(Kernel::HLERequestContext& ctx) {
  487. IPC::RequestParser rp{ctx};
  488. const auto is_record_volume_muted = rp.Pop<bool>();
  489. LOG_WARNING(Service_AM, "(STUBBED) called. is_record_volume_muted={}", is_record_volume_muted);
  490. IPC::ResponseBuilder rb{ctx, 2};
  491. rb.Push(ResultSuccess);
  492. }
  493. AppletMessageQueue::AppletMessageQueue(Core::System& system)
  494. : service_context{system, "AppletMessageQueue"} {
  495. on_new_message = service_context.CreateEvent("AMMessageQueue:OnMessageReceived");
  496. on_operation_mode_changed = service_context.CreateEvent("AMMessageQueue:OperationModeChanged");
  497. }
  498. AppletMessageQueue::~AppletMessageQueue() {
  499. service_context.CloseEvent(on_new_message);
  500. service_context.CloseEvent(on_operation_mode_changed);
  501. }
  502. Kernel::KReadableEvent& AppletMessageQueue::GetMessageReceiveEvent() {
  503. return on_new_message->GetReadableEvent();
  504. }
  505. Kernel::KReadableEvent& AppletMessageQueue::GetOperationModeChangedEvent() {
  506. return on_operation_mode_changed->GetReadableEvent();
  507. }
  508. void AppletMessageQueue::PushMessage(AppletMessage msg) {
  509. messages.push(msg);
  510. on_new_message->Signal();
  511. }
  512. AppletMessageQueue::AppletMessage AppletMessageQueue::PopMessage() {
  513. if (messages.empty()) {
  514. on_new_message->Clear();
  515. return AppletMessage::None;
  516. }
  517. auto msg = messages.front();
  518. messages.pop();
  519. if (messages.empty()) {
  520. on_new_message->Clear();
  521. }
  522. return msg;
  523. }
  524. std::size_t AppletMessageQueue::GetMessageCount() const {
  525. return messages.size();
  526. }
  527. void AppletMessageQueue::RequestExit() {
  528. PushMessage(AppletMessage::Exit);
  529. }
  530. void AppletMessageQueue::RequestResume() {
  531. PushMessage(AppletMessage::Resume);
  532. }
  533. void AppletMessageQueue::FocusStateChanged() {
  534. PushMessage(AppletMessage::FocusStateChanged);
  535. }
  536. void AppletMessageQueue::OperationModeChanged() {
  537. PushMessage(AppletMessage::OperationModeChanged);
  538. PushMessage(AppletMessage::PerformanceModeChanged);
  539. on_operation_mode_changed->Signal();
  540. }
  541. ICommonStateGetter::ICommonStateGetter(Core::System& system_,
  542. std::shared_ptr<AppletMessageQueue> msg_queue_)
  543. : ServiceFramework{system_, "ICommonStateGetter"}, msg_queue{std::move(msg_queue_)} {
  544. // clang-format off
  545. static const FunctionInfo functions[] = {
  546. {0, &ICommonStateGetter::GetEventHandle, "GetEventHandle"},
  547. {1, &ICommonStateGetter::ReceiveMessage, "ReceiveMessage"},
  548. {2, nullptr, "GetThisAppletKind"},
  549. {3, nullptr, "AllowToEnterSleep"},
  550. {4, nullptr, "DisallowToEnterSleep"},
  551. {5, &ICommonStateGetter::GetOperationMode, "GetOperationMode"},
  552. {6, &ICommonStateGetter::GetPerformanceMode, "GetPerformanceMode"},
  553. {7, nullptr, "GetCradleStatus"},
  554. {8, &ICommonStateGetter::GetBootMode, "GetBootMode"},
  555. {9, &ICommonStateGetter::GetCurrentFocusState, "GetCurrentFocusState"},
  556. {10, nullptr, "RequestToAcquireSleepLock"},
  557. {11, nullptr, "ReleaseSleepLock"},
  558. {12, nullptr, "ReleaseSleepLockTransiently"},
  559. {13, nullptr, "GetAcquiredSleepLockEvent"},
  560. {14, nullptr, "GetWakeupCount"},
  561. {20, nullptr, "PushToGeneralChannel"},
  562. {30, nullptr, "GetHomeButtonReaderLockAccessor"},
  563. {31, nullptr, "GetReaderLockAccessorEx"},
  564. {32, nullptr, "GetWriterLockAccessorEx"},
  565. {40, nullptr, "GetCradleFwVersion"},
  566. {50, &ICommonStateGetter::IsVrModeEnabled, "IsVrModeEnabled"},
  567. {51, &ICommonStateGetter::SetVrModeEnabled, "SetVrModeEnabled"},
  568. {52, &ICommonStateGetter::SetLcdBacklighOffEnabled, "SetLcdBacklighOffEnabled"},
  569. {53, &ICommonStateGetter::BeginVrModeEx, "BeginVrModeEx"},
  570. {54, &ICommonStateGetter::EndVrModeEx, "EndVrModeEx"},
  571. {55, nullptr, "IsInControllerFirmwareUpdateSection"},
  572. {59, nullptr, "SetVrPositionForDebug"},
  573. {60, &ICommonStateGetter::GetDefaultDisplayResolution, "GetDefaultDisplayResolution"},
  574. {61, &ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent, "GetDefaultDisplayResolutionChangeEvent"},
  575. {62, nullptr, "GetHdcpAuthenticationState"},
  576. {63, nullptr, "GetHdcpAuthenticationStateChangeEvent"},
  577. {64, nullptr, "SetTvPowerStateMatchingMode"},
  578. {65, nullptr, "GetApplicationIdByContentActionName"},
  579. {66, &ICommonStateGetter::SetCpuBoostMode, "SetCpuBoostMode"},
  580. {67, nullptr, "CancelCpuBoostMode"},
  581. {68, nullptr, "GetBuiltInDisplayType"},
  582. {80, &ICommonStateGetter::PerformSystemButtonPressingIfInFocus, "PerformSystemButtonPressingIfInFocus"},
  583. {90, nullptr, "SetPerformanceConfigurationChangedNotification"},
  584. {91, nullptr, "GetCurrentPerformanceConfiguration"},
  585. {100, nullptr, "SetHandlingHomeButtonShortPressedEnabled"},
  586. {110, nullptr, "OpenMyGpuErrorHandler"},
  587. {120, nullptr, "GetAppletLaunchedHistory"},
  588. {200, nullptr, "GetOperationModeSystemInfo"},
  589. {300, nullptr, "GetSettingsPlatformRegion"},
  590. {400, nullptr, "ActivateMigrationService"},
  591. {401, nullptr, "DeactivateMigrationService"},
  592. {500, nullptr, "DisableSleepTillShutdown"},
  593. {501, nullptr, "SuppressDisablingSleepTemporarily"},
  594. {502, nullptr, "IsSleepEnabled"},
  595. {503, nullptr, "IsDisablingSleepSuppressed"},
  596. {900, &ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled, "SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled"},
  597. };
  598. // clang-format on
  599. RegisterHandlers(functions);
  600. }
  601. ICommonStateGetter::~ICommonStateGetter() = default;
  602. void ICommonStateGetter::GetBootMode(Kernel::HLERequestContext& ctx) {
  603. LOG_DEBUG(Service_AM, "called");
  604. IPC::ResponseBuilder rb{ctx, 3};
  605. rb.Push(ResultSuccess);
  606. rb.Push<u8>(static_cast<u8>(Service::PM::SystemBootMode::Normal)); // Normal boot mode
  607. }
  608. void ICommonStateGetter::GetEventHandle(Kernel::HLERequestContext& ctx) {
  609. LOG_DEBUG(Service_AM, "called");
  610. IPC::ResponseBuilder rb{ctx, 2, 1};
  611. rb.Push(ResultSuccess);
  612. rb.PushCopyObjects(msg_queue->GetMessageReceiveEvent());
  613. }
  614. void ICommonStateGetter::ReceiveMessage(Kernel::HLERequestContext& ctx) {
  615. LOG_DEBUG(Service_AM, "called");
  616. const auto message = msg_queue->PopMessage();
  617. IPC::ResponseBuilder rb{ctx, 3};
  618. if (message == AppletMessageQueue::AppletMessage::None) {
  619. LOG_ERROR(Service_AM, "Message queue is empty");
  620. rb.Push(ERR_NO_MESSAGES);
  621. rb.PushEnum<AppletMessageQueue::AppletMessage>(message);
  622. return;
  623. }
  624. rb.Push(ResultSuccess);
  625. rb.PushEnum<AppletMessageQueue::AppletMessage>(message);
  626. }
  627. void ICommonStateGetter::GetCurrentFocusState(Kernel::HLERequestContext& ctx) {
  628. LOG_DEBUG(Service_AM, "(STUBBED) called");
  629. IPC::ResponseBuilder rb{ctx, 3};
  630. rb.Push(ResultSuccess);
  631. rb.Push(static_cast<u8>(FocusState::InFocus));
  632. }
  633. void ICommonStateGetter::IsVrModeEnabled(Kernel::HLERequestContext& ctx) {
  634. LOG_DEBUG(Service_AM, "called");
  635. IPC::ResponseBuilder rb{ctx, 3};
  636. rb.Push(ResultSuccess);
  637. rb.Push(vr_mode_state);
  638. }
  639. void ICommonStateGetter::SetVrModeEnabled(Kernel::HLERequestContext& ctx) {
  640. IPC::RequestParser rp{ctx};
  641. vr_mode_state = rp.Pop<bool>();
  642. LOG_WARNING(Service_AM, "VR Mode is {}", vr_mode_state ? "on" : "off");
  643. IPC::ResponseBuilder rb{ctx, 2};
  644. rb.Push(ResultSuccess);
  645. }
  646. void ICommonStateGetter::SetLcdBacklighOffEnabled(Kernel::HLERequestContext& ctx) {
  647. IPC::RequestParser rp{ctx};
  648. const auto is_lcd_backlight_off_enabled = rp.Pop<bool>();
  649. LOG_WARNING(Service_AM, "(STUBBED) called. is_lcd_backlight_off_enabled={}",
  650. is_lcd_backlight_off_enabled);
  651. IPC::ResponseBuilder rb{ctx, 2};
  652. rb.Push(ResultSuccess);
  653. }
  654. void ICommonStateGetter::BeginVrModeEx(Kernel::HLERequestContext& ctx) {
  655. LOG_WARNING(Service_AM, "(STUBBED) called");
  656. IPC::ResponseBuilder rb{ctx, 2};
  657. rb.Push(ResultSuccess);
  658. }
  659. void ICommonStateGetter::EndVrModeEx(Kernel::HLERequestContext& ctx) {
  660. LOG_WARNING(Service_AM, "(STUBBED) called");
  661. IPC::ResponseBuilder rb{ctx, 2};
  662. rb.Push(ResultSuccess);
  663. }
  664. void ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(Kernel::HLERequestContext& ctx) {
  665. LOG_DEBUG(Service_AM, "called");
  666. IPC::ResponseBuilder rb{ctx, 2, 1};
  667. rb.Push(ResultSuccess);
  668. rb.PushCopyObjects(msg_queue->GetOperationModeChangedEvent());
  669. }
  670. void ICommonStateGetter::GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx) {
  671. LOG_DEBUG(Service_AM, "called");
  672. IPC::ResponseBuilder rb{ctx, 4};
  673. rb.Push(ResultSuccess);
  674. if (Settings::values.use_docked_mode.GetValue()) {
  675. rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth));
  676. rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight));
  677. } else {
  678. rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth));
  679. rb.Push(static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight));
  680. }
  681. }
  682. void ICommonStateGetter::SetCpuBoostMode(Kernel::HLERequestContext& ctx) {
  683. LOG_DEBUG(Service_AM, "called, forwarding to APM:SYS");
  684. const auto& sm = system.ServiceManager();
  685. const auto apm_sys = sm.GetService<APM::APM_Sys>("apm:sys");
  686. ASSERT(apm_sys != nullptr);
  687. apm_sys->SetCpuBoostMode(ctx);
  688. }
  689. void ICommonStateGetter::PerformSystemButtonPressingIfInFocus(Kernel::HLERequestContext& ctx) {
  690. IPC::RequestParser rp{ctx};
  691. const auto system_button{rp.PopEnum<SystemButtonType>()};
  692. LOG_WARNING(Service_AM, "(STUBBED) called, system_button={}", system_button);
  693. IPC::ResponseBuilder rb{ctx, 2};
  694. rb.Push(ResultSuccess);
  695. }
  696. void ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled(
  697. Kernel::HLERequestContext& ctx) {
  698. LOG_WARNING(Service_AM, "(STUBBED) called");
  699. IPC::ResponseBuilder rb{ctx, 2};
  700. rb.Push(ResultSuccess);
  701. }
  702. IStorageImpl::~IStorageImpl() = default;
  703. class StorageDataImpl final : public IStorageImpl {
  704. public:
  705. explicit StorageDataImpl(std::vector<u8>&& buffer_) : buffer{std::move(buffer_)} {}
  706. std::vector<u8>& GetData() override {
  707. return buffer;
  708. }
  709. const std::vector<u8>& GetData() const override {
  710. return buffer;
  711. }
  712. std::size_t GetSize() const override {
  713. return buffer.size();
  714. }
  715. private:
  716. std::vector<u8> buffer;
  717. };
  718. IStorage::IStorage(Core::System& system_, std::vector<u8>&& buffer)
  719. : ServiceFramework{system_, "IStorage"}, impl{std::make_shared<StorageDataImpl>(
  720. std::move(buffer))} {
  721. Register();
  722. }
  723. void IStorage::Register() {
  724. // clang-format off
  725. static const FunctionInfo functions[] = {
  726. {0, &IStorage::Open, "Open"},
  727. {1, nullptr, "OpenTransferStorage"},
  728. };
  729. // clang-format on
  730. RegisterHandlers(functions);
  731. }
  732. IStorage::~IStorage() = default;
  733. void IStorage::Open(Kernel::HLERequestContext& ctx) {
  734. LOG_DEBUG(Service_AM, "called");
  735. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  736. rb.Push(ResultSuccess);
  737. rb.PushIpcInterface<IStorageAccessor>(system, *this);
  738. }
  739. void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
  740. const bool use_docked_mode{Settings::values.use_docked_mode.GetValue()};
  741. LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode);
  742. IPC::ResponseBuilder rb{ctx, 3};
  743. rb.Push(ResultSuccess);
  744. rb.Push(static_cast<u8>(use_docked_mode ? OperationMode::Docked : OperationMode::Handheld));
  745. }
  746. void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
  747. LOG_DEBUG(Service_AM, "called");
  748. IPC::ResponseBuilder rb{ctx, 3};
  749. rb.Push(ResultSuccess);
  750. rb.PushEnum(system.GetAPMController().GetCurrentPerformanceMode());
  751. }
  752. class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> {
  753. public:
  754. explicit ILibraryAppletAccessor(Core::System& system_, std::shared_ptr<Applets::Applet> applet_)
  755. : ServiceFramework{system_, "ILibraryAppletAccessor"}, applet{std::move(applet_)} {
  756. // clang-format off
  757. static const FunctionInfo functions[] = {
  758. {0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
  759. {1, &ILibraryAppletAccessor::IsCompleted, "IsCompleted"},
  760. {10, &ILibraryAppletAccessor::Start, "Start"},
  761. {20, nullptr, "RequestExit"},
  762. {25, nullptr, "Terminate"},
  763. {30, &ILibraryAppletAccessor::GetResult, "GetResult"},
  764. {50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"},
  765. {60, &ILibraryAppletAccessor::PresetLibraryAppletGpuTimeSliceZero, "PresetLibraryAppletGpuTimeSliceZero"},
  766. {100, &ILibraryAppletAccessor::PushInData, "PushInData"},
  767. {101, &ILibraryAppletAccessor::PopOutData, "PopOutData"},
  768. {102, nullptr, "PushExtraStorage"},
  769. {103, &ILibraryAppletAccessor::PushInteractiveInData, "PushInteractiveInData"},
  770. {104, &ILibraryAppletAccessor::PopInteractiveOutData, "PopInteractiveOutData"},
  771. {105, &ILibraryAppletAccessor::GetPopOutDataEvent, "GetPopOutDataEvent"},
  772. {106, &ILibraryAppletAccessor::GetPopInteractiveOutDataEvent, "GetPopInteractiveOutDataEvent"},
  773. {110, nullptr, "NeedsToExitProcess"},
  774. {120, nullptr, "GetLibraryAppletInfo"},
  775. {150, nullptr, "RequestForAppletToGetForeground"},
  776. {160, &ILibraryAppletAccessor::GetIndirectLayerConsumerHandle, "GetIndirectLayerConsumerHandle"},
  777. };
  778. // clang-format on
  779. RegisterHandlers(functions);
  780. }
  781. private:
  782. void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) {
  783. LOG_DEBUG(Service_AM, "called");
  784. IPC::ResponseBuilder rb{ctx, 2, 1};
  785. rb.Push(ResultSuccess);
  786. rb.PushCopyObjects(applet->GetBroker().GetStateChangedEvent());
  787. }
  788. void IsCompleted(Kernel::HLERequestContext& ctx) {
  789. LOG_DEBUG(Service_AM, "called");
  790. IPC::ResponseBuilder rb{ctx, 3};
  791. rb.Push(ResultSuccess);
  792. rb.Push<u32>(applet->TransactionComplete());
  793. }
  794. void GetResult(Kernel::HLERequestContext& ctx) {
  795. LOG_DEBUG(Service_AM, "called");
  796. IPC::ResponseBuilder rb{ctx, 2};
  797. rb.Push(applet->GetStatus());
  798. }
  799. void PresetLibraryAppletGpuTimeSliceZero(Kernel::HLERequestContext& ctx) {
  800. LOG_WARNING(Service_AM, "(STUBBED) called");
  801. IPC::ResponseBuilder rb{ctx, 2};
  802. rb.Push(ResultSuccess);
  803. }
  804. void Start(Kernel::HLERequestContext& ctx) {
  805. LOG_DEBUG(Service_AM, "called");
  806. ASSERT(applet != nullptr);
  807. applet->Initialize();
  808. applet->Execute();
  809. IPC::ResponseBuilder rb{ctx, 2};
  810. rb.Push(ResultSuccess);
  811. }
  812. void PushInData(Kernel::HLERequestContext& ctx) {
  813. LOG_DEBUG(Service_AM, "called");
  814. IPC::RequestParser rp{ctx};
  815. applet->GetBroker().PushNormalDataFromGame(rp.PopIpcInterface<IStorage>().lock());
  816. IPC::ResponseBuilder rb{ctx, 2};
  817. rb.Push(ResultSuccess);
  818. }
  819. void PopOutData(Kernel::HLERequestContext& ctx) {
  820. LOG_DEBUG(Service_AM, "called");
  821. auto storage = applet->GetBroker().PopNormalDataToGame();
  822. if (storage == nullptr) {
  823. LOG_DEBUG(Service_AM,
  824. "storage is a nullptr. There is no data in the current normal channel");
  825. IPC::ResponseBuilder rb{ctx, 2};
  826. rb.Push(ERR_NO_DATA_IN_CHANNEL);
  827. return;
  828. }
  829. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  830. rb.Push(ResultSuccess);
  831. rb.PushIpcInterface<IStorage>(std::move(storage));
  832. }
  833. void PushInteractiveInData(Kernel::HLERequestContext& ctx) {
  834. LOG_DEBUG(Service_AM, "called");
  835. IPC::RequestParser rp{ctx};
  836. applet->GetBroker().PushInteractiveDataFromGame(rp.PopIpcInterface<IStorage>().lock());
  837. ASSERT(applet->IsInitialized());
  838. applet->ExecuteInteractive();
  839. applet->Execute();
  840. IPC::ResponseBuilder rb{ctx, 2};
  841. rb.Push(ResultSuccess);
  842. }
  843. void PopInteractiveOutData(Kernel::HLERequestContext& ctx) {
  844. LOG_DEBUG(Service_AM, "called");
  845. auto storage = applet->GetBroker().PopInteractiveDataToGame();
  846. if (storage == nullptr) {
  847. LOG_DEBUG(Service_AM,
  848. "storage is a nullptr. There is no data in the current interactive channel");
  849. IPC::ResponseBuilder rb{ctx, 2};
  850. rb.Push(ERR_NO_DATA_IN_CHANNEL);
  851. return;
  852. }
  853. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  854. rb.Push(ResultSuccess);
  855. rb.PushIpcInterface<IStorage>(std::move(storage));
  856. }
  857. void GetPopOutDataEvent(Kernel::HLERequestContext& ctx) {
  858. LOG_DEBUG(Service_AM, "called");
  859. IPC::ResponseBuilder rb{ctx, 2, 1};
  860. rb.Push(ResultSuccess);
  861. rb.PushCopyObjects(applet->GetBroker().GetNormalDataEvent());
  862. }
  863. void GetPopInteractiveOutDataEvent(Kernel::HLERequestContext& ctx) {
  864. LOG_DEBUG(Service_AM, "called");
  865. IPC::ResponseBuilder rb{ctx, 2, 1};
  866. rb.Push(ResultSuccess);
  867. rb.PushCopyObjects(applet->GetBroker().GetInteractiveDataEvent());
  868. }
  869. void GetIndirectLayerConsumerHandle(Kernel::HLERequestContext& ctx) {
  870. LOG_WARNING(Service_AM, "(STUBBED) called");
  871. // We require a non-zero handle to be valid. Using 0xdeadbeef allows us to trace if this is
  872. // actually used anywhere
  873. constexpr u64 handle = 0xdeadbeef;
  874. IPC::ResponseBuilder rb{ctx, 4};
  875. rb.Push(ResultSuccess);
  876. rb.Push(handle);
  877. }
  878. std::shared_ptr<Applets::Applet> applet;
  879. };
  880. IStorageAccessor::IStorageAccessor(Core::System& system_, IStorage& backing_)
  881. : ServiceFramework{system_, "IStorageAccessor"}, backing{backing_} {
  882. // clang-format off
  883. static const FunctionInfo functions[] = {
  884. {0, &IStorageAccessor::GetSize, "GetSize"},
  885. {10, &IStorageAccessor::Write, "Write"},
  886. {11, &IStorageAccessor::Read, "Read"},
  887. };
  888. // clang-format on
  889. RegisterHandlers(functions);
  890. }
  891. IStorageAccessor::~IStorageAccessor() = default;
  892. void IStorageAccessor::GetSize(Kernel::HLERequestContext& ctx) {
  893. LOG_DEBUG(Service_AM, "called");
  894. IPC::ResponseBuilder rb{ctx, 4};
  895. rb.Push(ResultSuccess);
  896. rb.Push(static_cast<u64>(backing.GetSize()));
  897. }
  898. void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) {
  899. IPC::RequestParser rp{ctx};
  900. const u64 offset{rp.Pop<u64>()};
  901. const auto data{ctx.ReadBuffer()};
  902. const std::size_t size{std::min<u64>(data.size(), backing.GetSize() - offset)};
  903. LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
  904. if (offset > backing.GetSize()) {
  905. LOG_ERROR(Service_AM,
  906. "offset is out of bounds, backing_buffer_sz={}, data_size={}, offset={}",
  907. backing.GetSize(), size, offset);
  908. IPC::ResponseBuilder rb{ctx, 2};
  909. rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
  910. return;
  911. }
  912. std::memcpy(backing.GetData().data() + offset, data.data(), size);
  913. IPC::ResponseBuilder rb{ctx, 2};
  914. rb.Push(ResultSuccess);
  915. }
  916. void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
  917. IPC::RequestParser rp{ctx};
  918. const u64 offset{rp.Pop<u64>()};
  919. const std::size_t size{std::min<u64>(ctx.GetWriteBufferSize(), backing.GetSize() - offset)};
  920. LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
  921. if (offset > backing.GetSize()) {
  922. LOG_ERROR(Service_AM, "offset is out of bounds, backing_buffer_sz={}, size={}, offset={}",
  923. backing.GetSize(), size, offset);
  924. IPC::ResponseBuilder rb{ctx, 2};
  925. rb.Push(ERR_SIZE_OUT_OF_BOUNDS);
  926. return;
  927. }
  928. ctx.WriteBuffer(backing.GetData().data() + offset, size);
  929. IPC::ResponseBuilder rb{ctx, 2};
  930. rb.Push(ResultSuccess);
  931. }
  932. ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_)
  933. : ServiceFramework{system_, "ILibraryAppletCreator"} {
  934. static const FunctionInfo functions[] = {
  935. {0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"},
  936. {1, nullptr, "TerminateAllLibraryApplets"},
  937. {2, nullptr, "AreAnyLibraryAppletsLeft"},
  938. {10, &ILibraryAppletCreator::CreateStorage, "CreateStorage"},
  939. {11, &ILibraryAppletCreator::CreateTransferMemoryStorage, "CreateTransferMemoryStorage"},
  940. {12, &ILibraryAppletCreator::CreateHandleStorage, "CreateHandleStorage"},
  941. };
  942. RegisterHandlers(functions);
  943. }
  944. ILibraryAppletCreator::~ILibraryAppletCreator() = default;
  945. void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx) {
  946. IPC::RequestParser rp{ctx};
  947. const auto applet_id = rp.PopRaw<Applets::AppletId>();
  948. const auto applet_mode = rp.PopRaw<Applets::LibraryAppletMode>();
  949. LOG_DEBUG(Service_AM, "called with applet_id={:08X}, applet_mode={:08X}", applet_id,
  950. applet_mode);
  951. const auto& applet_manager{system.GetAppletManager()};
  952. const auto applet = applet_manager.GetApplet(applet_id, applet_mode);
  953. if (applet == nullptr) {
  954. LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", applet_id);
  955. IPC::ResponseBuilder rb{ctx, 2};
  956. rb.Push(ResultUnknown);
  957. return;
  958. }
  959. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  960. rb.Push(ResultSuccess);
  961. rb.PushIpcInterface<ILibraryAppletAccessor>(system, applet);
  962. }
  963. void ILibraryAppletCreator::CreateStorage(Kernel::HLERequestContext& ctx) {
  964. IPC::RequestParser rp{ctx};
  965. const s64 size{rp.Pop<s64>()};
  966. LOG_DEBUG(Service_AM, "called, size={}", size);
  967. if (size <= 0) {
  968. LOG_ERROR(Service_AM, "size is less than or equal to 0");
  969. IPC::ResponseBuilder rb{ctx, 2};
  970. rb.Push(ResultUnknown);
  971. return;
  972. }
  973. std::vector<u8> buffer(size);
  974. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  975. rb.Push(ResultSuccess);
  976. rb.PushIpcInterface<IStorage>(system, std::move(buffer));
  977. }
  978. void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx) {
  979. IPC::RequestParser rp{ctx};
  980. struct Parameters {
  981. u8 permissions;
  982. s64 size;
  983. };
  984. const auto parameters{rp.PopRaw<Parameters>()};
  985. const auto handle{ctx.GetCopyHandle(0)};
  986. LOG_DEBUG(Service_AM, "called, permissions={}, size={}, handle={:08X}", parameters.permissions,
  987. parameters.size, handle);
  988. if (parameters.size <= 0) {
  989. LOG_ERROR(Service_AM, "size is less than or equal to 0");
  990. IPC::ResponseBuilder rb{ctx, 2};
  991. rb.Push(ResultUnknown);
  992. return;
  993. }
  994. auto transfer_mem =
  995. system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle);
  996. if (transfer_mem.IsNull()) {
  997. LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle);
  998. IPC::ResponseBuilder rb{ctx, 2};
  999. rb.Push(ResultUnknown);
  1000. return;
  1001. }
  1002. const u8* const mem_begin = system.Memory().GetPointer(transfer_mem->GetSourceAddress());
  1003. const u8* const mem_end = mem_begin + transfer_mem->GetSize();
  1004. std::vector<u8> memory{mem_begin, mem_end};
  1005. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  1006. rb.Push(ResultSuccess);
  1007. rb.PushIpcInterface<IStorage>(system, std::move(memory));
  1008. }
  1009. void ILibraryAppletCreator::CreateHandleStorage(Kernel::HLERequestContext& ctx) {
  1010. IPC::RequestParser rp{ctx};
  1011. const s64 size{rp.Pop<s64>()};
  1012. const auto handle{ctx.GetCopyHandle(0)};
  1013. LOG_DEBUG(Service_AM, "called, size={}, handle={:08X}", size, handle);
  1014. if (size <= 0) {
  1015. LOG_ERROR(Service_AM, "size is less than or equal to 0");
  1016. IPC::ResponseBuilder rb{ctx, 2};
  1017. rb.Push(ResultUnknown);
  1018. return;
  1019. }
  1020. auto transfer_mem =
  1021. system.ApplicationProcess()->GetHandleTable().GetObject<Kernel::KTransferMemory>(handle);
  1022. if (transfer_mem.IsNull()) {
  1023. LOG_ERROR(Service_AM, "transfer_mem is a nullptr for handle={:08X}", handle);
  1024. IPC::ResponseBuilder rb{ctx, 2};
  1025. rb.Push(ResultUnknown);
  1026. return;
  1027. }
  1028. const u8* const mem_begin = system.Memory().GetPointer(transfer_mem->GetSourceAddress());
  1029. const u8* const mem_end = mem_begin + transfer_mem->GetSize();
  1030. std::vector<u8> memory{mem_begin, mem_end};
  1031. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  1032. rb.Push(ResultSuccess);
  1033. rb.PushIpcInterface<IStorage>(system, std::move(memory));
  1034. }
  1035. IApplicationFunctions::IApplicationFunctions(Core::System& system_)
  1036. : ServiceFramework{system_, "IApplicationFunctions"}, service_context{system,
  1037. "IApplicationFunctions"} {
  1038. // clang-format off
  1039. static const FunctionInfo functions[] = {
  1040. {1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
  1041. {10, nullptr, "CreateApplicationAndPushAndRequestToStart"},
  1042. {11, nullptr, "CreateApplicationAndPushAndRequestToStartForQuest"},
  1043. {12, nullptr, "CreateApplicationAndRequestToStart"},
  1044. {13, &IApplicationFunctions::CreateApplicationAndRequestToStartForQuest, "CreateApplicationAndRequestToStartForQuest"},
  1045. {14, nullptr, "CreateApplicationWithAttributeAndPushAndRequestToStartForQuest"},
  1046. {15, nullptr, "CreateApplicationWithAttributeAndRequestToStartForQuest"},
  1047. {20, &IApplicationFunctions::EnsureSaveData, "EnsureSaveData"},
  1048. {21, &IApplicationFunctions::GetDesiredLanguage, "GetDesiredLanguage"},
  1049. {22, &IApplicationFunctions::SetTerminateResult, "SetTerminateResult"},
  1050. {23, &IApplicationFunctions::GetDisplayVersion, "GetDisplayVersion"},
  1051. {24, nullptr, "GetLaunchStorageInfoForDebug"},
  1052. {25, &IApplicationFunctions::ExtendSaveData, "ExtendSaveData"},
  1053. {26, &IApplicationFunctions::GetSaveDataSize, "GetSaveDataSize"},
  1054. {27, nullptr, "CreateCacheStorage"},
  1055. {28, nullptr, "GetSaveDataSizeMax"},
  1056. {29, nullptr, "GetCacheStorageMax"},
  1057. {30, &IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed, "BeginBlockingHomeButtonShortAndLongPressed"},
  1058. {31, &IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed, "EndBlockingHomeButtonShortAndLongPressed"},
  1059. {32, &IApplicationFunctions::BeginBlockingHomeButton, "BeginBlockingHomeButton"},
  1060. {33, &IApplicationFunctions::EndBlockingHomeButton, "EndBlockingHomeButton"},
  1061. {34, nullptr, "SelectApplicationLicense"},
  1062. {35, nullptr, "GetDeviceSaveDataSizeMax"},
  1063. {36, nullptr, "GetLimitedApplicationLicense"},
  1064. {37, nullptr, "GetLimitedApplicationLicenseUpgradableEvent"},
  1065. {40, &IApplicationFunctions::NotifyRunning, "NotifyRunning"},
  1066. {50, &IApplicationFunctions::GetPseudoDeviceId, "GetPseudoDeviceId"},
  1067. {60, nullptr, "SetMediaPlaybackStateForApplication"},
  1068. {65, &IApplicationFunctions::IsGamePlayRecordingSupported, "IsGamePlayRecordingSupported"},
  1069. {66, &IApplicationFunctions::InitializeGamePlayRecording, "InitializeGamePlayRecording"},
  1070. {67, &IApplicationFunctions::SetGamePlayRecordingState, "SetGamePlayRecordingState"},
  1071. {68, nullptr, "RequestFlushGamePlayingMovieForDebug"},
  1072. {70, nullptr, "RequestToShutdown"},
  1073. {71, nullptr, "RequestToReboot"},
  1074. {72, nullptr, "RequestToSleep"},
  1075. {80, nullptr, "ExitAndRequestToShowThanksMessage"},
  1076. {90, &IApplicationFunctions::EnableApplicationCrashReport, "EnableApplicationCrashReport"},
  1077. {100, &IApplicationFunctions::InitializeApplicationCopyrightFrameBuffer, "InitializeApplicationCopyrightFrameBuffer"},
  1078. {101, &IApplicationFunctions::SetApplicationCopyrightImage, "SetApplicationCopyrightImage"},
  1079. {102, &IApplicationFunctions::SetApplicationCopyrightVisibility, "SetApplicationCopyrightVisibility"},
  1080. {110, &IApplicationFunctions::QueryApplicationPlayStatistics, "QueryApplicationPlayStatistics"},
  1081. {111, &IApplicationFunctions::QueryApplicationPlayStatisticsByUid, "QueryApplicationPlayStatisticsByUid"},
  1082. {120, &IApplicationFunctions::ExecuteProgram, "ExecuteProgram"},
  1083. {121, &IApplicationFunctions::ClearUserChannel, "ClearUserChannel"},
  1084. {122, &IApplicationFunctions::UnpopToUserChannel, "UnpopToUserChannel"},
  1085. {123, &IApplicationFunctions::GetPreviousProgramIndex, "GetPreviousProgramIndex"},
  1086. {124, nullptr, "EnableApplicationAllThreadDumpOnCrash"},
  1087. {130, &IApplicationFunctions::GetGpuErrorDetectedSystemEvent, "GetGpuErrorDetectedSystemEvent"},
  1088. {131, nullptr, "SetDelayTimeToAbortOnGpuError"},
  1089. {140, &IApplicationFunctions::GetFriendInvitationStorageChannelEvent, "GetFriendInvitationStorageChannelEvent"},
  1090. {141, &IApplicationFunctions::TryPopFromFriendInvitationStorageChannel, "TryPopFromFriendInvitationStorageChannel"},
  1091. {150, &IApplicationFunctions::GetNotificationStorageChannelEvent, "GetNotificationStorageChannelEvent"},
  1092. {151, nullptr, "TryPopFromNotificationStorageChannel"},
  1093. {160, &IApplicationFunctions::GetHealthWarningDisappearedSystemEvent, "GetHealthWarningDisappearedSystemEvent"},
  1094. {170, nullptr, "SetHdcpAuthenticationActivated"},
  1095. {180, nullptr, "GetLaunchRequiredVersion"},
  1096. {181, nullptr, "UpgradeLaunchRequiredVersion"},
  1097. {190, nullptr, "SendServerMaintenanceOverlayNotification"},
  1098. {200, nullptr, "GetLastApplicationExitReason"},
  1099. {500, nullptr, "StartContinuousRecordingFlushForDebug"},
  1100. {1000, nullptr, "CreateMovieMaker"},
  1101. {1001, &IApplicationFunctions::PrepareForJit, "PrepareForJit"},
  1102. };
  1103. // clang-format on
  1104. RegisterHandlers(functions);
  1105. gpu_error_detected_event =
  1106. service_context.CreateEvent("IApplicationFunctions:GpuErrorDetectedSystemEvent");
  1107. friend_invitation_storage_channel_event =
  1108. service_context.CreateEvent("IApplicationFunctions:FriendInvitationStorageChannelEvent");
  1109. notification_storage_channel_event =
  1110. service_context.CreateEvent("IApplicationFunctions:NotificationStorageChannelEvent");
  1111. health_warning_disappeared_system_event =
  1112. service_context.CreateEvent("IApplicationFunctions:HealthWarningDisappearedSystemEvent");
  1113. }
  1114. IApplicationFunctions::~IApplicationFunctions() {
  1115. service_context.CloseEvent(gpu_error_detected_event);
  1116. service_context.CloseEvent(friend_invitation_storage_channel_event);
  1117. service_context.CloseEvent(notification_storage_channel_event);
  1118. service_context.CloseEvent(health_warning_disappeared_system_event);
  1119. }
  1120. void IApplicationFunctions::EnableApplicationCrashReport(Kernel::HLERequestContext& ctx) {
  1121. LOG_WARNING(Service_AM, "(STUBBED) called");
  1122. IPC::ResponseBuilder rb{ctx, 2};
  1123. rb.Push(ResultSuccess);
  1124. }
  1125. void IApplicationFunctions::InitializeApplicationCopyrightFrameBuffer(
  1126. Kernel::HLERequestContext& ctx) {
  1127. LOG_WARNING(Service_AM, "(STUBBED) called");
  1128. IPC::ResponseBuilder rb{ctx, 2};
  1129. rb.Push(ResultSuccess);
  1130. }
  1131. void IApplicationFunctions::SetApplicationCopyrightImage(Kernel::HLERequestContext& ctx) {
  1132. LOG_WARNING(Service_AM, "(STUBBED) called");
  1133. IPC::ResponseBuilder rb{ctx, 2};
  1134. rb.Push(ResultSuccess);
  1135. }
  1136. void IApplicationFunctions::SetApplicationCopyrightVisibility(Kernel::HLERequestContext& ctx) {
  1137. IPC::RequestParser rp{ctx};
  1138. const auto is_visible = rp.Pop<bool>();
  1139. LOG_WARNING(Service_AM, "(STUBBED) called, is_visible={}", is_visible);
  1140. IPC::ResponseBuilder rb{ctx, 2};
  1141. rb.Push(ResultSuccess);
  1142. }
  1143. void IApplicationFunctions::BeginBlockingHomeButtonShortAndLongPressed(
  1144. Kernel::HLERequestContext& ctx) {
  1145. LOG_WARNING(Service_AM, "(STUBBED) called");
  1146. IPC::ResponseBuilder rb{ctx, 2};
  1147. rb.Push(ResultSuccess);
  1148. }
  1149. void IApplicationFunctions::EndBlockingHomeButtonShortAndLongPressed(
  1150. Kernel::HLERequestContext& ctx) {
  1151. LOG_WARNING(Service_AM, "(STUBBED) called");
  1152. IPC::ResponseBuilder rb{ctx, 2};
  1153. rb.Push(ResultSuccess);
  1154. }
  1155. void IApplicationFunctions::BeginBlockingHomeButton(Kernel::HLERequestContext& ctx) {
  1156. LOG_WARNING(Service_AM, "(STUBBED) called");
  1157. IPC::ResponseBuilder rb{ctx, 2};
  1158. rb.Push(ResultSuccess);
  1159. }
  1160. void IApplicationFunctions::EndBlockingHomeButton(Kernel::HLERequestContext& ctx) {
  1161. LOG_WARNING(Service_AM, "(STUBBED) called");
  1162. IPC::ResponseBuilder rb{ctx, 2};
  1163. rb.Push(ResultSuccess);
  1164. }
  1165. void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
  1166. IPC::RequestParser rp{ctx};
  1167. const auto kind = rp.PopEnum<LaunchParameterKind>();
  1168. LOG_DEBUG(Service_AM, "called, kind={:08X}", kind);
  1169. if (kind == LaunchParameterKind::ApplicationSpecific && !launch_popped_application_specific) {
  1170. const auto backend = BCAT::CreateBackendFromSettings(system, [this](u64 tid) {
  1171. return system.GetFileSystemController().GetBCATDirectory(tid);
  1172. });
  1173. const auto build_id_full = system.GetApplicationProcessBuildID();
  1174. u64 build_id{};
  1175. std::memcpy(&build_id, build_id_full.data(), sizeof(u64));
  1176. auto data =
  1177. backend->GetLaunchParameter({system.GetApplicationProcessProgramID(), build_id});
  1178. if (data.has_value()) {
  1179. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  1180. rb.Push(ResultSuccess);
  1181. rb.PushIpcInterface<IStorage>(system, std::move(*data));
  1182. launch_popped_application_specific = true;
  1183. return;
  1184. }
  1185. } else if (kind == LaunchParameterKind::AccountPreselectedUser &&
  1186. !launch_popped_account_preselect) {
  1187. LaunchParameterAccountPreselectedUser params{};
  1188. params.magic = LAUNCH_PARAMETER_ACCOUNT_PRESELECTED_USER_MAGIC;
  1189. params.is_account_selected = 1;
  1190. Account::ProfileManager profile_manager{};
  1191. const auto uuid = profile_manager.GetUser(static_cast<s32>(Settings::values.current_user));
  1192. ASSERT(uuid.has_value() && uuid->IsValid());
  1193. params.current_user = *uuid;
  1194. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  1195. rb.Push(ResultSuccess);
  1196. std::vector<u8> buffer(sizeof(LaunchParameterAccountPreselectedUser));
  1197. std::memcpy(buffer.data(), &params, buffer.size());
  1198. rb.PushIpcInterface<IStorage>(system, std::move(buffer));
  1199. launch_popped_account_preselect = true;
  1200. return;
  1201. }
  1202. LOG_ERROR(Service_AM, "Attempted to load launch parameter but none was found!");
  1203. IPC::ResponseBuilder rb{ctx, 2};
  1204. rb.Push(ERR_NO_DATA_IN_CHANNEL);
  1205. }
  1206. void IApplicationFunctions::CreateApplicationAndRequestToStartForQuest(
  1207. Kernel::HLERequestContext& ctx) {
  1208. LOG_WARNING(Service_AM, "(STUBBED) called");
  1209. IPC::ResponseBuilder rb{ctx, 2};
  1210. rb.Push(ResultSuccess);
  1211. }
  1212. void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
  1213. IPC::RequestParser rp{ctx};
  1214. u128 user_id = rp.PopRaw<u128>();
  1215. LOG_DEBUG(Service_AM, "called, uid={:016X}{:016X}", user_id[1], user_id[0]);
  1216. FileSys::SaveDataAttribute attribute{};
  1217. attribute.title_id = system.GetApplicationProcessProgramID();
  1218. attribute.user_id = user_id;
  1219. attribute.type = FileSys::SaveDataType::SaveData;
  1220. const auto res = system.GetFileSystemController().CreateSaveData(
  1221. FileSys::SaveDataSpaceId::NandUser, attribute);
  1222. IPC::ResponseBuilder rb{ctx, 4};
  1223. rb.Push(res.Code());
  1224. rb.Push<u64>(0);
  1225. }
  1226. void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) {
  1227. // Takes an input u32 Result, no output.
  1228. // For example, in some cases official apps use this with error 0x2A2 then
  1229. // uses svcBreak.
  1230. IPC::RequestParser rp{ctx};
  1231. u32 result = rp.Pop<u32>();
  1232. LOG_WARNING(Service_AM, "(STUBBED) called, result=0x{:08X}", result);
  1233. IPC::ResponseBuilder rb{ctx, 2};
  1234. rb.Push(ResultSuccess);
  1235. }
  1236. void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
  1237. LOG_DEBUG(Service_AM, "called");
  1238. std::array<u8, 0x10> version_string{};
  1239. const auto res = [this] {
  1240. const auto title_id = system.GetApplicationProcessProgramID();
  1241. const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
  1242. system.GetContentProvider()};
  1243. auto metadata = pm.GetControlMetadata();
  1244. if (metadata.first != nullptr) {
  1245. return metadata;
  1246. }
  1247. const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id),
  1248. system.GetFileSystemController(),
  1249. system.GetContentProvider()};
  1250. return pm_update.GetControlMetadata();
  1251. }();
  1252. if (res.first != nullptr) {
  1253. const auto& version = res.first->GetVersionString();
  1254. std::copy(version.begin(), version.end(), version_string.begin());
  1255. } else {
  1256. static constexpr char default_version[]{"1.0.0"};
  1257. std::memcpy(version_string.data(), default_version, sizeof(default_version));
  1258. }
  1259. IPC::ResponseBuilder rb{ctx, 6};
  1260. rb.Push(ResultSuccess);
  1261. rb.PushRaw(version_string);
  1262. }
  1263. void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
  1264. // TODO(bunnei): This should be configurable
  1265. LOG_DEBUG(Service_AM, "called");
  1266. // Get supported languages from NACP, if possible
  1267. // Default to 0 (all languages supported)
  1268. u32 supported_languages = 0;
  1269. const auto res = [this] {
  1270. const auto title_id = system.GetApplicationProcessProgramID();
  1271. const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
  1272. system.GetContentProvider()};
  1273. auto metadata = pm.GetControlMetadata();
  1274. if (metadata.first != nullptr) {
  1275. return metadata;
  1276. }
  1277. const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id),
  1278. system.GetFileSystemController(),
  1279. system.GetContentProvider()};
  1280. return pm_update.GetControlMetadata();
  1281. }();
  1282. if (res.first != nullptr) {
  1283. supported_languages = res.first->GetSupportedLanguages();
  1284. }
  1285. // Call IApplicationManagerInterface implementation.
  1286. auto& service_manager = system.ServiceManager();
  1287. auto ns_am2 = service_manager.GetService<NS::NS>("ns:am2");
  1288. auto app_man = ns_am2->GetApplicationManagerInterface();
  1289. // Get desired application language
  1290. const auto res_lang = app_man->GetApplicationDesiredLanguage(supported_languages);
  1291. if (res_lang.Failed()) {
  1292. IPC::ResponseBuilder rb{ctx, 2};
  1293. rb.Push(res_lang.Code());
  1294. return;
  1295. }
  1296. // Convert to settings language code.
  1297. const auto res_code = app_man->ConvertApplicationLanguageToLanguageCode(*res_lang);
  1298. if (res_code.Failed()) {
  1299. IPC::ResponseBuilder rb{ctx, 2};
  1300. rb.Push(res_code.Code());
  1301. return;
  1302. }
  1303. LOG_DEBUG(Service_AM, "got desired_language={:016X}", *res_code);
  1304. IPC::ResponseBuilder rb{ctx, 4};
  1305. rb.Push(ResultSuccess);
  1306. rb.Push(*res_code);
  1307. }
  1308. void IApplicationFunctions::IsGamePlayRecordingSupported(Kernel::HLERequestContext& ctx) {
  1309. LOG_WARNING(Service_AM, "(STUBBED) called");
  1310. constexpr bool gameplay_recording_supported = false;
  1311. IPC::ResponseBuilder rb{ctx, 3};
  1312. rb.Push(ResultSuccess);
  1313. rb.Push(gameplay_recording_supported);
  1314. }
  1315. void IApplicationFunctions::InitializeGamePlayRecording(Kernel::HLERequestContext& ctx) {
  1316. LOG_WARNING(Service_AM, "(STUBBED) called");
  1317. IPC::ResponseBuilder rb{ctx, 2};
  1318. rb.Push(ResultSuccess);
  1319. }
  1320. void IApplicationFunctions::SetGamePlayRecordingState(Kernel::HLERequestContext& ctx) {
  1321. LOG_WARNING(Service_AM, "(STUBBED) called");
  1322. IPC::ResponseBuilder rb{ctx, 2};
  1323. rb.Push(ResultSuccess);
  1324. }
  1325. void IApplicationFunctions::NotifyRunning(Kernel::HLERequestContext& ctx) {
  1326. LOG_WARNING(Service_AM, "(STUBBED) called");
  1327. IPC::ResponseBuilder rb{ctx, 3};
  1328. rb.Push(ResultSuccess);
  1329. rb.Push<u8>(0); // Unknown, seems to be ignored by official processes
  1330. }
  1331. void IApplicationFunctions::GetPseudoDeviceId(Kernel::HLERequestContext& ctx) {
  1332. LOG_WARNING(Service_AM, "(STUBBED) called");
  1333. IPC::ResponseBuilder rb{ctx, 6};
  1334. rb.Push(ResultSuccess);
  1335. // Returns a 128-bit UUID
  1336. rb.Push<u64>(0);
  1337. rb.Push<u64>(0);
  1338. }
  1339. void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
  1340. struct Parameters {
  1341. FileSys::SaveDataType type;
  1342. u128 user_id;
  1343. u64 new_normal_size;
  1344. u64 new_journal_size;
  1345. };
  1346. static_assert(sizeof(Parameters) == 40);
  1347. IPC::RequestParser rp{ctx};
  1348. const auto [type, user_id, new_normal_size, new_journal_size] = rp.PopRaw<Parameters>();
  1349. LOG_DEBUG(Service_AM,
  1350. "called with type={:02X}, user_id={:016X}{:016X}, new_normal={:016X}, "
  1351. "new_journal={:016X}",
  1352. static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);
  1353. system.GetFileSystemController().WriteSaveDataSize(
  1354. type, system.GetApplicationProcessProgramID(), user_id,
  1355. {new_normal_size, new_journal_size});
  1356. IPC::ResponseBuilder rb{ctx, 4};
  1357. rb.Push(ResultSuccess);
  1358. // The following value is used upon failure to help the system recover.
  1359. // Since we always succeed, this should be 0.
  1360. rb.Push<u64>(0);
  1361. }
  1362. void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
  1363. struct Parameters {
  1364. FileSys::SaveDataType type;
  1365. u128 user_id;
  1366. };
  1367. static_assert(sizeof(Parameters) == 24);
  1368. IPC::RequestParser rp{ctx};
  1369. const auto [type, user_id] = rp.PopRaw<Parameters>();
  1370. LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", type, user_id[1],
  1371. user_id[0]);
  1372. const auto size = system.GetFileSystemController().ReadSaveDataSize(
  1373. type, system.GetApplicationProcessProgramID(), user_id);
  1374. IPC::ResponseBuilder rb{ctx, 6};
  1375. rb.Push(ResultSuccess);
  1376. rb.Push(size.normal);
  1377. rb.Push(size.journal);
  1378. }
  1379. void IApplicationFunctions::QueryApplicationPlayStatistics(Kernel::HLERequestContext& ctx) {
  1380. LOG_WARNING(Service_AM, "(STUBBED) called");
  1381. IPC::ResponseBuilder rb{ctx, 3};
  1382. rb.Push(ResultSuccess);
  1383. rb.Push<u32>(0);
  1384. }
  1385. void IApplicationFunctions::QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx) {
  1386. LOG_WARNING(Service_AM, "(STUBBED) called");
  1387. IPC::ResponseBuilder rb{ctx, 3};
  1388. rb.Push(ResultSuccess);
  1389. rb.Push<u32>(0);
  1390. }
  1391. void IApplicationFunctions::ExecuteProgram(Kernel::HLERequestContext& ctx) {
  1392. LOG_WARNING(Service_AM, "(STUBBED) called");
  1393. IPC::RequestParser rp{ctx};
  1394. [[maybe_unused]] const auto unk_1 = rp.Pop<u32>();
  1395. [[maybe_unused]] const auto unk_2 = rp.Pop<u32>();
  1396. const auto program_index = rp.Pop<u64>();
  1397. IPC::ResponseBuilder rb{ctx, 2};
  1398. rb.Push(ResultSuccess);
  1399. system.ExecuteProgram(program_index);
  1400. }
  1401. void IApplicationFunctions::ClearUserChannel(Kernel::HLERequestContext& ctx) {
  1402. LOG_WARNING(Service_AM, "(STUBBED) called");
  1403. IPC::ResponseBuilder rb{ctx, 2};
  1404. rb.Push(ResultSuccess);
  1405. }
  1406. void IApplicationFunctions::UnpopToUserChannel(Kernel::HLERequestContext& ctx) {
  1407. LOG_WARNING(Service_AM, "(STUBBED) called");
  1408. IPC::ResponseBuilder rb{ctx, 2};
  1409. rb.Push(ResultSuccess);
  1410. }
  1411. void IApplicationFunctions::GetPreviousProgramIndex(Kernel::HLERequestContext& ctx) {
  1412. LOG_WARNING(Service_AM, "(STUBBED) called");
  1413. IPC::ResponseBuilder rb{ctx, 3};
  1414. rb.Push(ResultSuccess);
  1415. rb.Push<s32>(previous_program_index);
  1416. }
  1417. void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx) {
  1418. LOG_WARNING(Service_AM, "(STUBBED) called");
  1419. IPC::ResponseBuilder rb{ctx, 2, 1};
  1420. rb.Push(ResultSuccess);
  1421. rb.PushCopyObjects(gpu_error_detected_event->GetReadableEvent());
  1422. }
  1423. void IApplicationFunctions::GetFriendInvitationStorageChannelEvent(Kernel::HLERequestContext& ctx) {
  1424. LOG_DEBUG(Service_AM, "called");
  1425. IPC::ResponseBuilder rb{ctx, 2, 1};
  1426. rb.Push(ResultSuccess);
  1427. rb.PushCopyObjects(friend_invitation_storage_channel_event->GetReadableEvent());
  1428. }
  1429. void IApplicationFunctions::TryPopFromFriendInvitationStorageChannel(
  1430. Kernel::HLERequestContext& ctx) {
  1431. LOG_WARNING(Service_AM, "(STUBBED) called");
  1432. IPC::ResponseBuilder rb{ctx, 2};
  1433. rb.Push(ERR_NO_DATA_IN_CHANNEL);
  1434. }
  1435. void IApplicationFunctions::GetNotificationStorageChannelEvent(Kernel::HLERequestContext& ctx) {
  1436. LOG_DEBUG(Service_AM, "called");
  1437. IPC::ResponseBuilder rb{ctx, 2, 1};
  1438. rb.Push(ResultSuccess);
  1439. rb.PushCopyObjects(notification_storage_channel_event->GetReadableEvent());
  1440. }
  1441. void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx) {
  1442. LOG_DEBUG(Service_AM, "called");
  1443. IPC::ResponseBuilder rb{ctx, 2, 1};
  1444. rb.Push(ResultSuccess);
  1445. rb.PushCopyObjects(health_warning_disappeared_system_event->GetReadableEvent());
  1446. }
  1447. void IApplicationFunctions::PrepareForJit(Kernel::HLERequestContext& ctx) {
  1448. LOG_WARNING(Service_AM, "(STUBBED) called");
  1449. IPC::ResponseBuilder rb{ctx, 2};
  1450. rb.Push(ResultSuccess);
  1451. }
  1452. void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system) {
  1453. auto message_queue = std::make_shared<AppletMessageQueue>(system);
  1454. // Needed on game boot
  1455. message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
  1456. auto server_manager = std::make_unique<ServerManager>(system);
  1457. server_manager->RegisterNamedService(
  1458. "appletAE", std::make_shared<AppletAE>(nvflinger, message_queue, system));
  1459. server_manager->RegisterNamedService(
  1460. "appletOE", std::make_shared<AppletOE>(nvflinger, message_queue, system));
  1461. server_manager->RegisterNamedService("idle:sys", std::make_shared<IdleSys>(system));
  1462. server_manager->RegisterNamedService("omm", std::make_shared<OMM>(system));
  1463. server_manager->RegisterNamedService("spsm", std::make_shared<SPSM>(system));
  1464. ServerManager::RunServer(std::move(server_manager));
  1465. }
  1466. IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)
  1467. : ServiceFramework{system_, "IHomeMenuFunctions"}, service_context{system,
  1468. "IHomeMenuFunctions"} {
  1469. // clang-format off
  1470. static const FunctionInfo functions[] = {
  1471. {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"},
  1472. {11, nullptr, "LockForeground"},
  1473. {12, nullptr, "UnlockForeground"},
  1474. {20, nullptr, "PopFromGeneralChannel"},
  1475. {21, &IHomeMenuFunctions::GetPopFromGeneralChannelEvent, "GetPopFromGeneralChannelEvent"},
  1476. {30, nullptr, "GetHomeButtonWriterLockAccessor"},
  1477. {31, nullptr, "GetWriterLockAccessorEx"},
  1478. {40, nullptr, "IsSleepEnabled"},
  1479. {41, nullptr, "IsRebootEnabled"},
  1480. {100, nullptr, "PopRequestLaunchApplicationForDebug"},
  1481. {110, nullptr, "IsForceTerminateApplicationDisabledForDebug"},
  1482. {200, nullptr, "LaunchDevMenu"},
  1483. {1000, nullptr, "SetLastApplicationExitReason"},
  1484. };
  1485. // clang-format on
  1486. RegisterHandlers(functions);
  1487. pop_from_general_channel_event =
  1488. service_context.CreateEvent("IHomeMenuFunctions:PopFromGeneralChannelEvent");
  1489. }
  1490. IHomeMenuFunctions::~IHomeMenuFunctions() {
  1491. service_context.CloseEvent(pop_from_general_channel_event);
  1492. }
  1493. void IHomeMenuFunctions::RequestToGetForeground(Kernel::HLERequestContext& ctx) {
  1494. LOG_WARNING(Service_AM, "(STUBBED) called");
  1495. IPC::ResponseBuilder rb{ctx, 2};
  1496. rb.Push(ResultSuccess);
  1497. }
  1498. void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx) {
  1499. LOG_WARNING(Service_AM, "(STUBBED) called");
  1500. IPC::ResponseBuilder rb{ctx, 2, 1};
  1501. rb.Push(ResultSuccess);
  1502. rb.PushCopyObjects(pop_from_general_channel_event->GetReadableEvent());
  1503. }
  1504. IGlobalStateController::IGlobalStateController(Core::System& system_)
  1505. : ServiceFramework{system_, "IGlobalStateController"} {
  1506. // clang-format off
  1507. static const FunctionInfo functions[] = {
  1508. {0, nullptr, "RequestToEnterSleep"},
  1509. {1, nullptr, "EnterSleep"},
  1510. {2, nullptr, "StartSleepSequence"},
  1511. {3, nullptr, "StartShutdownSequence"},
  1512. {4, nullptr, "StartRebootSequence"},
  1513. {9, nullptr, "IsAutoPowerDownRequested"},
  1514. {10, nullptr, "LoadAndApplyIdlePolicySettings"},
  1515. {11, nullptr, "NotifyCecSettingsChanged"},
  1516. {12, nullptr, "SetDefaultHomeButtonLongPressTime"},
  1517. {13, nullptr, "UpdateDefaultDisplayResolution"},
  1518. {14, nullptr, "ShouldSleepOnBoot"},
  1519. {15, nullptr, "GetHdcpAuthenticationFailedEvent"},
  1520. {30, nullptr, "OpenCradleFirmwareUpdater"},
  1521. };
  1522. // clang-format on
  1523. RegisterHandlers(functions);
  1524. }
  1525. IGlobalStateController::~IGlobalStateController() = default;
  1526. IApplicationCreator::IApplicationCreator(Core::System& system_)
  1527. : ServiceFramework{system_, "IApplicationCreator"} {
  1528. // clang-format off
  1529. static const FunctionInfo functions[] = {
  1530. {0, nullptr, "CreateApplication"},
  1531. {1, nullptr, "PopLaunchRequestedApplication"},
  1532. {10, nullptr, "CreateSystemApplication"},
  1533. {100, nullptr, "PopFloatingApplicationForDevelopment"},
  1534. };
  1535. // clang-format on
  1536. RegisterHandlers(functions);
  1537. }
  1538. IApplicationCreator::~IApplicationCreator() = default;
  1539. IProcessWindingController::IProcessWindingController(Core::System& system_)
  1540. : ServiceFramework{system_, "IProcessWindingController"} {
  1541. // clang-format off
  1542. static const FunctionInfo functions[] = {
  1543. {0, nullptr, "GetLaunchReason"},
  1544. {11, nullptr, "OpenCallingLibraryApplet"},
  1545. {21, nullptr, "PushContext"},
  1546. {22, nullptr, "PopContext"},
  1547. {23, nullptr, "CancelWindingReservation"},
  1548. {30, nullptr, "WindAndDoReserved"},
  1549. {40, nullptr, "ReserveToStartAndWaitAndUnwindThis"},
  1550. {41, nullptr, "ReserveToStartAndWait"},
  1551. };
  1552. // clang-format on
  1553. RegisterHandlers(functions);
  1554. }
  1555. IProcessWindingController::~IProcessWindingController() = default;
  1556. } // namespace Service::AM