]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/asm64.h
xnu-3789.70.16.tar.gz
[apple/xnu.git] / osfmk / i386 / asm64.h
index bb1a51c0b42dee21976423c9b72e0cc90f1daadf..b576f792d879756a50817262e23c84e608e330f4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2006-2012 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
 
 /* Helper macros for 64-bit mode switching */
 
+
 /*
  * Long jump to 64-bit space from 32-bit compatibility mode.
+ * Effected, in fact, by a long return ..
+ *  - we push the 64-bit kernel code selector KERNEL64_CS
+ *  - call .+1 to get EIP on stack
+ *  - adjust return address after lret
+ *  - lret to return to next instruction but 64-bit mode.
  */
 #define        ENTER_64BIT_MODE()                      \
-       .code32                                 ;\
-       .byte   0xea    /* far jump longmode */ ;\
-       .long   1f                              ;\
-       .word   KERNEL64_CS                     ;\
-        .code64                                        ;\
-1:
-
-/*
- * Here in long mode but still running below 4G.
- * "Near" jump into uber-space.
- */
-#define        ENTER_UBERSPACE()                       \
-        mov     2f,%rax                                ;\
-        jmp     *%rax                          ;\
-2:      .long   3f                             ;\
-        .long   KERNEL_UBER_BASE_HI32          ;\
-3:     
+       push    $KERNEL64_CS                    ;\
+       call    1f                              ;\
+1:     addl    $(2f-1b), (%esp)                ;\
+       lret                                    ;\
+2:     .code64
 
 /*
  * Long jump to 32-bit compatibility mode from 64-bit space.
+ * Effected by long return similar to ENTER_64BIT_MODE.
  */
 #define ENTER_COMPAT_MODE()                    \
-       ljmp    *4f                             ;\
-4:     .long   5f                              ;\
-       .word   KERNEL_CS                       ;\
-       .code32                                 ;\
-5:
+       call    3f                              ;\
+3:     addq    $(4f-3b), (%rsp)                ;\
+       movl    $KERNEL32_CS, 4(%rsp)           ;\
+       lret                                    ;\
+4:     .code32