Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 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 | |
| 13 | .text |
| 14 | |
Russell King | 02fcb97 | 2006-06-21 14:44:52 +0100 | [diff] [blame] | 15 | /* Prototype: int __clear_user(void *addr, size_t sz) |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 16 | * Purpose : clear some user memory |
| 17 | * Params : addr - user memory address to clear |
| 18 | * : sz - number of bytes to clear |
| 19 | * Returns : number of bytes NOT cleared |
| 20 | */ |
Nicolas Pitre | a1f9884 | 2009-03-08 22:34:45 -0400 | [diff] [blame^] | 21 | ENTRY(__clear_user_std) |
| 22 | WEAK(__clear_user) |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 23 | stmfd sp!, {r1, lr} |
| 24 | mov r2, #0 |
| 25 | cmp r1, #4 |
| 26 | blt 2f |
| 27 | ands ip, r0, #3 |
| 28 | beq 1f |
| 29 | cmp ip, #2 |
| 30 | USER( strbt r2, [r0], #1) |
| 31 | USER( strlebt r2, [r0], #1) |
| 32 | USER( strltbt r2, [r0], #1) |
| 33 | rsb ip, ip, #4 |
| 34 | sub r1, r1, ip @ 7 6 5 4 3 2 1 |
| 35 | 1: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7 |
| 36 | USER( strplt r2, [r0], #4) |
| 37 | USER( strplt r2, [r0], #4) |
| 38 | bpl 1b |
| 39 | adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3 |
| 40 | USER( strplt r2, [r0], #4) |
| 41 | 2: tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x |
| 42 | USER( strnebt r2, [r0], #1) |
| 43 | USER( strnebt r2, [r0], #1) |
| 44 | tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1 |
Catalin Marinas | 9c23e5f | 2008-08-29 18:31:21 +0100 | [diff] [blame] | 45 | USER( strnebt r2, [r0]) |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 46 | mov r0, #0 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 47 | ldmfd sp!, {r1, pc} |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 48 | ENDPROC(__clear_user) |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 49 | |
| 50 | .section .fixup,"ax" |
| 51 | .align 0 |
Russell King | 1b93a71 | 2006-06-25 11:23:45 +0100 | [diff] [blame] | 52 | 9001: ldmfd sp!, {r0, pc} |
Nicolas Pitre | a0c6fdb | 2005-11-01 19:52:22 +0000 | [diff] [blame] | 53 | .previous |
| 54 | |