Add ptm:gets, ptm:sets and more ptm service commands
This commit is contained in:
parent
e996cef24d
commit
4fdc40228a
@ -60,6 +60,8 @@ extern "C" {
|
||||
#include <3ds/services/ps.h>
|
||||
#include <3ds/services/ptmu.h>
|
||||
#include <3ds/services/ptmsysm.h>
|
||||
#include <3ds/services/ptmgets.h>
|
||||
#include <3ds/services/ptmsets.h>
|
||||
#include <3ds/services/pxidev.h>
|
||||
#include <3ds/services/pxipm.h>
|
||||
#include <3ds/services/soc.h>
|
||||
|
25
libctru/include/3ds/services/ptmgets.h
Normal file
25
libctru/include/3ds/services/ptmgets.h
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @file ptmgets.h
|
||||
* @brief PTMGETS service.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// Initializes PTMGETS.
|
||||
Result ptmGetsInit(void);
|
||||
|
||||
/// Exits PTMGETS.
|
||||
void ptmGetsExit(void);
|
||||
|
||||
/**
|
||||
* @brief Gets a pointer to the current ptm:gets session handle.
|
||||
* @return A pointer to the current ptm:gets session handle.
|
||||
*/
|
||||
Handle *ptmGetsGetSessionHandle(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the system time.
|
||||
* @param[out] outMsY2k The pointer to write the number of milliseconds since 01/01/2000 to.
|
||||
*/
|
||||
Result PTMGETS_GetSystemTime(s64 *outMsY2k);
|
25
libctru/include/3ds/services/ptmsets.h
Normal file
25
libctru/include/3ds/services/ptmsets.h
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @file ptmsets.h
|
||||
* @brief PTMSETS service.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// Initializes PTMSETS.
|
||||
Result ptmSetsInit(void);
|
||||
|
||||
/// Exits PTMSETS.
|
||||
void ptmSetsExit(void);
|
||||
|
||||
/**
|
||||
* @brief Gets a pointer to the current ptm:sets session handle.
|
||||
* @return A pointer to the current ptm:sets session handle.
|
||||
*/
|
||||
Handle *ptmSetsGetSessionHandle(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the system time.
|
||||
* @param msY2k The number of milliseconds since 01/01/2000.
|
||||
*/
|
||||
Result PTMSETS_SetSystemTime(s64 msY2k);
|
@ -48,6 +48,12 @@ Result ptmSysmInit(void);
|
||||
/// Exits ptm:sysm.
|
||||
void ptmSysmExit(void);
|
||||
|
||||
/**
|
||||
* @brief Gets a pointer to the current ptm:sysm session handle.
|
||||
* @return A pointer to the current ptm:sysm session handle.
|
||||
*/
|
||||
Handle *ptmSysmGetSessionHandle(void);
|
||||
|
||||
/// Requests to enter sleep mode.
|
||||
Result PTMSYSM_RequestSleep(void);
|
||||
|
||||
@ -81,12 +87,18 @@ Result PTMSYSM_GetWakeReason(PtmSleepConfig *outSleepConfig);
|
||||
/// Cancels the "half-awake" state and fully wakes up the 3DS after some delay.
|
||||
Result PTMSYSM_Awaken(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the user time by updating the user time offset.
|
||||
* @param msY2k The number of milliseconds since 01/01/2000.
|
||||
*/
|
||||
Result PTMSYSM_SetUserTime(s64 msY2k);
|
||||
|
||||
/// Invalidates the "system time" (cfg block 0x30002)
|
||||
Result PTMSYSM_InvalidateSystemTime(void);
|
||||
|
||||
/**
|
||||
* @brief Reads the time and date coming from the RTC and converts the result.
|
||||
* @returns The number of milliseconds since 01/01/2000.
|
||||
* @param[out] outMsY2k The pointer to write the number of milliseconds since 01/01/2000 to.
|
||||
*/
|
||||
Result PTMSYSM_GetRtcTime(s64 *outMsY2k);
|
||||
|
||||
|
@ -10,6 +10,12 @@ Result ptmuInit(void);
|
||||
/// Exits PTMU.
|
||||
void ptmuExit(void);
|
||||
|
||||
/**
|
||||
* @brief Gets a pointer to the current ptm:u session handle.
|
||||
* @return A pointer to the current ptm:u session handle.
|
||||
*/
|
||||
Handle *ptmuGetSessionHandle(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the system's current shell state.
|
||||
* @param out Pointer to write the current shell state to. (0 = closed, 1 = open)
|
||||
|
43
libctru/source/services/ptmgets.c
Normal file
43
libctru/source/services/ptmgets.c
Normal file
@ -0,0 +1,43 @@
|
||||
#include <string.h>
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/result.h>
|
||||
#include <3ds/svc.h>
|
||||
#include <3ds/srv.h>
|
||||
#include <3ds/synchronization.h>
|
||||
#include <3ds/services/ptmgets.h>
|
||||
#include <3ds/ipc.h>
|
||||
|
||||
static Handle ptmGetsHandle;
|
||||
static int ptmGetsRefCount;
|
||||
|
||||
Result ptmGetsInit(void)
|
||||
{
|
||||
if (AtomicPostIncrement(&ptmGetsRefCount)) return 0;
|
||||
Result res = srvGetServiceHandle(&ptmGetsHandle, "ptm:gets");
|
||||
if (R_FAILED(res)) AtomicDecrement(&ptmGetsRefCount);
|
||||
return res;
|
||||
}
|
||||
|
||||
void ptmGetsExit(void)
|
||||
{
|
||||
if (AtomicDecrement(&ptmGetsRefCount)) return;
|
||||
svcCloseHandle(ptmGetsHandle);
|
||||
}
|
||||
|
||||
Handle *ptmGetsGetSessionHandle(void)
|
||||
{
|
||||
return &ptmGetsHandle;
|
||||
}
|
||||
|
||||
Result PTMGETS_GetSystemTime(s64 *outMsY2k)
|
||||
{
|
||||
Result ret;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
cmdbuf[0] = IPC_MakeHeader(0x401,0,0); // 0x04010000
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(ptmGetsHandle)))return ret;
|
||||
|
||||
memcpy(outMsY2k, &cmdbuf[2], 8);
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
42
libctru/source/services/ptmsets.c
Normal file
42
libctru/source/services/ptmsets.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include <string.h>
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/result.h>
|
||||
#include <3ds/svc.h>
|
||||
#include <3ds/srv.h>
|
||||
#include <3ds/synchronization.h>
|
||||
#include <3ds/services/ptmsets.h>
|
||||
#include <3ds/ipc.h>
|
||||
|
||||
static Handle ptmSetsHandle;
|
||||
static int ptmSetsRefCount;
|
||||
|
||||
Result ptmSetsInit(void)
|
||||
{
|
||||
if (AtomicPostIncrement(&ptmSetsRefCount)) return 0;
|
||||
Result res = srvGetServiceHandle(&ptmSetsHandle, "ptm:sets");
|
||||
if (R_FAILED(res)) AtomicDecrement(&ptmSetsRefCount);
|
||||
return res;
|
||||
}
|
||||
|
||||
void ptmSetsExit(void)
|
||||
{
|
||||
if (AtomicDecrement(&ptmSetsRefCount)) return;
|
||||
svcCloseHandle(ptmSetsHandle);
|
||||
}
|
||||
|
||||
Handle *ptmSetsGetSessionHandle(void)
|
||||
{
|
||||
return &ptmSetsHandle;
|
||||
}
|
||||
|
||||
Result PTMSETS_SetSystemTime(s64 msY2k)
|
||||
{
|
||||
Result ret;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
cmdbuf[0] = IPC_MakeHeader(0x1,2,0); // 0x00010080
|
||||
memcpy(&cmdbuf[1], &msY2k, 8);
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(ptmSetsHandle)))return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
@ -24,6 +24,11 @@ void ptmSysmExit(void)
|
||||
svcCloseHandle(ptmSysmHandle);
|
||||
}
|
||||
|
||||
Handle *ptmSysmGetSessionHandle(void)
|
||||
{
|
||||
return &ptmSysmHandle;
|
||||
}
|
||||
|
||||
Result PTMSYSM_RequestSleep(void)
|
||||
{
|
||||
Result ret;
|
||||
@ -144,6 +149,18 @@ Result PTMSYSM_RebootAsync(u64 timeout)
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result PTMSYSM_SetUserTime(s64 msY2k)
|
||||
{
|
||||
Result ret;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
cmdbuf[0] = IPC_MakeHeader(0x80C,2,0); // 0x080C0080
|
||||
memcpy(&cmdbuf[1], &msY2k, 8);
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(ptmSysmHandle)))return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result PTMSYSM_InvalidateSystemTime(void)
|
||||
{
|
||||
Result ret;
|
||||
|
@ -24,6 +24,11 @@ void ptmuExit(void)
|
||||
svcCloseHandle(ptmuHandle);
|
||||
}
|
||||
|
||||
Handle *ptmuGetSessionHandle(void)
|
||||
{
|
||||
return &ptmuHandle;
|
||||
}
|
||||
|
||||
Result PTMU_GetShellState(u8 *out)
|
||||
{
|
||||
Result ret=0;
|
||||
|
Loading…
Reference in New Issue
Block a user