xref: /linux/arch/arm/lib/clear_user.S (revision f3a8b6645dc2e60d11f20c1c23afd964ff4e55ae)
1/*
2 *  linux/arch/arm/lib/clear_user.S
3 *
4 *  Copyright (C) 1995, 1996,1997,1998 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/unwind.h>
13#include <asm/export.h>
14
15		.text
16
17/* Prototype: unsigned long arm_clear_user(void *addr, size_t sz)
18 * Purpose  : clear some user memory
19 * Params   : addr - user memory address to clear
20 *          : sz   - number of bytes to clear
21 * Returns  : number of bytes NOT cleared
22 */
23ENTRY(__clear_user_std)
24WEAK(arm_clear_user)
25UNWIND(.fnstart)
26UNWIND(.save {r1, lr})
27		stmfd	sp!, {r1, lr}
28		mov	r2, #0
29		cmp	r1, #4
30		blt	2f
31		ands	ip, r0, #3
32		beq	1f
33		cmp	ip, #2
34		strusr	r2, r0, 1
35		strusr	r2, r0, 1, le
36		strusr	r2, r0, 1, lt
37		rsb	ip, ip, #4
38		sub	r1, r1, ip		@  7  6  5  4  3  2  1
391:		subs	r1, r1, #8		@ -1 -2 -3 -4 -5 -6 -7
40		strusr	r2, r0, 4, pl, rept=2
41		bpl	1b
42		adds	r1, r1, #4		@  3  2  1  0 -1 -2 -3
43		strusr	r2, r0, 4, pl
442:		tst	r1, #2			@ 1x 1x 0x 0x 1x 1x 0x
45		strusr	r2, r0, 1, ne, rept=2
46		tst	r1, #1			@ x1 x0 x1 x0 x1 x0 x1
47		it	ne			@ explicit IT needed for the label
48USER(		strnebt	r2, [r0])
49		mov	r0, #0
50		ldmfd	sp!, {r1, pc}
51UNWIND(.fnend)
52ENDPROC(arm_clear_user)
53ENDPROC(__clear_user_std)
54#ifndef CONFIG_UACCESS_WITH_MEMCPY
55EXPORT_SYMBOL(arm_clear_user)
56#endif
57
58		.pushsection .text.fixup,"ax"
59		.align	0
609001:		ldmfd	sp!, {r0, pc}
61		.popsection
62
63