]> Chaos Git - corbenik/ctrulib.git/commitdiff
Add PTMSYSM_CheckNew3DS, PTMSYSM_ShutdownAsync and PTMSYSM_RebootAsync
authorThog <thog92@hotmail.fr>
Sun, 31 Jul 2016 20:42:20 +0000 (22:42 +0200)
committerThog <thog92@hotmail.fr>
Sun, 31 Jul 2016 20:42:20 +0000 (22:42 +0200)
libctru/include/3ds/services/ptmsysm.h
libctru/source/services/ptmsysm.c

index 772b2d4e672f5192285851b3c62f8b537c2104a8..0978bb6ce9cc18e1b0b28aa083477bc184a63f09 100644 (file)
@@ -10,9 +10,26 @@ Result ptmSysmInit(void);
 /// Exits ptm:sysm.
 void ptmSysmExit(void);
 
+
+/**
+ * @brief return 1 if it's a New 3DS otherwise, return 0 for Old 3DS.
+ */
+Result PTMSYSM_CheckNew3DS(void);
+
 /**
  * @brief Configures the New 3DS' CPU clock speed and L2 cache.
  * @param value Bit0: enable higher clock, Bit1: enable L2 cache.
  */
 Result PTMSYSM_ConfigureNew3DSCPU(u8 value);
 
+/**
+ * @brief Trigger a hardware system shutdown via the MCU
+ * @param timeout: timeout passed to PMApp:TerminateNonEssential.
+ */
+Result PTMSYSM_ShutdownAsync(u64 timeout);
+
+/**
+ * @brief Trigger a hardware system reboot via the MCU.
+ * @param timeout: timeout passed to PMApp:TerminateNonEssential.
+ */
+Result PTMSYSM_RebootAsync(u64 timeout);
index ecd736fb979ba95fd3639a729490eb4deffb5275..6ee8da4cc270425bf5cdbd5080df552fbff008e5 100644 (file)
@@ -24,6 +24,17 @@ void ptmSysmExit(void)
        svcCloseHandle(ptmSysmHandle);
 }
 
+Result PTMSYSM_CheckNew3DS(void)
+{
+       Result ret;
+       u32 *cmdbuf = getThreadCommandBuffer();
+       cmdbuf[0] = IPC_MakeHeader(0x040A,0,0); // 0x040A0000
+
+       if(R_FAILED(ret = svcSendSyncRequest(ptmSysmHandle)))return 0;
+
+       return (Result)cmdbuf[1];
+}
+
 Result PTMSYSM_ConfigureNew3DSCPU(u8 value)
 {
        Result ret;
@@ -37,3 +48,29 @@ Result PTMSYSM_ConfigureNew3DSCPU(u8 value)
        return (Result)cmdbuf[1];
 }
 
+Result PTMSYSM_ShutdownAsync(u64 timeout)
+{
+       Result ret;
+       u32 *cmdbuf = getThreadCommandBuffer();
+       cmdbuf[0] = IPC_MakeHeader(0x407,3,0); // 0x040700C0
+       cmdbuf[1] = 0;
+       cmdbuf[2] = timeout & 0xffffffff;
+       cmdbuf[3] = (timeout >> 32) & 0xffffffff;
+
+       if(R_FAILED(ret = svcSendSyncRequest(ptmSysmHandle)))return ret;
+
+       return (Result)cmdbuf[1];
+}
+
+Result PTMSYSM_RebootAsync(u64 timeout)
+{
+       Result ret;
+       u32 *cmdbuf = getThreadCommandBuffer();
+       cmdbuf[0] = IPC_MakeHeader(0x409,2,0); // 0x04090080
+       cmdbuf[1] = timeout & 0xffffffff;
+       cmdbuf[2] = (timeout >> 32) & 0xffffffff;
+
+       if(R_FAILED(ret = svcSendSyncRequest(ptmSysmHandle)))return ret;
+
+       return (Result)cmdbuf[1];
+}