2 * include/asm-xtensa/uaccess.h
4 * User space memory access functions
6 * These routines provide basic accessing functions to the user memory
7 * space for the kernel. This header file provides functions such as:
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
13 * Copyright (C) 2001 - 2005 Tensilica Inc.
16 #ifndef _XTENSA_ASM_UACCESS_H
17 #define _XTENSA_ASM_UACCESS_H
19 #include <linux/errno.h>
20 #include <asm/types.h>
22 #include <asm/current.h>
23 #include <asm/asm-offsets.h>
24 #include <asm/processor.h>
27 * These assembly macros mirror the C macros in asm/uaccess.h. They
28 * should always have identical functionality. See
29 * arch/xtensa/kernel/sys.S for usage.
35 #define get_ds (KERNEL_DS)
38 * get_fs reads current->thread.current_ds into a register.
43 * <ad> contains current->thread.current_ds
47 #if THREAD_CURRENT_DS > 1020
48 addi
\ad
, \ad
, TASK_THREAD
49 l32i
\ad
, \ad
, THREAD_CURRENT_DS
- TASK_THREAD
51 l32i
\ad
, \ad
, THREAD_CURRENT_DS
56 * set_fs sets current->thread.current_ds to some value.
58 * <at> anything (temp register)
62 * <at> destroyed (actually, current)
63 * <av> preserved, value to write
65 .macro set_fs at
, av
, sp
67 s32i
\av
, \at
, THREAD_CURRENT_DS
71 * kernel_ok determines whether we should bypass addr/size checking.
72 * See the equivalent C-macro version below for clarity.
73 * On success, kernel_ok branches to a label indicated by parameter
74 * <success>. This implies that the macro falls through to the next
75 * insruction on an error.
77 * Note that while this macro can be used independently, we designed
78 * in for optimal use in the access_ok macro below (i.e., we fall
82 * <at> anything (temp register)
83 * <success> label to branch to on success; implies
84 * fall-through macro on error
87 * <at> destroyed (actually, current->thread.current_ds)
90 #if ((KERNEL_DS != 0) || (USER_DS == 0))
91 # error Assembly macro kernel_ok fails
93 .macro kernel_ok at
, sp
, success
99 * user_ok determines whether the access to user-space memory is allowed.
100 * See the equivalent C-macro version below for clarity.
102 * On error, user_ok branches to a label indicated by parameter
103 * <error>. This implies that the macro falls through to the next
104 * instruction on success.
106 * Note that while this macro can be used independently, we designed
107 * in for optimal use in the access_ok macro below (i.e., we fall
108 * through on success).
111 * <aa> register containing memory address
112 * <as> register containing memory size
114 * <error> label to branch to on error; implies fall-through
119 * <at> destroyed (actually, (TASK_SIZE + 1 - size))
121 .macro user_ok aa
, as
, at
, error
122 movi
\at
, __XTENSA_UL_CONST(TASK_SIZE
)
123 bgeu
\as
, \at
, \error
125 bgeu
\aa
, \at
, \error
129 * access_ok determines whether a memory access is allowed. See the
130 * equivalent C-macro version below for clarity.
132 * On error, access_ok branches to a label indicated by parameter
133 * <error>. This implies that the macro falls through to the next
134 * instruction on success.
136 * Note that we assume success is the common case, and we optimize the
137 * branch fall-through case on success.
140 * <aa> register containing memory address
141 * <as> register containing memory size
144 * <error> label to branch to on error; implies fall-through
151 .macro access_ok aa
, as
, at
, sp
, error
152 kernel_ok
\at
, \sp
, .Laccess_ok_\@
153 user_ok
\aa
, \as
, \at
, \error
157 #endif /* _XTENSA_ASM_UACCESS_H */