• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * linux/arch/unicore32/lib/strnlen_user.S
4 *
5 * Code specific to PKUnity SoC and UniCore ISA
6 *
7 * Copyright (C) 2001-2010 GUAN Xue-tao
8 */
9#include <linux/linkage.h>
10#include <asm/assembler.h>
11#include <asm/errno.h>
12
13	.text
14	.align	5
15
16/* Prototype: unsigned long __strnlen_user(const char *str, long n)
17 * Purpose  : get length of a string in user memory
18 * Params   : str - address of string in user memory
19 * Returns  : length of string *including terminator*
20 *	      or zero on exception, or n + 1 if too long
21 */
22ENTRY(__strnlen_user)
23	mov	r2, r0
241:
25	ldrusr	r3, r0, 1
26	cxor.a	r3, #0
27	beq	2f
28	sub.a	r1, r1, #1
29	bne	1b
30	add	r0, r0, #1
312:	sub	r0, r0, r2
32	mov	pc, lr
33ENDPROC(__strnlen_user)
34
35	.pushsection .fixup,"ax"
36	.align	0
379001:	mov	r0, #0
38	mov	pc, lr
39	.popsection
40