]> Chaos Git - corbenik/ctrulib.git/commitdiff
Merge branch 'master' into great-refactor
authorfincs <fincs.alt1@gmail.com>
Sat, 3 Oct 2015 10:39:09 +0000 (12:39 +0200)
committerfincs <fincs.alt1@gmail.com>
Sat, 3 Oct 2015 10:39:09 +0000 (12:39 +0200)
Conflicts:
libctru/include/3ds/services/apt.h
libctru/include/3ds/services/fs.h
libctru/source/services/apt.c

1  2 
libctru/include/3ds/services/apt.h
libctru/include/3ds/services/fs.h
libctru/source/services/apt.c
libctru/source/services/fs.c

index 74fda48659b04b6e289c95da40c580bdb5d432d6,437829935c419c5c7b6ec1ce422c1268cb0e31f1..636ecdbb9afe189bb4a50a8ea070e5e871e63be0
@@@ -91,40 -91,41 +91,41 @@@ bool aptMainLoop(void); // Use like thi
  void aptHook(aptHookCookie* cookie, aptHookFn callback, void* param);
  void aptUnhook(aptHookCookie* cookie);
  
 -Result APT_GetLockHandle(Handle* handle, u16 flags, Handle* lockHandle);
 -Result APT_Initialize(Handle* handle, NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2);
 -Result APT_Finalize(Handle* handle, NS_APPID appId);
 -Result APT_HardwareResetAsync(Handle* handle);
 -Result APT_Enable(Handle* handle, u32 a);
 -Result APT_GetAppletManInfo(Handle* handle, u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid);
 -Result APT_GetAppletInfo(Handle* handle, NS_APPID appID, u64* pProgramID, u8* pMediaType, u8* pRegistered, u8* pLoadState, u32* pAttributes);
 -Result APT_GetAppletProgramInfo(Handle* handle, u32 id, u32 flags, u16 *titleversion);
 -Result APT_GetProgramID(Handle* handle, u64* pProgramID);
 -Result APT_PrepareToJumpToHomeMenu(Handle* handle);
 -Result APT_JumpToHomeMenu(Handle* handle, u32 a, u32 b, u32 c);
 -Result APT_PrepareToJumpToApplication(Handle* handle, u32 a);
 -Result APT_JumpToApplication(Handle* handle, u32 a, u32 b, u32 c);
 -Result APT_IsRegistered(Handle* handle, NS_APPID appID, u8* out);
 -Result APT_InquireNotification(Handle* handle, u32 appID, u8* signalType);
 -Result APT_NotifyToWait(Handle* handle, NS_APPID appID);
 -Result APT_AppletUtility(Handle* handle, u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2);
 -Result APT_GlanceParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
 -Result APT_ReceiveParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
 -Result APT_SendParameter(Handle* handle, NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType);
 -Result APT_SendCaptureBufferInfo(Handle* handle, u32 bufferSize, u32* buffer);
 -Result APT_ReplySleepQuery(Handle* handle, NS_APPID appID, u32 a);
 -Result APT_ReplySleepNotificationComplete(Handle* handle, NS_APPID appID);
 -Result APT_PrepareToCloseApplication(Handle* handle, u8 a);
 -Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c);
 -Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent);
 -Result APT_GetAppCpuTimeLimit(Handle* handle, u32 *percent);
 -Result APT_CheckNew3DS_Application(Handle* handle, u8 *out);// Note: this function is unreliable, see: http://3dbrew.org/wiki/APT:PrepareToStartApplication
 -Result APT_CheckNew3DS_System(Handle* handle, u8 *out);
 -Result APT_CheckNew3DS(Handle* handle, u8 *out);
 -Result APT_PrepareToDoAppJump(Handle* handle, u8 flags, u64 programID, u8 mediatype);
 -Result APT_DoAppJump(Handle* handle, u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr);
 -Result APT_PrepareToStartLibraryApplet(Handle* handle, NS_APPID appID);
 -Result APT_StartLibraryApplet(Handle* handle, NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize);
 +Result APT_GetLockHandle(u16 flags, Handle* lockHandle);
 +Result APT_Initialize(NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2);
 +Result APT_Finalize(NS_APPID appId);
 +Result APT_HardwareResetAsync(void);
 +Result APT_Enable(u32 a);
 +Result APT_GetAppletManInfo(u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid);
 +Result APT_GetAppletInfo(NS_APPID appID, u64* pProgramID, u8* pMediaType, u8* pRegistered, u8* pLoadState, u32* pAttributes);
 +Result APT_GetAppletProgramInfo(u32 id, u32 flags, u16 *titleversion);
