Home | History | Annotate | Line # | Download | only in acpi
acpi_wakecode.S revision 1.1.2.2
      1  1.1.2.2  jmcneill /* $NetBSD: acpi_wakecode.S,v 1.1.2.2 2007/09/06 23:09:08 jmcneill Exp $ */
      2  1.1.2.1  jmcneill 
      3  1.1.2.1  jmcneill /*-
      4  1.1.2.1  jmcneill  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
      5  1.1.2.1  jmcneill  * All rights reserved.
      6  1.1.2.1  jmcneill  *
      7  1.1.2.1  jmcneill  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1.2.1  jmcneill  * by Takuya SHIOZAKI, and by Andrew Doran.
      9  1.1.2.1  jmcneill  *
     10  1.1.2.1  jmcneill  * Redistribution and use in source and binary forms, with or without
     11  1.1.2.1  jmcneill  * modification, are permitted provided that the following conditions
     12  1.1.2.1  jmcneill  * are met:
     13  1.1.2.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     14  1.1.2.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     15  1.1.2.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1.2.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     17  1.1.2.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     18  1.1.2.1  jmcneill  * 3. All advertising materials mentioning features or use of this software
     19  1.1.2.1  jmcneill  *    must display the following acknowledgement:
     20  1.1.2.1  jmcneill  *	  This product includes software developed by the NetBSD
     21  1.1.2.1  jmcneill  *	  Foundation, Inc. and its contributors.
     22  1.1.2.1  jmcneill  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1.2.1  jmcneill  *    contributors may be used to endorse or promote products derived
     24  1.1.2.1  jmcneill  *    from this software without specific prior written permission.
     25  1.1.2.1  jmcneill  *
     26  1.1.2.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1.2.1  jmcneill  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1.2.1  jmcneill  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1.2.1  jmcneill  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1.2.1  jmcneill  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1.2.1  jmcneill  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1.2.1  jmcneill  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1.2.1  jmcneill  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1.2.1  jmcneill  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1.2.1  jmcneill  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1.2.1  jmcneill  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1.2.1  jmcneill  */
     38  1.1.2.1  jmcneill 
     39  1.1.2.1  jmcneill 
     40  1.1.2.1  jmcneill /*
     41  1.1.2.1  jmcneill  * This code is derived from FreeBSD.  Original copyrights:
     42  1.1.2.1  jmcneill  *
     43  1.1.2.1  jmcneill  * Copyright (c) 2001 Takanori Watanabe <takawata (at) jp.freebsd.org>
     44  1.1.2.1  jmcneill  * Copyright (c) 2001 Mitsuru IWASAKI <iwasaki (at) jp.freebsd.org>
     45  1.1.2.1  jmcneill  * All rights reserved.
     46  1.1.2.1  jmcneill  *
     47  1.1.2.1  jmcneill  * Redistribution and use in source and binary forms, with or without
     48  1.1.2.1  jmcneill  * modification, are permitted provided that the following conditions
     49  1.1.2.1  jmcneill  * are met:
     50  1.1.2.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     51  1.1.2.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     52  1.1.2.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     53  1.1.2.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     54  1.1.2.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     55  1.1.2.1  jmcneill  *
     56  1.1.2.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     57  1.1.2.1  jmcneill  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     58  1.1.2.1  jmcneill  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     59  1.1.2.1  jmcneill  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     60  1.1.2.1  jmcneill  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     61  1.1.2.1  jmcneill  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     62  1.1.2.1  jmcneill  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     63  1.1.2.1  jmcneill  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     64  1.1.2.1  jmcneill  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     65  1.1.2.1  jmcneill  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     66  1.1.2.1  jmcneill  * SUCH DAMAGE.
     67  1.1.2.1  jmcneill  *
     68  1.1.2.1  jmcneill  *	FreeBSD: src/sys/i386/acpica/acpi_wakecode.S,v 1.1 2001/07/20 06:07:31 takawata Exp
     69  1.1.2.1  jmcneill  */
     70  1.1.2.1  jmcneill 
     71  1.1.2.1  jmcneill #define _LOCORE
     72  1.1.2.1  jmcneill 
     73  1.1.2.1  jmcneill /* #define WAKECODE_VERBOSE */
     74  1.1.2.1  jmcneill 
     75  1.1.2.1  jmcneill #include <machine/asm.h>
     76  1.1.2.1  jmcneill #include <machine/specialreg.h>
     77  1.1.2.1  jmcneill #include <machine/param.h>
     78  1.1.2.1  jmcneill #include <machine/segments.h>
     79  1.1.2.1  jmcneill #include <machine/psl.h>
     80  1.1.2.1  jmcneill 
     81  1.1.2.1  jmcneill /*
     82  1.1.2.1  jmcneill  * Should not be needed, but...  Note that we rely on the below code
     83  1.1.2.1  jmcneill  * being copied to a 16-byte aligned address.
     84  1.1.2.1  jmcneill  */
     85  1.1.2.1  jmcneill #define	RELOC(x)	x - wakeup_16
     86  1.1.2.1  jmcneill 
     87  1.1.2.1  jmcneill 	.text
     88  1.1.2.1  jmcneill 	.org	0
     89  1.1.2.1  jmcneill 
     90  1.1.2.1  jmcneill 	.align	16
     91  1.1.2.1  jmcneill 	.code16
     92  1.1.2.1  jmcneill wakeup_16:
     93  1.1.2.1  jmcneill 
     94  1.1.2.1  jmcneill 	nop
     95  1.1.2.1  jmcneill 	cli
     96  1.1.2.1  jmcneill 	cld
     97  1.1.2.1  jmcneill 
     98  1.1.2.1  jmcneill 	/* Set up segment registers for real mode */
     99  1.1.2.1  jmcneill 	movw	%cs, %ax
    100  1.1.2.1  jmcneill 	movw	%ax, %ds
    101  1.1.2.1  jmcneill 	movw	%ax, %ss
    102  1.1.2.1  jmcneill 
    103  1.1.2.1  jmcneill 	/* Small call stack XXXAD Where is this? Is it in the ACPI spec? */
    104  1.1.2.1  jmcneill 	mov	$0x1000, %sp
    105  1.1.2.1  jmcneill 
    106  1.1.2.1  jmcneill 	/* Clear flags */
    107  1.1.2.1  jmcneill 	pushl	$0
    108  1.1.2.1  jmcneill 	popfl
    109  1.1.2.1  jmcneill 
    110  1.1.2.1  jmcneill 	/* Only beep on reset if machdep.acpi_beep_on_reset=1 */
    111  1.1.2.1  jmcneill 	cmpb	$1, RELOC(beep_on_reset)
    112  1.1.2.1  jmcneill 	jne	nobeepon
    113  1.1.2.1  jmcneill 	call	beepon
    114  1.1.2.1  jmcneill 
    115  1.1.2.1  jmcneill nobeepon:
    116  1.1.2.1  jmcneill 
    117  1.1.2.1  jmcneill 	/* Only reset the VBIOS if machdep.acpi_vbios_reset=1 */
    118  1.1.2.1  jmcneill 	cmpb	$1, RELOC(vbios_reset)
    119  1.1.2.1  jmcneill 	jne	novbiosreset
    120  1.1.2.1  jmcneill 
    121  1.1.2.1  jmcneill 	/* Kick the VBIOS. */
    122  1.1.2.1  jmcneill 	lcall	$0xc000, $3
    123  1.1.2.1  jmcneill 
    124  1.1.2.1  jmcneill 	/* Paranoid, restore segment registers. */
    125  1.1.2.1  jmcneill 	movw	%cs, %ax
    126  1.1.2.1  jmcneill 	movw	%ax, %ds
    127  1.1.2.1  jmcneill 	movw	%ax, %ss
    128  1.1.2.1  jmcneill 
    129  1.1.2.1  jmcneill novbiosreset:
    130  1.1.2.1  jmcneill 
    131  1.1.2.1  jmcneill 	/* Only beep on reset if machdep.acpi_beep_on_reset=1 */
    132  1.1.2.1  jmcneill 	cmpb	$1, RELOC(beep_on_reset)
    133  1.1.2.1  jmcneill 	jne	nobeepoff
    134  1.1.2.1  jmcneill 	call	beepoff
    135  1.1.2.1  jmcneill 
    136  1.1.2.1  jmcneill nobeepoff:
    137  1.1.2.1  jmcneill 
    138  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    139  1.1.2.1  jmcneill 	movw	$0xb800, %ax
    140  1.1.2.1  jmcneill 	movw	%ax, %fs
    141  1.1.2.1  jmcneill 	movw	$0x0200 + '0', %fs:(0x00)
    142  1.1.2.1  jmcneill #endif
    143  1.1.2.1  jmcneill 
    144  1.1.2.1  jmcneill 	/* Get physical address of the code */
    145  1.1.2.1  jmcneill 	mov	%cs, %ax
    146  1.1.2.1  jmcneill 	movzx	%ax, %esi
    147  1.1.2.1  jmcneill 	shll	$4, %esi
    148  1.1.2.1  jmcneill 
    149  1.1.2.1  jmcneill 	/* Fill 16->32 address */
    150  1.1.2.1  jmcneill 	addl	%esi, RELOC(wakeup_sw32)+2	/* 1b opcode, 1b prefix */
    151  1.1.2.1  jmcneill 	addl	%esi, RELOC(wakeup_sw64)+1	/* 1b opcode */
    152  1.1.2.1  jmcneill 	addl	%esi, RELOC(tmp_gdt)+2
    153  1.1.2.1  jmcneill 	addl	%esi, RELOC(tmp_gdt64)+2
    154  1.1.2.1  jmcneill 	wbinvd					/* flush uop/trace cache */
    155  1.1.2.1  jmcneill 	jmp	1f
    156  1.1.2.1  jmcneill 1:	jmp	1f
    157  1.1.2.1  jmcneill 1:
    158  1.1.2.1  jmcneill 
    159  1.1.2.1  jmcneill 
    160  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    161  1.1.2.1  jmcneill 	movw	$0xb800, %ax
    162  1.1.2.1  jmcneill 	movw	%ax, %fs
    163  1.1.2.1  jmcneill 	movw	$0x0200 + '1', %fs:(0x02)
    164  1.1.2.1  jmcneill #endif
    165  1.1.2.1  jmcneill 
    166  1.1.2.1  jmcneill 	/* Load GDT, enable protected mode */
    167  1.1.2.1  jmcneill 	lgdtl	RELOC(tmp_gdt)
    168  1.1.2.1  jmcneill 	movl	%eax, %cr0
    169  1.1.2.1  jmcneill 	orb	$CR0_PE, %al
    170  1.1.2.1  jmcneill 	movl	%eax, %cr0
    171  1.1.2.1  jmcneill 
    172  1.1.2.1  jmcneill wakeup_sw32:
    173  1.1.2.1  jmcneill 
    174  1.1.2.1  jmcneill 	/* Switch to protected mode by intersegmental jump */
    175  1.1.2.1  jmcneill 	ljmpl	$GSEL(GCODE_SEL,SEL_KPL), $(RELOC(wakeup_32))
    176  1.1.2.1  jmcneill 
    177  1.1.2.1  jmcneill 	.align	16
    178  1.1.2.1  jmcneill 	.code32
    179  1.1.2.1  jmcneill wakeup_32:
    180  1.1.2.1  jmcneill 
    181  1.1.2.1  jmcneill 	movl	$GSEL(GDATA_SEL,SEL_KPL), %eax
    182  1.1.2.1  jmcneill 	movw	%ax, %ds
    183  1.1.2.1  jmcneill 	movw	%ax, %ss
    184  1.1.2.1  jmcneill 	movw	%ax, %es
    185  1.1.2.1  jmcneill 	movw	%ax, %fs
    186  1.1.2.1  jmcneill 	movw	%ax, %gs
    187  1.1.2.1  jmcneill 
    188  1.1.2.1  jmcneill 	movl	$0x1000, %esp	/* XXXJDM is this needed? */
    189  1.1.2.1  jmcneill 
    190  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    191  1.1.2.1  jmcneill 	movw	$0x0200 + '2', (0xb8004)
    192  1.1.2.1  jmcneill #endif
    193  1.1.2.1  jmcneill 
    194  1.1.2.1  jmcneill 	pushl	$PSL_MBO
    195  1.1.2.1  jmcneill 	popfl
    196  1.1.2.1  jmcneill 
    197  1.1.2.1  jmcneill 	movl	%cr4, %eax
    198  1.1.2.1  jmcneill 	orl	$(CR4_PAE|CR4_OSFXSR|CR4_OSXMMEXCPT), %eax
    199  1.1.2.1  jmcneill 	movl	%eax, %cr4
    200  1.1.2.1  jmcneill 
    201  1.1.2.1  jmcneill 	/* Set long mode enable in EFER and enable syscall extensions */
    202  1.1.2.1  jmcneill 	movl	$MSR_EFER, %ecx
    203  1.1.2.1  jmcneill 	rdmsr
    204  1.1.2.1  jmcneill 	xorl	%eax, %eax
    205  1.1.2.1  jmcneill 	orl	$(EFER_LME|EFER_SCE), %eax
    206  1.1.2.1  jmcneill 	wrmsr
    207  1.1.2.1  jmcneill 
    208  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    209  1.1.2.1  jmcneill 	movw	$0x0200 + '3', (0xb8006)
    210  1.1.2.1  jmcneill #endif
    211  1.1.2.1  jmcneill 
    212  1.1.2.1  jmcneill 	movl	(RELOC(tmp_pml4))(%esi), %ecx
    213  1.1.2.1  jmcneill 	movl	%ecx, %cr3
    214  1.1.2.1  jmcneill 
    215  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    216  1.1.2.1  jmcneill 	movw	$0x0200 + '4', (0xb8008)
    217  1.1.2.1  jmcneill #endif
    218  1.1.2.1  jmcneill 
    219  1.1.2.1  jmcneill 	movl	%cr0, %eax
    220  1.1.2.1  jmcneill 	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP), %eax
    221  1.1.2.1  jmcneill 	movl	%eax, %cr0
    222  1.1.2.1  jmcneill 	jmp	compat
    223  1.1.2.1  jmcneill compat:
    224  1.1.2.1  jmcneill 
    225  1.1.2.1  jmcneill 	movb	$0xc0, %al
    226  1.1.2.1  jmcneill 	outb	%al, $0x42
    227  1.1.2.1  jmcneill 	movb	$0x04, %al
    228  1.1.2.1  jmcneill 	outb	%al, $0x42
    229  1.1.2.1  jmcneill 	inb	$0x61, %al
    230  1.1.2.1  jmcneill 	orb	$0x3, %al
    231  1.1.2.1  jmcneill 	outb	%al, $0x61
    232  1.1.2.1  jmcneill 
    233  1.1.2.1  jmcneill 	movl	$GSEL(GDATA_SEL,SEL_KPL), %eax
    234  1.1.2.1  jmcneill 	movl	%eax, %ds
    235  1.1.2.1  jmcneill 	movl	%eax, %es
    236  1.1.2.1  jmcneill 	movl	%eax, %ss
    237  1.1.2.1  jmcneill 
    238  1.1.2.1  jmcneill 	movw	$0x0200 + '5', (0xb800a)
    239  1.1.2.1  jmcneill 
    240  1.1.2.1  jmcneill 	/* Load 64-bit GDT. */
    241  1.1.2.1  jmcneill 	lgdt	(RELOC(tmp_gdt64))(%esi)
    242  1.1.2.1  jmcneill 
    243  1.1.2.1  jmcneill 	movw	$0x0200 + '6', (0xb800c)
    244  1.1.2.1  jmcneill 
    245  1.1.2.1  jmcneill wakeup_sw64:
    246  1.1.2.1  jmcneill 
    247  1.1.2.1  jmcneill 	/* Jump to long mode segment. */
    248  1.1.2.1  jmcneill 	ljmpl	$GSEL(GCODE_SEL,SEL_KPL), $(RELOC(wakeup_64))
    249  1.1.2.1  jmcneill 
    250  1.1.2.1  jmcneill 	.align	16
    251  1.1.2.1  jmcneill 	.code64
    252  1.1.2.1  jmcneill wakeup_64:
    253  1.1.2.1  jmcneill 
    254  1.1.2.1  jmcneill 	nop
    255  1.1.2.1  jmcneill 	nop
    256  1.1.2.1  jmcneill 
    257  1.1.2.1  jmcneill 	/* Re-initialize segment regsisters to be on the safe side. */
    258  1.1.2.1  jmcneill 	movl	$GSEL(GDATA_SEL,SEL_KPL), %eax
    259  1.1.2.1  jmcneill 	movl	%eax, %ds
    260  1.1.2.1  jmcneill 	movl	%eax, %es
    261  1.1.2.1  jmcneill 	movl	%eax, %gs
    262  1.1.2.1  jmcneill 	movl	%eax, %ss
    263  1.1.2.1  jmcneill 	movl	%eax, %fs
    264  1.1.2.1  jmcneill 
    265  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    266  1.1.2.1  jmcneill 	movw	$0x0200 + '7', (0xb800e)
    267  1.1.2.2  jmcneill #endif
    268  1.1.2.1  jmcneill 
    269  1.1.2.1  jmcneill 	movq	previous_rsp(%rsi), %rsp
    270  1.1.2.1  jmcneill 
    271  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    272  1.1.2.1  jmcneill 	movw	$0x0200 + '8', (0xb8010)
    273  1.1.2.2  jmcneill #endif
    274  1.1.2.1  jmcneill 
    275  1.1.2.1  jmcneill #if 1	/* XXXAD ?? */
    276  1.1.2.1  jmcneill 	/* Fixup TSS type field; 386 busy TSS (11) -> 386 available TSS (9) */
    277  1.1.2.1  jmcneill #define TSS_TYPEFIX_MASK	0xf9
    278  1.1.2.1  jmcneill 	movq	physical_gdt+2(%rsi), %rbx
    279  1.1.2.1  jmcneill 	movzxw	previous_tr(%rsi), %rcx
    280  1.1.2.1  jmcneill 	leaq	(%rbx,%rcx),%rax	/* get TSS segment descriptor */
    281  1.1.2.1  jmcneill 	andb	$TSS_TYPEFIX_MASK, 5(%rax)
    282  1.1.2.1  jmcneill #endif
    283  1.1.2.1  jmcneill 
    284  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    285  1.1.2.1  jmcneill 	movw	$0x0200 + '9', (0xb8012)
    286  1.1.2.2  jmcneill #endif
    287  1.1.2.1  jmcneill 
    288  1.1.2.1  jmcneill         /* Restore registers */
    289  1.1.2.1  jmcneill 	lgdt	previous_gdt(%rsi)
    290  1.1.2.1  jmcneill 	lidt	previous_idt(%rsi)
    291  1.1.2.1  jmcneill         lldt	previous_ldt(%rsi)
    292  1.1.2.1  jmcneill #if 0
    293  1.1.2.1  jmcneill         ltr     previous_tr(%rsi)
    294  1.1.2.1  jmcneill #endif
    295  1.1.2.1  jmcneill 
    296  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    297  1.1.2.1  jmcneill 	movw	$0x0200 + 'a', (0xb8014)
    298  1.1.2.2  jmcneill #endif
    299  1.1.2.1  jmcneill 
    300  1.1.2.1  jmcneill 	movq	previous_cr2(%rsi), %rax
    301  1.1.2.1  jmcneill 	movq	%rax, %cr2
    302  1.1.2.1  jmcneill 	movq	previous_cr3(%rsi), %rdx
    303  1.1.2.1  jmcneill 	movq	previous_cr4(%rsi), %rax
    304  1.1.2.1  jmcneill 	movq	%rax, %cr4
    305  1.1.2.1  jmcneill 
    306  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    307  1.1.2.1  jmcneill 	movw	$0x0200 + 'b', (0xb8016)
    308  1.1.2.2  jmcneill #endif
    309  1.1.2.1  jmcneill 
    310  1.1.2.1  jmcneill         movw	previous_es(%rsi), %ax
    311  1.1.2.1  jmcneill         movw	%ax, %es
    312  1.1.2.1  jmcneill         movw	previous_fs(%rsi), %ax
    313  1.1.2.1  jmcneill         movw	%ax, %fs
    314  1.1.2.1  jmcneill         movw	previous_gs(%rsi), %ax
    315  1.1.2.1  jmcneill         movw	%ax, %gs
    316  1.1.2.1  jmcneill         movw	previous_ss(%rsi), %ax
    317  1.1.2.1  jmcneill         movw	%ax, %ss
    318  1.1.2.1  jmcneill         movq	where_to_recover(%rsi), %rbx
    319  1.1.2.1  jmcneill         movw	previous_ds(%rsi), %ax
    320  1.1.2.1  jmcneill 
    321  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    322  1.1.2.1  jmcneill 	movw	$0x0200 + 'c', (0xb8018)
    323  1.1.2.2  jmcneill #endif
    324  1.1.2.1  jmcneill 
    325  1.1.2.1  jmcneill 	/* Re-enable paging, %rdx loaded above */
    326  1.1.2.1  jmcneill 	movq	%rdx, %cr3
    327  1.1.2.1  jmcneill 	movq	previous_cr0(%rsi), %rcx
    328  1.1.2.1  jmcneill 	movq	%rcx, %cr0
    329  1.1.2.1  jmcneill 	jmp	1f
    330  1.1.2.1  jmcneill 1:	jmp	1f
    331  1.1.2.1  jmcneill 1:
    332  1.1.2.1  jmcneill 
    333  1.1.2.1  jmcneill 	/* New address space active - reload %ds */
    334  1.1.2.1  jmcneill         movw	%ax, %ds
    335  1.1.2.1  jmcneill         jmp	*%rbx
    336  1.1.2.1  jmcneill 
    337  1.1.2.1  jmcneill beepon:
    338  1.1.2.1  jmcneill 	movb	$0xc0, %al
    339  1.1.2.1  jmcneill 	outb	%al, $0x42
    340  1.1.2.1  jmcneill 	movb	$0x04, %al
    341  1.1.2.1  jmcneill 	outb	%al, $0x42
    342  1.1.2.1  jmcneill 	inb	$0x61, %al
    343  1.1.2.1  jmcneill 	orb	$0x3, %al
    344  1.1.2.1  jmcneill 	outb	%al, $0x61
    345  1.1.2.1  jmcneill 	ret
    346  1.1.2.1  jmcneill 
    347  1.1.2.1  jmcneill beepoff:
    348  1.1.2.1  jmcneill 	inb	$0x61, %al
    349  1.1.2.1  jmcneill 	andb	$0xfc, %al
    350  1.1.2.1  jmcneill 	outb	%al, $0x61
    351  1.1.2.1  jmcneill 	ret
    352  1.1.2.1  jmcneill 
    353  1.1.2.1  jmcneill tmp_gdt:
    354  1.1.2.1  jmcneill 	.word	0xffff
    355  1.1.2.1  jmcneill 	.long	RELOC(tmp_gdtable)
    356  1.1.2.1  jmcneill 
    357  1.1.2.1  jmcneill tmp_gdtable:
    358  1.1.2.1  jmcneill 	/* null */
    359  1.1.2.1  jmcneill 	.word	0, 0
    360  1.1.2.1  jmcneill 	.byte	0, 0, 0, 0
    361  1.1.2.1  jmcneill 	/* code */
    362  1.1.2.1  jmcneill 	.word	0xffff, 0
    363  1.1.2.1  jmcneill 	.byte	0, 0x9f, 0xcf, 0
    364  1.1.2.1  jmcneill 	/* data */
    365  1.1.2.1  jmcneill 	.word	0xffff, 0
    366  1.1.2.1  jmcneill 	.byte	0, 0x93, 0xcf, 0
    367  1.1.2.1  jmcneill 
    368  1.1.2.1  jmcneill tmp_gdt64:
    369  1.1.2.1  jmcneill 	.word	0xffff
    370  1.1.2.1  jmcneill 	.long	RELOC(tmp_gdtable64)
    371  1.1.2.1  jmcneill 
    372  1.1.2.1  jmcneill tmp_gdtable64:
    373  1.1.2.1  jmcneill 	/* null */
    374  1.1.2.1  jmcneill 	.word	0, 0
    375  1.1.2.1  jmcneill 	.byte	0, 0, 0, 0
    376  1.1.2.1  jmcneill 	/* code */
    377  1.1.2.1  jmcneill 	.word	0xffff, 0
    378  1.1.2.1  jmcneill 	.byte	0, 0x9a, 0xaf, 0
    379  1.1.2.1  jmcneill 	/* data */
    380  1.1.2.1  jmcneill 	.word	0xffff, 0
    381  1.1.2.1  jmcneill 	.byte	0, 0x92, 0xcf, 0
    382  1.1.2.1  jmcneill 
    383  1.1.2.1  jmcneill 	.align	16, 0
    384  1.1.2.1  jmcneill physical_gdt:		.word 0
    385  1.1.2.1  jmcneill 			.quad 0
    386  1.1.2.1  jmcneill previous_cr2:		.quad 0
    387  1.1.2.1  jmcneill previous_cr3:		.quad 0
    388  1.1.2.1  jmcneill previous_cr4:		.quad 0
    389  1.1.2.1  jmcneill previous_cr0:		.quad 0
    390  1.1.2.1  jmcneill previous_tr:		.word 0
    391  1.1.2.1  jmcneill previous_gdt:		.word 0
    392  1.1.2.1  jmcneill 			.quad 0
    393  1.1.2.1  jmcneill previous_ldt:		.word 0
    394  1.1.2.1  jmcneill previous_idt:		.word 0
    395  1.1.2.1  jmcneill 			.quad 0
    396  1.1.2.1  jmcneill previous_ds:		.word 0
    397  1.1.2.1  jmcneill previous_es:		.word 0
    398  1.1.2.1  jmcneill previous_fs:		.word 0
    399  1.1.2.1  jmcneill previous_gs:		.word 0
    400  1.1.2.1  jmcneill previous_ss:		.word 0
    401  1.1.2.1  jmcneill previous_rsp:		.quad 0
    402  1.1.2.1  jmcneill where_to_recover:	.quad 0
    403  1.1.2.1  jmcneill tmp_pml4:		.quad 0
    404  1.1.2.1  jmcneill vbios_reset:		.byte 0
    405  1.1.2.1  jmcneill beep_on_reset:		.byte 0
    406