aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-06-12 16:15:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-12 16:15:17 -0400
commit02a99ed6207e9a1d787bb360ef97de023c7edf4a (patch)
treef5818df7dd3f3741d02afbdd4271deed48c41f3d /arch/microblaze/lib
parent2b10dc45d15150434d7f206264e912eacbff734b (diff)
parent3447ef29a7f3b1fd0d8d58376950e695e04f6f8b (diff)
Merge branch 'for-linus' of git://git.monstr.eu/linux-2.6-microblaze
* 'for-linus' of git://git.monstr.eu/linux-2.6-microblaze: (55 commits) microblaze: Don't use access_ok for unaligned microblaze: remove unused flat_stack_align() definition microblaze: Fix problem with early_printk in startup microblaze_mmu_v2: Makefiles microblaze_mmu_v2: Kconfig update microblaze_mmu_v2: stat.h MMU update microblaze_mmu_v2: Elf update microblaze_mmu_v2: Update dma.h for MMU microblaze_mmu_v2: Update cacheflush.h microblaze_mmu_v2: Update signal returning address microblaze_mmu_v2: Traps MMU update microblaze_mmu_v2: Enable fork syscall for MMU and add fork as vfork for noMMU microblaze_mmu_v2: Update linker script for MMU microblaze_mmu_v2: Add MMU related exceptions handling microblaze_mmu_v2: uaccess MMU update microblaze_mmu_v2: Update exception handling - MMU exception microblaze_mmu_v2: entry.S, entry.h microblaze_mmu_v2: Add CURRENT_TASK for entry.S microblaze_mmu_v2: MMU asm offset update microblaze_mmu_v2: Update tlb.h and tlbflush.h ...
Diffstat (limited to 'arch/microblaze/lib')
-rw-r--r--arch/microblaze/lib/Makefile3
-rw-r--r--arch/microblaze/lib/checksum.c31
-rw-r--r--arch/microblaze/lib/memcpy.c5
-rw-r--r--arch/microblaze/lib/uaccess_old.S135
4 files changed, 157 insertions, 17 deletions
diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile
index d27126bf306a..71c8cb6c9e43 100644
--- a/arch/microblaze/lib/Makefile
+++ b/arch/microblaze/lib/Makefile
@@ -10,4 +10,5 @@ else
10lib-y += memcpy.o memmove.o 10lib-y += memcpy.o memmove.o
11endif 11endif
12 12
13lib-y += uaccess.o 13lib-$(CONFIG_NO_MMU) += uaccess.o
14lib-$(CONFIG_MMU) += uaccess_old.o
diff --git a/arch/microblaze/lib/checksum.c b/arch/microblaze/lib/checksum.c
index 809340070a13..f08e74591418 100644
--- a/arch/microblaze/lib/checksum.c
+++ b/arch/microblaze/lib/checksum.c
@@ -32,9 +32,10 @@
32/* Revised by Kenneth Albanowski for m68knommu. Basic problem: unaligned access 32/* Revised by Kenneth Albanowski for m68knommu. Basic problem: unaligned access
33 kills, so most of the assembly has to go. */ 33 kills, so most of the assembly has to go. */
34 34
35#include <net/checksum.h>
36#include <asm/checksum.h>
37#include <linux/module.h> 35#include <linux/module.h>
36#include <net/checksum.h>
37
38#include <asm/byteorder.h>
38 39
39static inline unsigned short from32to16(unsigned long x) 40static inline unsigned short from32to16(unsigned long x)
40{ 41{
@@ -102,6 +103,7 @@ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
102{ 103{
103 return (__force __sum16)~do_csum(iph, ihl*4); 104 return (__force __sum16)~do_csum(iph, ihl*4);
104} 105}
106EXPORT_SYMBOL(ip_fast_csum);
105 107
106/* 108/*
107 * computes the checksum of a memory block at buff, length len, 109 * computes the checksum of a memory block at buff, length len,
@@ -115,15 +117,16 @@ __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
115 * 117 *
116 * it's best to have buff aligned on a 32-bit boundary 118 * it's best to have buff aligned on a 32-bit boundary
117 */ 119 */
118__wsum csum_partial(const void *buff, int len, __wsum sum) 120__wsum csum_partial(const void *buff, int len, __wsum wsum)
119{ 121{
122 unsigned int sum = (__force unsigned int)wsum;
120 unsigned int result = do_csum(buff, len); 123 unsigned int result = do_csum(buff, len);
121 124
122 /* add in old sum, and carry.. */ 125 /* add in old sum, and carry.. */
123 result += sum; 126 result += sum;
124 if (sum > result) 127 if (sum > result)
125 result += 1; 128 result += 1;
126 return result; 129 return (__force __wsum)result;
127} 130}
128EXPORT_SYMBOL(csum_partial); 131EXPORT_SYMBOL(csum_partial);
129 132
@@ -131,9 +134,9 @@ EXPORT_SYMBOL(csum_partial);
131 * this routine is used for miscellaneous IP-like checksums, mainly 134 * this routine is used for miscellaneous IP-like checksums, mainly
132 * in icmp.c 135 * in icmp.c
133 */ 136 */
134__sum16 ip_compute_csum(const unsigned char *buff, int len) 137__sum16 ip_compute_csum(const void *buff, int len)
135{ 138{
136 return ~do_csum(buff, len); 139 return (__force __sum16)~do_csum(buff, len);
137} 140}
138EXPORT_SYMBOL(ip_compute_csum); 141EXPORT_SYMBOL(ip_compute_csum);
139 142
@@ -141,12 +144,18 @@ EXPORT_SYMBOL(ip_compute_csum);
141 * copy from fs while checksumming, otherwise like csum_partial 144 * copy from fs while checksumming, otherwise like csum_partial
142 */ 145 */
143__wsum 146__wsum
144csum_partial_copy_from_user(const char __user *src, char *dst, int len, 147csum_partial_copy_from_user(const void __user *src, void *dst, int len,
145 int sum, int *csum_err) 148 __wsum sum, int *csum_err)
146{ 149{
147 if (csum_err) 150 int missing;
151
152 missing = __copy_from_user(dst, src, len);
153 if (missing) {
154 memset(dst + len - missing, 0, missing);
155 *csum_err = -EFAULT;
156 } else
148 *csum_err = 0; 157 *csum_err = 0;
149 memcpy(dst, src, len); 158
150 return csum_partial(dst, len, sum); 159 return csum_partial(dst, len, sum);
151} 160}
152EXPORT_SYMBOL(csum_partial_copy_from_user); 161EXPORT_SYMBOL(csum_partial_copy_from_user);
@@ -155,7 +164,7 @@ EXPORT_SYMBOL(csum_partial_copy_from_user);
155 * copy from ds while checksumming, otherwise like csum_partial 164 * copy from ds while checksumming, otherwise like csum_partial
156 */ 165 */
157__wsum 166__wsum
158csum_partial_copy(const char *src, char *dst, int len, int sum) 167csum_partial_copy(const void *src, void *dst, int len, __wsum sum)
159{ 168{
160 memcpy(dst, src, len); 169 memcpy(dst, src, len);
161 return csum_partial(dst, len, sum); 170 return csum_partial(dst, len, sum);
diff --git a/arch/microblaze/lib/memcpy.c b/arch/microblaze/lib/memcpy.c
index 5880119c4487..6a907c58a4bc 100644
--- a/arch/microblaze/lib/memcpy.c
+++ b/arch/microblaze/lib/memcpy.c
@@ -154,8 +154,3 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c)
154} 154}
155EXPORT_SYMBOL(memcpy); 155EXPORT_SYMBOL(memcpy);
156#endif /* __HAVE_ARCH_MEMCPY */ 156#endif /* __HAVE_ARCH_MEMCPY */
157
158void *cacheable_memcpy(void *d, const void *s, __kernel_size_t c)
159{
160 return memcpy(d, s, c);
161}
diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S
new file mode 100644
index 000000000000..67f991c14b8a
--- /dev/null
+++ b/arch/microblaze/lib/uaccess_old.S
@@ -0,0 +1,135 @@
1/*
2 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2009 PetaLogix
4 * Copyright (C) 2007 LynuxWorks, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/errno.h>
12#include <linux/linkage.h>
13
14/*
15 * int __strncpy_user(char *to, char *from, int len);
16 *
17 * Returns:
18 * -EFAULT for an exception
19 * len if we hit the buffer limit
20 * bytes copied
21 */
22
23 .text
24.globl __strncpy_user;
25.align 4;
26__strncpy_user:
27
28 /*
29 * r5 - to
30 * r6 - from
31 * r7 - len
32 * r3 - temp count
33 * r4 - temp val
34 */
35 addik r3,r7,0 /* temp_count = len */
36 beqi r3,3f
371:
38 lbu r4,r6,r0
39 sb r4,r5,r0
40
41 addik r3,r3,-1
42 beqi r3,2f /* break on len */
43
44 addik r5,r5,1
45 bneid r4,1b
46 addik r6,r6,1 /* delay slot */
47 addik r3,r3,1 /* undo "temp_count--" */
482:
49 rsubk r3,r3,r7 /* temp_count = len - temp_count */
503:
51 rtsd r15,8
52 nop
53
54
55 .section .fixup, "ax"
56 .align 2
574:
58 brid 3b
59 addik r3,r0, -EFAULT
60
61 .section __ex_table, "a"
62 .word 1b,4b
63
64/*
65 * int __strnlen_user(char __user *str, int maxlen);
66 *
67 * Returns:
68 * 0 on error
69 * maxlen + 1 if no NUL byte found within maxlen bytes
70 * size of the string (including NUL byte)
71 */
72
73 .text
74.globl __strnlen_user;
75.align 4;
76__strnlen_user:
77 addik r3,r6,0
78 beqi r3,3f
791:
80 lbu r4,r5,r0
81 beqid r4,2f /* break on NUL */
82 addik r3,r3,-1 /* delay slot */
83
84 bneid r3,1b
85 addik r5,r5,1 /* delay slot */
86
87 addik r3,r3,-1 /* for break on len */
882:
89 rsubk r3,r3,r6
903:
91 rtsd r15,8
92 nop
93
94
95 .section .fixup,"ax"
964:
97 brid 3b
98 addk r3,r0,r0
99
100 .section __ex_table,"a"
101 .word 1b,4b
102
103/*
104 * int __copy_tofrom_user(char *to, char *from, int len)
105 * Return:
106 * 0 on success
107 * number of not copied bytes on error
108 */
109 .text
110.globl __copy_tofrom_user;
111.align 4;
112__copy_tofrom_user:
113 /*
114 * r5 - to
115 * r6 - from
116 * r7, r3 - count
117 * r4 - tempval
118 */
119 addik r3,r7,0
120 beqi r3,3f
1211:
122 lbu r4,r6,r0
123 addik r6,r6,1
1242:
125 sb r4,r5,r0
126 addik r3,r3,-1
127 bneid r3,1b
128 addik r5,r5,1 /* delay slot */
1293:
130 rtsd r15,8
131 nop
132
133
134 .section __ex_table,"a"
135 .word 1b,3b,2b,3b