#endif
#include <i386/pmCPU.h>
+#include <i386/tsc.h>
+
#include <kern/cpu_data.h>
#include <console/serial_protos.h>
+#include <vm/vm_page.h>
#if HIBERNATION
#include <IOKit/IOHibernatePrivate.h>
#endif
#include <IOKit/IOPlatformExpert.h>
+#include <sys/kdebug.h>
+
#if CONFIG_SLEEP
extern void acpi_sleep_cpu(acpi_sleep_callback, void * refcon);
extern void acpi_wake_prot(void);
};
typedef struct acpi_hibernate_callback_data acpi_hibernate_callback_data_t;
+unsigned int save_kdebug_enable = 0;
+static uint64_t acpi_sleep_abstime;
+
+
#if CONFIG_SLEEP
static void
acpi_hibernate(void *refcon)
cpu_IA32e_disable(current_cpu_datap());
#endif
}
+ kdebug_enable = 0;
+
+ acpi_sleep_abstime = mach_absolute_time();
(data->func)(data->refcon);
#endif /* CONFIG_SLEEP */
#endif /* HIBERNATION */
-static uint64_t acpi_sleep_abstime;
-extern void slave_pstart(void);
+extern void slave_pstart(void);
void
acpi_sleep_kernel(acpi_sleep_callback func, void *refcon)
unsigned int cpu;
kern_return_t rc;
unsigned int my_cpu;
+ uint64_t now;
+ uint64_t my_tsc;
+ uint64_t my_abs;
kprintf("acpi_sleep_kernel hib=%d\n",
current_cpu_datap()->cpu_hibernate);
*/
cpu_IA32e_disable(current_cpu_datap());
#endif
+ /*
+ * Enable FPU/SIMD unit for potential hibernate acceleration
+ */
+ clear_ts();
+
+ KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 0) | DBG_FUNC_START, 0, 0, 0, 0, 0);
+
+ save_kdebug_enable = kdebug_enable;
+ kdebug_enable = 0;
acpi_sleep_abstime = mach_absolute_time();
#else
acpi_sleep_cpu(func, refcon);
#endif
+
#ifdef __x86_64__
x86_64_post_sleep(old_cr3);
#endif
*/
pmMarkAllCPUsOff();
+ ml_get_timebase(&now);
+
+ /* re-enable and re-init local apic (prior to starting timers) */
+ if (lapic_probe())
+ lapic_configure();
+
/* let the realtime clock reset */
rtc_sleep_wakeup(acpi_sleep_abstime);
- if (did_hibernate){
+ kdebug_enable = save_kdebug_enable;
+
+ if (did_hibernate) {
+
+ my_tsc = (now >> 32) | (now << 32);
+ my_abs = tmrCvt(my_tsc, tscFCvtt2n);
+
+ KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 2) | DBG_FUNC_START,
+ (uint32_t)(my_abs >> 32), (uint32_t)my_abs, 0, 0, 0);
hibernate_machine_init();
+ KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 2) | DBG_FUNC_END, 0, 0, 0, 0, 0);
+
current_cpu_datap()->cpu_hibernate = 0;
- }
- /* re-enable and re-init local apic */
- if (lapic_probe())
- lapic_configure();
+
+ KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 0) | DBG_FUNC_END, 0, 0, 0, 0, 0);
+ } else
+ KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 0) | DBG_FUNC_END, 0, 0, 0, 0, 0);
/* Restore power management register state */
pmCPUMarkRunning(current_cpu_datap());
/* Restore power management timer state */
pmTimerRestore();
- /* Restart tick interrupts from the LAPIC timer */
- rtc_lapic_start_ticking();
+ /* Restart timer interrupts */
+ rtc_timer_start();
- fpinit();
- clear_fpu();
+ /* Reconfigure FP/SIMD unit */
+ init_fpu();
#if HIBERNATION
#ifdef __i386__