reboot.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER))
  20. return;
  21. reset_value = acpi_gbl_FADT.reset_value;
  22. /* The reset register can only exist in I/O, Memory or PCI config space
  23. * on a device on bus 0. */
  24. switch (rr->space_id) {
  25. case ACPI_ADR_SPACE_PCI_CONFIG:
  26. /* The reset register can only live on bus 0. */
  27. bus0 = pci_find_bus(0, 0);
  28. if (!bus0)
  29. return;
  30. /* Form PCI device/function pair. */
  31. devfn = PCI_DEVFN((rr->address >> 32) & 0xffff,
  32. (rr->address >> 16) & 0xffff);
  33. printk(KERN_DEBUG "Resetting with ACPI PCI RESET_REG.");
  34. /* Write the value that resets us. */
  35. pci_bus_write_config_byte(bus0, devfn,
  36. (rr->address & 0xffff), reset_value);
  37. break;
  38. case ACPI_ADR_SPACE_SYSTEM_MEMORY:
  39. case ACPI_ADR_SPACE_SYSTEM_IO:
  40. printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n");
  41. acpi_reset();
  42. break;
  43. }
  44. }