feat(power): introduced a power subsystem with shutdown and reboot support - #179
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
High Risk
Changes privileged shutdown/reboot paths (ACPI PM1/AML, I/O ports, MMIO, PSCI) that can hang or misbehave on wrong firmware; bugs affect every platform build.
Overview
Introduces a shared
power::shutdown()/power::reboot()API and arch-specific implementations that drive real hardware power transitions instead of only halting.ACPI gains typed FADT / GAS layouts,
acpi::get_fadt(),acpi::map_table()(for DSDT and other pointer-referenced tables), and sharedmap_sdt()mapping logic. Existing FACP users (RTC century, RPi4 detection, SMP) move off raw header hacks to these helpers.On x86_64, shutdown walks ACPI S5: map DSDT, scan AML for
\_S5_sleep types, enable ACPI mode if needed, then program PM1a/PM1b with SLP_EN. Reboot tries FADT reset register, keyboard-controller pulse, 0xCF9, then triple-fault.On aarch64, shutdown/reboot use PSCI SYSTEM_OFF / SYSTEM_RESET after
psci::detect_conduit()(moved out of SMP). PSCI helpers and conduit detection are centralized inpsci.Call sites return
ERR_UNSUPPORTEDwhen a mechanism fails so upper layers can fall back.Reviewed by Cursor Bugbot for commit 8230c57. Bugbot is set up for automated code reviews on this repo. Configure here.