asm-uaccess.h 2.3 KB

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