2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #include <i386/misc_protos.h>
24 #include <i386/proc_reg.h>
25 #include <i386/pmap.h>
26 #include <i386/mtrr.h>
27 #include <i386/acpi.h>
30 #include <kern/cpu_data.h>
31 #include <IOKit/IOPlatformExpert.h>
33 extern void acpi_sleep_cpu(acpi_sleep_callback
, void * refcon
);
34 extern char acpi_wake_start
[];
35 extern char acpi_wake_end
[];
37 extern int serial_init(void);
38 extern unsigned int disableSerialOuput
;
40 extern void set_kbd_leds(int leds
);
43 acpi_install_wake_handler(void)
45 /* copy wake code to ACPI_WAKE_ADDR in low memory */
46 bcopy_phys((addr64_t
) kvtophys((vm_offset_t
)acpi_wake_start
),
47 (addr64_t
) ACPI_WAKE_ADDR
,
48 acpi_wake_end
- acpi_wake_start
);
53 /* return physical address of the wakeup code */
54 return ACPI_WAKE_ADDR
;
57 typedef struct acpi_sleep_callback_data
{
58 acpi_sleep_callback func
;
60 } acpi_sleep_callback_data
;
63 acpi_sleep_do_callback(void *refcon
)
65 acpi_sleep_callback_data
*data
= (acpi_sleep_callback_data
*)refcon
;
68 (data
->func
)(data
->refcon
);
70 /* should never get here! */
74 acpi_sleep_kernel(acpi_sleep_callback func
, void *refcon
)
76 acpi_sleep_callback_data data
;
78 /* shutdown local APIC before passing control to BIOS */
85 * Save master CPU state and sleep platform.
86 * Will not return until platform is woken up,
89 acpi_sleep_cpu(acpi_sleep_do_callback
, &data
);
91 /* reset UART if kprintf is enabled */
92 if (FALSE
== disableSerialOuput
)
96 /* restore MTRR settings */
99 /* set up PAT following boot processor power up */
102 /* re-enable and re-init local apic */
106 /* let the realtime clock reset */