X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0a7de7458d150b5d4dffc935ba399be265ef0a1a..cb3231590a3c94ab4375e2228bd5e86b0cf1ad7e:/osfmk/kern/misc_protos.h diff --git a/osfmk/kern/misc_protos.h b/osfmk/kern/misc_protos.h index c1dee4267..a2585e473 100644 --- a/osfmk/kern/misc_protos.h +++ b/osfmk/kern/misc_protos.h @@ -86,17 +86,44 @@ extern int testbit( int which, int *bitmap); -/* Move an aligned 32 or 64-bit word from user space to kernel space +/* + * Move an aligned 32 or 64-bit word from user space to kernel space * using a single read instruction + */ +extern int copyin_atomic32( + const user_addr_t user_addr, + uint32_t *kernel_addr); + +extern int copyin_atomic64( + const user_addr_t user_addr, + uint64_t *kernel_addr); + +/* + * Does an atomic copyin at the specified user_address and compares + * it to the passed in value, and if it matches, waits. * - * when reading a 32-bit word, the value is 0-extended into the kernel space - * 64-bit buffer passed as `kernel_addr` - * (think `*kernel_addr = *(uint32_t *)user_addr`) + * This is used to implement adaptive spinning for userspace synchronization + * + * Returns: + * 0: the value mached, and it paused efficiently for the platform + * ESTALE: the value didn't match, and it returned immediately + * other: the copyin failed (EFAULT, EINVAL, ...) */ -extern int copyin_word( +extern int copyin_atomic32_wait_if_equals( const user_addr_t user_addr, - uint64_t *kernel_addr, - vm_size_t nbytes); + uint32_t value); + +/* + * Move a 32 or 64-bit word from kernel space to user space + * using a single write instruction + */ +extern int copyout_atomic32( + uint32_t u32, + user_addr_t user_addr); + +extern int copyout_atomic64( + uint64_t u64, + user_addr_t user_addr); /* Move a NUL-terminated string from a user space to kernel space */ extern int copyinstr( @@ -121,9 +148,6 @@ extern int copyoutmsg( extern void inval_copy_windows(thread_t); extern void copy_window_fault(thread_t, vm_map_t, int); -extern int copyin_validate(const user_addr_t, uintptr_t, vm_size_t); -extern int copyout_validate(uintptr_t, const user_addr_t, vm_size_t); - extern int sscanf(const char *input, const char *fmt, ...) __scanflike(2, 3); /* sprintf() is being deprecated. Please use snprintf() instead. */