PSC services: Difference between revisions

No edit summary
No edit summary
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
PSC (Power State Control) provides services related to power state changes in the system.
PSC (Power State Control) provides services related to power state changes in the system.
= Concept =
psc:m allows a process to register a module that depends on power management in some way. A client calls GetPmModule to receive an IPmModule (Power Managed Module), and then calls IPmModule->Initialize(module_id, module_dependency_list) where module_id is the ModuleId enum member for the client, and the dependency list is an array of module IDs for the modules that this depends on. Initialize() returns an event handle that the client can wait on to be notified of a power state change.
psc:c allows a module to the power state controller for the system (in practice, AM is the only client to the controller). IPmControl->DispatchRequest() is used notify all IPmModules of a state change.
For example, FS registers itself as an IPmModule with dependencies on pinmux, gpio, pcv, tma, and initializes the SD card once those dependencies have registered..
It then does (basically) the following pseudocode (actual code located at .text + 0xB2DB0 in 6.0.0 FS):
    while (true) {
        Fs_IPmModule->WaitSignaled();
       
        Fs_IPmModule->GetRequest(&state);
        switch (state) {
            case WakingUp:
                /* hardware devices are woken up here */
            case GoingToSleep:
                /* hardware devices are put to sleep here */
            case ShuttingDown:
                /* hardware devices are turned off here */
        }
       
        Fs_IPmModule->Acknowledge(state);
    }


