strlen_user.S 915 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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/regdef.h>
  13. #define EX(insn,reg,addr,handler) \
  14. 9: insn reg, addr; \
  15. .section __ex_table,"a"; \
  16. PTR 9b, handler; \
  17. .previous
  18. /*
  19. * Return the size of a string (including the ending 0)
  20. *
  21. * Return 0 for error
  22. */
  23. LEAF(__strlen_user_asm)
  24. LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok?
  25. and v0, a0
  26. bnez v0, .Lfault
  27. FEXPORT(__strlen_user_nocheck_asm)
  28. move v0, a0
  29. 1: EX(lbu, v1, (v0), .Lfault)
  30. PTR_ADDIU v0, 1
  31. bnez v1, 1b
  32. PTR_SUBU v0, a0
  33. jr ra
  34. END(__strlen_user_asm)
  35. .Lfault: move v0, zero
  36. jr ra