++Result APT_GetProgramID(u64* pProgramID);
 +Result APT_PrepareToJumpToHomeMenu(void);
 +Result APT_JumpToHomeMenu(u32 a, u32 b, u32 c);
 +Result APT_PrepareToJumpToApplication(u32 a);
 +Result APT_JumpToApplication(u32 a, u32 b, u32 c);
 +Result APT_IsRegistered(NS_APPID appID, u8* out);
 +Result APT_InquireNotification(u32 appID, u8* signalType);
 +Result APT_NotifyToWait(NS_APPID appID);
 +Result APT_AppletUtility(u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2);
 +Result APT_GlanceParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
 +Result APT_ReceiveParameter(NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
 +Result APT_SendParameter(NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType);
 +Result APT_SendCaptureBufferInfo(u32 bufferSize, u32* buffer);
 +Result APT_ReplySleepQuery(NS_APPID appID, u32 a);
 +Result APT_ReplySleepNotificationComplete(NS_APPID appID);
 +Result APT_PrepareToCloseApplication(u8 a);
 +Result APT_CloseApplication(u32 a, u32 b, u32 c);
 +Result APT_SetAppCpuTimeLimit(u32 percent);
 +Result APT_GetAppCpuTimeLimit(u32 *percent);
 +Result APT_CheckNew3DS_Application(u8 *out);// Note: this function is unreliable, see: http://3dbrew.org/wiki/APT:PrepareToStartApplication
 +Result APT_CheckNew3DS_System(u8 *out);
 +Result APT_CheckNew3DS(u8 *out);
 +Result APT_PrepareToDoAppJump(u8 flags, u64 programID, u8 mediatype);
 +Result APT_DoAppJump(u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr);
 +Result APT_PrepareToStartLibraryApplet(NS_APPID appID);
 +Result APT_StartLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize);
  Result APT_LaunchLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize);//This should be used for launching library applets, this uses the above APT_StartLibraryApplet/APT_PrepareToStartLibraryApplet funcs + apt*Session(). parambuf is used for APT params input, when the applet closes the output param block is copied here. This is not usable from the homebrew launcher. This is broken: when the applet does get launched at all, the applet process doesn't actually get terminated when the applet gets closed.
 -Result APT_PrepareToStartSystemApplet(Handle* handle, NS_APPID appID);
 -Result APT_StartSystemApplet(Handle* handle, NS_APPID appID, u32 bufSize, Handle applHandle, u8 *buf);
 +Result APT_PrepareToStartSystemApplet(NS_APPID appID);
 +Result APT_StartSystemApplet(NS_APPID appID, u32 bufSize, Handle applHandle, u8 *buf);
  
