]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/asm64.h
xnu-2050.18.24.tar.gz
[apple/xnu.git] / osfmk / i386 / asm64.h
index 08afac97a326152831f56688252b968190984c9e..0f9213e7d63c4d7bbf29c16059999990dc39eaf5 100644 (file)
@@ -28,6 +28,7 @@
 
 /* Helper macros for 64-bit mode switching */
 
+#if __i386__
 /*
  * Long jump to 64-bit space from 32-bit compatibility mode.
  */
        .code32                                 ;\
 4:
 
+#else
+
+/*
+ * 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()                      \
+       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()                    \
+       call    3f                              ;\
+3:     addq    $(4f-3b), (%rsp)                ;\
+       movl    $KERNEL32_CS, 4(%rsp)           ;\
+       lret                                    ;\
+4:     .code32
+
+#endif