reboot.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <linux/pci.h>
  2. #include <linux/acpi.h>
  3. #include <acpi/reboot.h>
  4. void acpi_reboot(void)
  5. {
  6. struct acpi_generic_address *rr;
  7. struct pci_bus *bus0;
  8. u8 reset_value;
  9. unsigned int devfn;
  10. if (acpi_disabled)
  11. return;
  12. rr = &acpi_gbl_FADT.reset_register;
  13. /* ACPI reset register was only introduced with v2 of the FADT */
  14. if (acpi_gbl_FADT.header.revision < 2)
  15. return;
  16. /* Is the reset register supported? The spec says we should be
  17. * checking the bit width and bit offset, but Windows ignores
  18. * these fields */
  19. /* Ignore also acpi_gbl_FADT.flags.ACPI_FADT_RESET_REGISTER */
  20. reset_value = acpi_gbl_FADT.reset_value;
  21. /* The reset register can only exist in I/O, Memory or PCI config space
  22. * on a device on bus 0. */
  23. switch (rr->space_id) {
  24. case ACPI_ADR_SPACE_PCI_CONFIG:
  25. /* The reset register can only live on bus 0. */
  26. bus0 = pci_find_bus(0, 0);
  27. if (!bus0)
  28. return;
  29. /* Form PCI device/function pair. */
  30. devfn = PCI_DEVFN((rr->address >> 32) & 0xffff,
  31. (rr->address >> 16) & 0xffff);
  32. printk(KERN_DEBUG "Resetting with ACPI PCI RESET_REG.");
  33. /* Write the value that resets us. */
  34. pci_bus_write_config_byte(bus0, devfn,
  35. (rr->address & 0xffff), reset_value);
  36. break;
  37. case ACPI_ADR_SPACE_SYSTEM_MEMORY:
  38. case ACPI_ADR_SPACE_SYSTEM_IO:
  39. printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n");
  40. acpi_reset();
  41. break;
  42. }
  43. }