]> Chaos Git - corbenik/ctrulib.git/commitdiff
Add AM_GetTitleProductCode, FSUSER_GetNandArchiveResource, and fix missing service...
authorSteven Smith <Steveice10@gmail.com>
Mon, 19 Jan 2015 02:20:47 +0000 (18:20 -0800)
committerSteven Smith <Steveice10@gmail.com>
Sun, 1 Mar 2015 07:13:21 +0000 (23:13 -0800)
libctru/include/3ds.h
libctru/include/3ds/services/am.h
libctru/include/3ds/services/fs.h
libctru/source/services/am.c
libctru/source/services/fs.c

index 17132558b784c2f7c7d30ef66b74c60368363465..741ad034af60a2a34d5d17c3a4f56a7f412cb01e 100644 (file)
@@ -15,6 +15,7 @@ extern "C" {
 #include <3ds/console.h>
 
 #include <3ds/services/ac.h>
+#include <3ds/services/am.h>
 #include <3ds/services/apt.h>
 #include <3ds/services/cfgnor.h>
 #include <3ds/services/cfgu.h>
@@ -25,6 +26,9 @@ extern "C" {
 #include <3ds/services/irrst.h>
 #include <3ds/services/httpc.h>
 #include <3ds/services/ir.h>
+#include <3ds/services/ns.h>
+#include <3ds/services/pm.h>
+#include <3ds/services/ps.h>
 #include <3ds/services/ptm.h>
 #include <3ds/services/soc.h>
 #include <3ds/services/mic.h>
index 79da46f6480f65a56a1f1971e56fe8090c088ae1..34620d32349c32892b5c9229b04e979c3da0a360 100644 (file)
@@ -90,4 +90,14 @@ Note: The title must have the uniqueid: 0x00000, otherwise this will fail.
   mediatype            mediatype of title
   titleid              title id of title
 */
-Result AM_InstallFIRM(u8 mediatype, u64 titleid);
\ No newline at end of file
+Result AM_InstallFIRM(u8 mediatype, u64 titleid);
+
+/* AM_GetTitleProductCode()
+About: Gets the product code of a title based on its title id.
+
+  mediatype            mediatype of title
+  titleid              title id of title
+  productcode           buffer to output the product code to (should have a length of 16) 
+*/
+Result AM_GetTitleProductCode(u8 mediatype, u64 titleid, char* productcode);
+
index a20fb9b7effff84992ef16b398be69021a8e244c..b1498ae50b56b0c7e5594ec0e146d1a26add0f6f 100644 (file)
@@ -145,6 +145,7 @@ Result FSUSER_DeleteDirectory(Handle *handle, FS_archive archive, FS_path dirLow
 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);
 
index 4105e895cadab27577de703286204167d20ea9a9..56f3448a37b1685da78865b7e3b954ef2dd9752d 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include <stdlib.h>
 #include <3ds/types.h>
 #include <3ds/svc.h>
@@ -165,3 +166,19 @@ Result AM_InstallFIRM(u8 mediatype, u64 titleid)
 
        return (Result)cmdbuf[1];
 }
+
+Result AM_GetTitleProductCode(u8 mediatype, u64 titleid, char* productcode)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+       
+       cmdbuf[0] = 0x000500C0;
+       cmdbuf[1] = mediatype;
+       cmdbuf[2] = titleid & 0xffffffff;
+       cmdbuf[3] = (titleid >> 32) & 0xffffffff;
+       
+       if((ret = svcSendSyncRequest(amHandle))!=0) return ret;
+
+       snprintf(productcode, 16, "%s", (char*)(&cmdbuf[2]));
+       return (Result)cmdbuf[1];
+}
index 2c610b32b37bf3cc519493ce211413f7becd78c6..6a02044572ca8566759407c98854144c69158f20 100644 (file)
@@ -887,6 +887,68 @@ FSUSER_GetSdmcArchiveResource(Handle *handle,
        return cmdbuf[1];
 }
 
+/*! Get NAND information
+ *
+ *  @param[in]  handle       fs:USER handle
+ *  @param[out] sectorSize   Sector size (bytes)
+ *  @param[out] clusterSize  Cluster size (bytes)
+ *  @param[out] numClusters  Total number of clusters
+ *  @param[out] freeClusters Number of free clusters
+ *
+ *  @returns error
+ *
+ *  @internal
+ *
+ *  #### Request
+ *
+ *  Index Word | Description
+ *  -----------|-------------------------
+ *  0          | Header code [0x08140000]
+ *
+ *  #### Response
+ *
+ *  Index Word | Description
+ *  -----------|-------------------------
+ *  0          | Header code
+ *  1          | Result code
+ *  2          | Sector (bytes)
+ *  3          | Cluster (bytes)
+ *  4          | Partition capacity (clusters)
+ *  5          | Free space (clusters)
+ */
+Result
+FSUSER_GetNandArchiveResource(Handle *handle,
+                              u32    *sectorSize,
+                              u32    *clusterSize,
+                              u32    *numClusters,
+                              u32    *freeClusters)
+{
+       if(!handle)
+               handle = &fsuHandle;
+
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = 0x08150000;
+
+       Result ret = 0;
+       if((ret = svcSendSyncRequest(*handle)))
+               return ret;
+
+       if(sectorSize)
+               *sectorSize = cmdbuf[2];
+
+       if(clusterSize)
+               *clusterSize = cmdbuf[3];
+
+       if(numClusters)
+               *numClusters = cmdbuf[4];
+
+       if(freeClusters)
+               *freeClusters = cmdbuf[5];
+
+       return cmdbuf[1];
+}
+
 /*! Check if SD card is detected
  *
  *  @param[in]  handle   fs:USER handle