Difference between revisions of "PSC services"

From Nintendo Switch Brew
Jump to navigation Jump to search
(add module id table (incomplete))
Line 133: Line 133:
 
|-
 
|-
 
| 20401 || [6.0.0+]
 
| 20401 || [6.0.0+]
 +
|}
 +
 +
= PSC Module IDs =
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! ID || Module
 +
|-
 +
| 0x1B ||
 +
|-
 +
| 0x1E ||
 +
|-
 +
| 0x29 || [[Log services|nn::psc::PmModuleId_Lm]]
 
|}
 
|}
  
 
[[Category:Services]]
 
[[Category:Services]]

Revision as of 07:22, 20 December 2018

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

This is "nn::psc::sf::IPmControl".

Cmd Name
0 Initialize
1 DispatchRequest
2 GetResult
3 GetState
4 Cancel
5 PrintModuleInformation
6 GetModuleInformation

psc:m

This is "nn::psc::sf::IPmService".

Cmd Name Notes
0 GetPmModule Returns an #IPmModule.

IPmModule

This is "nn::psc::sf::IPmModule".

Cmd Name
0 Initialize
1 GetRequest
2 Acknowledge
3 Finalize
4 [6.0.0+] AcknowledgeEx

srepo:u, srepo:a

These are "nn::srepo::detail::ipc::ISrepoService".

Cmd Name
10100
10101 [6.0.0+]
10200 [6.0.0+]
10201 [6.0.0+]
11000 [6.0.0+]
11001 [6.0.0+]
11002 [6.0.0+]
11003 [6.0.0+]
11004 [6.0.0+]
11100 [6.0.0+]
11200 [6.0.0+]
11300 [6.0.0+]
11400 [6.0.0+]
11500 [6.0.0+]
11600 [6.0.0+]
11601 [6.0.0+]
11602 [6.0.0+]
11700 [6.0.0+]
11800 [6.0.0+]
11801 [6.0.0+]
20100
20200
20300 [6.0.0+]
20400 [6.0.0+]
20401 [6.0.0+]

PSC Module IDs

ID Module
0x1B
0x1E
0x29 nn::psc::PmModuleId_Lm