Home | History | Annotate | Line # | Download | only in acpi
acpi_wakeup_low.S revision 1.4
      1  1.4     joerg /*	$NetBSD: acpi_wakeup_low.S,v 1.4 2007/12/18 07:17:13 joerg Exp $	*/
      2  1.2  jmcneill 
      3  1.2  jmcneill /*-
      4  1.2  jmcneill  * Copyright (c) 2007 Joerg Sonnenberger <joerg (at) netbsd.org>
      5  1.2  jmcneill  * Copyright (c) 2001 Takanori Watanabe <takawata (at) jp.freebsd.org>
      6  1.2  jmcneill  * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki (at) jp.freebsd.org>
      7  1.2  jmcneill  * All rights reserved.
      8  1.2  jmcneill  *
      9  1.2  jmcneill  * Redistribution and use in source and binary forms, with or without
     10  1.2  jmcneill  * modification, are permitted provided that the following conditions
     11  1.2  jmcneill  * are met:
     12  1.2  jmcneill  * 1. Redistributions of source code must retain the above copyright
     13  1.2  jmcneill  *    notice, this list of conditions and the following disclaimer.
     14  1.2  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.2  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     16  1.2  jmcneill  *    documentation and/or other materials provided with the distribution.
     17  1.2  jmcneill  *
     18  1.2  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     19  1.2  jmcneill  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  1.2  jmcneill  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  1.2  jmcneill  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     22  1.2  jmcneill  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  1.2  jmcneill  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24  1.2  jmcneill  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  1.2  jmcneill  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  1.2  jmcneill  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  1.2  jmcneill  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  1.2  jmcneill  * SUCH DAMAGE.
     29  1.2  jmcneill  */
     30  1.2  jmcneill 
     31  1.3     lukem #include <machine/asm.h>
     32  1.4     joerg __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup_low.S,v 1.4 2007/12/18 07:17:13 joerg Exp $");
     33  1.3     lukem 
     34  1.2  jmcneill #include "assym.h"
     35  1.4     joerg #include <machine/segments.h>
     36  1.2  jmcneill 
     37  1.2  jmcneill 	.text
     38  1.2  jmcneill 	.p2align 2, 0x90
     39  1.2  jmcneill 	.globl acpi_md_sleep_exit
     40  1.2  jmcneill acpi_md_sleep_exit:
     41  1.4     joerg 	lgdt	ACPI_SUSPEND_GDT(%edx)
     42  1.4     joerg 
     43  1.4     joerg 	/* Reload fixed descriptors for new GDT */
     44  1.4     joerg 	movw	$GSEL(GDATA_SEL, SEL_KPL),%ax
     45  1.4     joerg 	movw	%ax,%ds
     46  1.2  jmcneill 	movw	%ax,%es
     47  1.4     joerg 	movw	%ax,%ss
     48  1.4     joerg 
     49  1.4     joerg 	movw	ACPI_SUSPEND_FS(%edx),%ax
     50  1.2  jmcneill 	movw	%ax,%fs
     51  1.4     joerg 	movw	ACPI_SUSPEND_GS(%edx),%ax
     52  1.2  jmcneill 	movw	%ax,%gs
     53  1.2  jmcneill 
     54  1.4     joerg 	movl	ACPI_SUSPEND_CR2(%edx),%eax
     55  1.2  jmcneill 	movl	%eax,%cr2
     56  1.4     joerg 
     57  1.4     joerg 	movl	ACPI_SUSPEND_CR4(%edx),%eax
     58  1.2  jmcneill 	movl	%eax,%cr4
     59  1.4     joerg 	movl	ACPI_SUSPEND_CR3(%edx),%eax
     60  1.2  jmcneill 	movl	%eax,%cr3
     61  1.2  jmcneill 
     62  1.2  jmcneill 	jmp 1f
     63  1.2  jmcneill 1:
     64  1.2  jmcneill 
     65  1.4     joerg 	lidt	ACPI_SUSPEND_IDT(%edx)
     66  1.4     joerg 	lldt	ACPI_SUSPEND_LDT(%edx)
     67  1.2  jmcneill 
     68  1.2  jmcneill 	movl	CPUVAR(GDT),%eax
     69  1.4     joerg 	movzwl	ACPI_SUSPEND_TR(%edx),%ecx
     70  1.4     joerg 	andl	$~0x0200,4(%eax,%ecx, 1)
     71  1.4     joerg 	ltr	%cx
     72  1.4     joerg 
     73  1.4     joerg 	movl	ACPI_SUSPEND_EBX(%edx),%ebx
     74  1.4     joerg 	movl	ACPI_SUSPEND_ESI(%edx),%esi
     75  1.4     joerg 	movl	ACPI_SUSPEND_EDI(%edx),%edi
     76  1.4     joerg 	movl	ACPI_SUSPEND_EBP(%edx),%ebp
     77  1.4     joerg 	movl	ACPI_SUSPEND_ESP(%edx),%esp
     78  1.2  jmcneill 
     79  1.4     joerg 	pushl	ACPI_SUSPEND_EFL(%edx)
     80  1.2  jmcneill 	popfl
     81  1.2  jmcneill 
     82  1.2  jmcneill 	xorl	%eax,%eax
     83  1.2  jmcneill 
     84  1.2  jmcneill 	ret
     85  1.2  jmcneill 
     86  1.2  jmcneill 	.p2align 2, 0x90
     87  1.2  jmcneill 	.type acpi_md_sleep_prepare, @function
     88  1.2  jmcneill 	.globl acpi_md_sleep_prepare
     89  1.2  jmcneill acpi_md_sleep_prepare:
     90  1.4     joerg 	movl	CPUVAR(SELF),%edx
     91  1.4     joerg 	movw	%fs,ACPI_SUSPEND_FS(%edx)
     92  1.4     joerg 	movw	%gs,ACPI_SUSPEND_GS(%edx)
     93  1.4     joerg 
     94  1.4     joerg 	movl	%ebx,ACPI_SUSPEND_EBX(%edx)
     95  1.4     joerg 	movl	%esi,ACPI_SUSPEND_ESI(%edx)
     96  1.4     joerg 	movl	%edi,ACPI_SUSPEND_EDI(%edx)
     97  1.4     joerg 	movl	%ebp,ACPI_SUSPEND_EBP(%edx)
     98  1.4     joerg 	movl	%esp,ACPI_SUSPEND_ESP(%edx)
     99  1.2  jmcneill 
    100  1.2  jmcneill 	movl	%cr0,%eax
    101  1.4     joerg 	movl	%eax,ACPI_SUSPEND_CR0(%edx)
    102  1.2  jmcneill 	movl	%cr2,%eax
    103  1.4     joerg 	movl	%eax,ACPI_SUSPEND_CR2(%edx)
    104  1.2  jmcneill 	movl	%cr3,%eax
    105  1.4     joerg 	movl	%eax,ACPI_SUSPEND_CR3(%edx)
    106  1.2  jmcneill 	movl	%cr4,%eax
    107  1.4     joerg 	movl	%eax,ACPI_SUSPEND_CR4(%edx)
    108  1.2  jmcneill 
    109  1.2  jmcneill 	pushfl
    110  1.4     joerg 	popl	ACPI_SUSPEND_EFL(%edx)
    111  1.2  jmcneill 
    112  1.4     joerg 	sgdt	ACPI_SUSPEND_GDT(%edx)
    113  1.4     joerg 	sidt	ACPI_SUSPEND_IDT(%edx)
    114  1.4     joerg 	sldt	ACPI_SUSPEND_LDT(%edx)
    115  1.4     joerg 	str	ACPI_SUSPEND_TR(%edx)
    116  1.2  jmcneill 
    117  1.2  jmcneill 	movl	4(%esp),%eax
    118  1.2  jmcneill 	pushl	%eax
    119  1.2  jmcneill 	call	acpi_md_sleep_enter
    120  1.2  jmcneill 	/* acpi_md_sleep_enter only returns on failure. */
    121  1.2  jmcneill 	popl	%eax
    122  1.2  jmcneill 	movl	$-1,%eax
    123  1.2  jmcneill 	ret
    124