1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     applet_API.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 46369 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_APPLET_CTR_APPLET_API_H_
17 #define NN_APPLET_CTR_APPLET_API_H_
18 
19 #include <nn/os.h>
20 #include <nn/applet/CTR/applet_Parameters.h>
21 #include <nn/applet/CTR/applet_AppJump.h>
22 
23 #include <nn/gx.h>
24 #include <nn/hid.h>
25 #include <nn/fs/fs_Parameters.h>
26 
27 /* Please see man pages for details
28 
29 */
30 namespace nn {
31 namespace applet {
32 namespace CTR {
33 namespace detail {
34 
35     //---- Initialize/finalize
36     Result Initialize( AppletAttr appletAttr = DEFAULT_APPLET_ATTRIBUTE );
37     void   Enable(bool isSleepEnabled=true);
38 
39     bool   IsRegistered( AppletId appletId );
40     bool   WaitForRegister( AppletId appletId, nn::fnd::TimeSpan span );
41     bool   IsActive(void);
42     void   SetActive(void);
43     void   SetInactive(void);
44 
45     //================
46     // GPU rights
47     bool   IsGpuRightGiven(void);
48 
49     //================
50     // Attach sharedMemory
51     void AttachTransferMemoryHandle( os::TransferMemoryBlock* transferMemory, nn::Handle handle, size_t size, bit32 otherPermission );
52 
53     //================
54     // Send user message to applet
55     Result SendMessage( AppletId receiverId, const u8* pParam, size_t paramSize, nn::Handle handle=NN_APPLET_HANDLE_NONE, nn::fnd::TimeSpan timeout=WAIT_INFINITE );
56     Result TrySendMessage( AppletId receiverId, const u8* pParam, size_t paramSize, nn::Handle handle=NN_APPLET_HANDLE_NONE );
57 
58 
59     // Power button click notification
60     AppletPowerButtonState GetPowerButtonState(void);
61     void ClearPowerButtonState(void);
62 
63     // Termination request
64     AppletOrderToCloseState GetOrderToCloseState(void);
65     void ClearOrderToCloseState(void);
66 
67     //================
68     // Preload library applet
69     Result PreloadLibraryApplet( AppletId id );
70 
71     // Start library applet
72     Result PrepareToStartLibraryApplet( AppletId id );
73     Result StartLibraryApplet( AppletId id, const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE );
74 
75     // Cancel startup
76     Result CancelLibraryApplet( bool isApplicationEnd=false );
77     Result CancelLibraryAppletIfRegistered( bool isApplicationEnd=false, AppletWakeupState *pWakeupState=NULL );
78 
79     // Quit the application
80     Result PrepareToCloseApplication( bool isCancelPreload=false );
81     Result CloseApplication( const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE );
82 
83     // Restart
84     Result RestartApplication( const void* pParam, size_t paramSize );
85     bool   GetStartupArgument( void* pParam, size_t paramSize = NN_APPLET_PARAM_BUF_SIZE );
86 
87     //================
88     // Receive argument
89     bool ReceiveDeliverArg( u8 pParam[], size_t paramSize, u8 pHmacBuf[], size_t hmacBufSize, bit32* pUniqueId );
90     bool ReceiveDeliverArg( u8 pParam[], u8 pHmacBuf[], bit32* pUniqueId );
91     AppletWakeupState GetInitialWakeupState(void);
92 
93     //================
94     Result GetSharedFont(Handle* pHandle, uptr* pAddr);
95     Result GetWirelessRebootInfo(u8* pInfo, size_t size);
96     Result Wrap(void* pWrappedBuffer, const void* pData, size_t dataSize, s32 idOffset, size_t idSize);
97     Result Unwrap(void* pData, const void* pWrapped, size_t wrappedSize, s32 idOffset, size_t idSize);
98     Result Wrap1(void* pWrappedBuffer, const void* pData, size_t dataSize, s32 idOffset, size_t idSize);
99     Result Unwrap1(void* pData, const void* pWrapped, size_t wrappedSize, s32 idOffset, size_t idSize);
100 }
101 }
102 }
103 }
104 
105 namespace nn {
106 namespace applet {
107 namespace CTR {
108 
109     using namespace nn::applet::CTR;
110 
111 /* Please see man pages for details
112 
113 
114  */
115     /* Please see man pages for details
116 
117 
118 
119 
120      */
121     inline Result Initialize(AppletAttr appletAttr = NN_APPLET_DEFAULT_APPLET_ATTRIBUTE )
122     {
123         return detail::Initialize( appletAttr );
124     }
125     /* Please see man pages for details
126 
127 
128 
129 
130      */
131     inline void Enable(bool isSleepEnabled=true)
132     {
133         detail::Enable(isSleepEnabled);
134     }
135 /*
136 
137 */
138 
139 /* Please see man pages for details
140 
141 
142  */
143     /* Please see man pages for details
144 
145 
146 
147 
148 
149 
150 
151     */
ReceiveDeliverArg(u8 pParam[],size_t paramSize,u8 pHmacBuf[],size_t hmacBufSize,bit32 * pUniqueId)152     inline bool ReceiveDeliverArg( u8 pParam[], size_t paramSize, u8 pHmacBuf[], size_t hmacBufSize, bit32* pUniqueId )
153     {
154         return detail::ReceiveDeliverArg( pParam, paramSize, pHmacBuf, hmacBufSize, pUniqueId );
155     }
ReceiveDeliverArg(u8 pParam[],u8 pHmacBuf[],bit32 * pUniqueId)156     inline bool ReceiveDeliverArg( u8 pParam[], u8 pHmacBuf[], bit32* pUniqueId )
157     {
158         return detail::ReceiveDeliverArg( pParam, pHmacBuf, pUniqueId );
159     }
160 
161     /* Please see man pages for details
162 
163 
164     */
GetInitialWakeupState(void)165     inline AppletWakeupState GetInitialWakeupState(void)
166     {
167         return detail::GetInitialWakeupState();
168     }
169 
170     /* Please see man pages for details
171 
172 
173 
174      */
IsRegistered(AppletId appletId)175     inline bool IsRegistered( AppletId appletId )
176     {
177         return detail::IsRegistered( appletId );
178     }
179 
180     /* Please see man pages for details
181 
182 
183      */
IsActive(void)184     inline bool IsActive(void)
185     {
186         return detail::IsActive();
187     }
188 
189     /* Please see man pages for details
190 
191 
192 
193      */
SetActive(void)194     inline void SetActive(void)
195     {
196         detail::SetActive();
197     }
198 
199     /* Please see man pages for details
200 
201 
202 
203     */
SetInactive(void)204     inline void SetInactive(void)
205     {
206         detail::SetInactive();
207     }
208 
209     /* Please see man pages for details
210 
211 
212 
213      */
214     bool IsInitialized();
215 /*
216 
217 */
218 
219 /* Please see man pages for details
220 
221 
222  */
223     /* Please see man pages for details
224 
225 
226 
227 
228      */
229     inline bool WaitForRegister( AppletId appletId, nn::fnd::TimeSpan span = NN_APPLET_WAIT_INFINITE )
230     {
231         return detail::WaitForRegister( appletId, span );
232     }
233 /*
234 
235 */
236 
237 /* Please see man pages for details
238 
239 
240  */
241     /* Please see man pages for details
242 
243 
244 
245      */
IsGpuRightGiven(void)246     inline bool IsGpuRightGiven(void)
247     {
248         return detail::IsGpuRightGiven();
249     }
250 
251 /*
252 
253 */
254 
255     /* Please see man pages for details
256 
257 
258 
259 
260 
261      */
AttachTransferMemoryHandle(os::TransferMemoryBlock * transferMemory,nn::Handle handle,size_t size,bit32 otherPermission)262     inline void AttachTransferMemoryHandle( os::TransferMemoryBlock* transferMemory, nn::Handle handle, size_t size, bit32 otherPermission )
263     {
264         detail::AttachTransferMemoryHandle( transferMemory, handle, size, otherPermission );
265     }
266 
267 /* Please see man pages for details
268 
269 
270  */
271     /* Please see man pages for details
272 
273 
274 
275 
276 
277 
278 
279      */
280     inline Result SendMessage( AppletId receiverId, const u8* pParam, size_t paramSize, nn::Handle handle=NN_APPLET_HANDLE_NONE, nn::fnd::TimeSpan timeout=WAIT_INFINITE )
281     {
282         return detail::SendMessage( receiverId, pParam, paramSize, handle, timeout );
283     }
284 
285     /* Please see man pages for details
286 
287 
288 
289 
290 
291 
292      */
293     inline Result TrySendMessage( AppletId receiverId, const u8* pParam, size_t paramSize, nn::Handle handle=NN_APPLET_HANDLE_NONE )
294     {
295         return detail::TrySendMessage( receiverId, pParam, paramSize, handle );
296     }
297 /*
298 
299 */
300 
301 /* Please see man pages for details
302 
303 
304  */
305     /* Please see man pages for details
306 
307 
308 
309 
310 
311 
312 
313 
314      */
GetPowerButtonState(void)315     inline AppletPowerButtonState GetPowerButtonState(void)
316     {
317         return detail::GetPowerButtonState();
318     }
319 
320     /* Please see man pages for details
321 
322      */
ClearPowerButtonState(void)323     inline void ClearPowerButtonState(void)
324     {
325         detail::ClearPowerButtonState();
326     }
327 
328     bool IsReceivedWakeupByCancel(void);
329 
330     /* Please see man pages for details
331 
332 
333 
334      */
IsExpectedToProcessPowerButton(void)335     inline bool IsExpectedToProcessPowerButton(void)
336     {
337         return ( GetPowerButtonState() != POWER_BUTTON_STATE_NONE )? true: false;
338     }
339 /*
340 
341 */
342 
343     //================================================================
344     // Termination request
345     //================================================================
GetOrderToCloseState(void)346     inline AppletOrderToCloseState GetOrderToCloseState(void)
347     {
348         return detail::GetOrderToCloseState();
349     }
ClearOrderToCloseState(void)350     inline void ClearOrderToCloseState(void)
351     {
352         detail::ClearOrderToCloseState();
353     }
354 
355 /* Please see man pages for details
356 
357 
358  */
359     /* Please see man pages for details
360 
361 
362 
363 
364 
365 
366 
367 
368 
369      */
PreloadLibraryApplet(AppletId id)370     inline Result PreloadLibraryApplet( AppletId id )
371     {
372         return detail::PreloadLibraryApplet(id);
373     }
374 
375     /* Please see man pages for details
376 
377 
378 
379 
380 
381 
382 
383 
384      */
385     inline Result CancelLibraryAppletIfRegistered( bool isApplicationEnd, AppletWakeupState *pWakeupState=NULL )
386     {
387         return detail::CancelLibraryAppletIfRegistered( isApplicationEnd, pWakeupState );
388     }
389 /*
390 
391 */
392 
393 /* Please see man pages for details
394 
395 
396  */
397     /* Please see man pages for details
398 
399 
400 
401 
402 
403 
404 
405 
406 
407 
408      */
PrepareToStartLibraryApplet(AppletId id)409     inline Result PrepareToStartLibraryApplet( AppletId id )
410     {
411         return detail::PrepareToStartLibraryApplet(id);
412     }
413 
414     /* Please see man pages for details
415 
416 
417 
418 
419 
420 
421 
422 
423 
424 
425 
426 
427 
428 
429 
430      */
431     inline Result StartLibraryApplet( AppletId id, const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE )
432     {
433         return detail::StartLibraryApplet(id, pParam, paramSize, handle);
434     }
435 /*
436 
437 */
438 
439 /* Please see man pages for details
440 
441 
442  */
443     /* Please see man pages for details
444 
445 
446 
447      */
IsExpectedToCloseApplication(void)448     inline bool IsExpectedToCloseApplication(void)
449     {
450         return ( GetOrderToCloseState() != ORDER_TO_CLOSE_STATE_NONE ||
451                  IsReceivedWakeupByCancel() )? true: false;
452     }
453 
454     /* Please see man pages for details
455 
456 
457 
458      */
PrepareToCloseApplication(void)459     inline Result PrepareToCloseApplication(void)
460     {
461         return detail::PrepareToCloseApplication();
462     }
463 
464     /* Please see man pages for details
465 
466 
467 
468 
469 
470 
471      */
472     inline Result CloseApplication( const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE )
473     {
474         return detail::CloseApplication( pParam, paramSize, handle );
475     }
476 
477     /* Please see man pages for details
478 
479 
480 
481 
482 
483 
484      */
485     inline Result RestartApplication( const void* pParam = NULL, size_t paramSize = NN_APPLET_PARAM_BUF_SIZE )
486     {
487         return detail::RestartApplication( pParam, paramSize );
488     }
489 
490     /* Please see man pages for details
491 
492 
493 
494 
495 
496 
497     */
498     inline bool GetStartupArgument( void* pParam, size_t paramSize = NN_APPLET_PARAM_BUF_SIZE )
499     {
500         return detail::GetStartupArgument( pParam, paramSize );
501     }
502 /* Please see man pages for details
503 
504  */
505 
506     // Obsolete function.
PrepareToClosePreloadedApplication(void)507     inline Result PrepareToClosePreloadedApplication(void)
508     {
509         return detail::PrepareToCloseApplication( true );
510     }
511     inline Result ClosePreloadedApplication( const u8* pParam=NULL, size_t paramSize=0, Handle handle=NN_APPLET_HANDLE_NONE )
512     {
513         return detail::CloseApplication( pParam, paramSize, handle );
514     }
515 }
516 }
517 }
518 
519 #endif  // ifndef NN_APPLET_CTR_APPLET_API_H_
520