1 #include <xen/pci.h>
2 #include <xen/acpi.h>
3 #include <acpi/acpi.h>
4 
acpi_reboot(void)5 void acpi_reboot(void)
6 {
7 	struct acpi_generic_address *rr;
8 	u8 reset_value;
9 
10 	rr = &acpi_gbl_FADT.reset_register;
11 
12 	/* Is the reset register supported? The spec says we should be
13 	 * checking the bit width and bit offset, but Windows ignores
14 	 * these fields */
15 	if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER))
16 		return;
17 
18 	reset_value = acpi_gbl_FADT.reset_value;
19 
20 	/* The reset register can only exist in I/O, Memory or PCI config space
21 	 * on a device on bus 0. */
22 	switch (rr->space_id) {
23 	case ACPI_ADR_SPACE_PCI_CONFIG:
24 		printk("Resetting with ACPI PCI RESET_REG.\n");
25 		/* Write the value that resets us. */
26 		pci_conf_write8(0, 0,
27 				(rr->address >> 32) & 31,
28 				(rr->address >> 16) & 7,
29 				(rr->address & 255),
30 				reset_value);
31 		break;
32 	case ACPI_ADR_SPACE_SYSTEM_MEMORY:
33 	case ACPI_ADR_SPACE_SYSTEM_IO:
34 		printk("Resetting with ACPI MEMORY or I/O RESET_REG.\n");
35 		acpi_hw_low_level_write(8, reset_value, rr);
36 		break;
37 	}
38 }
39