Home | History | Annotate | Line # | Download | only in acpi
acpi_wakecode.S revision 1.1.2.4
      1  1.1.2.4  jmcneill /* $NetBSD: acpi_wakecode.S,v 1.1.2.4 2007/09/08 02:43:24 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.3  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 	.text
     82  1.1.2.1  jmcneill 	.code16
     83  1.1.2.3  jmcneill 	.org	0
     84  1.1.2.3  jmcneill 	.globl wakeup_16
     85  1.1.2.1  jmcneill wakeup_16:
     86  1.1.2.1  jmcneill 	nop
     87  1.1.2.1  jmcneill 	cli
     88  1.1.2.1  jmcneill 	cld
     89  1.1.2.1  jmcneill 
     90  1.1.2.1  jmcneill 	/* Set up segment registers for real mode */
     91  1.1.2.1  jmcneill 	movw	%cs, %ax
     92  1.1.2.1  jmcneill 	movw	%ax, %ds
     93  1.1.2.1  jmcneill 	movw	%ax, %ss
     94  1.1.2.1  jmcneill 
     95  1.1.2.1  jmcneill 	/* Small call stack XXXAD Where is this? Is it in the ACPI spec? */
     96  1.1.2.1  jmcneill 	mov	$0x1000, %sp
     97  1.1.2.1  jmcneill 
     98  1.1.2.1  jmcneill 	/* Clear flags */
     99  1.1.2.1  jmcneill 	pushl	$0
    100  1.1.2.1  jmcneill 	popfl
    101  1.1.2.1  jmcneill 
    102  1.1.2.1  jmcneill 	/* Only beep on reset if machdep.acpi_beep_on_reset=1 */
    103  1.1.2.3  jmcneill 	cmpb	$1, beep_on_reset
    104  1.1.2.1  jmcneill 	jne	nobeepon
    105  1.1.2.1  jmcneill 	call	beepon
    106  1.1.2.1  jmcneill 
    107  1.1.2.1  jmcneill nobeepon:
    108  1.1.2.1  jmcneill 
    109  1.1.2.1  jmcneill 	/* Only reset the VBIOS if machdep.acpi_vbios_reset=1 */
    110  1.1.2.3  jmcneill 	cmpb	$1, vbios_reset
    111  1.1.2.1  jmcneill 	jne	novbiosreset
    112  1.1.2.1  jmcneill 
    113  1.1.2.1  jmcneill 	/* Kick the VBIOS. */
    114  1.1.2.1  jmcneill 	lcall	$0xc000, $3
    115  1.1.2.1  jmcneill 
    116  1.1.2.1  jmcneill 	/* Paranoid, restore segment registers. */
    117  1.1.2.1  jmcneill 	movw	%cs, %ax
    118  1.1.2.1  jmcneill 	movw	%ax, %ds
    119  1.1.2.1  jmcneill 	movw	%ax, %ss
    120  1.1.2.1  jmcneill 
    121  1.1.2.1  jmcneill novbiosreset:
    122  1.1.2.1  jmcneill 
    123  1.1.2.1  jmcneill 	/* Only beep on reset if machdep.acpi_beep_on_reset=1 */
    124  1.1.2.3  jmcneill 	cmpb	$1, beep_on_reset
    125  1.1.2.1  jmcneill 	jne	nobeepoff
    126  1.1.2.1  jmcneill 	call	beepoff
    127  1.1.2.1  jmcneill 
    128  1.1.2.1  jmcneill nobeepoff:
    129  1.1.2.1  jmcneill 
    130  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    131  1.1.2.1  jmcneill 	movw	$0xb800, %ax
    132  1.1.2.1  jmcneill 	movw	%ax, %fs
    133  1.1.2.1  jmcneill 	movw	$0x0200 + '0', %fs:(0x00)
    134  1.1.2.1  jmcneill #endif
    135  1.1.2.1  jmcneill 
    136  1.1.2.1  jmcneill 	/* Get physical address of the code */
    137  1.1.2.1  jmcneill 	mov	%cs, %ax
    138  1.1.2.1  jmcneill 	movzx	%ax, %esi
    139  1.1.2.1  jmcneill 	shll	$4, %esi
    140  1.1.2.1  jmcneill 
    141  1.1.2.1  jmcneill 	/* Fill 16->32 address */
    142  1.1.2.3  jmcneill 	addl	%esi, wakeup_sw32+2	/* 1b opcode, 1b prefix */
    143  1.1.2.3  jmcneill 	addl	%esi, wakeup_sw64+1	/* 1b opcode */
    144  1.1.2.3  jmcneill 	addl	%esi, tmp_gdt+2
    145  1.1.2.3  jmcneill 	addl	%esi, tmp_gdt64+2
    146  1.1.2.1  jmcneill 	wbinvd					/* flush uop/trace cache */
    147  1.1.2.1  jmcneill 	jmp	1f
    148  1.1.2.1  jmcneill 1:	jmp	1f
    149  1.1.2.1  jmcneill 1:
    150  1.1.2.1  jmcneill 
    151  1.1.2.1  jmcneill 
    152  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    153  1.1.2.1  jmcneill 	movw	$0xb800, %ax
    154  1.1.2.1  jmcneill 	movw	%ax, %fs
    155  1.1.2.1  jmcneill 	movw	$0x0200 + '1', %fs:(0x02)
    156  1.1.2.1  jmcneill #endif
    157  1.1.2.1  jmcneill 
    158  1.1.2.1  jmcneill 	/* Load GDT, enable protected mode */
    159  1.1.2.3  jmcneill 	lgdt	tmp_gdt
    160  1.1.2.3  jmcneill 
    161  1.1.2.3  jmcneill 	/* Enable protected mode */
    162  1.1.2.1  jmcneill 	movl	%eax, %cr0
    163  1.1.2.3  jmcneill 	orb	$(CR0_PE), %al
    164  1.1.2.1  jmcneill 	movl	%eax, %cr0
    165  1.1.2.1  jmcneill 
    166  1.1.2.1  jmcneill wakeup_sw32:
    167  1.1.2.1  jmcneill 
    168  1.1.2.1  jmcneill 	/* Switch to protected mode by intersegmental jump */
    169  1.1.2.3  jmcneill 	ljmpl	$GSEL(GCODE_SEL,SEL_KPL), $wakeup_32
    170  1.1.2.1  jmcneill 
    171  1.1.2.1  jmcneill 	.align	16
    172  1.1.2.1  jmcneill 	.code32
    173  1.1.2.1  jmcneill wakeup_32:
    174  1.1.2.1  jmcneill 
    175  1.1.2.3  jmcneill 	nop
    176  1.1.2.1  jmcneill 	movl	$GSEL(GDATA_SEL,SEL_KPL), %eax
    177  1.1.2.1  jmcneill 	movw	%ax, %ds
    178  1.1.2.1  jmcneill 	movw	%ax, %ss
    179  1.1.2.1  jmcneill 	movw	%ax, %es
    180  1.1.2.1  jmcneill 	movw	%ax, %fs
    181  1.1.2.1  jmcneill 	movw	%ax, %gs
    182  1.1.2.1  jmcneill 
    183  1.1.2.1  jmcneill 	movl	$0x1000, %esp	/* XXXJDM is this needed? */
    184  1.1.2.1  jmcneill 
    185  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    186  1.1.2.1  jmcneill 	movw	$0x0200 + '2', (0xb8004)
    187  1.1.2.1  jmcneill #endif
    188  1.1.2.1  jmcneill 
    189  1.1.2.1  jmcneill 	pushl	$PSL_MBO
    190  1.1.2.1  jmcneill 	popfl
    191  1.1.2.1  jmcneill 
    192  1.1.2.1  jmcneill 	movl	%cr4, %eax
    193  1.1.2.1  jmcneill 	orl	$(CR4_PAE|CR4_OSFXSR|CR4_OSXMMEXCPT), %eax
    194  1.1.2.1  jmcneill 	movl	%eax, %cr4
    195  1.1.2.1  jmcneill 
    196  1.1.2.1  jmcneill 	/* Set long mode enable in EFER and enable syscall extensions */
    197  1.1.2.1  jmcneill 	movl	$MSR_EFER, %ecx
    198  1.1.2.1  jmcneill 	rdmsr
    199  1.1.2.1  jmcneill 	xorl	%eax, %eax
    200  1.1.2.1  jmcneill 	orl	$(EFER_LME|EFER_SCE), %eax
    201  1.1.2.1  jmcneill 	wrmsr
    202  1.1.2.1  jmcneill 
    203  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    204  1.1.2.1  jmcneill 	movw	$0x0200 + '3', (0xb8006)
    205  1.1.2.1  jmcneill #endif
    206  1.1.2.1  jmcneill 
    207  1.1.2.3  jmcneill 	movl	tmp_pml4(%esi), %ecx
    208  1.1.2.1  jmcneill 	movl	%ecx, %cr3
    209  1.1.2.1  jmcneill 
    210  1.1.2.1  jmcneill #ifdef WAKECODE_VERBOSE
    211  1.1.2.1  jmcneill 	movw	$0x0200 + '4', (0xb8008)
    212  1.1.2.1  jmcneill #endif
    213  1.1.2.1  jmcneill 
    214  1.1.2.1  jmcneill 	movl	%cr0, %eax
    215  1.1.2.1  jmcneill 	orl	$(CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP), %eax
    216  1.1.2.1  jmcneill 	movl	%eax, %cr0
    217  1.1.2.1  jmcneill 	jmp	compat
    218  1.1.2.1  jmcneill compat:
    219  1.1.2.1  jmcneill 
    220  1.1.2.1  jmcneill 	movl	$GSEL(GDATA_SEL,SEL_KPL), %eax
    221  1.1.2.1  jmcneill 	movl	%eax, %ds
    222  1.1.2.1  jmcneill 	movl	%eax, %es
    223  1.1.2.1  jmcneill 	movl	%eax, %ss
    224  1.1.2.1  jmcneill 
    225  1.1.2.4  jmcneill #ifdef WAKECODE_VERBOSE
    226  1.1.2.1  jmcneill 	movw	$0x0200 + '5', (0xb800a)
    227  1.1.2.4  jmcneill #endif
    228  1.1.2.1  jmcneill 
    229  1.1.2.1  jmcneill 	/* Load 64-bit GDT. */
    230  1.1.2.3  jmcneill 	lgdt	tmp_gdt64(%esi)
    231  1.1.2.1  jmcneill 
    232  1.1.2.4  jmcneill #ifdef WAKECODE_VERBOSE
    233  1.1.2.1  jmcneill 	movw	$0x0200 + '6', (0xb800c)
    234  1.1.2.4  jmcneill #endif
    235  1.1.2.1  jmcneill 
    236  1.1.2.1  jmcneill wakeup_sw64:
    237  1.1.2.1  jmcneill 
    238  1.1.2.1  jmcneill 	/* Jump to long mode segment. */
    239  1.1.2.3  jmcneill 	ljmpl	$GSEL(GCODE_SEL,SEL_KPL), $wakeup_64
    240  1.1.2.1  jmcneill 
    241  1.1.2.1  jmcneill 	.align	16
    242  1.1.2.1  jmcneill 	.code64
    243  1.1.2.1  jmcneill wakeup_64:
    244  1.1.2.1  jmcneill 
    245  1.1.2.1  jmcneill 	nop
    246  1.1.2.1  jmcneill 	nop
    247  1.1.2.1  jmcneill 
    248  1.1.2.1  jmcneill 	/* Re-initialize segment regsisters to be on the safe side. */
    249  1.1.2.1  jmcneill 	movl	$GSEL(GDATA_SEL,SEL_KPL), %eax
    250  1.1.2.1  jmcneill 	movl	%eax, %ds
    251  1.1.2.1  jmcneill 	movl	%eax, %es
    252  1.1.2.1  jmcneill 	movl	%eax, %gs
    253  1.1.2.1  jmcneill 	movl	%eax, %ss
    254  1.1.2.1  jmcneill 	movl	%eax, %fs
    255  1.1.2.1  jmcneill 
    256  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    257  1.1.2.1  jmcneill 	movw	$0x0200 + '7', (0xb800e)
    258  1.1.2.2  jmcneill #endif
    259  1.1.2.1  jmcneill 
    260  1.1.2.1  jmcneill 	movq	previous_rsp(%rsi), %rsp
    261  1.1.2.1  jmcneill 
    262  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    263  1.1.2.1  jmcneill 	movw	$0x0200 + '8', (0xb8010)
    264  1.1.2.2  jmcneill #endif
    265  1.1.2.1  jmcneill 
    266  1.1.2.1  jmcneill #if 1	/* XXXAD ?? */
    267  1.1.2.1  jmcneill 	/* Fixup TSS type field; 386 busy TSS (11) -> 386 available TSS (9) */
    268  1.1.2.1  jmcneill #define TSS_TYPEFIX_MASK	0xf9
    269  1.1.2.1  jmcneill 	movq	physical_gdt+2(%rsi), %rbx
    270  1.1.2.1  jmcneill 	movzxw	previous_tr(%rsi), %rcx
    271  1.1.2.1  jmcneill 	leaq	(%rbx,%rcx),%rax	/* get TSS segment descriptor */
    272  1.1.2.1  jmcneill 	andb	$TSS_TYPEFIX_MASK, 5(%rax)
    273  1.1.2.1  jmcneill #endif
    274  1.1.2.1  jmcneill 
    275  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    276  1.1.2.1  jmcneill 	movw	$0x0200 + '9', (0xb8012)
    277  1.1.2.2  jmcneill #endif
    278  1.1.2.1  jmcneill 
    279  1.1.2.1  jmcneill         /* Restore registers */
    280  1.1.2.1  jmcneill 	lgdt	previous_gdt(%rsi)
    281  1.1.2.1  jmcneill 	lidt	previous_idt(%rsi)
    282  1.1.2.1  jmcneill         lldt	previous_ldt(%rsi)
    283  1.1.2.1  jmcneill #if 0
    284  1.1.2.1  jmcneill         ltr     previous_tr(%rsi)
    285  1.1.2.1  jmcneill #endif
    286  1.1.2.1  jmcneill 
    287  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    288  1.1.2.1  jmcneill 	movw	$0x0200 + 'a', (0xb8014)
    289  1.1.2.2  jmcneill #endif
    290  1.1.2.1  jmcneill 
    291  1.1.2.1  jmcneill 	movq	previous_cr2(%rsi), %rax
    292  1.1.2.1  jmcneill 	movq	%rax, %cr2
    293  1.1.2.1  jmcneill 	movq	previous_cr3(%rsi), %rdx
    294  1.1.2.1  jmcneill 	movq	previous_cr4(%rsi), %rax
    295  1.1.2.1  jmcneill 	movq	%rax, %cr4
    296  1.1.2.1  jmcneill 
    297  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    298  1.1.2.1  jmcneill 	movw	$0x0200 + 'b', (0xb8016)
    299  1.1.2.2  jmcneill #endif
    300  1.1.2.1  jmcneill 
    301  1.1.2.1  jmcneill         movw	previous_es(%rsi), %ax
    302  1.1.2.1  jmcneill         movw	%ax, %es
    303  1.1.2.1  jmcneill         movw	previous_fs(%rsi), %ax
    304  1.1.2.1  jmcneill         movw	%ax, %fs
    305  1.1.2.1  jmcneill         movw	previous_gs(%rsi), %ax
    306  1.1.2.1  jmcneill         movw	%ax, %gs
    307  1.1.2.1  jmcneill         movw	previous_ss(%rsi), %ax
    308  1.1.2.1  jmcneill         movw	%ax, %ss
    309  1.1.2.1  jmcneill         movq	where_to_recover(%rsi), %rbx
    310  1.1.2.1  jmcneill         movw	previous_ds(%rsi), %ax
    311  1.1.2.1  jmcneill 
    312  1.1.2.2  jmcneill #ifdef WAKECODE_VERBOSE
    313  1.1.2.1  jmcneill 	movw	$0x0200 + 'c', (0xb8018)
    314  1.1.2.2  jmcneill #endif
    315  1.1.2.1  jmcneill 
    316  1.1.2.1  jmcneill 	/* Re-enable paging, %rdx loaded above */
    317  1.1.2.1  jmcneill 	movq	%rdx, %cr3
    318  1.1.2.1  jmcneill 	movq	previous_cr0(%rsi), %rcx
    319  1.1.2.1  jmcneill 	movq	%rcx, %cr0
    320  1.1.2.1  jmcneill 	jmp	1f
    321  1.1.2.1  jmcneill 1:	jmp	1f
    322  1.1.2.1  jmcneill 1:
    323  1.1.2.1  jmcneill 
    324  1.1.2.1  jmcneill 	/* New address space active - reload %ds */
    325  1.1.2.1  jmcneill         movw	%ax, %ds
    326  1.1.2.1  jmcneill         jmp	*%rbx
    327  1.1.2.1  jmcneill 
    328  1.1.2.1  jmcneill beepon:
    329  1.1.2.1  jmcneill 	movb	$0xc0, %al
    330  1.1.2.1  jmcneill 	outb	%al, $0x42
    331  1.1.2.1  jmcneill 	movb	$0x04, %al
    332  1.1.2.1  jmcneill 	outb	%al, $0x42
    333  1.1.2.1  jmcneill 	inb	$0x61, %al
    334  1.1.2.1  jmcneill 	orb	$0x3, %al
    335  1.1.2.1  jmcneill 	outb	%al, $0x61
    336  1.1.2.1  jmcneill 	ret
    337  1.1.2.1  jmcneill 
    338  1.1.2.1  jmcneill beepoff:
    339  1.1.2.1  jmcneill 	inb	$0x61, %al
    340  1.1.2.1  jmcneill 	andb	$0xfc, %al
    341  1.1.2.1  jmcneill 	outb	%al, $0x61
    342  1.1.2.1  jmcneill 	ret
    343  1.1.2.1  jmcneill 
    344  1.1.2.1  jmcneill tmp_gdt:
    345  1.1.2.1  jmcneill 	.word	0xffff
    346  1.1.2.3  jmcneill 	.long	tmp_gdtable
    347  1.1.2.1  jmcneill 
    348  1.1.2.1  jmcneill tmp_gdtable:
    349  1.1.2.1  jmcneill 	/* null */
    350  1.1.2.1  jmcneill 	.word	0, 0
    351  1.1.2.1  jmcneill 	.byte	0, 0, 0, 0
    352  1.1.2.1  jmcneill 	/* code */
    353  1.1.2.1  jmcneill 	.word	0xffff, 0
    354  1.1.2.1  jmcneill 	.byte	0, 0x9f, 0xcf, 0
    355  1.1.2.1  jmcneill 	/* data */
    356  1.1.2.1  jmcneill 	.word	0xffff, 0
    357  1.1.2.1  jmcneill 	.byte	0, 0x93, 0xcf, 0
    358  1.1.2.1  jmcneill 
    359  1.1.2.1  jmcneill tmp_gdt64:
    360  1.1.2.1  jmcneill 	.word	0xffff
    361  1.1.2.3  jmcneill 	.long	tmp_gdtable64
    362  1.1.2.1  jmcneill 
    363  1.1.2.1  jmcneill tmp_gdtable64:
    364  1.1.2.1  jmcneill 	/* null */
    365  1.1.2.1  jmcneill 	.word	0, 0
    366  1.1.2.1  jmcneill 	.byte	0, 0, 0, 0
    367  1.1.2.1  jmcneill 	/* code */
    368  1.1.2.1  jmcneill 	.word	0xffff, 0
    369  1.1.2.1  jmcneill 	.byte	0, 0x9a, 0xaf, 0
    370  1.1.2.1  jmcneill 	/* data */
    371  1.1.2.1  jmcneill 	.word	0xffff, 0
    372  1.1.2.1  jmcneill 	.byte	0, 0x92, 0xcf, 0
    373  1.1.2.1  jmcneill 
    374  1.1.2.1  jmcneill 	.align	16, 0
    375  1.1.2.3  jmcneill 	.global	WAKEUP_physical_gdt
    376  1.1.2.3  jmcneill WAKEUP_physical_gdt:
    377  1.1.2.1  jmcneill physical_gdt:		.word 0
    378  1.1.2.1  jmcneill 			.quad 0
    379  1.1.2.3  jmcneill 	.global WAKEUP_previous_cr2
    380  1.1.2.3  jmcneill WAKEUP_previous_cr2:
    381  1.1.2.1  jmcneill previous_cr2:		.quad 0
    382  1.1.2.3  jmcneill 	.global	WAKEUP_previous_cr3
    383  1.1.2.3  jmcneill WAKEUP_previous_cr3:
    384  1.1.2.1  jmcneill previous_cr3:		.quad 0
    385  1.1.2.3  jmcneill 	.global	WAKEUP_previous_cr4
    386  1.1.2.3  jmcneill WAKEUP_previous_cr4:
    387  1.1.2.1  jmcneill previous_cr4:		.quad 0
    388  1.1.2.3  jmcneill 	.global	WAKEUP_previous_cr0
    389  1.1.2.3  jmcneill WAKEUP_previous_cr0:
    390  1.1.2.1  jmcneill previous_cr0:		.quad 0
    391  1.1.2.3  jmcneill 	.global	WAKEUP_previous_tr
    392  1.1.2.3  jmcneill WAKEUP_previous_tr:
    393  1.1.2.1  jmcneill previous_tr:		.word 0
    394  1.1.2.3  jmcneill 	.global	WAKEUP_previous_gdt
    395  1.1.2.3  jmcneill WAKEUP_previous_gdt:
    396  1.1.2.1  jmcneill previous_gdt:		.word 0
    397  1.1.2.1  jmcneill 			.quad 0
    398  1.1.2.3  jmcneill 	.global	WAKEUP_previous_ldt
    399  1.1.2.3  jmcneill WAKEUP_previous_ldt:
    400  1.1.2.1  jmcneill previous_ldt:		.word 0
    401  1.1.2.3  jmcneill 	.global WAKEUP_previous_idt
    402  1.1.2.3  jmcneill WAKEUP_previous_idt:
    403  1.1.2.1  jmcneill previous_idt:		.word 0
    404  1.1.2.1  jmcneill 			.quad 0
    405  1.1.2.3  jmcneill 	.global WAKEUP_previous_ds
    406  1.1.2.3  jmcneill WAKEUP_previous_ds:
    407  1.1.2.1  jmcneill previous_ds:		.word 0
    408  1.1.2.3  jmcneill 	.global	WAKEUP_previous_es
    409  1.1.2.3  jmcneill WAKEUP_previous_es:
    410  1.1.2.1  jmcneill previous_es:		.word 0
    411  1.1.2.3  jmcneill 	.global	WAKEUP_previous_fs
    412  1.1.2.3  jmcneill WAKEUP_previous_fs:
    413  1.1.2.1  jmcneill previous_fs:		.word 0
    414  1.1.2.3  jmcneill 	.global	WAKEUP_previous_gs
    415  1.1.2.3  jmcneill WAKEUP_previous_gs:
    416  1.1.2.1  jmcneill previous_gs:		.word 0
    417  1.1.2.3  jmcneill 	.global	WAKEUP_previous_ss
    418  1.1.2.3  jmcneill WAKEUP_previous_ss:
    419  1.1.2.1  jmcneill previous_ss:		.word 0
    420  1.1.2.3  jmcneill 	.global	WAKEUP_previous_rsp
    421  1.1.2.3  jmcneill WAKEUP_previous_rsp:
    422  1.1.2.1  jmcneill previous_rsp:		.quad 0
    423  1.1.2.3  jmcneill 	.global WAKEUP_where_to_recover
    424  1.1.2.3  jmcneill WAKEUP_where_to_recover:
    425  1.1.2.1  jmcneill where_to_recover:	.quad 0
    426  1.1.2.3  jmcneill 	.global WAKEUP_tmp_pml4
    427  1.1.2.3  jmcneill WAKEUP_tmp_pml4:
    428  1.1.2.1  jmcneill tmp_pml4:		.quad 0
    429  1.1.2.3  jmcneill 	.global WAKEUP_vbios_reset
    430  1.1.2.3  jmcneill WAKEUP_vbios_reset:
    431  1.1.2.1  jmcneill vbios_reset:		.byte 0
    432  1.1.2.3  jmcneill 	.global	WAKEUP_beep_on_reset
    433  1.1.2.3  jmcneill WAKEUP_beep_on_reset:
    434  1.1.2.1  jmcneill beep_on_reset:		.byte 0
    435