1 /* $NetBSD: acpi_wakeup_low.S,v 1.4 2007/12/18 07:17:13 joerg Exp $ */
4 * Copyright (c) 2007 Joerg Sonnenberger <joerg@netbsd.org>
5 * Copyright (c) 2001 Takanori Watanabe <takawata@jp.freebsd.org>
6 * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki@jp.freebsd.org>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <machine/asm.h>
32 __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup_low.S,v 1.4 2007/12/18 07:17:13 joerg Exp $");
35 #include <machine/segments.h>
39 .globl acpi_md_sleep_exit
41 lgdt ACPI_SUSPEND_GDT(%edx)
43 /* Reload fixed descriptors for new GDT */
44 movw $GSEL(GDATA_SEL, SEL_KPL),%ax
49 movw ACPI_SUSPEND_FS(%edx),%ax
51 movw ACPI_SUSPEND_GS(%edx),%ax
54 movl ACPI_SUSPEND_CR2(%edx),%eax
57 movl ACPI_SUSPEND_CR4(%edx),%eax
59 movl ACPI_SUSPEND_CR3(%edx),%eax
65 lidt ACPI_SUSPEND_IDT(%edx)
66 lldt ACPI_SUSPEND_LDT(%edx)
69 movzwl ACPI_SUSPEND_TR(%edx),%ecx
70 andl $~0x0200,4(%eax,%ecx, 1)
73 movl ACPI_SUSPEND_REG+(0*4)(%edx),%ebx
74 movl ACPI_SUSPEND_REG+(1*4)(%edx),%esi
75 movl ACPI_SUSPEND_REG+(2*4)(%edx),%edi
76 movl ACPI_SUSPEND_REG+(3*4)(%edx),%ebp
77 movl ACPI_SUSPEND_REG+(4*4)(%edx),%esp
79 pushl ACPI_SUSPEND_REG+(5*4)(%edx)
87 .type acpi_md_sleep_prepare, @function
88 .globl acpi_md_sleep_prepare
89 acpi_md_sleep_prepare:
90 movl CPUVAR(SELF),%edx
91 movw %fs,ACPI_SUSPEND_FS(%edx)
92 movw %gs,ACPI_SUSPEND_GS(%edx)
94 movl %ebx,ACPI_SUSPEND_REG+(0*4)(%edx)
95 movl %esi,ACPI_SUSPEND_REG+(1*4)(%edx)
96 movl %edi,ACPI_SUSPEND_REG+(2*4)(%edx)
97 movl %ebp,ACPI_SUSPEND_REG+(3*4)(%edx)
98 movl %esp,ACPI_SUSPEND_REG+(4*4)(%edx)
101 movl %eax,ACPI_SUSPEND_CR0(%edx)
103 movl %eax,ACPI_SUSPEND_CR2(%edx)
105 movl %eax,ACPI_SUSPEND_CR3(%edx)
107 movl %eax,ACPI_SUSPEND_CR4(%edx)
110 popl ACPI_SUSPEND_REG+(5*4)(%edx)
112 sgdt ACPI_SUSPEND_GDT(%edx)
113 sidt ACPI_SUSPEND_IDT(%edx)
114 sldt ACPI_SUSPEND_LDT(%edx)
115 str ACPI_SUSPEND_TR(%edx)
119 call acpi_md_sleep_enter
120 /* acpi_md_sleep_enter only returns on failure. */