]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/locore.s
xnu-1228.15.4.tar.gz
[apple/xnu.git] / osfmk / i386 / locore.s
index 29e35692299bf0bffee0111899248507a5981dec..5b57ee4cc8e4bc5a48b7f6e59b53ddeee4a8d988 100644 (file)
@@ -66,6 +66,8 @@
 #include <i386/asm.h>
 #include <i386/cpuid.h>
 #include <i386/eflags.h>
+#include <i386/lapic.h>
+#include <i386/rtclock.h>
 #include <i386/proc_reg.h>
 #include <i386/trap.h>
 #include <assym.s>
        call    EXT(fn)                 ;\
        movl    %edi, %esp
 
-#define CCALL3(fn, arg1, arg2, arg3)   \
+/*
+ * CCALL5 is used for callee functions with 3 arguments but
+ * where arg2 (a3:a2) and arg3 (a5:a4) are 64-bit values.
+ */
+#define CCALL5(fn, a1, a2, a3, a4, a5) \
        movl    %esp, %edi              ;\
-       subl    $12, %esp               ;\
+       subl    $20, %esp               ;\
        andl    $0xFFFFFFF0, %esp       ;\
-       movl    arg3, 8(%esp)           ;\
-       movl    arg2, 4(%esp)           ;\
-       movl    arg1, 0(%esp)           ;\
+       movl    a5, 16(%esp)            ;\
+       movl    a4, 12(%esp)            ;\
+       movl    a3,  8(%esp)            ;\
+       movl    a2,  4(%esp)            ;\
+       movl    a1,  0(%esp)            ;\
        call    EXT(fn)                 ;\
        movl    %edi, %esp
 
@@ -229,27 +237,10 @@ Entry(timer_grab)
  *
  * Uses %eax, %ebx, %ecx, %edx, %esi, %edi.
  */
-#define RNT_INFO               _rtc_nanotime_info
-#define NANOTIME                                                                                                                 \
-0:     movl    RNT_INFO+RNT_TSC_BASE,%esi                                                                      ; \
-       movl    RNT_INFO+RNT_TSC_BASE+4,%edi                                                            ; \
-       rdtsc                                                                                                                           ; \
-       subl    %esi,%eax                                               /* tsc - tsc_base */            ; \
-       sbbl    %edi,%edx                                                                                                       ; \
-       movl    RNT_INFO+RNT_SCALE,%ecx                                                                         ; \
-       movl    %edx,%ebx                                               /* delta * scale */                     ; \
-       mull    %ecx                                                                                                            ; \
-       movl    %ebx,%eax                                                                                                       ; \
-       movl    %edx,%ebx                                                                                                       ; \
-       mull    %ecx                                                                                                            ; \
-       addl    %ebx,%eax                                                                                                       ; \
-       adcl    $0,%edx                                                 /* add carry into hi */         ; \
-       addl    RNT_INFO+RNT_NS_BASE,%eax               /* add ns_base lo */            ; \
-       adcl    RNT_INFO+RNT_NS_BASE+4,%edx             /* add ns_base hi */            ; \
-       cmpl    RNT_INFO+RNT_TSC_BASE,%esi                                                                      ; \
-       jne     0b                                                                      /* repeat if changed */         ; \
-       cmpl    RNT_INFO+RNT_TSC_BASE+4,%edi                                                            ; \
-       jne     0b
+#define NANOTIME                                                       \
+       mov     %gs:CPU_NANOTIME,%edi                                   ; \
+       RTC_NANOTIME_READ_FAST()
+
 
 /*
  * Add 64-bit delta in register dreg : areg to timer pointed to by register treg.
@@ -292,13 +283,13 @@ Entry(timer_grab)
  * Update time on user trap entry.
  * Uses %eax,%ebx,%ecx,%edx,%esi,%edi.
  */
-#define        TIME_TRAP_UENTRY        TIMER_EVENT(USER,SYSTEM)
+#define        TIME_TRAP_UENTRY                        TIMER_EVENT(USER,SYSTEM)
 
 /*
  * update time on user trap exit.
  * Uses %eax,%ebx,%ecx,%edx,%esi,%edi.
  */
-#define        TIME_TRAP_UEXIT         TIMER_EVENT(SYSTEM,USER)
+#define        TIME_TRAP_UEXIT                         TIMER_EVENT(SYSTEM,USER)
 
 /*
  * update time on interrupt entry.
@@ -921,7 +912,7 @@ Entry(lo_diag_scall)
        popl    %esp                    // Get back the original stack
        jmp     EXT(return_to_user)     // Normal return, do not check asts...
 2:     
-       CCALL3(i386_exception, $EXC_SYSCALL, $0x6000, $1)
+       CCALL5(i386_exception, $EXC_SYSCALL, $0x6000, $0, $1, $0)
                // pass what would be the diag syscall
                // error return - cause an exception
        /* no return */
@@ -945,6 +936,8 @@ Entry(lo_diag_scall)
  */
 
 Entry(lo_syscall)
+       TIME_TRAP_UENTRY
+
        /*
         * We can be here either for a mach, unix machdep or diag syscall,
         * as indicated by the syscall class:
@@ -967,13 +960,11 @@ Entry(lo_syscall)
        sti
 
        /* Syscall class unknown */
-       CCALL3(i386_exception, $(EXC_SYSCALL), %eax, $1)
+       CCALL5(i386_exception, $(EXC_SYSCALL), %eax, $0, $1, $0)
        /* no return */
 
 
 Entry(lo64_unix_scall)
-       TIME_TRAP_UENTRY
-
        movl    %gs:CPU_ACTIVE_THREAD,%ecx      /* get current thread     */
        movl    ACT_TASK(%ecx),%ebx                     /* point to current task  */
        addl    $1,TASK_SYSCALLS_UNIX(%ebx)     /* increment call count   */
@@ -1002,8 +993,6 @@ Entry(lo64_unix_scall)
 
 
 Entry(lo64_mach_scall)
-       TIME_TRAP_UENTRY
-
        movl    %gs:CPU_ACTIVE_THREAD,%ecx      /* get current thread     */
        movl    ACT_TASK(%ecx),%ebx                     /* point to current task  */
        addl    $1,TASK_SYSCALLS_MACH(%ebx)     /* increment call count   */
@@ -1032,8 +1021,6 @@ Entry(lo64_mach_scall)
 
 
 Entry(lo64_mdep_scall)
-       TIME_TRAP_UENTRY
-
        movl    %gs:CPU_ACTIVE_THREAD,%ecx      /* get current thread     */
        movl    ACT_TASK(%ecx),%ebx                     /* point to current task  */
 
@@ -1061,8 +1048,6 @@ Entry(lo64_mdep_scall)
 
 
 Entry(lo64_diag_scall)
-       TIME_TRAP_UENTRY
-
        movl    %gs:CPU_ACTIVE_THREAD,%ecx      /* get current thread     */
        movl    ACT_TASK(%ecx),%ebx                     /* point to current task  */
 
@@ -1089,7 +1074,7 @@ Entry(lo64_diag_scall)
        popl    %esp                    // Get back the original stack
        jmp     EXT(return_to_user)     // Normal return, do not check asts...
 2:     
-       CCALL3(i386_exception, $EXC_SYSCALL, $0x6000, $1)
+       CCALL5(i386_exception, $EXC_SYSCALL, $0x6000, $0, $1, $0)
                // pass what would be the diag syscall
                // error return - cause an exception
        /* no return */