1*76580237SAl Viro /* 2*76580237SAl Viro * include/asm-xtensa/uaccess.h 3*76580237SAl Viro * 4*76580237SAl Viro * User space memory access functions 5*76580237SAl Viro * 6*76580237SAl Viro * These routines provide basic accessing functions to the user memory 7*76580237SAl Viro * space for the kernel. This header file provides functions such as: 8*76580237SAl Viro * 9*76580237SAl Viro * This file is subject to the terms and conditions of the GNU General Public 10*76580237SAl Viro * License. See the file "COPYING" in the main directory of this archive 11*76580237SAl Viro * for more details. 12*76580237SAl Viro * 13*76580237SAl Viro * Copyright (C) 2001 - 2005 Tensilica Inc. 14*76580237SAl Viro */ 15*76580237SAl Viro 16*76580237SAl Viro #ifndef _XTENSA_ASM_UACCESS_H 17*76580237SAl Viro #define _XTENSA_ASM_UACCESS_H 18*76580237SAl Viro 19*76580237SAl Viro #include <linux/errno.h> 20*76580237SAl Viro #include <asm/types.h> 21*76580237SAl Viro 22*76580237SAl Viro #include <asm/current.h> 23*76580237SAl Viro #include <asm/asm-offsets.h> 24*76580237SAl Viro #include <asm/processor.h> 25*76580237SAl Viro 26*76580237SAl Viro /* 27*76580237SAl Viro * user_ok determines whether the access to user-space memory is allowed. 28*76580237SAl Viro * See the equivalent C-macro version below for clarity. 29*76580237SAl Viro * 30*76580237SAl Viro * On error, user_ok branches to a label indicated by parameter 31*76580237SAl Viro * <error>. This implies that the macro falls through to the next 32*76580237SAl Viro * instruction on success. 33*76580237SAl Viro * 34*76580237SAl Viro * Note that while this macro can be used independently, we designed 35*76580237SAl Viro * in for optimal use in the access_ok macro below (i.e., we fall 36*76580237SAl Viro * through on success). 37*76580237SAl Viro * 38*76580237SAl Viro * On Entry: 39*76580237SAl Viro * <aa> register containing memory address 40*76580237SAl Viro * <as> register containing memory size 41*76580237SAl Viro * <at> temp register 42*76580237SAl Viro * <error> label to branch to on error; implies fall-through 43*76580237SAl Viro * macro on success 44*76580237SAl Viro * On Exit: 45*76580237SAl Viro * <aa> preserved 46*76580237SAl Viro * <as> preserved 47*76580237SAl Viro * <at> destroyed (actually, (TASK_SIZE + 1 - size)) 48*76580237SAl Viro */ 49*76580237SAl Viro .macro user_ok aa, as, at, error 50*76580237SAl Viro movi \at, __XTENSA_UL_CONST(TASK_SIZE) 51*76580237SAl Viro bgeu \as, \at, \error 52*76580237SAl Viro sub \at, \at, \as 53*76580237SAl Viro bgeu \aa, \at, \error 54*76580237SAl Viro .endm 55*76580237SAl Viro 56*76580237SAl Viro /* 57*76580237SAl Viro * access_ok determines whether a memory access is allowed. See the 58*76580237SAl Viro * equivalent C-macro version below for clarity. 59*76580237SAl Viro * 60*76580237SAl Viro * On error, access_ok branches to a label indicated by parameter 61*76580237SAl Viro * <error>. This implies that the macro falls through to the next 62*76580237SAl Viro * instruction on success. 63*76580237SAl Viro * 64*76580237SAl Viro * Note that we assume success is the common case, and we optimize the 65*76580237SAl Viro * branch fall-through case on success. 66*76580237SAl Viro * 67*76580237SAl Viro * On Entry: 68*76580237SAl Viro * <aa> register containing memory address 69*76580237SAl Viro * <as> register containing memory size 70*76580237SAl Viro * <at> temp register 71*76580237SAl Viro * <sp> 72*76580237SAl Viro * <error> label to branch to on error; implies fall-through 73*76580237SAl Viro * macro on success 74*76580237SAl Viro * On Exit: 75*76580237SAl Viro * <aa> preserved 76*76580237SAl Viro * <as> preserved 77*76580237SAl Viro * <at> destroyed 78*76580237SAl Viro */ 79*76580237SAl Viro .macro access_ok aa, as, at, sp, error 80*76580237SAl Viro user_ok \aa, \as, \at, \error 81*76580237SAl Viro .Laccess_ok_\@: 82*76580237SAl Viro .endm 83*76580237SAl Viro 84*76580237SAl Viro #endif /* _XTENSA_ASM_UACCESS_H */ 85