Moved amapp init into a seperate function.

This commit is contained in:
yellows8 2016-06-02 20:49:01 -04:00
parent 94b3748870
commit 12f0f638ff
2 changed files with 16 additions and 1 deletions

View File

@ -56,9 +56,12 @@ typedef struct {
u64 titlesFreeSpace; ///< Free space for titles.
} AM_TWLPartitionInfo;
/// Initializes AM.
/// Initializes AM. This doesn't initialize with "am:app", see amAppInit().
Result amInit(void);
/// Initializes AM with a service which has access to the amapp-commands. This should only be used when using the amapp commands, not non-amapp AM commands.
Result amAppInit(void);
/// Exits AM.
void amExit(void);

View File

@ -20,6 +20,18 @@ Result amInit(void)
ret = srvGetServiceHandle(&amHandle, "am:net");
if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:u");
if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:sys");
if (R_FAILED(ret)) AtomicDecrement(&amRefCount);
return ret;
}
Result amAppInit(void)
{
Result ret;
if (AtomicPostIncrement(&amRefCount)) return 0;
ret = srvGetServiceHandle(&amHandle, "am:sys");
if (R_FAILED(ret)) ret = srvGetServiceHandle(&amHandle, "am:app");
if (R_FAILED(ret)) AtomicDecrement(&amRefCount);