acpi_status acpi_system_save_state (u32 state);
This handles saving all context to memory, and possibly disk. First, we call to the device driver layer to save device state. Once we have that, we save whatevery processor and kernel state we need to memory. If we're entering S4, we then write the memory image to disk.
Only then is it safe for us to power down devices, since we may need the disks and upstream buses to write to.