2 * Copyright (c) 2006 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 <platforms.h>
27 #include <i386/asm64.h>
28 #include <i386/proc_reg.h>
29 #include <i386/postcode.h>
35 /* align below right */
38 .word Times(8,GDTSZ)-1
39 /* XXX really want .quad here */
41 .long KERNEL_UBER_BASE_HI32 /* must be in uber-space */
45 /* align below right */
48 .word Times(16,IDTSZ)-1
49 /* XXX really want .quad here */
50 .long EXT(master_idt64)
51 .long KERNEL_UBER_BASE_HI32 /* must be in uber-space */
59 POSTCODE(ML_LOAD_DESC64_ENTRY)
61 lgdt EXT(gdtptr64) /* load GDT */
63 POSTCODE(ML_LOAD_DESC64_GDT)
65 lidt EXT(idtptr64) /* load IDT */
67 POSTCODE(ML_LOAD_DESC64_IDT)
69 movw $(KERNEL_LDT),%ax /* get LDT segment */
70 lldt %ax /* load LDT */
72 POSTCODE(ML_LOAD_DESC64_LDT)
74 movw $(KERNEL_TSS),%ax
75 ltr %ax /* set up KTSS */
77 POSTCODE(ML_LOAD_DESC64_EXIT)
84 Entry(ml_64bit_wrmsr64)
85 /* (uint32_t msr, uint64_t value) */
86 /* (uint32_t msr, uint32_t lo, uint32_t hi) */
104 /* (int32_t selector) */
118 Entry(set_64bit_debug_regs)
119 /* x86_debug_state64_t *ds */
126 mov DS64_DR0(%edx), %rax
128 mov DS64_DR1(%edx), %rax
130 mov DS64_DR2(%edx), %rax
132 mov DS64_DR3(%edx), %rax
154 /* FXSAVE and FXRSTOR operate in a mode dependent fashion, hence these variants.
155 * Must be called with interrupts disabled.
156 * We clear pending x87 exceptions here; this is technically incorrect, since we should
157 * propagate those to the user, but the compatibility mode kernel is currently not
158 * prepared to handle exceptions originating in 64-bit kernel mode. However, it may be possible
159 * to work around this should it prove necessary.