Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/lib/copy_to_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_to_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 user memory from kernel memory |
| 24 | * |
| 25 | * Params: |
| 26 | * |
| 27 | * to = user memory |
| 28 | * from = kernel 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 | #define LDR1W_SHIFT 0 |
| 37 | #ifndef CONFIG_THUMB2_KERNEL |
| 38 | #define STR1W_SHIFT 0 |
| 39 | #else |
| 40 | #define STR1W_SHIFT 1 |
| 41 | #endif |
| 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 | W(ldr) \reg, [\ptr], #4 |
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 | ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4} |
| 49 | .endm |
| 50 | |
| 51 | .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort |
| 52 | ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8} |
| 53 | .endm |
| 54 | |
| 55 | .macro ldr1b ptr reg cond=al abort |
| 56 | ldr\cond\()b \reg, [\ptr], #1 |
| 57 | .endm |
| 58 | |
| 59 | .macro str1w ptr reg abort |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 60 | strusr \reg, \ptr, 4, abort=\abort |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 61 | .endm |
| 62 | |
| 63 | .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort |
| 64 | str1w \ptr, \reg1, \abort |
| 65 | str1w \ptr, \reg2, \abort |
| 66 | str1w \ptr, \reg3, \abort |
| 67 | str1w \ptr, \reg4, \abort |
| 68 | str1w \ptr, \reg5, \abort |
| 69 | str1w \ptr, \reg6, \abort |
| 70 | str1w \ptr, \reg7, \abort |
| 71 | str1w \ptr, \reg8, \abort |
| 72 | .endm |
| 73 | |
| 74 | .macro str1b ptr reg cond=al abort |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 75 | strusr \reg, \ptr, 1, \cond, abort=\abort |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 76 | .endm |
| 77 | |
| 78 | .macro enter reg1 reg2 |
| 79 | mov r3, #0 |
| 80 | stmdb sp!, {r0, r2, r3, \reg1, \reg2} |
| 81 | .endm |
| 82 | |
| 83 | .macro exit reg1 reg2 |
| 84 | add sp, sp, #8 |
| 85 | ldmfd sp!, {r0, \reg1, \reg2} |
| 86 | .endm |
| 87 | |
| 88 | .text |
| 89 | |
Nicolas Pitre | a1f9884 | 2009-03-08 22:34:45 -0400 | [diff] [blame] | 90 | ENTRY(__copy_to_user_std) |
| 91 | WEAK(__copy_to_user) |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 92 | |
| 93 | #include "copy_template.S" |
| 94 | |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 95 | ENDPROC(__copy_to_user) |
Catalin Marinas | e814d82 | 2010-05-07 10:52:32 +0100 | [diff] [blame] | 96 | ENDPROC(__copy_to_user_std) |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 97 | |
Russell King | 4260415 | 2010-04-19 10:15:03 +0100 | [diff] [blame] | 98 | .pushsection .fixup,"ax" |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 99 | .align 0 |
| 100 | copy_abort_preamble |
| 101 | ldmfd sp!, {r1, r2, r3} |
| 102 | sub r0, r0, r1 |
| 103 | rsb r0, r0, r2 |
| 104 | copy_abort_end |
Russell King | 4260415 | 2010-04-19 10:15:03 +0100 | [diff] [blame] | 105 | .popsection |
Nicolas Pitre | fadab09 | 2005-11-01 19:52:24 +0000 | [diff] [blame] | 106 | |