This document describes the power management system on the PlayStation Classic.
It is mostly focused on the power_manage
executable: the command line arguments,
control files, and processes. It'll also touch upon the system service setup
and startup script.
There are a few components to the power management system: the startup script,
the power management service, thermal kernel modules, and supporting programs
such as the USB reset script and thermal handling scripts. Let's start with
the power_manage
executable, which is the main service of the power management
system.
power_manage
is a daemon for managing power-related tasks. It sits in the
background and waits for incoming commands from control files, monitors temperature
for throttling, and monitors key presses to respond to reset and power button
press from the console.
You may pass a number of command line arguments to power_manage
to modify its
behavior. Pass as many or few arguments as you want from the following table, in
any order.
%
denotes additional an additional argument you need to pass.
Argument | Description |
---|---|
noapps | Do not attempt to shut down frontend apps before suspending. |
abeled | Sets the LED mode. |
softled | Sets the LED mode. |
nothermal | Disable auto throttling and response to overtemperature. |
thermallog | Logs temperature, auto throttle temperature and counters, and other thermal-related messages |
nokeytime %timeout=3600 | Power save timeout in seconds. Must be greater than or equal to 30. |
ipt %timeout=15 | Minimum amount of time in seconds after resume before system can be suspended again using the power button. Must be less than or equal to 300. |
temp %start_temp=80000 %end_temp=55000 %start_time=3 %end_time=5 | Auto throttle params. start_temp is temperature when throttling starts, end_temp is temperature below which throttling ends, both in 1/1000 degree Celsius. start_time is sustained high temperature before throttling starts, end_time is sustained low temperature before throttling ends, both in minutes. |
stopweston | Stop Weston when suspending. |
rtcon | Handle resume caused by alarm wake (otherwise system resume will not be run until you press the power button). Practically, sets keypress polling timeout to 1000 instead of infinite. |
safereboot | Notifies frontend and unmounts /dev/sda1 and /dev/sdb1 before rebooting. |
keylog | Log input events. |
usbreset | Check and reset USB devices when reset button is pressed. |
By default (per startup script) the service is run with usbreset rtcon safereboot softled
.
power_manage
is responsible for the following:
- Managing system suspend/resume
- Handling thermal throttling
- Handling overheating
- Handling power save timeout and suspend
- Responding to power button press
- Initiate reset of USB devices
- Setting LED lights
Before suspending, the service will signal to the frontend by way of /data/power/prepare_suspend
that the system is going to suspend. It waits for /data/power/apps_timeout
seconds for app to respond with OK (/data/power/apps_okay
) or cancel
(/data/power/apps_cancel
). If canceled, suspend is canceled, unless suspend
was initiated by overheating. Otherwise, Weston will be stopped if selected,
the LEDs set (under softled
mode, yellow for normal suspend, red for overheating),
and the system put into suspend mode. Suspend control file is set accordingly.
When system is resuming, the LEDs are reset (under softled
mode, green), the
power flag and resume count updated, and /usr/bin/resume_run
is executed.
When CPU temperature exceeds throttle start temperature for a period, cpu_mode auto
is called and the LEDs set (under softled
mode, flashing yellow and green). When CPU temperature goes below throttle end temperature for a period,
cpu_mode full
is called and the LEDs set (under softled
mode, green).
If thermal management is not disabled, the service will hook into the console's
thermal notification and suspend if overheat has been signaled.
/dev/shm/thermal/mtkthermal_signal
is executed then the system is supended
when overheat is asserted.
If power save is enabled, waits for the timeout that no input has been received
and initiates suspend when the timeout has been exceeded. The time it has been
since last input is written to /data/power/time
.
If the reset button has been pressed, a USB reset will be triggered. Any presses within 3 seconds will be ignored. If the power button is pressed, unless disabled, a suspend is initiated.
It calls /usr/bin/usbreset_auto
(covered later) when USB reset is triggered.
Every 60 seconds, thermal checks will be performed (auto throttle, thermal
interval script). Every usbreset_auto
seconds (2 or more), USB reset is
triggered. Every second, CPU temperature file is updated, and control files
are checked.
When power_manage
starts, it will create a directory at /dev/shm/power
, and
symlink /data/power
to it. This means the following control files can be
accessed through /data/power
as well.
Write-only
Master control file.
%
in the following table indicates an integer value. Make sure the length of
what you're writing to the file is no longer than 9 characters.
Value | Description |
---|---|
aoff% | Sets power save timeout in seconds. Must be greater than 30. |
aon% | Automatic resume timeout in seconds. Must be greater than 3. (You should issue a standby after this.) |
usbr% | USB reset interval in seconds. 0 to disable USB reset, 1 to enable when pressing reset button, greater than 1 to set auto USB reset interval. |
reboot | Reboots the system. May do it safely (see safereboot command line arg). |
off | Suspends the system. |
Read/write
Whether power save is disabled.
Value | Description |
---|---|
0 | Power save enabled. |
1 | Power save disabled. |
2 | Power save and power button disabled (for suspend). |
Read-only
Seconds since last input received. Content is a binary int
value.
Read-only
System power status.
Value | Description |
---|---|
0 | Normal operations. |
1 | Suspending. |
Read-write
The number of times the system has been resumed.
Read-write
The number of times USB reset has been performed.
Read-write
The number of seconds to wait for the frontend to acknowledge suspending. Values
between 0 and 3600, inclusive. Invalid range will default setting to 5.
Additionally, the following will set the value to 5 and carry out additional function:
Value | Description |
---|---|
debugon | Redirect logging to /dev/tty . |
debugoff | Redirect logging to stdout . |
Presence
Signals to frontend apps that the system is preparing to suspend.
Presence
Response to service that system is OK to continue suspend.
Presence
Response to service that system should not suspend. Ignored if system is suspending
due to overheating.
Read-only
Reports the current CPU temperature in 1/1000 degree Celsius and the current
throttling mode. 0
is throttled, 1
is full speed. Format is two numbers
delimited by a space. Only present when thermal management is enabled.
Read-only
Reports current throttling settings. Contents look like this:
CPU_AUTO_START_TEMP 80000
CPU_AUTO_START_TIME 3
CPU_AUTO_END_TEMP 55000
CPU_AUTO_END_TIME 5
Only present when thermal management is enabled.
The following table summarizes how the LEDs behave when set on from within the service, depending on the mode:
LED | Default | softled | abeled |
---|---|---|---|
Red | Off | On | Off |
Green | On | On | Off |
Invert table values for set off from within the service.
Although the file name claims it starts power_manage
, it's actually an extended
startup script. It is started by the systemd
unit powermanage.service
.
Here's what it does:
Simply put, if it thinks the console is connected to a computer through the
Micro USB port, and the current unit is the user variant (from /etc/versions/variant
),
it will light the LED red and shut down.
If the current unit's node name (hostname) is not aiv8167-rockman-emmc
,
the unit will light the LED red and shut down.
It sets up symlinks as necessary to PCSX config files and BIOS and whatnot.
See /usr/sony/bin/sonyapp-copylink
for details.
Certain files are protected, and will be restored by SIC if it's detected to
be modified. See /usr/bin/sic
and /etc/sic.db
.
If thermal config and /data/thermal
exists, copy thermal config and restart
thermal manager. /data/thermal
does not exist on a stock system. Also, the
systemd
unit overrides the config file path, so this really doesn't do anything.
If not DVT version (I don't know what that means), set LEDs yellow and pass
softled
mode for power_manage
.
No, we don't use power_manage
to suspend on boot, instead we do it ourselves
because nothing should be running yet. If /etc/autostart
exists, the value
in it is used to auto wake the system.
I thought systemd
or one of the other scripts was supposed to handle this?
This program resets USB devices in case the hub puts them to sleep. It will
only reset devices if the devices are suspended. It calls /usr/bin/usbreset
to do the actual resetting.
The following options are flags (i.e. presence only to enable).
Reset the hub when resetting USB.
Disable resetting USB devices (but does not disable hub reset, if enabled).
Forces USB reset even when not necessary.
The following files are used by the power management system, but are not managed
by the power_manage
service.
Copied from /usr/bin/mtkthermal_interval
. It prints the contents of each file
matching /proc/mtktz/mtkts*
if the system is not a retail release model.
Copied from /usr/bin/mtkthermal_signal
. Ran in preparation for thermal shutdown.
It prints the contents of /proc/mtktz/mtkts*
, runs fsck
on /data
in dry
mode, and prints a list of zero-length files in /data
. Why is it doing all
of this when the system should be suspending to prevent damage? No one knows.
Resumes system from suspend. Closes error message instance of Weston, restarts
Weston if not running, waits for SDL to be inittable, logrotates, and restarts
sonyapp
(but not by using systemd
for some reason).
Actually part of the system thermal driver, write your process ID to register
to receive SIGIO
with si_code=1
when the system asserts overheating.
Sets CPU throttling mode. full
and auto
are the most commonly used options,
but there's a lot of other ones. Read the script if you want to know more.
Loads up thermal config. Looks by default at /data/thermal/thermal.conf
, but
the systemd
unit associated with it actually specifies /etc/.tp/thermal.conf
.
Although this is a compiled binary that loads another library, what it actually
does is fairly straightforward. It reads the contents of the conf file and writes
lines to the files specified.
Conf file format is as follows: one line of path of the file to write to, another
line of the content to write. Rinse and repeat. End the file with the string EOF
.