-
Notifications
You must be signed in to change notification settings - Fork 40
Add Power Service #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
* Added bunch of missing functions left to reverse engineer.
…ure areas in greater detail.
…] struct. Moved some macros to syscon.h as a result. The size of the struct was also incorrect previously (too large), this has been fixed as part of this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic work, @Felix-Dev! I can imagine some of it must have been quite tedious!
| #define POWER_ERROR_H | ||
|
|
||
| /* This constant represents an unknown power service error (related to the PSP system chip's temperature). */ | ||
| #define SCE_POWER_ERROR_0010 0x802B0010 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file be a part of / be included from include/common/errors.h?
| * This constant specifies that a search for a slot number from among the empty slots is to be automatically performed | ||
| * when a callback is registered with the ::scePowerRegisterCallback() function. | ||
| */ | ||
| #define SCE_POWER_CALLBACKSLOT_AUTO (-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like there is a lot of duplication with power_kernel.h can we re-factor this out into power_common.h?
src/power/battery.c
Outdated
| * voltage, charge cycle,...). Internally, we set up a worker thread which periodically polls the battery to update | ||
| * the collected battery properties. | ||
| * | ||
| * Starting with the PSP N-1000 (PSP-Go) serie, the battery equipped by default no longer has hardware included to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Starting with the PSP N-1000 (PSP-Go) serie, the battery equipped by default no longer has hardware included to | |
| * Starting with the PSP N-1000 (PSP-Go) series, the battery equipped by default no longer has hardware included to |
src/power/battery.c
Outdated
| * At the time of power service termination, there might be an active [permit battery charging] request | ||
| * in our battery manager. This request might currently be lined up in our battery worker thread for | ||
| * execution or scheduled to happen after some delay time. However, as we are in the process of shutting | ||
| * down the kernel (anf thus our battery worker thread) we will removed any scheduled/lined up work here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * down the kernel (anf thus our battery worker thread) we will removed any scheduled/lined up work here | |
| * down the kernel (and thus our battery worker thread) we will remove any scheduled/lined up work here |
| #define SCE_SYSCON_BARYON_STATUS_ALARM (1 << 3) | ||
| #define SCE_SYSCON_BARYON_STATUS_POWER_SW_ON (1 << 4) | ||
| #define SCE_SYSCON_BARYON_STATUS_IS_LOW_BATTERY_01G (1 << 5) | ||
| #define SCE_SYSCON_BARYON_STATUS_HDD_POWER (1 << 18) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a typo? sceSysconGetBaryonStatus returns a u8, so (1 << 7) would be the max possible
src/power/clockFrequency.c
Outdated
| * - Scratchpad memory | ||
| * - Graphic Engine and the Graphic Engine's eDRAM | ||
| * - DMA transfers for general-purpose memory copying | ||
| * - DMA transfers for the Memory Stic, WLAN, USB, LCD, or audio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * - DMA transfers for the Memory Stic, WLAN, USB, LCD, or audio | |
| * - DMA transfers for the Memory Stick, WLAN, USB, LCD, or audio |
src/power/clockFrequency.c
Outdated
| * - Graphic Engine and the Graphic Engine's eDRAM | ||
| * - DMA transfers for general-purpose memory copying | ||
| * - DMA transfers for the Memory Stic, WLAN, USB, LCD, or audio | ||
| * - DMA transfers for transfers to the MediaEngine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * - DMA transfers for transfers to the MediaEngine | |
| * - DMA transfers to the MediaEngine |
|
|
||
| u8 baryonVersionMajor = PSP_SYSCON_BARYON_GET_VERSION_MAJOR(g_Power.baryonVersion); | ||
| u8 baryonVersionMinor = PSP_SYSCON_BARYON_GET_VERSION_MINOR(g_Power.baryonVersion); | ||
| if (baryonVersionMajor == 0x2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be greatly simplified, but it seems like we're trying to match Sony's implementation which must have had the optimizer turned off or something.
| } | ||
|
|
||
| // scePower_DB9D28DD | ||
| s32 scePowerUnregitserCallback(s32 slot) __attribute__((alias("scePowerUnregisterCallback"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely handled
src/power/powerSwitch.c
Outdated
| * used to contain a copy of the on-board eDRAM content as the 4MB eDRAM memory is volatile when the system is | ||
| * suspended. When the PSP resumes, this saved content is then written back to the on-board eDRAM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * used to contain a copy of the on-board eDRAM content as the 4MB eDRAM memory is volatile when the system is | |
| * suspended. When the PSP resumes, this saved content is then written back to the on-board eDRAM. | |
| * used to contain a copy of the on-board eDRAM content as the 4MB eDRAM memory is volatile and lost when | |
| * the system is suspended. When the PSP resumes, this saved content is then written back to the on-board eDRAM. |
|
I saw some .a files added to the PR, is that right? |
Yes these are stub libraries required to build the module. |
|
Why is this not merged yet? |
Well, it can't now because it has merge conflicts. Aything in this PR under the "src" directory needs to be moved to "src/kd/". |
The stuff asked by Hedge a few years ago has not been fixed yet. Feel free to do it if you want. It could be ignored and merged anyway but I feel it'd be a waste to discard the remarks.
This is trivial to rebase anyway, that's not an issue. |
Description
This PR adds the fully reverse-engineered Power Service (power_0x.prx) to uofw.
Except for the PSP Go (PSP N-1000), all PSP series should be supported. We currently don't have support for the PSP Go model due to a missing reverse engineering of the PSP Go's exclusive hibernation feature. I don't have any plans right now to add that support, so if anyone wants to take a look at that, feel free to go ahead :)
Highlights
Motivation and Context
Closes #39.
How Has This Been Tested?
The module has been compiled and tested successfully on a PSP-1000. Testing included the following:
Specific APIs have not been tested and as such might contain bugs. However, the overall impression after testing is that our power module can be run on a PSP device without causing any major issues.
Additional Context
Power service can be compiled using the archaic PSPSDK 0.11 release as well as the most recent PSPSDK as part of the PSP toolchain. Once we've updated the toolchain version used in our CI, support for PSPSDK 0.11 can be removed from power.
Note that if you want to run the power module on your PSP using the UOFW installer, make sure to comment out its patching of the power service to make sure no issue is introduced by running power through the UOFW installer.
Final Notes
I had started working on power all the way back in early 2013 and then stopped soon after that...until starting to work on it again since the beginning of this year. If it weren't for the amazing PSP community on discord, I doubt I would have ever gathered the necessary motivation and drive to finally bring power over the finish line. Many thanks to the PSP community 👍