apt.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. // Copyright 2015 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <array>
  6. #include "core/hle/result.h"
  7. #include "core/hle/service/service.h"
  8. namespace Service {
  9. namespace APT {
  10. /// Signals used by APT functions
  11. enum class SignalType : u32 {
  12. None = 0x0,
  13. AppJustStarted = 0x1,
  14. ReturningToApp = 0xB,
  15. ExitingApp = 0xC,
  16. };
  17. /// App Id's used by APT functions
  18. enum class AppID : u32 {
  19. HomeMenu = 0x101,
  20. AlternateMenu = 0x103,
  21. Camera = 0x110,
  22. FriendsList = 0x112,
  23. GameNotes = 0x113,
  24. InternetBrowser = 0x114,
  25. InstructionManual = 0x115,
  26. Notifications = 0x116,
  27. Miiverse = 0x117,
  28. SoftwareKeyboard1 = 0x201,
  29. Ed = 0x202,
  30. PnoteApp = 0x204,
  31. SnoteApp = 0x205,
  32. Error = 0x206,
  33. Mint = 0x207,
  34. Extrapad = 0x208,
  35. Memolib = 0x209,
  36. Application = 0x300,
  37. SoftwareKeyboard2 = 0x401,
  38. };
  39. /**
  40. * APT::Initialize service function
  41. * Service function that initializes the APT process for the running application
  42. * Outputs:
  43. * 1 : Result of the function, 0 on success, otherwise error code
  44. * 3 : Handle to the notification event
  45. * 4 : Handle to the pause event
  46. */
  47. void Initialize(Service::Interface* self);
  48. /**
  49. * APT::GetSharedFont service function
  50. * Outputs:
  51. * 1 : Result of function, 0 on success, otherwise error code
  52. * 2 : Virtual address of where shared font will be loaded in memory
  53. * 4 : Handle to shared font memory
  54. */
  55. void GetSharedFont(Service::Interface* self);
  56. /**
  57. * APT::NotifyToWait service function
  58. * Inputs:
  59. * 1 : AppID
  60. * Outputs:
  61. * 1 : Result of function, 0 on success, otherwise error code
  62. */
  63. void NotifyToWait(Service::Interface* self);
  64. void GetLockHandle(Service::Interface* self);
  65. void Enable(Service::Interface* self);
  66. /**
  67. * APT::GetAppletManInfo service function.
  68. * Inputs:
  69. * 1 : Unknown
  70. * Outputs:
  71. * 1 : Result of function, 0 on success, otherwise error code
  72. * 2 : Unknown u32 value
  73. * 3 : Unknown u8 value
  74. * 4 : Home Menu AppId
  75. * 5 : AppID of currently active app
  76. */
  77. void GetAppletManInfo(Service::Interface* self);
  78. /**
  79. * APT::IsRegistered service function. This returns whether the specified AppID is registered with NS yet.
  80. * An AppID is "registered" once the process associated with the AppID uses APT:Enable. Home Menu uses this
  81. * command to determine when the launched process is running and to determine when to stop using GSP etc,
  82. * while displaying the "Nintendo 3DS" loading screen.
  83. * Inputs:
  84. * 1 : AppID
  85. * Outputs:
  86. * 0 : Return header
  87. * 1 : Result of function, 0 on success, otherwise error code
  88. * 2 : Output, 0 = not registered, 1 = registered.
  89. */
  90. void IsRegistered(Service::Interface* self);
  91. void InquireNotification(Service::Interface* self);
  92. /**
  93. * APT::SendParameter service function. This sets the parameter data state.
  94. * Inputs:
  95. * 1 : Source AppID
  96. * 2 : Destination AppID
  97. * 3 : Signal type
  98. * 4 : Parameter buffer size, max size is 0x1000 (this can be zero)
  99. * 5 : Value
  100. * 6 : Handle to the destination process, likely used for shared memory (this can be zero)
  101. * 7 : (Size<<14) | 2
  102. * 8 : Input parameter buffer ptr
  103. * Outputs:
  104. * 0 : Return Header
  105. * 1 : Result of function, 0 on success, otherwise error code
  106. */
  107. void SendParameter(Service::Interface* self);
  108. /**
  109. * APT::ReceiveParameter service function. This returns the current parameter data from NS state,
  110. * from the source process which set the parameters. Once finished, NS will clear a flag in the NS
  111. * state so that this command will return an error if this command is used again if parameters were
  112. * not set again. This is called when the second Initialize event is triggered. It returns a signal
  113. * type indicating why it was triggered.
  114. * Inputs:
  115. * 1 : AppID
  116. * 2 : Parameter buffer size, max size is 0x1000
  117. * Outputs:
  118. * 1 : Result of function, 0 on success, otherwise error code
  119. * 2 : AppID of the process which sent these parameters
  120. * 3 : Signal type
  121. * 4 : Actual parameter buffer size, this is <= to the the input size
  122. * 5 : Value
  123. * 6 : Handle from the source process which set the parameters, likely used for shared memory
  124. * 7 : Size
  125. * 8 : Output parameter buffer ptr
  126. */
  127. void ReceiveParameter(Service::Interface* self);
  128. /**
  129. * APT::GlanceParameter service function. This is exactly the same as APT_U::ReceiveParameter
  130. * (except for the word value prior to the output handle), except this will not clear the flag
  131. * (except when responseword[3]==8 || responseword[3]==9) in NS state.
  132. * Inputs:
  133. * 1 : AppID
  134. * 2 : Parameter buffer size, max size is 0x1000
  135. * Outputs:
  136. * 1 : Result of function, 0 on success, otherwise error code
  137. * 2 : Unknown, for now assume AppID of the process which sent these parameters
  138. * 3 : Unknown, for now assume Signal type
  139. * 4 : Actual parameter buffer size, this is <= to the the input size
  140. * 5 : Value
  141. * 6 : Handle from the source process which set the parameters, likely used for shared memory
  142. * 7 : Size
  143. * 8 : Output parameter buffer ptr
  144. */
  145. void GlanceParameter(Service::Interface* self);
  146. /**
  147. * APT::CancelParameter service function. When the parameter data is available, and when the above
  148. * specified fields match the ones in NS state(for the ones where the checks are enabled), this
  149. * clears the flag which indicates that parameter data is available
  150. * (same flag cleared by APT:ReceiveParameter).
  151. * Inputs:
  152. * 1 : Flag, when non-zero NS will compare the word after this one with a field in the NS state.
  153. * 2 : Unknown, this is the same as the first unknown field returned by APT:ReceiveParameter.
  154. * 3 : Flag, when non-zero NS will compare the word after this one with a field in the NS state.
  155. * 4 : AppID
  156. * Outputs:
  157. * 0 : Return header
  158. * 1 : Result of function, 0 on success, otherwise error code
  159. * 2 : Status flag, 0 = failure due to no parameter data being available, or the above enabled
  160. * fields don't match the fields in NS state. 1 = success.
  161. */
  162. void CancelParameter(Service::Interface* self);
  163. /**
  164. * APT::AppletUtility service function
  165. * Inputs:
  166. * 1 : Unknown, but clearly used for something
  167. * 2 : Buffer 1 size (purpose is unknown)
  168. * 3 : Buffer 2 size (purpose is unknown)
  169. * 5 : Buffer 1 address (purpose is unknown)
  170. * 65 : Buffer 2 address (purpose is unknown)
  171. * Outputs:
  172. * 1 : Result of function, 0 on success, otherwise error code
  173. */
  174. void AppletUtility(Service::Interface* self);
  175. /**
  176. * APT::SetAppCpuTimeLimit service function
  177. * Inputs:
  178. * 1 : Value, must be one
  179. * 2 : Percentage of CPU time from 5 to 80
  180. * Outputs:
  181. * 1 : Result of function, 0 on success, otherwise error code
  182. */
  183. void SetAppCpuTimeLimit(Service::Interface* self);
  184. /**
  185. * APT::GetAppCpuTimeLimit service function
  186. * Inputs:
  187. * 1 : Value, must be one
  188. * Outputs:
  189. * 0 : Return header
  190. * 1 : Result of function, 0 on success, otherwise error code
  191. * 2 : System core CPU time percentage
  192. */
  193. void GetAppCpuTimeLimit(Service::Interface* self);
  194. /// Initialize the APT service
  195. void APTInit();
  196. /// Shutdown the APT service
  197. void APTShutdown();
  198. } // namespace APT
  199. } // namespace Service