Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/lib/copy_from_user.S |
| 3 | * |
| 4 | * Author: Nicolas Pitre |
| 5 | * Created: Sep 29, 2005 |
| 6 | * Copyright: MontaVista Software, Inc. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/linkage.h> |
| 14 | #include <asm/assembler.h> |
| 15 | |
| 16 | /* |
| 17 | * Prototype: |
| 18 | * |
Russell King | 02fcb97 | 2006-06-21 14:44:52 +0100 | [diff] [blame] | 19 | * size_t __copy_from_user(void *to, const void *from, size_t n) |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 20 | * |
| 21 | * Purpose: |
| 22 | * |
| 23 | * copy a block to kernel memory from user memory |
| 24 | * |
| 25 | * Params: |
| 26 | * |
| 27 | * to = kernel memory |
| 28 | * from = user memory |
| 29 | * n = number of bytes to copy |
| 30 | * |
| 31 | * Return value: |
| 32 | * |
| 33 | * Number of bytes NOT copied. |
| 34 | */ |
| 35 | |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 36 | #ifndef CONFIG_THUMB2_KERNEL |
| 37 | #define LDR1W_SHIFT 0 |
| 38 | #else |
| 39 | #define LDR1W_SHIFT 1 |
| 40 | #endif |
| 41 | #define STR1W_SHIFT 0 |
| 42 | |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 43 | .macro ldr1w ptr reg abort |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 44 | ldrusr \reg, \ptr, 4, abort=\abort |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 45 | .endm |
| 46 | |
| 47 | .macro ldr4w ptr reg1 reg2 reg3 reg4 abort |
| 48 | ldr1w \ptr, \reg1, \abort |
| 49 | ldr1w \ptr, \reg2, \abort |
| 50 | ldr1w \ptr, \reg3, \abort |
| 51 | ldr1w \ptr, \reg4, \abort |
| 52 | .endm |
| 53 | |
| 54 | .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort |
| 55 | ldr4w \ptr, \reg1, \reg2, \reg3, \reg4, \abort |
| 56 | ldr4w \ptr, \reg5, \reg6, \reg7, \reg8, \abort |
| 57 | .endm |
| 58 | |
| 59 | .macro ldr1b ptr reg cond=al abort |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 60 | ldrusr \reg, \ptr, 1, \cond, abort=\abort |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 61 | .endm |
| 62 | |
| 63 | .macro str1w ptr reg abort |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 64 | W(str) \reg, [\ptr], #4 |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 65 | .endm |
| 66 | |
| 67 | .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort |
| 68 | stmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8} |
| 69 | .endm |
| 70 | |
| 71 | .macro str1b ptr reg cond=al abort |
| 72 | str\cond\()b \reg, [\ptr], #1 |
| 73 | .endm |
| 74 | |
| 75 | .macro enter reg1 reg2 |
| 76 | mov r3, #0 |
| 77 | stmdb sp!, {r0, r2, r3, \reg1, \reg2} |
| 78 | .endm |
| 79 | |
| 80 | .macro exit reg1 reg2 |
| 81 | add sp, sp, #8 |
| 82 | ldmfd sp!, {r0, \reg1, \reg2} |
| 83 | .endm |
| 84 | |
| 85 | .text |
| 86 | |
Russell King | 02fcb97 | 2006-06-21 14:44:52 +0100 | [diff] [blame] | 87 | ENTRY(__copy_from_user) |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 88 | |
| 89 | #include "copy_template.S" |
| 90 | |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 91 | ENDPROC(__copy_from_user) |
| 92 | |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 93 | .section .fixup,"ax" |
| 94 | .align 0 |
| 95 | copy_abort_preamble |
| 96 | ldmfd sp!, {r1, r2} |
| 97 | sub r3, r0, r1 |
| 98 | rsb r1, r3, r2 |
| 99 | str r1, [sp] |
| 100 | bl __memzero |
| 101 | ldr r0, [sp], #4 |
| 102 | copy_abort_end |
| 103 | .previous |
| 104 | |