Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/lib/csumpartialcopyuser.S |
| 3 | * |
| 4 | * Copyright (C) 1995-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 | * 27/03/03 Ian Molton Clean up CONFIG_CPU |
| 11 | * |
| 12 | */ |
| 13 | #include <linux/linkage.h> |
| 14 | #include <asm/assembler.h> |
| 15 | #include <asm/errno.h> |
Sam Ravnborg | e6ae744 | 2005-09-09 21:08:59 +0200 | [diff] [blame] | 16 | #include <asm/asm-offsets.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | .text |
| 19 | |
| 20 | .macro save_regs |
Catalin Marinas | 22acc4e | 2008-08-29 18:31:27 +0100 | [diff] [blame] | 21 | stmfd sp!, {r1, r2, r4 - r8, lr} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | .endm |
| 23 | |
Catalin Marinas | 90303b1 | 2006-01-12 16:53:51 +0000 | [diff] [blame] | 24 | .macro load_regs |
Catalin Marinas | 22acc4e | 2008-08-29 18:31:27 +0100 | [diff] [blame] | 25 | ldmfd sp!, {r1, r2, r4 - r8, pc} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | .endm |
| 27 | |
| 28 | .macro load1b, reg1 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 29 | ldrusr \reg1, r0, 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | .endm |
| 31 | |
| 32 | .macro load2b, reg1, reg2 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 33 | ldrusr \reg1, r0, 1 |
| 34 | ldrusr \reg2, r0, 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | .endm |
| 36 | |
| 37 | .macro load1l, reg1 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 38 | ldrusr \reg1, r0, 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | .endm |
| 40 | |
| 41 | .macro load2l, reg1, reg2 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 42 | ldrusr \reg1, r0, 4 |
| 43 | ldrusr \reg2, r0, 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | .endm |
| 45 | |
| 46 | .macro load4l, reg1, reg2, reg3, reg4 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 47 | ldrusr \reg1, r0, 4 |
| 48 | ldrusr \reg2, r0, 4 |
| 49 | ldrusr \reg3, r0, 4 |
| 50 | ldrusr \reg4, r0, 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | .endm |
| 52 | |
| 53 | /* |
| 54 | * unsigned int |
| 55 | * csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *err_ptr) |
| 56 | * r0 = src, r1 = dst, r2 = len, r3 = sum, [sp] = *err_ptr |
| 57 | * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT |
| 58 | */ |
| 59 | |
| 60 | #define FN_ENTRY ENTRY(csum_partial_copy_from_user) |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 61 | #define FN_EXIT ENDPROC(csum_partial_copy_from_user) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | #include "csumpartialcopygeneric.S" |
| 64 | |
| 65 | /* |
| 66 | * FIXME: minor buglet here |
| 67 | * We don't return the checksum for the data present in the buffer. To do |
| 68 | * so properly, we would have to add in whatever registers were loaded before |
| 69 | * the fault, which, with the current asm above is not predictable. |
| 70 | */ |
| 71 | .section .fixup,"ax" |
| 72 | .align 4 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 73 | 9001: mov r4, #-EFAULT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | ldr r5, [fp, #4] @ *err_ptr |
| 75 | str r4, [r5] |
| 76 | ldmia sp, {r1, r2} @ retrieve dst, len |
| 77 | add r2, r2, r1 |
| 78 | mov r0, #0 @ zero the buffer |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 79 | 9002: teq r2, r1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | strneb r0, [r1], #1 |
Catalin Marinas | 8b59278 | 2009-07-24 12:32:57 +0100 | [diff] [blame] | 81 | bne 9002b |
Catalin Marinas | 90303b1 | 2006-01-12 16:53:51 +0000 | [diff] [blame] | 82 | load_regs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | .previous |