Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mm/copypage-v3.c |
| 3 | * |
| 4 | * Copyright (C) 1995-1999 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/init.h> |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 11 | #include <linux/highmem.h> |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 12 | |
| 13 | /* |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 14 | * ARMv3 optimised copy_user_highpage |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 15 | * |
| 16 | * FIXME: do we need to handle cache stuff... |
| 17 | */ |
Uwe Kleine-König | 446c92b | 2009-03-12 18:03:16 +0100 | [diff] [blame] | 18 | static void __naked |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 19 | v3_copy_user_page(void *kto, const void *kfrom) |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 20 | { |
| 21 | asm("\n\ |
| 22 | stmfd sp!, {r4, lr} @ 2\n\ |
| 23 | mov r2, %2 @ 1\n\ |
| 24 | ldmia %0!, {r3, r4, ip, lr} @ 4+1\n\ |
| 25 | 1: stmia %1!, {r3, r4, ip, lr} @ 4\n\ |
| 26 | ldmia %0!, {r3, r4, ip, lr} @ 4+1\n\ |
| 27 | stmia %1!, {r3, r4, ip, lr} @ 4\n\ |
| 28 | ldmia %0!, {r3, r4, ip, lr} @ 4+1\n\ |
| 29 | stmia %1!, {r3, r4, ip, lr} @ 4\n\ |
| 30 | ldmia %0!, {r3, r4, ip, lr} @ 4\n\ |
| 31 | subs r2, r2, #1 @ 1\n\ |
| 32 | stmia %1!, {r3, r4, ip, lr} @ 4\n\ |
| 33 | ldmneia %0!, {r3, r4, ip, lr} @ 4\n\ |
| 34 | bne 1b @ 1\n\ |
| 35 | ldmfd sp!, {r4, pc} @ 3" |
| 36 | : |
| 37 | : "r" (kfrom), "r" (kto), "I" (PAGE_SIZE / 64)); |
| 38 | } |
| 39 | |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 40 | void v3_copy_user_highpage(struct page *to, struct page *from, |
| 41 | unsigned long vaddr) |
| 42 | { |
| 43 | void *kto, *kfrom; |
| 44 | |
| 45 | kto = kmap_atomic(to, KM_USER0); |
| 46 | kfrom = kmap_atomic(from, KM_USER1); |
| 47 | v3_copy_user_page(kto, kfrom); |
| 48 | kunmap_atomic(kfrom, KM_USER1); |
| 49 | kunmap_atomic(kto, KM_USER0); |
| 50 | } |
| 51 | |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 52 | /* |
| 53 | * ARMv3 optimised clear_user_page |
| 54 | * |
| 55 | * FIXME: do we need to handle cache stuff... |
| 56 | */ |
Russell King | 303c644 | 2008-10-31 16:32:19 +0000 | [diff] [blame] | 57 | void v3_clear_user_highpage(struct page *page, unsigned long vaddr) |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 58 | { |
Nicolas Pitre | 43ae286 | 2008-11-04 02:42:27 -0500 | [diff] [blame] | 59 | void *ptr, *kaddr = kmap_atomic(page, KM_USER0); |
| 60 | asm volatile("\n\ |
| 61 | mov r1, %2 @ 1\n\ |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 62 | mov r2, #0 @ 1\n\ |
| 63 | mov r3, #0 @ 1\n\ |
| 64 | mov ip, #0 @ 1\n\ |
| 65 | mov lr, #0 @ 1\n\ |
| 66 | 1: stmia %0!, {r2, r3, ip, lr} @ 4\n\ |
| 67 | stmia %0!, {r2, r3, ip, lr} @ 4\n\ |
| 68 | stmia %0!, {r2, r3, ip, lr} @ 4\n\ |
| 69 | stmia %0!, {r2, r3, ip, lr} @ 4\n\ |
| 70 | subs r1, r1, #1 @ 1\n\ |
Russell King | 303c644 | 2008-10-31 16:32:19 +0000 | [diff] [blame] | 71 | bne 1b @ 1" |
Nicolas Pitre | 43ae286 | 2008-11-04 02:42:27 -0500 | [diff] [blame] | 72 | : "=r" (ptr) |
| 73 | : "0" (kaddr), "I" (PAGE_SIZE / 64) |
Russell King | 303c644 | 2008-10-31 16:32:19 +0000 | [diff] [blame] | 74 | : "r1", "r2", "r3", "ip", "lr"); |
| 75 | kunmap_atomic(kaddr, KM_USER0); |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | struct cpu_user_fns v3_user_fns __initdata = { |
Russell King | 303c644 | 2008-10-31 16:32:19 +0000 | [diff] [blame] | 79 | .cpu_clear_user_highpage = v3_clear_user_highpage, |
Russell King | 063b0a4 | 2008-10-31 15:08:35 +0000 | [diff] [blame] | 80 | .cpu_copy_user_highpage = v3_copy_user_highpage, |
Russell King | d73e60b | 2008-10-31 13:08:02 +0000 | [diff] [blame] | 81 | }; |