= psc:c =
= psc:c =
Line 228: Line 203:
|-
|-
| 12001 || [8.0.0+] [[#UnregisterWatchdog]]
| 12001 || [8.0.0+] [[#UnregisterWatchdog]]
|-
| 12010 || [20.0.0+]
|-
|-
| 13000 || [8.0.0+] [[#GetSyslogLogger]]
| 13000 || [8.0.0+] [[#GetSyslogLogger]]
|-
|-
| 13001 || [8.0.0+] [[#SaveSyslogReport]]
| 13001 || [8.0.0-19.0.1] [[#SaveSyslogReport]]
|-
|-
| 20100 || [[#PopReport]]
| 13002 || [19.0.0+]
|-
| 13003 || [20.0.0+]
|-
| 13004 || [20.0.0+]
|-
| 20100 || [[#PopReport]]
|-
|-
| 20200 || [[#GetPushEventReadableHandle]]
| 20200 || [[#GetPushEventReadableHandle]]
Line 249: Line 232:
| 20600 || [15.0.0+] [[#NotifyForegroundTransmissionResult]]
| 20600 || [15.0.0+] [[#NotifyForegroundTransmissionResult]]
|}
|}
[20.0.0+] Cmd13002 now takes a total of 8-bytes of input.


== SaveReport ==
== SaveReport ==
Takes a type-0x9 input buffer containing the [[#EventId]], an input u64 '''ApplicationId''' and a type-0x5 input buffer containing the [[#SystemReport]]. No output.
Takes a type-0x9 input buffer containing the [[#EventId]], an input u64 '''ApplicationId''' and a type-0x5 input buffer containing the [[#SystemReport]]. No output.
[21.0.0+] Now takes an additional 8-bytes of input.


<code>nn::srepo::detail::VerifyEventId</code> is then used with the [[#EventId]], throwing error on failure.
<code>nn::srepo::detail::VerifyEventId</code> is then used with the [[#EventId]], throwing error on failure.
Line 261: Line 248:
== SaveReportWithUser ==
== SaveReportWithUser ==
Takes a type-0x9 input buffer containing the [[#EventId]], an input u64 '''ApplicationId''', a type-0x5 input buffer containing the [[#SystemReport]] and an input [[Account_services#Uid|Uid]]. No output.
Takes a type-0x9 input buffer containing the [[#EventId]], an input u64 '''ApplicationId''', a type-0x5 input buffer containing the [[#SystemReport]] and an input [[Account_services#Uid|Uid]]. No output.
[21.0.0+] Now takes an additional 8-bytes of input.


Same as [[#SaveReport]] except instead of calling the processing func with Uid=all-zero, the input Uid is passed instead (which must be non-zero).
Same as [[#SaveReport]] except instead of calling the processing func with Uid=all-zero, the input Uid is passed instead (which must be non-zero).
Line 346: Line 335:
== NotifyApplicationRightsInfo ==
== NotifyApplicationRightsInfo ==
Takes an input u64 '''ApplicationId''' and an input u32 (padded to u64). No output.
Takes an input u64 '''ApplicationId''' and an input u32 (padded to u64). No output.
If the input u32 is 0 or none of the bits are recognized, this just returns 0. Otherwise the lowest set bit is used to determine a value to write to stack (the ApplicationId is also written afterwards), for passing to a func.
{| class="wikitable" border="1"
|-
! Bit || Write value
|-
| 0 || 0x2
|-
| 3 || 0x3
|-
| 4 || 0x4
|-
| 5 || [20.1.0+] 0x5
|-
| 6 || [20.1.0+] 0x6
|}


== RegisterWatchdog ==
== RegisterWatchdog ==
Line 460: Line 466:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 || OpenReceiver
| 0 || [[#OpenReceiver|OpenReceiver]]
|}
|}
== OpenReceiver ==
No input. Returns an [[#IReceiver|IReceiver]].


== IReceiver ==
== IReceiver ==
Line 470: Line 479:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 || AddSource
| 0 || [[#AddSource|AddSource]]
|-
|-
| 1 || RemoveSource
| 1 || [[#RemoveSource|RemoveSource]]
|-
|-
| 2 || GetReceiveEventHandle
| 2 || [[#GetReceiveEventHandle|GetReceiveEventHandle]]
|-
|-
| 3 || Receive
| 3 || [[#Receive|Receive]]
|-
|-
| 4 || ReceiveWithTick
| 4 || [[#ReceiveWithTick|ReceiveWithTick]]
|}
|}
=== AddSource ===
Takes an input [[#SourceName|SourceName]]. No output.
=== RemoveSource ===
Takes an input [[#SourceName|SourceName]]. No output.
=== GetReceiveEventHandle ===
No input. Returns an output Event handle.
=== Receive ===
No input. Returns an output [[#RawMessage|RawMessage]].
=== ReceiveWithTick ===
No input. Returns an output [[#RawMessage|RawMessage]] and an output s64.


= ovln:snd =
= ovln:snd =
Line 488: Line 512:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 || OpenSender
| 0 || [[#OpenSender|OpenSender]]
|}
|}
== OpenSender ==
Takes an input [[#SourceName|SourceName]] and an input [[#QueueAttribute|QueueAttribute]]. Returns an [[#ISender|ISender]].


== ISender ==
== ISender ==
Line 498: Line 525:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 || Send
| 0 || [[#Send|Send]]
|-
|-
| 1 || GetUnreceivedMessageCount
| 1 || [[#GetUnreceivedMessageCount|GetUnreceivedMessageCount]]
|}
|}
=== Send ===
Takes an input [[#RawMessage|RawMessage]] and an input [[#SendOption|SendOption]]. No output.
=== GetUnreceivedMessageCount ===
No input. Returns an output u32.


= time:m =
= time:m =
Line 533: Line 566:
|-
|-
| 15 || [[#SetupEphemeralNetworkSystemClockCore]]
| 15 || [[#SetupEphemeralNetworkSystemClockCore]]
|-
| 20 || [19.0.0+] GetStandardSteadyClockCurrentTimePoint
|-
| 21 || [22.0.0+] GetStandardNetworkSystemClockCurrentTime
|-
|-
| 50 || GetStandardLocalClockOperationEvent
| 50 || GetStandardLocalClockOperationEvent
Line 733: Line 770:
|-
|-
| 501 || [4.0.0+] CalculateSpanBetween ||  
| 501 || [4.0.0+] CalculateSpanBetween ||  
|-
| 600 || [19.0.0+] GetInitialLaunchEndTime ||
|-
| 601 || [22.0.0+] NotifyInitialLaunchSettingsDone ||
|}
|}


Line 997: Line 1,038:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 ||
| 0 || GetBatteryPercentage
|-
|-
| 1 ||
| 1 || GetChargerType
|-
|-
| 2 || [[#OpenChargeSession]]
| 2 || [[#OpenChargeSession]]
|-
|-
| 3 ||
| 3 || GetRawBatteryPercentage
|-
|-
| 4 ||
| 4 || GetBatteryVoltageLevel
|-
|-
| 5 || [[#OpenThermalSession]]
| 5 || [[#OpenThermalSession]]
|-
|-
| 6 ||
| 6 || GetAbnormalTemperatureSet
|-
|-
| 7 || [[#OpenClockSession]]
| 7 || [[#OpenClockSession]]
|-
|-
| 8 ||
| 8 || GetClockRate
|-
|-
| 9 || [17.0.0+] [[#OpenBridgeSession]]
| 9 || [17.0.0+] [[#OpenBridgeSession]]
|-
|-
| 10 || [17.0.0+]  
| 10 || [17.0.0+] GetBridgePowerSupply
|-
|-
| 11 || [18.0.0+]  
| 11 || [18.0.0+] [[#OpenVsysVoltageSession]]
|-
|-
| 12 || [18.0.0+]  
| 12 || [18.0.0+] GetIsBatteryEnoughForFullAwake
|-
| 13 || [19.0.0+] GetIsCharging
|-
| 14 || [20.0.0+]
|-
| 15 || [20.0.0+]
|}
|}


Line 1,035: Line 1,082:
== OpenBridgeSession ==
== OpenBridgeSession ==
No input. Returns an [[#IBridgeSession]].
No input. Returns an [[#IBridgeSession]].
== OpenVsysVoltageSession ==
No input. Returns an [[#IVsysVoltageSession]].


== IChargeSession ==
== IChargeSession ==
Line 1,043: Line 1,093:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 ||
| 0 || GetStateChangeEvent
|-
|-
| 1 ||
| 1 || SetStateChangeSet
|}
|}


Line 1,055: Line 1,105:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 ||
| 0 || GetAbnormalTemperatureEvent
|-
|-
| 1 ||
| 1 || SetAbnormalTemperatureEventMask
|}
|}


Line 1,067: Line 1,117:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 ||  
| 0 || GetStateChangeEvent
|}
|}


Line 1,077: Line 1,127:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 ||  
| 0 || GetStateChangeEvent
|}
 
== IVsysVoltageSession ==
This is "nn::hshl::IVsysVoltageSession".
 
{| class="wikitable" border="1"
|-
! Cmd || Name
|-
| 0 || GetStateChangeEvent
|}
|}


Line 1,089: Line 1,149:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 || [[#OpenChargeSetterSession]]
| 0 || [[#OpenChargeSession_2|OpenChargeSession]]
|-
|-
| 1 || [[#OpenThermalSetterSession]]
| 1 || [[#OpenThermalSession_2|OpenThermalSession]]
|-
|-
| 2 ||
| 2 || SetClockRate
|-
|-
| 3 || [17.0.0+]  
| 3 || [17.0.0+] SetBridgePowerSupply
|-
|-
| 4 || [18.0.0+]  
| 4 || [18.0.0+]  
Line 1,102: Line 1,162:
|}
|}


== OpenChargeSetterSession ==
== OpenChargeSession ==
Takes an input u32. Returns an [[#IChargeSetterSession]].
Takes an input u32. Returns an [[#IChargeSetterSession]].


== OpenThermalSetterSession ==
== OpenThermalSession ==
Takes an input u32. Returns an [[#IThermalSetterSession]].
Takes an input u32. Returns an [[#IThermalSetterSession]].


Line 1,115: Line 1,175:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 ||
| 0 || SetBatteryPercentage
|-
|-
| 1 ||
| 1 || SetRawBatteryPercentage
|-
|-
| 2 ||
| 2 || SetChargerType
|-
|-
| 3 ||
| 3 || SetBatteryVoltageLevel
|-
|-
| 4 || [18.0.0+]
| 4 || [18.0.0+]
|-
| 5 || [19.0.0+]
|-
| 6 || [20.0.0+]
|-
| 7 || [20.0.0+]
|}
|}


Line 1,133: Line 1,199:
! Cmd || Name
! Cmd || Name
|-
|-
| 0 ||
| 0 || SetAbnormalTemperatureSet
|}
|}


Line 1,259: Line 1,325:
| 0x39 || [[PCV_services|Rtc]]
| 0x39 || [[PCV_services|Rtc]]
|-
|-
| 0x3A ||
| 0x3A || [[PCV_services|Regulator]]
|-
|-
| 0x3B ||
| 0x3B || [[PCV_services|Clkrst]]
|-
|-
| 0x3C || [[Bus_services|Led]]
| 0x3C || [[Bus_services|Led]]
|-
|-
| 0x3D || [[NS_Services|Ns]]
| 0x3D || [[NS_Services|NuiShell]]
|-
|-
| 0x3E || [[PTM_services|Powctl]]
| 0x3E || [[PTM_services|Powctl]]
Line 1,273: Line 1,339:
| 0x40 || [[Glue_services|Notification]]
| 0x40 || [[Glue_services|Notification]]
|-
|-
| 0x41 || [[Sockets_services|Dhcps]]
| 0x41 || [[Sockets_services|Dhcpc]]
|-
|-
| 0x42 || [[BCAT_services|Mnpp]]
| 0x42 || [[BCAT_services|Mnpp]]
Line 1,330: Line 1,396:
! Description
! Description
|-
|-
| 0x00
| 0x0
| 0x08
| 0x8
| TimeBefore
| TimeBefore
|-
|-
| 0x08
| 0x8
| 0x10
| 0x10
| TimeAfter
| TimeAfter
|-
|-
| 0x10
| 0x10
| 0x04
| 0x4
| Result
| Result
|-
|-
| 0x14
| 0x14
| 0x04
| 0x4
| [[#PmState|StateBefore]]
| [[#PmState|StateBefore]]
|-
|-
| 0x18
| 0x18
| 0x04
| 0x4
| [[#PmState|StateAfter]]
| [[#PmState|StateAfter]]
|-
|-
| 0x1C
| 0x1C
| 0x04
| 0x4
| Reserved
| Reserved
|}
|}
Line 1,364: Line 1,430:
! Description
! Description
|-
|-
| 0x00
| 0x0
| 0x20
| 0x20
| [[#EventId|EventId]]
| [[#EventId|EventId]]
|-
|-
| 0x20
| 0x20
| 0x08
| 0x8
| ApplicationId
| ApplicationId
|-
|-
| 0x28
| 0x28
| 0x04
| 0x4
| Flags
| Flags
|-
|-
| 0x2C
| 0x2C
| 0x01
| 0x1
|  
|  
|-
|-
| 0x2D
| 0x2D
| 0x03
| 0x3
| Reserved
| Reserved
|-
|-
| 0x30
| 0x30
| 0x08
| 0x8
| ReportBufferAddress
| ReportBufferAddress
|-
|-
| 0x38
| 0x38
| 0x08
| 0x8
| ReportBufferTotalSize
| ReportBufferTotalSize
|-
|-
| 0x40
| 0x40
| 0x08
| 0x8
| ReportBufferCurrentSize
| ReportBufferCurrentSize
|}
|}
Line 1,412: Line 1,478:
! Description
! Description
|-
|-
| 0x00
| 0x0
| 0x08
| 0x8
|  
|  
|-
|-
| 0x08
| 0x8
| 0x08
| 0x8
|  
|  
|}
|}
Line 1,426: Line 1,492:
= SfAppletIdentityInfo =
= SfAppletIdentityInfo =
This is "nn::srepo::detail::ipc::SfAppletIdentityInfo". This is a 0x10-byte struct.
This is "nn::srepo::detail::ipc::SfAppletIdentityInfo". This is a 0x10-byte struct.
= SourceName =
This is "nn::ovln::SourceName".
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x10
| Name
|}
= RawMessage =
This is "nn::ovln::RawMessage".
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x4
| Tag
|-
| 0x4
| 0x4
| DataSize
|-
| 0x8
| 0x78
| Data
|}
= QueueAttribute =
This is "nn::ovln::QueueAttribute".
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x4
| QueueLength
|-
| 0x4
| 0x4
| Reserved
|}
= SendOption =
This is "nn::ovln::SendOption".
{| class="wikitable" border="1"
|-
! Offset
! Size
! Description
|-
| 0x0
| 0x1
| EnqueuePosition
|-
| 0x1
| 0x1
| OverflowOption
|-
| 0x2
| 0x6
| Reserved
|}
== EnqueuePosition ==
This is "nn::ovln::EnqueuePosition".
{| class="wikitable" border="1"
|-
! Value
! Description
|-
| 0 || Front
|-
| 1 || Back
|}
== OverflowOption ==
This is "nn::ovln::OverflowOption".
{| class="wikitable" border="1"
|-
! Value
! Description
|-
| 0 || Error
|-
| 1 || RemoveFront
|-
| 2 || RemoveBack
|-
| 3 || Block
|}
= Notes =
psc:m allows a process to register a module that depends on power management in some way. A client calls GetPmModule to receive an IPmModule (Power Managed Module), and then calls IPmModule->Initialize(module_id, module_dependency_list) where module_id is the ModuleId enum member for the client, and the dependency list is an array of module IDs for the modules that this depends on. Initialize() returns an event handle that the client can wait on to be notified of a power state change.
psc:c allows a module to the power state controller for the system (in practice, AM is the only client to the controller). IPmControl->DispatchRequest() is used notify all IPmModules of a state change.
For example, FS registers itself as an IPmModule with dependencies on pinmux, gpio, pcv, tma, and initializes the SD card once those dependencies have registered..
It then does (basically) the following pseudocode (actual code located at .text + 0xB2DB0 in 6.0.0 FS):
    while (true) {
        Fs_IPmModule->WaitSignaled();
       
        Fs_IPmModule->GetRequest(&state);
        switch (state) {
            case WakingUp:
                /* hardware devices are woken up here */
            case GoingToSleep:
                /* hardware devices are put to sleep here */
            case ShuttingDown:
                /* hardware devices are turned off here */
        }
       
        Fs_IPmModule->Acknowledge(state);
    }


[[Category:Services]]
[[Category:Services]]