#include <IOKit/IOPlatformExpert.h>
#include <sys/kdebug.h>
+#if MONOTONIC
+#include <kern/monotonic.h>
+#endif /* MONOTONIC */
+
#if CONFIG_SLEEP
extern void acpi_sleep_cpu(acpi_sleep_callback, void * refcon);
extern void acpi_wake_prot(void);
acpi_hibernate_callback_data_t data;
#endif
boolean_t did_hibernate;
+ cpu_data_t *cdp = current_cpu_datap();
unsigned int cpu;
kern_return_t rc;
unsigned int my_cpu;
uint64_t elapsed = 0;
uint64_t elapsed_trace_start = 0;
- kprintf("acpi_sleep_kernel hib=%d, cpu=%d\n",
- current_cpu_datap()->cpu_hibernate, cpu_number());
+ my_cpu = cpu_number();
+ kprintf("acpi_sleep_kernel hib=%d, cpu=%d\n", cdp->cpu_hibernate,
+ my_cpu);
- /* Get all CPUs to be in the "off" state */
- my_cpu = cpu_number();
+ /* Get all CPUs to be in the "off" state */
for (cpu = 0; cpu < real_ncpus; cpu += 1) {
- if (cpu == my_cpu)
+ if (cpu == my_cpu)
continue;
rc = pmCPUExitHaltToOff(cpu);
if (rc != KERN_SUCCESS)
data.refcon = refcon;
#endif
+#if MONOTONIC
+ mt_cpu_down(cdp);
+#endif /* MONOTONIC */
+
/* Save power management timer state */
pmTimerSave();
*/
clear_ts();
- KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 0) | DBG_FUNC_START, 0, 0, 0, 0, 0);
+ KDBG(IOKDBG_CODE(DBG_HIBERNATE, 0) | DBG_FUNC_START);
save_kdebug_enable = kdebug_enable;
kdebug_enable = 0;
did_hibernate = FALSE;
}
- /* Re-enable mode (including 64-bit if applicable) */
- cpu_mode_init(current_cpu_datap());
+ /* Re-enable fast syscall */
+ cpu_syscall_init(current_cpu_datap());
#if CONFIG_MCA
/* Re-enable machine check handling */
if (lapic_probe())
lapic_configure();
+#if KASAN
+ /*
+ * The sleep implementation uses indirect noreturn calls, so we miss stack
+ * unpoisoning. Do it explicitly.
+ */
+ __asan_handle_no_return();
+#endif
+
#if HIBERNATION
hibernate_rebuild_vm_structs();
#endif
#if HIBERNATION
if (did_hibernate) {
- elapsed += mach_absolute_time() - start;
-
- KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 2) | DBG_FUNC_START, elapsed, elapsed_trace_start, 0, 0, 0);
+ KDBG(IOKDBG_CODE(DBG_HIBERNATE, 2) | DBG_FUNC_START);
hibernate_machine_init();
- KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 2) | DBG_FUNC_END, 0, 0, 0, 0, 0);
+ KDBG(IOKDBG_CODE(DBG_HIBERNATE, 2) | DBG_FUNC_END);
current_cpu_datap()->cpu_hibernate = 0;
-
- KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 0) | DBG_FUNC_END, 0, 0, 0, 0, 0);
- } else
+ }
#endif /* HIBERNATION */
- KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 0) | DBG_FUNC_END, 0, 0, 0, 0, 0);
+
+ KDBG(IOKDBG_CODE(DBG_HIBERNATE, 0) | DBG_FUNC_END, start, elapsed,
+ elapsed_trace_start, acpi_wake_abstime);
/* Restore power management register state */
pmCPUMarkRunning(current_cpu_datap());
* Call back to caller to indicate that interrupts will remain
* disabled while we deep idle, wake and return.
*/
+ IOCPURunPlatformQuiesceActions();
+
func(refcon);
acpi_idle_abstime = mach_absolute_time();
/* Like S3 sleep, turn on tracing if trace_wake boot-arg is present */
if (kdebug_enable == 0) {
- if (wake_nkdbufs)
+ if (wake_nkdbufs) {
+ __kdebug_only uint64_t start = mach_absolute_time();
kdebug_trace_start(wake_nkdbufs, NULL, TRUE);
+ KDBG(IOKDBG_CODE(DBG_HIBERNATE, 15), start);
+ }
}
IOCPURunPlatformActiveActions();