strlen_user.S 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1996, 1998, 1999, 2004 by Ralf Baechle
  7. * Copyright (C) 1999 Silicon Graphics, Inc.
  8. * Copyright (C) 2011 MIPS Technologies, Inc.
  9. */
  10. #include <asm/asm.h>
  11. #include <asm/asm-offsets.h>
  12. #include <asm/export.h>
  13. #include <asm/regdef.h>
  14. #define EX(insn,reg,addr,handler) \
  15. 9: insn reg, addr; \
  16. .section __ex_table,"a"; \
  17. PTR 9b, handler; \
  18. .previous
  19. /*
  20. * Return the size of a string (including the ending 0)
  21. *
  22. * Return 0 for error
  23. */
  24. .macro __BUILD_STRLEN_ASM func
  25. LEAF(__strlen_\func\()_asm)
  26. LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok?
  27. and v0, a0
  28. bnez v0, .Lfault\@
  29. move v0, a0
  30. .ifeqs "\func", "kernel"
  31. 1: EX(lbu, v1, (v0), .Lfault\@)
  32. .else
  33. 1: EX(lbue, v1, (v0), .Lfault\@)
  34. .endif
  35. PTR_ADDIU v0, 1
  36. bnez v1, 1b
  37. PTR_SUBU v0, a0
  38. jr ra
  39. END(__strlen_\func\()_asm)
  40. .Lfault\@: move v0, zero
  41. jr ra
  42. .endm
  43. #ifndef CONFIG_EVA
  44. /* Set aliases */
  45. .global __strlen_user_asm
  46. .set __strlen_user_asm, __strlen_kernel_asm
  47. EXPORT_SYMBOL(__strlen_user_asm)
  48. #endif
  49. __BUILD_STRLEN_ASM kernel
  50. EXPORT_SYMBOL(__strlen_kernel_asm)
  51. #ifdef CONFIG_EVA
  52. .set push
  53. .set eva
  54. __BUILD_STRLEN_ASM user
  55. .set pop
  56. EXPORT_SYMBOL(__strlen_user_asm)
  57. #endif