111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/**************************************************************************** 211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert **************************************************************************** 311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *** 411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *** This header was automatically generated from a Linux kernel header 511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *** of the same name, to make information necessary for userspace to 611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *** call into the kernel available to libc. It contains only constants, 711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *** structures, and macros generated from the original header, and thus, 811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *** contains no copyrightable information. 911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *** 1011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert **************************************************************************** 1111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert ****************************************************************************/ 1211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifndef _ASMARM_UACCESS_H 1311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define _ASMARM_UACCESS_H 1411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 1511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <linux/sched.h> 1611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <asm/errno.h> 1711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <asm/memory.h> 1811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <asm/domain.h> 1911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <asm/system.h> 2011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 2111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define VERIFY_READ 0 2211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define VERIFY_WRITE 1 2311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 2411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertstruct exception_table_entry 2511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert{ 2611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert unsigned long insn, fixup; 2711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert}; 2811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 2911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define KERNEL_DS 0x00000000 3011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define get_ds() (KERNEL_DS) 3111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 3211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define USER_DS KERNEL_DS 3311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 3411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define segment_eq(a,b) (1) 3511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __addr_ok(addr) (1) 3611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __range_ok(addr,size) (0) 3711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define get_fs() (KERNEL_DS) 3811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 3911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define get_user(x,p) __get_user(x,p) 4011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define put_user(x,p) __put_user(x,p) 4111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define access_ok(type,addr,size) (__range_ok(addr,size) == 0) 4211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __get_user(x,ptr) ({ long __gu_err = 0; __get_user_err((x),(ptr),__gu_err); __gu_err; }) 4311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __get_user_error(x,ptr,err) ({ __get_user_err((x),(ptr),err); (void) 0; }) 4411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __get_user_err(x,ptr,err) do { unsigned long __gu_addr = (unsigned long)(ptr); unsigned long __gu_val; __chk_user_ptr(ptr); switch (sizeof(*(ptr))) { case 1: __get_user_asm_byte(__gu_val,__gu_addr,err); break; case 2: __get_user_asm_half(__gu_val,__gu_addr,err); break; case 4: __get_user_asm_word(__gu_val,__gu_addr,err); break; default: (__gu_val) = __get_user_bad(); } (x) = (__typeof__(*(ptr)))__gu_val; } while (0) 4511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __get_user_asm_byte(x,addr,err) __asm__ __volatile__( "1: ldrbt %1,[%2],#0\n" "2:\n" " .section .fixup,\"ax\"\n" " .align 2\n" "3: mov %0, %3\n" " mov %1, #0\n" " b 2b\n" " .previous\n" " .section __ex_table,\"a\"\n" " .align 3\n" " .long 1b, 3b\n" " .previous" : "+r" (err), "=&r" (x) : "r" (addr), "i" (-EFAULT) : "cc") 4611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifndef __ARMEB__ 4711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __get_user_asm_half(x,__gu_addr,err) ({ unsigned long __b1, __b2; __get_user_asm_byte(__b1, __gu_addr, err); __get_user_asm_byte(__b2, __gu_addr + 1, err); (x) = __b1 | (__b2 << 8); }) 4811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#else 4911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __get_user_asm_half(x,__gu_addr,err) ({ unsigned long __b1, __b2; __get_user_asm_byte(__b1, __gu_addr, err); __get_user_asm_byte(__b2, __gu_addr + 1, err); (x) = (__b1 << 8) | __b2; }) 5011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif 5111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __get_user_asm_word(x,addr,err) __asm__ __volatile__( "1: ldrt %1,[%2],#0\n" "2:\n" " .section .fixup,\"ax\"\n" " .align 2\n" "3: mov %0, %3\n" " mov %1, #0\n" " b 2b\n" " .previous\n" " .section __ex_table,\"a\"\n" " .align 3\n" " .long 1b, 3b\n" " .previous" : "+r" (err), "=&r" (x) : "r" (addr), "i" (-EFAULT) : "cc") 5211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __put_user(x,ptr) ({ long __pu_err = 0; __put_user_err((x),(ptr),__pu_err); __pu_err; }) 5311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __put_user_error(x,ptr,err) ({ __put_user_err((x),(ptr),err); (void) 0; }) 5411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __put_user_err(x,ptr,err) do { unsigned long __pu_addr = (unsigned long)(ptr); __typeof__(*(ptr)) __pu_val = (x); __chk_user_ptr(ptr); switch (sizeof(*(ptr))) { case 1: __put_user_asm_byte(__pu_val,__pu_addr,err); break; case 2: __put_user_asm_half(__pu_val,__pu_addr,err); break; case 4: __put_user_asm_word(__pu_val,__pu_addr,err); break; case 8: __put_user_asm_dword(__pu_val,__pu_addr,err); break; default: __put_user_bad(); } } while (0) 5511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __put_user_asm_byte(x,__pu_addr,err) __asm__ __volatile__( "1: strbt %1,[%2],#0\n" "2:\n" " .section .fixup,\"ax\"\n" " .align 2\n" "3: mov %0, %3\n" " b 2b\n" " .previous\n" " .section __ex_table,\"a\"\n" " .align 3\n" " .long 1b, 3b\n" " .previous" : "+r" (err) : "r" (x), "r" (__pu_addr), "i" (-EFAULT) : "cc") 5611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifndef __ARMEB__ 5711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __put_user_asm_half(x,__pu_addr,err) ({ unsigned long __temp = (unsigned long)(x); __put_user_asm_byte(__temp, __pu_addr, err); __put_user_asm_byte(__temp >> 8, __pu_addr + 1, err); }) 5811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#else 5911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __put_user_asm_half(x,__pu_addr,err) ({ unsigned long __temp = (unsigned long)(x); __put_user_asm_byte(__temp >> 8, __pu_addr, err); __put_user_asm_byte(__temp, __pu_addr + 1, err); }) 6011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif 6111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __put_user_asm_word(x,__pu_addr,err) __asm__ __volatile__( "1: strt %1,[%2],#0\n" "2:\n" " .section .fixup,\"ax\"\n" " .align 2\n" "3: mov %0, %3\n" " b 2b\n" " .previous\n" " .section __ex_table,\"a\"\n" " .align 3\n" " .long 1b, 3b\n" " .previous" : "+r" (err) : "r" (x), "r" (__pu_addr), "i" (-EFAULT) : "cc") 6211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifndef __ARMEB__ 6311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __reg_oper0 "%R2" 6411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __reg_oper1 "%Q2" 6511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#else 6611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __reg_oper0 "%Q2" 6711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __reg_oper1 "%R2" 6811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif 6911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __put_user_asm_dword(x,__pu_addr,err) __asm__ __volatile__( "1: strt " __reg_oper1 ", [%1], #4\n" "2: strt " __reg_oper0 ", [%1], #0\n" "3:\n" " .section .fixup,\"ax\"\n" " .align 2\n" "4: mov %0, %3\n" " b 3b\n" " .previous\n" " .section __ex_table,\"a\"\n" " .align 3\n" " .long 1b, 4b\n" " .long 2b, 4b\n" " .previous" : "+r" (err), "+r" (__pu_addr) : "r" (x), "i" (-EFAULT) : "cc") 7011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0) 7111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0) 7211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __clear_user(addr,n) (memset((void __force *)addr, 0, n), 0) 7311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert 7411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __copy_to_user_inatomic __copy_to_user 7511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __copy_from_user_inatomic __copy_from_user 7611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define strlen_user(s) strnlen_user(s, ~0UL >> 1) 7711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif 78