#elif defined(__arm__)
#include <mach/arm/syscall_sw.h>
+#include <mach/arm/traps.h>
/*
* If userspace access to the timebase is supported (indicated through the commpage),
movw ip, #((_COMM_PAGE_TIMEBASE_OFFSET) & 0x0000FFFF)
movt ip, #(((_COMM_PAGE_TIMEBASE_OFFSET) >> 16) & 0x0000FFFF)
ldrb r0, [ip, #((_COMM_PAGE_USER_TIMEBASE) - (_COMM_PAGE_TIMEBASE_OFFSET))]
- cmp r0, #0 // Are userspace reads supported?
+ cmp r0, #USER_TIMEBASE_NONE // Are userspace reads supported?
beq _mach_absolute_time_kernel // If not, go to the kernel
- isb // Prevent speculation on CNTPCT across calls
+ isb // Prevent speculation on CNTVCT across calls
// (see ARMV7C.b section B8.1.2, ARMv8 section D6.1.2)
push {r4, r5, r7, lr} // Push a frame
add r7, sp, #8
.align 2
.globl _mach_absolute_time_kernel
_mach_absolute_time_kernel:
- mov r12, #-3 // Load the magic MAT number
+ mov r12, #MACH_ARM_TRAP_ABSTIME // Load the magic MAT number
swi #SWI_SYSCALL
bx lr
.align 2
.globl _mach_continuous_time_kernel
_mach_continuous_time_kernel:
- mov r12, #-4 // Load the magic MCT number
+ mov r12, #MACH_ARM_TRAP_CONTTIME // Load the magic MCT number
swi #SWI_SYSCALL
bx lr
#elif defined(__arm64__)
#include <mach/arm/syscall_sw.h>
+#include <mach/arm/traps.h>
/*
* If userspace access to the timebase is supported (indicated through the commpage),
* read the register. If the offset changes, we have gone to sleep in the midst of
* doing a read. This case should be exceedingly rare, but could result in a terribly
* inaccurate result, so we need to get a fresh timebase value.
- *
- * Note that the commpage address construction expects our top 2 bytes to be 0xFFFF.
- * If this changes (i.e, we significantly relocate the commpage), this logic will need
- * to change as well (use 4 movk instructions rather than cheating with the movn).
*/
.text
.align 2
.globl _mach_absolute_time
_mach_absolute_time:
- movn x3, #(~((_COMM_PAGE_TIMEBASE_OFFSET) >> 32) & 0x000000000000FFFF), lsl #32
+ movk x3, #(((_COMM_PAGE_TIMEBASE_OFFSET) >> 48) & 0x000000000000FFFF), lsl #48
+ movk x3, #(((_COMM_PAGE_TIMEBASE_OFFSET) >> 32) & 0x000000000000FFFF), lsl #32
movk x3, #(((_COMM_PAGE_TIMEBASE_OFFSET) >> 16) & 0x000000000000FFFF), lsl #16
movk x3, #((_COMM_PAGE_TIMEBASE_OFFSET) & 0x000000000000FFFF)
ldrb w2, [x3, #((_COMM_PAGE_USER_TIMEBASE) - (_COMM_PAGE_TIMEBASE_OFFSET))]
- cmp x2, #0 // Are userspace reads supported?
+ cmp x2, #USER_TIMEBASE_NONE // Are userspace reads supported?
b.eq _mach_absolute_time_kernel // If not, go to the kernel
- isb // Prevent speculation on CNTPCT across calls
+ isb // Prevent speculation on CNTVCT across calls
// (see ARMV7C.b section B8.1.2, ARMv8 section D6.1.2)
L_mach_absolute_time_user:
ldr x1, [x3] // Load the offset
- mrs x0, CNTPCT_EL0 // Read the timebase
+ mrs x0, CNTVCT_EL0 // Read the timebase
ldr x2, [x3] // Load the offset
cmp x1, x2 // Compare our offset values...
b.ne L_mach_absolute_time_user // If they changed, try again
add x0, x0, x1 // Construct mach_absolute_time
- ret
+ ret
+
+
.text
.align 2
.globl _mach_absolute_time_kernel
_mach_absolute_time_kernel:
- mov w16, #-3 // Load the magic MAT number
+ mov w16, #MACH_ARM_TRAP_ABSTIME // Load the magic MAT number
svc #SWI_SYSCALL
ret
.align 2
.globl _mach_continuous_time_kernel
_mach_continuous_time_kernel:
- mov w16, #-4 // Load the magic MCT number
+ mov w16, #MACH_ARM_TRAP_CONTTIME // Load the magic MCT number
svc #SWI_SYSCALL
ret