libctru  v2.4.1
Data Structures | Enumerations | Functions
ptmsysm.h File Reference

PTMSYSM service. More...

#include <3ds/types.h>

Go to the source code of this file.

Data Structures

struct  PtmWakeEvents
 PDN wake events and MCU interrupts to select, combined with those of other processes. More...
 
struct  PtmSleepConfig
 

Enumerations

enum  {
  PTMNOTIFID_SLEEP_REQUESTED = 0x101 ,
  PTMNOTIFID_SLEEP_DENIED = 0x102 ,
  PTMNOTIFID_SLEEP_ALLOWED = 0x103 ,
  PTMNOTIFID_GOING_TO_SLEEP = 0x104 ,
  PTMNOTIFID_FULLY_WAKING_UP = 0x105 ,
  PTMNOTIFID_FULLY_AWAKE = 0x106 ,
  PTMNOTIFID_HALF_AWAKE = 0x107 ,
  PTMNOTIFID_SHUTDOWN = 0x108 ,
  PTMNOTIFID_BATTERY_VERY_LOW = 0x211 ,
  PTMNOTIFID_BATTERY_LOW = 0x212
}
 

Functions

static s32 ptmSysmGetNotificationAckValue (u32 id)
 See PTMSYSM_NotifySleepPreparationComplete. Corresponds to the number of potentially remaning notifs. until sleep/wakeup.
 
Result ptmSysmInit (void)
 Initializes ptm:sysm.
 
void ptmSysmExit (void)
 Exits ptm:sysm.
 
HandleptmSysmGetSessionHandle (void)
 Gets a pointer to the current ptm:sysm session handle. More...
 
Result PTMSYSM_RequestSleep (void)
 Requests to enter sleep mode.
 
Result PTMSYSM_ReplyToSleepQuery (bool deny)
 Accepts or denies the incoming sleep mode request. More...
 
Result PTMSYSM_NotifySleepPreparationComplete (s32 ackValue)
 Acknowledges the current sleep notification and advance the internal sleep mode FSM. More...
 
Result PTMSYSM_SetWakeEvents (const PtmSleepConfig *sleepConfig)
 Sets the wake events (two sets: when to fully wake up and when to return to sleep). More...
 
Result PTMSYSM_GetWakeReason (PtmSleepConfig *outSleepConfig)
 Gets the wake reason (only the first applicable wake event is taken into account). More...
 
Result PTMSYSM_Awaken (void)
 Cancels the "half-awake" state and fully wakes up the 3DS after some delay.
 
Result PTMSYSM_SetUserTime (s64 msY2k)
 Sets the user time by updating the user time offset. More...
 
Result PTMSYSM_InvalidateSystemTime (void)
 Invalidates the "system time" (cfg block 0x30002)
 
Result PTMSYSM_GetRtcTime (s64 *outMsY2k)
 Reads the time and date coming from the RTC and converts the result. More...
 
Result PTMSYSM_SetRtcTime (s64 msY2k)
 Writes the time and date coming to the RTC, after conversion. More...
 
Result PTMSYSM_CheckNew3DS (bool *out)
 Checks whether the system is a New 3DS. More...
 
Result PTMSYSM_ConfigureNew3DSCPU (u8 value)
 Configures the New 3DS' CPU clock speed and L2 cache. More...
 
Result PTMSYSM_ShutdownAsync (u64 timeout)
 Trigger a hardware system shutdown via the MCU. More...
 
Result PTMSYSM_RebootAsync (u64 timeout)
 Trigger a hardware system reboot via the MCU. More...
 

Detailed Description

PTMSYSM service.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PTMNOTIFID_SLEEP_REQUESTED 

PTMSYSM_RequestSleep has been called (ack = 3)

PTMNOTIFID_SLEEP_DENIED 

The sleep request has been denied by PTMSYSM_ReplyToSleepQuery(true) (no ack required).

PTMNOTIFID_SLEEP_ALLOWED 

The sleep request has been allowed by PTMSYSM_ReplyToSleepQuery(false) (ack = 1).

PTMNOTIFID_GOING_TO_SLEEP 

All processes not having "RunnableOnSleep" have been paused & the system is about to go to sleep (ack = 0).

