Added implementation for ACPI to read the relevant data \_Sx from AML to be prepared for shutdown/sleep.
Added implementation to use the \_Sx data to issue a shutdown/sleep with ACPI.
Implemented unmounting for filesystems (for now we can't unmount a specific fs, but all at once as part of the shutdown process).
Implemented shutdown process which is as follows:
power::start_shutdown is called.
scheduler stops scheduling and starts exiting processes when they arrive for rescheduling, keeps waiting until all have exited.
the filesystem is unmounted and any related data is flushed.
Issue a shutdown command to ACPI to finally shutdown the machine.
Implement reboot process which is similar to the above shutdown process except the last part:
Issue a reset command through the PS2 interface in the keyboard/mouse device.
We can implement this in ACPI using the reset_register, but its not available for my testing setup now.
Userspace access to shutdown and reboot through /devices/power virtual device
shutdown can be started by echo shutdown > /devices/power or echo reboot > ...
Added power commands that does the above, choose shutdown or reboot
Checklist
[x] The changes are tested and works as expected (mention if not)
[ ] Tests if applicable (new features, regression tests, etc...)
won't do this for now, I want to write test but it would be tricky, since we need a custom test image that does shutdown and reboot and a userspace (linux program/shell) that monitors qemu and asserts shutdown/reboot is good.
Summary
Implemented shutdown functionality
Related issue
Partial fix for #38, only shutdown for now
Changes
\_Sx
fromAML
to be prepared for shutdown/sleep.\_Sx
data to issue a shutdown/sleep withACPI
.power::start_shutdown
is called.scheduler
stops scheduling and starts exiting processes when they arrive for rescheduling, keeps waiting until all have exited.ACPI
to finally shutdown the machine.reset_register
, but its not available for my testing setup now.shutdown
andreboot
through/devices/power
virtual deviceecho shutdown > /devices/power
orecho reboot > ...
power
commands that does the above, chooseshutdown
orreboot
Checklist