/*
- * Copyright (c) 2000-2009 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <i386/tsc.h>
#include <kern/cpu_data.h>
-#include <kern/etimer.h>
#include <kern/machine.h>
#include <kern/timer_queue.h>
#include <console/serial_protos.h>
if (current_cpu_datap()->cpu_hibernate)
{
-#if defined(__i386__)
- cpu_IA32e_enable(current_cpu_datap());
-#endif
mode = hibernate_write_image();
if( mode == kIOHibernatePostWriteHalt )
cpu_datap(0)->cpu_hibernate = 0;
}
-#if defined(__i386__)
- /*
- * If we're in 64-bit mode, drop back into legacy mode during sleep.
- */
- cpu_IA32e_disable(current_cpu_datap());
-#endif
}
kdebug_enable = 0;
#endif /* HIBERNATION */
extern void slave_pstart(void);
+extern void hibernate_rebuild_vm_structs(void);
extern unsigned int wake_nkdbufs;
unsigned int cpu;
kern_return_t rc;
unsigned int my_cpu;
- uint64_t now;
- uint64_t my_tsc;
- uint64_t my_abs;
+ uint64_t start;
+ 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());
vmx_suspend();
#endif
-#if defined(__i386__)
- /*
- * If we're in 64-bit mode, drop back into legacy mode during sleep.
- */
- cpu_IA32e_disable(current_cpu_datap());
-#endif
/*
* Enable FPU/SIMD unit for potential hibernate acceleration
*/
* Will not return until platform is woken up,
* or if sleep failed.
*/
-#ifdef __x86_64__
uint64_t old_cr3 = x86_64_pre_sleep();
-#endif
#if HIBERNATION
acpi_sleep_cpu(acpi_hibernate, &data);
#else
acpi_sleep_cpu(func, refcon);
#endif
-#ifdef __x86_64__
+ start = mach_absolute_time();
+
x86_64_post_sleep(old_cr3);
-#endif
#endif /* CONFIG_SLEEP */
#if HIBERNATION
if (current_cpu_datap()->cpu_hibernate) {
-#if defined(__i386__)
- int i;
- for (i = 0; i < PMAP_NWINDOWS; i++)
- *current_cpu_datap()->cpu_pmap->mapwindow[i].prv_CMAP = 0;
-#endif
did_hibernate = TRUE;
} else
*/
pmMarkAllCPUsOff();
- ml_get_timebase(&now);
/* re-enable and re-init local apic (prior to starting timers) */
if (lapic_probe())
lapic_configure();
+ hibernate_rebuild_vm_structs();
+
+ elapsed += mach_absolute_time() - start;
acpi_wake_abstime = mach_absolute_time();
/* let the realtime clock reset */
kdebug_enable = save_kdebug_enable;
if (kdebug_enable == 0) {
- if (wake_nkdbufs)
+ if (wake_nkdbufs) {
+ start = mach_absolute_time();
start_kern_tracing(wake_nkdbufs, TRUE);
+ elapsed_trace_start += mach_absolute_time() - start;
+ }
}
+ start = mach_absolute_time();
/* Reconfigure FP/SIMD unit */
init_fpu();
IOCPURunPlatformActiveActions();
if (did_hibernate) {
+ elapsed += mach_absolute_time() - start;
- 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);
+ KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 2) | DBG_FUNC_START, elapsed, elapsed_trace_start, 0, 0, 0);
hibernate_machine_init();
KERNEL_DEBUG_CONSTANT(IOKDBG_CODE(DBG_HIBERNATE, 2) | DBG_FUNC_END, 0, 0, 0, 0, 0);
/* Restart timer interrupts */
rtc_timer_start();
-
-
#if HIBERNATION
-#ifdef __i386__
- /* The image is written out using the copy engine, which disables
- * preemption. Since the copy engine writes out the page which contains
- * the preemption variable when it is disabled, we need to explicitly
- * enable it here */
- if (did_hibernate)
- enable_preemption();
-#endif
kprintf("ret from acpi_sleep_cpu hib=%d\n", did_hibernate);
#endif