index d85f75f12b629f78115b43e32bb2fc5782b68093,acac55aac8c6bd2a76dee10221c64d69e54b3f21..a6e1f9b400e5f4c7d3552bae497b091362a85b2c
@@@ -133,23 -133,24 +133,24 @@@ Handle *fsGetSessionHandle(void)
  
  FS_path FS_makePath(FS_pathType type, const char  *path);
  
 -Result FSUSER_Initialize(Handle* handle);
 -Result FSUSER_OpenArchive(Handle* handle, FS_archive* archive);
 -Result FSUSER_OpenDirectory(Handle* handle, Handle* out, FS_archive archive, FS_path dirLowPath);
 -Result FSUSER_OpenFile(Handle* handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
 -Result FSUSER_OpenFileDirectly(Handle* handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
 -Result FSUSER_CloseArchive(Handle* handle, FS_archive* archive);
 -Result FSUSER_CreateFile(Handle* handle, FS_archive archive, FS_path fileLowPath, u32 fileSize);
 -Result FSUSER_CreateDirectory(Handle* handle, FS_archive archive, FS_path dirLowPath);
 -Result FSUSER_DeleteFile(Handle *handle, FS_archive archive, FS_path fileLowPath);
 -Result FSUSER_DeleteDirectory(Handle *handle, FS_archive archive, FS_path dirLowPath);
 -Result FSUSER_DeleteDirectoryRecursively(Handle *handle, FS_archive archive, FS_path dirLowPath);
 -Result FSUSER_RenameFile(Handle *handle, FS_archive srcArchive, FS_path srcFileLowPath, FS_archive destArchive, FS_path destFileLowPath);
 -Result FSUSER_RenameDirectory(Handle *handle, FS_archive srcArchive, FS_path srcDirLowPath, FS_archive destArchive, FS_path destDirLowPath);
 -Result FSUSER_GetSdmcArchiveResource(Handle *handle, u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);
 -Result FSUSER_GetNandArchiveResource(Handle *handle, u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);
 -Result FSUSER_IsSdmcDetected(Handle *handle, u8 *detected);
 -Result FSUSER_IsSdmcWritable(Handle *handle, u8 *writable);
 -Result FSUSER_GetMediaType(Handle *handle, u8* mediatype);
 +Result FSUSER_Initialize(Handle handle);
 +Result FSUSER_OpenArchive(FS_archive* archive);
 +Result FSUSER_OpenDirectory(Handle* out, FS_archive archive, FS_path dirLowPath);
 +Result FSUSER_OpenFile(Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
 +Result FSUSER_OpenFileDirectly(Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
 +Result FSUSER_CloseArchive(FS_archive* archive);
 +Result FSUSER_CreateFile(FS_archive archive, FS_path fileLowPath, u32 fileSize);
 +Result FSUSER_CreateDirectory(FS_archive archive, FS_path dirLowPath);
 +Result FSUSER_DeleteFile(FS_archive archive, FS_path fileLowPath);
 +Result FSUSER_DeleteDirectory(FS_archive archive, FS_path dirLowPath);
 +Result FSUSER_DeleteDirectoryRecursively(FS_archive archive, FS_path dirLowPath);
 +Result FSUSER_RenameFile(FS_archive srcArchive, FS_path srcFileLowPath, FS_archive destArchive, FS_path destFileLowPath);
 +Result FSUSER_RenameDirectory(FS_archive srcArchive, FS_path srcDirLowPath, FS_archive destArchive, FS_path destDirLowPath);
 +Result FSUSER_GetSdmcArchiveResource(u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);
 +Result FSUSER_GetNandArchiveResource(u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters);
 +Result FSUSER_IsSdmcDetected(u8 *detected);
 +Result FSUSER_IsSdmcWritable(u8 *writable);
++Result FSUSER_GetMediaType(u8* mediatype);
  
  Result FSFILE_Close(Handle handle);
  Result FSFILE_Read(Handle handle, u32 *bytesRead, u64 offset, void *buffer, u32 size);
index e5260f84aa3510bd84f45c265dd8d78afefae8ca,95283bd07e64abc8f5fa4497ef43d5882b2d150d..90cd6af96a499098ece5f494499b6c1ef5f56688
@@@ -825,8 -833,30 +825,27 @@@ Result APT_GetAppletProgramInfo(u32 id
        return cmdbuf[1];
  }
  
 -Result APT_GetProgramID(Handle* handle, u64* pProgramID)
++Result APT_GetProgramID(u64* pProgramID)
+ {
 -      if(!handle)handle=&aptuHandle;
 -
+       u32* cmdbuf=getThreadCommandBuffer();
+       cmdbuf[0] = 0x00580002; //request header code
+       cmdbuf[1] = 0x20;
+       
+       Result ret=0;
 -      if((ret=svcSendSyncRequest(*handle)))return ret;
++      if((ret=svcSendSyncRequest(aptuHandle)))return ret;
+       if(ret==0)ret = cmdbuf[1];
+       if(pProgramID)
+       {
+               if(ret==0) *pProgramID=((u64)cmdbuf[3]<<32)|cmdbuf[2];
+       }
+       return ret;
+ }
 -Result APT_IsRegistered(Handle* handle, NS_APPID appID, u8* out)
 +Result APT_IsRegistered(NS_APPID appID, u8* out)
  {
 -      if(!handle)handle=&aptuHandle;
        u32* cmdbuf=getThreadCommandBuffer();
        cmdbuf[0]=0x90040; //request header code
        cmdbuf[1]=appID;
index 0bbdd7a4617f765748d86e7e7ba5c162841e9252,04f93ad3247f5ea50a6999551fb0a75e2d9c274f..21d42dda9f592c89cfe2f580cf10ded505848809
@@@ -966,8 -1051,52 +966,46 @@@ FSUSER_IsSdmcDetected(u8    *detected
        return cmdbuf[1];
  }
  
 - *  @param[in]  handle   fs:USER handle
+ /*! Get curent process mediatype
+  *
 -FSUSER_GetMediaType(Handle *handle,
 -                                      u8* mediatype)
+  *  @param[out] mediatype Output curent process mediatype
+  *
+  *  @returns error
+  *
+  *  @internal
+  *
+  *  #### Request
+  *
+  *  Index Word | Description
+  *  -----------|-------------------------
+  *  0          | Header code [0x08680000]
+  *
+  *  #### Response
+  *
+  *  Index Word | Description
+  *  -----------|-------------------------
+  *  0          | Header code
+  *  1          | Result code
+  */
+ Result
 -      if(!handle)
 -              handle = &fsuHandle;
 -
++FSUSER_GetMediaType(u8* mediatype)
+ {
 -      if((ret = svcSendSyncRequest(*handle)))
+       u32* cmdbuf = getThreadCommandBuffer();
+       cmdbuf[0] = 0x08680000;
+       Result ret = 0;
++      if((ret = svcSendSyncRequest(fsuHandle)))
+               return ret;
+       if(mediatype)
+               *mediatype = cmdbuf[2];
+       return cmdbuf[1];
+ }
  /*! Check if SD card is writable
   *
 - *  @param[in]  handle   fs:USER handle
   *  @param[out] writable Output writable state
   *
   *  @returns error