PTMNOTIFID_FULLY_WAKING_UP 

The system has been woken up, and the paused processes are about to be unpaused (ack = 1).

PTMNOTIFID_FULLY_AWAKE 

The system is fully awake (no ack required).

PTMNOTIFID_HALF_AWAKE 

The system has been woken up but is about to go to sleep again (ack = 2).

PTMNOTIFID_SHUTDOWN 

The system is about to power off or reboot.

PTMNOTIFID_BATTERY_VERY_LOW 

The battery level has reached 5% or below.

PTMNOTIFID_BATTERY_LOW 

The battery level has reached 10% or below.

Function Documentation

◆ PTMSYSM_CheckNew3DS()

Result PTMSYSM_CheckNew3DS ( bool *  out)

Checks whether the system is a New 3DS.

Parameters
[out]outPointer to write the New 3DS flag to.

◆ PTMSYSM_ConfigureNew3DSCPU()

Result PTMSYSM_ConfigureNew3DSCPU ( u8  value)

Configures the New 3DS' CPU clock speed and L2 cache.

Parameters
valueBit0: enable higher clock, Bit1: enable L2 cache.

◆ PTMSYSM_GetRtcTime()

Result PTMSYSM_GetRtcTime ( s64 outMsY2k)

Reads the time and date coming from the RTC and converts the result.

Parameters
[out]outMsY2kThe pointer to write the number of milliseconds since 01/01/2000 to.

◆ PTMSYSM_GetWakeReason()

Result PTMSYSM_GetWakeReason ( PtmSleepConfig outSleepConfig)

Gets the wake reason (only the first applicable wake event is taken into account).

Parameters
sleepConfigPointer to the two sets of wake events. Only the relevant set will be filled.

◆ PTMSYSM_NotifySleepPreparationComplete()

Result PTMSYSM_NotifySleepPreparationComplete ( s32  ackValue)

Acknowledges the current sleep notification and advance the internal sleep mode FSM.

All subscribers must reply.

Parameters
ackValueUse ptmSysmGetNotificationAckValue
Note
PTMNOTIFID_SLEEP_DENIED and PTMNOTIFID_FULLY_AWAKE don't require this.

◆ PTMSYSM_RebootAsync()

Result PTMSYSM_RebootAsync ( u64  timeout)

Trigger a hardware system reboot via the MCU.

Parameters
timeouttimeout passed to PMApp:ShutdownAsync (PrepareForReboot).

◆ PTMSYSM_ReplyToSleepQuery()

Result PTMSYSM_ReplyToSleepQuery ( bool  deny)

Accepts or denies the incoming sleep mode request.

Parameters
denyWhether or not to deny the sleep request.
Note
If deny = false, this is equivalent to calling PTMSYSM_NotifySleepPreparationComplete(3)

◆ PTMSYSM_SetRtcTime()

Result PTMSYSM_SetRtcTime ( s64  msY2k)

Writes the time and date coming to the RTC, after conversion.

Parameters
msY2kThe number of milliseconds since 01/01/2000.

◆ PTMSYSM_SetUserTime()

Result PTMSYSM_SetUserTime ( s64  msY2k)

Sets the user time by updating the user time offset.

Parameters
msY2kThe number of milliseconds since 01/01/2000.

◆ PTMSYSM_SetWakeEvents()

Result PTMSYSM_SetWakeEvents ( const PtmSleepConfig sleepConfig)

Sets the wake events (two sets: when to fully wake up and when to return to sleep).

Parameters
sleepConfigPointer to the two sets of wake events.
Note
Can only be called just before acknowledging PTMNOTIFID_GOING_TO_SLEEP or PTMNOTIFID_HALF_AWAKE.

◆ PTMSYSM_ShutdownAsync()

Result PTMSYSM_ShutdownAsync ( u64  timeout)

Trigger a hardware system shutdown via the MCU.

Parameters
timeouttimeout passed to PMApp:ShutdownAsync (PrepareForReboot).

◆ ptmSysmGetSessionHandle()

Handle* ptmSysmGetSessionHandle ( void  )

Gets a pointer to the current ptm:sysm session handle.

Returns
A pointer to the current ptm:sysm session handle.