X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/cf7d32b81c573a0536dc4da4157f9c26f8d0bed3..6d2010ae8f7a6078e10b361c6962983bab233e0f:/osfmk/i386/machine_routines_asm.s diff --git a/osfmk/i386/machine_routines_asm.s b/osfmk/i386/machine_routines_asm.s index b7187aecf..0e3d9fb68 100644 --- a/osfmk/i386/machine_routines_asm.s +++ b/osfmk/i386/machine_routines_asm.s @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * Copyright (c) 2000-2010 Apple Inc. All rights reserved. * * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * @@ -27,11 +27,11 @@ */ #include -#include +#include #include - +#include #include -#include +#include #include /* @@ -46,7 +46,9 @@ ENTRY(ml_get_timebase) movl S_ARG0, %ecx + lfence rdtsc + lfence movl %edx, 0(%ecx) movl %eax, 4(%ecx) @@ -132,43 +134,30 @@ LEXT(tmrCvt) ret // Leave... - .globl EXT(_rtc_nanotime_store) - .align FALIGN - -LEXT(_rtc_nanotime_store) - push %ebp - movl %esp,%ebp - push %esi - - mov 32(%ebp),%edx /* get ptr to rtc_nanotime_info */ - - movl RNT_GENERATION(%edx),%esi /* get current generation */ - movl $0,RNT_GENERATION(%edx) /* flag data as being updated */ - mov 8(%ebp),%eax - mov %eax,RNT_TSC_BASE(%edx) - mov 12(%ebp),%eax - mov %eax,RNT_TSC_BASE+4(%edx) +/* void _rtc_nanotime_adjust( + uint64_t tsc_base_delta, + rtc_nanotime_t *dst); +*/ + .globl EXT(_rtc_nanotime_adjust) + .align FALIGN - mov 24(%ebp),%eax - mov %eax,RNT_SCALE(%edx) +LEXT(_rtc_nanotime_adjust) + mov 12(%esp),%edx /* ptr to rtc_nanotime_info */ + + movl RNT_GENERATION(%edx),%ecx /* get current generation */ + movl $0,RNT_GENERATION(%edx) /* flag data as being updated */ - mov 28(%ebp),%eax - mov %eax,RNT_SHIFT(%edx) + movl 4(%esp),%eax /* get lower 32-bits of delta */ + addl %eax,RNT_TSC_BASE(%edx) + adcl $0,RNT_TSC_BASE+4(%edx) /* propagate carry */ - mov 16(%ebp),%eax - mov %eax,RNT_NS_BASE(%edx) - mov 20(%ebp),%eax - mov %eax,RNT_NS_BASE+4(%edx) - - incl %esi /* next generation */ - jnz 1f - incl %esi /* skip 0, which is a flag */ -1: movl %esi,RNT_GENERATION(%edx) /* update generation and make usable */ + incl %ecx /* next generation */ + jnz 1f + incl %ecx /* skip 0, which is a flag */ +1: movl %ecx,RNT_GENERATION(%edx) /* update generation and make usable */ - pop %esi - pop %ebp - ret + ret /* unint64_t _rtc_nanotime_read( rtc_nanotime_t *rntp, int slow ); @@ -217,30 +206,7 @@ LEXT(_rtc_nanotime_read) jnz Lslow /* Processor whose TSC frequency is faster than SLOW_TSC_THRESHOLD */ -0: - movl RNT_GENERATION(%edi),%esi /* get generation (0 if being changed) */ - testl %esi,%esi /* if being changed, loop until stable */ - jz 0b - - rdtsc /* get TSC in %edx:%eax */ - subl RNT_TSC_BASE(%edi),%eax - sbbl RNT_TSC_BASE+4(%edi),%edx - - movl RNT_SCALE(%edi),%ecx - - movl %edx,%ebx - mull %ecx - movl %ebx,%eax - movl %edx,%ebx - mull %ecx - addl %ebx,%eax - adcl $0,%edx - - addl RNT_NS_BASE(%edi),%eax - adcl RNT_NS_BASE+4(%edi),%edx - - cmpl RNT_GENERATION(%edi),%esi /* have the parameters changed? */ - jne 0b /* yes, loop until stable */ + PAL_RTC_NANOTIME_READ_FAST() popl %ebx popl %edi @@ -256,7 +222,9 @@ Lslow: pushl %esi /* save generation */ pushl RNT_SHIFT(%edi) /* save low 32 bits of tscFreq */ - rdtsc /* get TSC in %edx:%eax */ + lfence + rdtsc /* get TSC in %edx:%eax */ + lfence subl RNT_TSC_BASE(%edi),%eax sbbl RNT_TSC_BASE+4(%edi),%edx @@ -302,3 +270,42 @@ Lslow: pop %ebp ret /* result in edx:eax */ + + +/* + * Timing routines. + */ +Entry(timer_update) + movl 4(%esp),%ecx + movl 8(%esp),%eax + movl 12(%esp),%edx + movl %eax,TIMER_HIGHCHK(%ecx) + movl %edx,TIMER_LOW(%ecx) + movl %eax,TIMER_HIGH(%ecx) + ret + +Entry(timer_grab) + movl 4(%esp),%ecx +0: movl TIMER_HIGH(%ecx),%edx + movl TIMER_LOW(%ecx),%eax + cmpl TIMER_HIGHCHK(%ecx),%edx + jne 0b + ret + + +Entry(call_continuation) + movl S_ARG0,%eax /* get continuation */ + movl S_ARG1,%edx /* continuation param */ + movl S_ARG2,%ecx /* wait result */ + movl %gs:CPU_KERNEL_STACK,%esp /* pop the stack */ + xorl %ebp,%ebp /* zero frame pointer */ + subl $8,%esp /* align the stack */ + pushl %ecx + pushl %edx + call *%eax /* call continuation */ + addl $16,%esp + movl %gs:CPU_ACTIVE_THREAD,%eax + pushl %eax + call EXT(thread_terminate) + +