poweroff.c 400 B

123456789101112131415
  1. /* Poweroff command: shut down the virtual machine (QEMU/Bochs ACPI port). */
  2. static inline void outw(unsigned short port, unsigned short v)
  3. {
  4. __asm__ volatile ("outw %0, %%dx" : : "a"(v), "d"(port));
  5. }
  6. void program_poweroff_main(void)
  7. {
  8. /* Bochs/QEMU "ACPI" shutdown — see https://wiki.osdev.org/Shutdown */
  9. outw(0x604, 0x2000);
  10. outw(0xB004, 0x2000);
  11. for (;;)
  12. __asm__ volatile ("hlt");
  13. }