]> Chaos Git - corbenik/ctrulib.git/commitdiff
Implement some cfg:i functions.
authorSciresM <Sciresm@gmail.com>
Sun, 28 Aug 2016 07:45:09 +0000 (00:45 -0700)
committerMichael Scire <SciresM@gmail.com>
Sun, 28 Aug 2016 08:03:50 +0000 (01:03 -0700)
libctru/include/3ds/services/cfgu.h
libctru/source/services/cfgu.c

index 718e516c35f95bf30ae10c48c8eacc3834ecc5a7..f75cfba423793c7afdb46298004e09466b95c7a8 100644 (file)
@@ -85,13 +85,51 @@ Result CFGU_GetCountryCodeString(u16 code, u16* string);
 Result CFGU_GetCountryCodeID(u16 string, u16* code);
 
 /**
- * @brief Gets a config info block.
+ * @brief Gets a config info block with flags = 2.
  * @param size Size of the data to retrieve.
  * @param blkID ID of the block to retrieve.
  * @param outData Pointer to write the block data to.
  */
 Result CFGU_GetConfigInfoBlk2(u32 size, u32 blkID, u8* outData);
 
+/**
+ * @brief Gets a config info block with flags = 4.
+ * @param size Size of the data to retrieve.
+ * @param blkID ID of the block to retrieve.
+ * @param outData Pointer to write the block data to.
+ */
+Result CFG_GetConfigInfoBlk4(u32 size, u32 blkID, u8* outData);
+
+/**
+ * @brief Gets a config info block with flags = 8.
+ * @param size Size of the data to retrieve.
+ * @param blkID ID of the block to retrieve.
+ * @param outData Pointer to write the block data to.
+ */
+Result CFG_GetConfigInfoBlk8(u32 size, u32 blkID, u8* outData);
+
+/**
+ * @brief Sets a config info block with flags = 4.
+ * @param size Size of the data to retrieve.
+ * @param blkID ID of the block to retrieve.
+ * @param inData Pointer to block data to write.
+ */
+Result CFG_SetConfigInfoBlk4(u32 size, u32 blkID, u8* inData);
+
+/**
+ * @brief Sets a config info block with flags = 8.
+ * @param size Size of the data to retrieve.
+ * @param blkID ID of the block to retrieve.
+ * @param inData Pointer to block data to write.
+ */
+Result CFG_SetConfigInfoBlk8(u32 size, u32 blkID, u8* inData);
+
+
+/**
+ * @brief Writes the CFG buffer in memory to the savegame in NAND.
+ */
+Result CFG_UpdateConfigNANDSavegame(void);
+
 /**
  * @brief Gets the system's language.
  * @param language Pointer to write the language to. (see @ref CFG_Language)
index a5c81754c8f4bc03873f5b3e547577ee7df0ad07..0a657c8fe37ec33e70f4d8d0dfe9682920480062 100644 (file)
@@ -151,6 +151,82 @@ Result CFGU_GetConfigInfoBlk2(u32 size, u32 blkID, u8* outData)
        return (Result)cmdbuf[1];
 }
 
+Result CFG_GetConfigInfoBlk4(u32 size, u32 blkID, u8* outData)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0x401,2,2); // 0x4010082
+       cmdbuf[1] = size;
+       cmdbuf[2] = blkID;
+       cmdbuf[3] = IPC_Desc_Buffer(size,IPC_BUFFER_W);
+       cmdbuf[4] = (u32)outData;
+
+       if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret;
+
+       return (Result)cmdbuf[1];
+}
+
+Result CFG_GetConfigInfoBlk8(u32 size, u32 blkID, u8* outData)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0x801,2,2); // 0x8010082
+       cmdbuf[1] = size;
+       cmdbuf[2] = blkID;
+       cmdbuf[3] = IPC_Desc_Buffer(size,IPC_BUFFER_W);
+       cmdbuf[4] = (u32)outData;
+
+       if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret;
+
+       return (Result)cmdbuf[1];
+}
+
+Result CFG_SetConfigInfoBlk4(u32 size, u32 blkID, u8* inData)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0x402,2,2); // 0x4020082
+       cmdbuf[1] = blkID;
+       cmdbuf[2] = size;
+       cmdbuf[3] = IPC_Desc_Buffer(size,IPC_BUFFER_R);
+       cmdbuf[4] = (u32)inData;
+
+       if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret;
+
+       return (Result)cmdbuf[1];
+}
+
+Result CFG_SetConfigInfoBlk8(u32 size, u32 blkID, u8* inData)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0x802,2,2); // 0x8020082
+       cmdbuf[1] = blkID;
+       cmdbuf[2] = size;
+       cmdbuf[3] = IPC_Desc_Buffer(size,IPC_BUFFER_R);
+       cmdbuf[4] = (u32)inData;
+
+       if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret;
+
+       return (Result)cmdbuf[1];
+}
+
+Result CFG_UpdateConfigNANDSavegame(void)
+{
+       Result ret = 0;
+       u32 *cmdbuf = getThreadCommandBuffer();
+
+       cmdbuf[0] = IPC_MakeHeader(0x803,0,0); // 0x8030000
+
+       if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret;
+
+       return (Result)cmdbuf[1];
+}
+
 Result CFGU_GetSystemLanguage(u8* language)
 {
        return CFGU_GetConfigInfoBlk2(1, 0xA0002, language);