Skip to content

Commit

Permalink
acpi: add ACPI power off functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Aug 30, 2021
1 parent b84be73 commit ea4f092
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ endif # HAVE_KVM
QEMU_PARAMS += -m 8192
QEMU_PARAMS += -display none -vga none -vnc none
QEMU_PARAMS += -serial stdio
QEMU_PARAMS += -no-reboot -no-shutdown
QEMU_PARAMS += -smp cpus=2

QEMU_PARAMS_KERNEL := -append "param1 param2 param3"
Expand Down
7 changes: 7 additions & 0 deletions common/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,4 +511,11 @@ ACPI_STATUS init_acpi(unsigned bsp_cpu_id) {
status = InitializeFullAcpi();
return status;
}

void acpi_power_off(void) {
AcpiEnterSleepStatePrep(ACPI_STATE_S5);
cli();
AcpiEnterSleepState(ACPI_STATE_S5);
panic("Power Off");
}
#endif /* KTF_ACPICA */
4 changes: 4 additions & 0 deletions common/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <acpi_ktf.h>
#include <console.h>
#include <drivers/keyboard.h>
#include <ktf.h>
Expand Down Expand Up @@ -67,5 +68,8 @@ void __naked kernel_main(void) {

printk("All tasks done.\n");

#ifdef KTF_ACPICA
acpi_power_off();
#endif
echo_loop();
}
1 change: 1 addition & 0 deletions include/acpi_ktf.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ extern void acpi_walk_subtables(ACPI_SUBTABLE_HEADER *entry, uint32_t length,
acpi_subtable_parser_t parser, void *arg);

extern ACPI_STATUS init_acpi(unsigned bsp_cpu_id);
extern void acpi_power_off(void);

#endif /* KTF_ACPICA */
#endif /* KTF_ACPI_H */

0 comments on commit ea4f092

Please sign in to comment.