aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-09-08 05:39:55 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-09-08 05:39:55 -0400
commitc324b44c34050cf2a9b58830e11c974806bd85d8 (patch)
tree3ac45a783221283925cd698334a8f5e7dd4c1df8 /arch/m68k
parent2fcf522509cceea524b6e7ece8fd6759b682175a (diff)
parentcaf39e87cc1182f7dae84eefc43ca14d54c78ef9 (diff)
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'arch/m68k')
-rw-r--r--arch/m68k/Kconfig5
-rw-r--r--arch/m68k/bvme6000/rtc.c5
-rw-r--r--arch/m68k/kernel/m68k_ksyms.c4
-rw-r--r--arch/m68k/kernel/ptrace.c370
-rw-r--r--arch/m68k/kernel/time.c5
-rw-r--r--arch/m68k/lib/Makefile2
-rw-r--r--arch/m68k/lib/memcmp.c11
-rw-r--r--arch/m68k/lib/memcpy.c75
-rw-r--r--arch/m68k/lib/memset.c68
-rw-r--r--arch/m68k/lib/string.c237
-rw-r--r--arch/m68k/mm/Makefile2
-rw-r--r--arch/m68k/mm/cache.c118
-rw-r--r--arch/m68k/mm/memory.c104
-rw-r--r--arch/m68k/mvme16x/rtc.c4
14 files changed, 529 insertions, 481 deletions
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 178c4a3fbb72..ba960bbc8e6d 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -25,6 +25,11 @@ config GENERIC_CALIBRATE_DELAY
25 bool 25 bool
26 default y 26 default y
27 27
28config ARCH_MAY_HAVE_PC_FDC
29 bool
30 depends on Q40 || (BROKEN && SUN3X)
31 default y
32
28mainmenu "Linux/68k Kernel Configuration" 33mainmenu "Linux/68k Kernel Configuration"
29 34
30source "init/Kconfig" 35source "init/Kconfig"
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index c6b2a410bf9a..eb63ca6ed94c 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -14,6 +14,7 @@
14#include <linux/fcntl.h> 14#include <linux/fcntl.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/poll.h> 16#include <linux/poll.h>
17#include <linux/module.h>
17#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */ 18#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
18#include <linux/smp_lock.h> 19#include <linux/smp_lock.h>
19#include <asm/bvme6000hw.h> 20#include <asm/bvme6000hw.h>
@@ -171,7 +172,7 @@ static struct miscdevice rtc_dev = {
171 .fops = &rtc_fops 172 .fops = &rtc_fops
172}; 173};
173 174
174int __init rtc_DP8570A_init(void) 175static int __init rtc_DP8570A_init(void)
175{ 176{
176 if (!MACH_IS_BVME6000) 177 if (!MACH_IS_BVME6000)
177 return -ENODEV; 178 return -ENODEV;
@@ -179,4 +180,4 @@ int __init rtc_DP8570A_init(void)
179 printk(KERN_INFO "DP8570A Real Time Clock Driver v%s\n", RTC_VERSION); 180 printk(KERN_INFO "DP8570A Real Time Clock Driver v%s\n", RTC_VERSION);
180 return misc_register(&rtc_dev); 181 return misc_register(&rtc_dev);
181} 182}
182 183module_init(rtc_DP8570A_init);
diff --git a/arch/m68k/kernel/m68k_ksyms.c b/arch/m68k/kernel/m68k_ksyms.c
index fe837e31afbf..73e2f5e168dd 100644
--- a/arch/m68k/kernel/m68k_ksyms.c
+++ b/arch/m68k/kernel/m68k_ksyms.c
@@ -74,10 +74,6 @@ EXPORT_SYMBOL(vme_brdtype);
74EXPORT_SYMBOL(__ashldi3); 74EXPORT_SYMBOL(__ashldi3);
75EXPORT_SYMBOL(__ashrdi3); 75EXPORT_SYMBOL(__ashrdi3);
76EXPORT_SYMBOL(__lshrdi3); 76EXPORT_SYMBOL(__lshrdi3);
77EXPORT_SYMBOL(memcpy);
78EXPORT_SYMBOL(memset);
79EXPORT_SYMBOL(memcmp);
80EXPORT_SYMBOL(memscan);
81EXPORT_SYMBOL(__muldi3); 77EXPORT_SYMBOL(__muldi3);
82 78
83EXPORT_SYMBOL(__down_failed); 79EXPORT_SYMBOL(__down_failed);
diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c
index f4e1e5eb8e12..8ed1b01a6a87 100644
--- a/arch/m68k/kernel/ptrace.c
+++ b/arch/m68k/kernel/ptrace.c
@@ -95,7 +95,7 @@ static inline int put_reg(struct task_struct *task, int regno,
95 if (regno == PT_USP) 95 if (regno == PT_USP)
96 addr = &task->thread.usp; 96 addr = &task->thread.usp;
97 else if (regno < sizeof(regoff)/sizeof(regoff[0])) 97 else if (regno < sizeof(regoff)/sizeof(regoff[0]))
98 addr = (unsigned long *) (task->thread.esp0 + regoff[regno]); 98 addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);
99 else 99 else
100 return -1; 100 return -1;
101 *addr = data; 101 *addr = data;
@@ -103,48 +103,56 @@ static inline int put_reg(struct task_struct *task, int regno,
103} 103}
104 104
105/* 105/*
106 * Called by kernel/ptrace.c when detaching..
107 *
108 * Make sure the single step bit is not set. 106 * Make sure the single step bit is not set.
109 */ 107 */
110void ptrace_disable(struct task_struct *child) 108static inline void singlestep_disable(struct task_struct *child)
111{ 109{
112 unsigned long tmp; 110 unsigned long tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
113 /* make sure the single step bit is not set. */
114 tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
115 put_reg(child, PT_SR, tmp); 111 put_reg(child, PT_SR, tmp);
116 child->thread.work.delayed_trace = 0; 112 child->thread.work.delayed_trace = 0;
113}
114
115/*
116 * Called by kernel/ptrace.c when detaching..
117 */
118void ptrace_disable(struct task_struct *child)
119{
120 singlestep_disable(child);
117 child->thread.work.syscall_trace = 0; 121 child->thread.work.syscall_trace = 0;
118} 122}
119 123
120asmlinkage int sys_ptrace(long request, long pid, long addr, long data) 124asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
121{ 125{
122 struct task_struct *child; 126 struct task_struct *child;
123 int ret; 127 unsigned long tmp;
128 int i, ret = 0;
124 129
125 lock_kernel(); 130 lock_kernel();
126 ret = -EPERM;
127 if (request == PTRACE_TRACEME) { 131 if (request == PTRACE_TRACEME) {
128 /* are we already being traced? */ 132 /* are we already being traced? */
129 if (current->ptrace & PT_PTRACED) 133 if (current->ptrace & PT_PTRACED) {
134 ret = -EPERM;
130 goto out; 135 goto out;
136 }
131 /* set the ptrace bit in the process flags. */ 137 /* set the ptrace bit in the process flags. */
132 current->ptrace |= PT_PTRACED; 138 current->ptrace |= PT_PTRACED;
133 ret = 0;
134 goto out; 139 goto out;
135 } 140 }
136 ret = -ESRCH;
137 read_lock(&tasklist_lock); 141 read_lock(&tasklist_lock);
138 child = find_task_by_pid(pid); 142 child = find_task_by_pid(pid);
139 if (child) 143 if (child)
140 get_task_struct(child); 144 get_task_struct(child);
141 read_unlock(&tasklist_lock); 145 read_unlock(&tasklist_lock);
142 if (!child) 146 if (unlikely(!child)) {
147 ret = -ESRCH;
143 goto out; 148 goto out;
149 }
144 150
145 ret = -EPERM; 151 /* you may not mess with init */
146 if (pid == 1) /* you may not mess with init */ 152 if (unlikely(pid == 1)) {
153 ret = -EPERM;
147 goto out_tsk; 154 goto out_tsk;
155 }
148 156
149 if (request == PTRACE_ATTACH) { 157 if (request == PTRACE_ATTACH) {
150 ret = ptrace_attach(child); 158 ret = ptrace_attach(child);
@@ -152,227 +160,171 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
152 } 160 }
153 161
154 ret = ptrace_check_attach(child, request == PTRACE_KILL); 162 ret = ptrace_check_attach(child, request == PTRACE_KILL);
155 if (ret < 0) 163 if (ret)
156 goto out_tsk; 164 goto out_tsk;
157 165
158 switch (request) { 166 switch (request) {
159 /* when I and D space are separate, these will need to be fixed. */ 167 /* when I and D space are separate, these will need to be fixed. */
160 case PTRACE_PEEKTEXT: /* read word at location addr. */ 168 case PTRACE_PEEKTEXT: /* read word at location addr. */
161 case PTRACE_PEEKDATA: { 169 case PTRACE_PEEKDATA:
162 unsigned long tmp; 170 i = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
163 int copied; 171 if (i != sizeof(tmp))
164 172 goto out_eio;
165 copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0); 173 ret = put_user(tmp, (unsigned long *)data);
166 ret = -EIO; 174 break;
167 if (copied != sizeof(tmp))
168 break;
169 ret = put_user(tmp,(unsigned long *) data);
170 break;
171 }
172 175
173 /* read the word at location addr in the USER area. */ 176 /* read the word at location addr in the USER area. */
174 case PTRACE_PEEKUSR: { 177 case PTRACE_PEEKUSR:
175 unsigned long tmp; 178 if (addr & 3)
176 179 goto out_eio;
177 ret = -EIO; 180 addr >>= 2; /* temporary hack. */
178 if ((addr & 3) || addr < 0 || 181
179 addr > sizeof(struct user) - 3) 182 if (addr >= 0 && addr < 19) {
180 break; 183 tmp = get_reg(child, addr);
181 184 if (addr == PT_SR)
182 tmp = 0; /* Default return condition */ 185 tmp >>= 16;
183 addr = addr >> 2; /* temporary hack. */ 186 } else if (addr >= 21 && addr < 49) {
184 ret = -EIO; 187 tmp = child->thread.fp[addr - 21];
185 if (addr < 19) { 188 /* Convert internal fpu reg representation
186 tmp = get_reg(child, addr); 189 * into long double format
187 if (addr == PT_SR) 190 */
188 tmp >>= 16; 191 if (FPU_IS_EMU && (addr < 45) && !(addr % 3))
189 } else if (addr >= 21 && addr < 49) { 192 tmp = ((tmp & 0xffff0000) << 15) |
190 tmp = child->thread.fp[addr - 21]; 193 ((tmp & 0x0000ffff) << 16);
191#ifdef CONFIG_M68KFPU_EMU 194 } else
192 /* Convert internal fpu reg representation
193 * into long double format
194 */
195 if (FPU_IS_EMU && (addr < 45) && !(addr % 3))
196 tmp = ((tmp & 0xffff0000) << 15) |
197 ((tmp & 0x0000ffff) << 16);
198#endif
199 } else
200 break;
201 ret = put_user(tmp,(unsigned long *) data);
202 break;
203 }
204
205 /* when I and D space are separate, this will have to be fixed. */
206 case PTRACE_POKETEXT: /* write the word at location addr. */
207 case PTRACE_POKEDATA:
208 ret = 0;
209 if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data))
210 break;
211 ret = -EIO;
212 break;
213
214 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
215 ret = -EIO;
216 if ((addr & 3) || addr < 0 ||
217 addr > sizeof(struct user) - 3)
218 break;
219
220 addr = addr >> 2; /* temporary hack. */
221
222 if (addr == PT_SR) {
223 data &= SR_MASK;
224 data <<= 16;
225 data |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
226 }
227 if (addr < 19) {
228 if (put_reg(child, addr, data))
229 break;
230 ret = 0;
231 break;
232 }
233 if (addr >= 21 && addr < 48)
234 {
235#ifdef CONFIG_M68KFPU_EMU
236 /* Convert long double format
237 * into internal fpu reg representation
238 */
239 if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) {
240 data = (unsigned long)data << 15;
241 data = (data & 0xffff0000) |
242 ((data & 0x0000ffff) >> 1);
243 }
244#endif
245 child->thread.fp[addr - 21] = data;
246 ret = 0;
247 }
248 break; 195 break;
249 196 ret = put_user(tmp, (unsigned long *)data);
250 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ 197 break;
251 case PTRACE_CONT: { /* restart after signal. */ 198
252 long tmp; 199 /* when I and D space are separate, this will have to be fixed. */
253 200 case PTRACE_POKETEXT: /* write the word at location addr. */
254 ret = -EIO; 201 case PTRACE_POKEDATA:
255 if (!valid_signal(data)) 202 if (access_process_vm(child, addr, &data, sizeof(data), 1) != sizeof(data))
256 break; 203 goto out_eio;
257 if (request == PTRACE_SYSCALL) { 204 break;
258 child->thread.work.syscall_trace = ~0; 205
259 } else { 206 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
260 child->thread.work.syscall_trace = 0; 207 if (addr & 3)
208 goto out_eio;
209 addr >>= 2; /* temporary hack. */
210
211 if (addr == PT_SR) {
212 data &= SR_MASK;
213 data <<= 16;
214 data |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
215 } else if (addr >= 0 && addr < 19) {
216 if (put_reg(child, addr, data))
217 goto out_eio;
218 } else if (addr >= 21 && addr < 48) {
219 /* Convert long double format
220 * into internal fpu reg representation
221 */
222 if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) {
223 data = (unsigned long)data << 15;
224 data = (data & 0xffff0000) |
225 ((data & 0x0000ffff) >> 1);
261 } 226 }
262 child->exit_code = data; 227 child->thread.fp[addr - 21] = data;
263 /* make sure the single step bit is not set. */ 228 } else
264 tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); 229 goto out_eio;
265 put_reg(child, PT_SR, tmp); 230 break;
266 child->thread.work.delayed_trace = 0; 231
267 wake_up_process(child); 232 case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
268 ret = 0; 233 case PTRACE_CONT: /* restart after signal. */
269 break; 234 if (!valid_signal(data))
270 } 235 goto out_eio;
271 236
272/* 237 if (request == PTRACE_SYSCALL)
273 * make the child exit. Best I can do is send it a sigkill. 238 child->thread.work.syscall_trace = ~0;
274 * perhaps it should be put in the status that it wants to 239 else
275 * exit.
276 */
277 case PTRACE_KILL: {
278 long tmp;
279
280 ret = 0;
281 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
282 break;
283 child->exit_code = SIGKILL;
284 /* make sure the single step bit is not set. */
285 tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16);
286 put_reg(child, PT_SR, tmp);
287 child->thread.work.delayed_trace = 0;
288 wake_up_process(child);
289 break;
290 }
291
292 case PTRACE_SINGLESTEP: { /* set the trap flag. */
293 long tmp;
294
295 ret = -EIO;
296 if (!valid_signal(data))
297 break;
298 child->thread.work.syscall_trace = 0; 240 child->thread.work.syscall_trace = 0;
299 tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); 241 child->exit_code = data;
300 put_reg(child, PT_SR, tmp); 242 singlestep_disable(child);
301 child->thread.work.delayed_trace = 1; 243 wake_up_process(child);
302 244 break;
303 child->exit_code = data;
304 /* give it a chance to run. */
305 wake_up_process(child);
306 ret = 0;
307 break;
308 }
309 245
310 case PTRACE_DETACH: /* detach a process that was attached. */ 246 /*
311 ret = ptrace_detach(child, data); 247 * make the child exit. Best I can do is send it a sigkill.
248 * perhaps it should be put in the status that it wants to
249 * exit.
250 */
251 case PTRACE_KILL:
252 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
312 break; 253 break;
313 254 child->exit_code = SIGKILL;
314 case PTRACE_GETREGS: { /* Get all gp regs from the child. */ 255 singlestep_disable(child);
315 int i; 256 wake_up_process(child);
316 unsigned long tmp; 257 break;
317 for (i = 0; i < 19; i++) { 258
318 tmp = get_reg(child, i); 259 case PTRACE_SINGLESTEP: /* set the trap flag. */
319 if (i == PT_SR) 260 if (!valid_signal(data))
261 goto out_eio;
262
263 child->thread.work.syscall_trace = 0;
264 tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
265 put_reg(child, PT_SR, tmp);
266 child->thread.work.delayed_trace = 1;
267
268 child->exit_code = data;
269 /* give it a chance to run. */
270 wake_up_process(child);
271 break;
272
273 case PTRACE_DETACH: /* detach a process that was attached. */
274 ret = ptrace_detach(child, data);
275 break;
276
277 case PTRACE_GETREGS: /* Get all gp regs from the child. */
278 for (i = 0; i < 19; i++) {
279 tmp = get_reg(child, i);
280 if (i == PT_SR)
320 tmp >>= 16; 281 tmp >>= 16;
321 if (put_user(tmp, (unsigned long *) data)) { 282 ret = put_user(tmp, (unsigned long *)data);
322 ret = -EFAULT; 283 if (ret)
323 break; 284 break;
324 } 285 data += sizeof(long);
325 data += sizeof(long);
326 }
327 ret = 0;
328 break;
329 } 286 }
287 break;
330 288
331 case PTRACE_SETREGS: { /* Set all gp regs in the child. */ 289 case PTRACE_SETREGS: /* Set all gp regs in the child. */
332 int i; 290 for (i = 0; i < 19; i++) {
333 unsigned long tmp; 291 ret = get_user(tmp, (unsigned long *)data);
334 for (i = 0; i < 19; i++) { 292 if (ret)
335 if (get_user(tmp, (unsigned long *) data)) {
336 ret = -EFAULT;
337 break; 293 break;
338 } 294 if (i == PT_SR) {
339 if (i == PT_SR) {
340 tmp &= SR_MASK; 295 tmp &= SR_MASK;
341 tmp <<= 16; 296 tmp <<= 16;
342 tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16); 297 tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
343 }
344 put_reg(child, i, tmp);
345 data += sizeof(long);
346 } 298 }
347 ret = 0; 299 put_reg(child, i, tmp);
348 break; 300 data += sizeof(long);
349 } 301 }
350 302 break;
351 case PTRACE_GETFPREGS: { /* Get the child FPU state. */ 303
352 ret = 0; 304 case PTRACE_GETFPREGS: /* Get the child FPU state. */
353 if (copy_to_user((void *)data, &child->thread.fp, 305 if (copy_to_user((void *)data, &child->thread.fp,
354 sizeof(struct user_m68kfp_struct))) 306 sizeof(struct user_m68kfp_struct)))
355 ret = -EFAULT; 307 ret = -EFAULT;
356 break; 308 break;
357 } 309
358 310 case PTRACE_SETFPREGS: /* Set the child FPU state. */
359 case PTRACE_SETFPREGS: { /* Set the child FPU state. */ 311 if (copy_from_user(&child->thread.fp, (void *)data,
360 ret = 0; 312 sizeof(struct user_m68kfp_struct)))
361 if (copy_from_user(&child->thread.fp, (void *)data, 313 ret = -EFAULT;
362 sizeof(struct user_m68kfp_struct))) 314 break;
363 ret = -EFAULT; 315
364 break; 316 default:
365 } 317 ret = ptrace_request(child, request, addr, data);
366 318 break;
367 default:
368 ret = ptrace_request(child, request, addr, data);
369 break;
370 } 319 }
371out_tsk: 320out_tsk:
372 put_task_struct(child); 321 put_task_struct(child);
373out: 322out:
374 unlock_kernel(); 323 unlock_kernel();
375 return ret; 324 return ret;
325out_eio:
326 ret = -EIO;
327 goto out_tsk;
376} 328}
377 329
378asmlinkage void syscall_trace(void) 330asmlinkage void syscall_trace(void)
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index e47e19588525..4ec95e3cb874 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -166,10 +166,7 @@ int do_settimeofday(struct timespec *tv)
166 set_normalized_timespec(&xtime, sec, nsec); 166 set_normalized_timespec(&xtime, sec, nsec);
167 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec); 167 set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec);
168 168
169 time_adjust = 0; /* stop active adjtime() */ 169 ntp_clear();
170 time_status |= STA_UNSYNC;
171 time_maxerror = NTP_PHASE_LIMIT;
172 time_esterror = NTP_PHASE_LIMIT;
173 write_sequnlock_irq(&xtime_lock); 170 write_sequnlock_irq(&xtime_lock);
174 clock_was_set(); 171 clock_was_set();
175 return 0; 172 return 0;
diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index 34b6dbc29c85..ebe51a513817 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -5,4 +5,4 @@
5EXTRA_AFLAGS := -traditional 5EXTRA_AFLAGS := -traditional
6 6
7lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ 7lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
8 checksum.o memcmp.o memcpy.o memset.o semaphore.o 8 checksum.o string.o semaphore.o
diff --git a/arch/m68k/lib/memcmp.c b/arch/m68k/lib/memcmp.c
deleted file mode 100644
index f4796febb773..000000000000
--- a/arch/m68k/lib/memcmp.c
+++ /dev/null
@@ -1,11 +0,0 @@
1#include <linux/types.h>
2
3int memcmp(const void * cs,const void * ct,size_t count)
4{
5 const unsigned char *su1, *su2;
6
7 for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--)
8 if (*su1 != *su2)
9 return((*su1 < *su2) ? -1 : +1);
10 return(0);
11}
diff --git a/arch/m68k/lib/memcpy.c b/arch/m68k/lib/memcpy.c
deleted file mode 100644
index 73e181823d9b..000000000000
--- a/arch/m68k/lib/memcpy.c
+++ /dev/null
@@ -1,75 +0,0 @@
1#include <linux/types.h>
2
3void * memcpy(void * to, const void * from, size_t n)
4{
5 void *xto = to;
6 size_t temp, temp1;
7
8 if (!n)
9 return xto;
10 if ((long) to & 1)
11 {
12 char *cto = to;
13 const char *cfrom = from;
14 *cto++ = *cfrom++;
15 to = cto;
16 from = cfrom;
17 n--;
18 }
19 if (n > 2 && (long) to & 2)
20 {
21 short *sto = to;
22 const short *sfrom = from;
23 *sto++ = *sfrom++;
24 to = sto;
25 from = sfrom;
26 n -= 2;
27 }
28 temp = n >> 2;
29 if (temp)
30 {
31 long *lto = to;
32 const long *lfrom = from;
33
34 __asm__ __volatile__("movel %2,%3\n\t"
35 "andw #7,%3\n\t"
36 "lsrl #3,%2\n\t"
37 "negw %3\n\t"
38 "jmp %%pc@(1f,%3:w:2)\n\t"
39 "4:\t"
40 "movel %0@+,%1@+\n\t"
41 "movel %0@+,%1@+\n\t"
42 "movel %0@+,%1@+\n\t"
43 "movel %0@+,%1@+\n\t"
44 "movel %0@+,%1@+\n\t"
45 "movel %0@+,%1@+\n\t"
46 "movel %0@+,%1@+\n\t"
47 "movel %0@+,%1@+\n\t"
48 "1:\t"
49 "dbra %2,4b\n\t"
50 "clrw %2\n\t"
51 "subql #1,%2\n\t"
52 "jpl 4b\n\t"
53 : "=a" (lfrom), "=a" (lto), "=d" (temp),
54 "=&d" (temp1)
55 : "0" (lfrom), "1" (lto), "2" (temp)
56 );
57 to = lto;
58 from = lfrom;
59 }
60 if (n & 2)
61 {
62 short *sto = to;
63 const short *sfrom = from;
64 *sto++ = *sfrom++;
65 to = sto;
66 from = sfrom;
67 }
68 if (n & 1)
69 {
70 char *cto = to;
71 const char *cfrom = from;
72 *cto = *cfrom;
73 }
74 return xto;
75}
diff --git a/arch/m68k/lib/memset.c b/arch/m68k/lib/memset.c
deleted file mode 100644
index d55fdb2ee9d3..000000000000
--- a/arch/m68k/lib/memset.c
+++ /dev/null
@@ -1,68 +0,0 @@
1#include <linux/types.h>
2
3void * memset(void * s, int c, size_t count)
4{
5 void *xs = s;
6 size_t temp, temp1;
7
8 if (!count)
9 return xs;
10 c &= 0xff;
11 c |= c << 8;
12 c |= c << 16;
13 if ((long) s & 1)
14 {
15 char *cs = s;
16 *cs++ = c;
17 s = cs;
18 count--;
19 }
20 if (count > 2 && (long) s & 2)
21 {
22 short *ss = s;
23 *ss++ = c;
24 s = ss;
25 count -= 2;
26 }
27 temp = count >> 2;
28 if (temp)
29 {
30 long *ls = s;
31
32 __asm__ __volatile__("movel %1,%2\n\t"
33 "andw #7,%2\n\t"
34 "lsrl #3,%1\n\t"
35 "negw %2\n\t"
36 "jmp %%pc@(2f,%2:w:2)\n\t"
37 "1:\t"
38 "movel %3,%0@+\n\t"
39 "movel %3,%0@+\n\t"
40 "movel %3,%0@+\n\t"
41 "movel %3,%0@+\n\t"
42 "movel %3,%0@+\n\t"
43 "movel %3,%0@+\n\t"
44 "movel %3,%0@+\n\t"
45 "movel %3,%0@+\n\t"
46 "2:\t"
47 "dbra %1,1b\n\t"
48 "clrw %1\n\t"
49 "subql #1,%1\n\t"
50 "jpl 1b\n\t"
51 : "=a" (ls), "=d" (temp), "=&d" (temp1)
52 : "d" (c), "0" (ls), "1" (temp)
53 );
54 s = ls;
55 }
56 if (count & 2)
57 {
58 short *ss = s;
59 *ss++ = c;
60 s = ss;
61 }
62 if (count & 1)
63 {
64 char *cs = s;
65 *cs = c;
66 }
67 return xs;
68}
diff --git a/arch/m68k/lib/string.c b/arch/m68k/lib/string.c
new file mode 100644
index 000000000000..b92b89e1ea0c
--- /dev/null
+++ b/arch/m68k/lib/string.c
@@ -0,0 +1,237 @@
1
2#include <linux/types.h>
3#include <linux/module.h>
4
5void *memset(void *s, int c, size_t count)
6{
7 void *xs = s;
8 size_t temp, temp1;
9
10 if (!count)
11 return xs;
12 c &= 0xff;
13 c |= c << 8;
14 c |= c << 16;
15 if ((long)s & 1) {
16 char *cs = s;
17 *cs++ = c;
18 s = cs;
19 count--;
20 }
21 if (count > 2 && (long)s & 2) {
22 short *ss = s;
23 *ss++ = c;
24 s = ss;
25 count -= 2;
26 }
27 temp = count >> 2;
28 if (temp) {
29 long *ls = s;
30
31 asm volatile (
32 " movel %1,%2\n"
33 " andw #7,%2\n"
34 " lsrl #3,%1\n"
35 " negw %2\n"
36 " jmp %%pc@(2f,%2:w:2)\n"
37 "1: movel %3,%0@+\n"
38 " movel %3,%0@+\n"
39 " movel %3,%0@+\n"
40 " movel %3,%0@+\n"
41 " movel %3,%0@+\n"
42 " movel %3,%0@+\n"
43 " movel %3,%0@+\n"
44 " movel %3,%0@+\n"
45 "2: dbra %1,1b\n"
46 " clrw %1\n"
47 " subql #1,%1\n"
48 " jpl 1b"
49 : "=a" (ls), "=d" (temp), "=&d" (temp1)
50 : "d" (c), "0" (ls), "1" (temp));
51 s = ls;
52 }
53 if (count & 2) {
54 short *ss = s;
55 *ss++ = c;
56 s = ss;
57 }
58 if (count & 1) {
59 char *cs = s;
60 *cs = c;
61 }
62 return xs;
63}
64EXPORT_SYMBOL(memset);
65
66void *memcpy(void *to, const void *from, size_t n)
67{
68 void *xto = to;
69 size_t temp, temp1;
70
71 if (!n)
72 return xto;
73 if ((long)to & 1) {
74 char *cto = to;
75 const char *cfrom = from;
76 *cto++ = *cfrom++;
77 to = cto;
78 from = cfrom;
79 n--;
80 }
81 if (n > 2 && (long)to & 2) {
82 short *sto = to;
83 const short *sfrom = from;
84 *sto++ = *sfrom++;
85 to = sto;
86 from = sfrom;
87 n -= 2;
88 }
89 temp = n >> 2;
90 if (temp) {
91 long *lto = to;
92 const long *lfrom = from;
93
94 asm volatile (
95 " movel %2,%3\n"
96 " andw #7,%3\n"
97 " lsrl #3,%2\n"
98 " negw %3\n"
99 " jmp %%pc@(1f,%3:w:2)\n"
100 "4: movel %0@+,%1@+\n"
101 " movel %0@+,%1@+\n"
102 " movel %0@+,%1@+\n"
103 " movel %0@+,%1@+\n"
104 " movel %0@+,%1@+\n"
105 " movel %0@+,%1@+\n"
106 " movel %0@+,%1@+\n"
107 " movel %0@+,%1@+\n"
108 "1: dbra %2,4b\n"
109 " clrw %2\n"
110 " subql #1,%2\n"
111 " jpl 4b"
112 : "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1)
113 : "0" (lfrom), "1" (lto), "2" (temp));
114 to = lto;
115 from = lfrom;
116 }
117 if (n & 2) {
118 short *sto = to;
119 const short *sfrom = from;
120 *sto++ = *sfrom++;
121 to = sto;
122 from = sfrom;
123 }
124 if (n & 1) {
125 char *cto = to;
126 const char *cfrom = from;
127 *cto = *cfrom;
128 }
129 return xto;
130}
131EXPORT_SYMBOL(memcpy);
132
133void *memmove(void *dest, const void *src, size_t n)
134{
135 void *xdest = dest;
136 size_t temp;
137
138 if (!n)
139 return xdest;
140
141 if (dest < src) {
142 if ((long)dest & 1) {
143 char *cdest = dest;
144 const char *csrc = src;
145 *cdest++ = *csrc++;
146 dest = cdest;
147 src = csrc;
148 n--;
149 }
150 if (n > 2 && (long)dest & 2) {
151 short *sdest = dest;
152 const short *ssrc = src;
153 *sdest++ = *ssrc++;
154 dest = sdest;
155 src = ssrc;
156 n -= 2;
157 }
158 temp = n >> 2;
159 if (temp) {
160 long *ldest = dest;
161 const long *lsrc = src;
162 temp--;
163 do
164 *ldest++ = *lsrc++;
165 while (temp--);
166 dest = ldest;
167 src = lsrc;
168 }
169 if (n & 2) {
170 short *sdest = dest;
171 const short *ssrc = src;
172 *sdest++ = *ssrc++;
173 dest = sdest;
174 src = ssrc;
175 }
176 if (n & 1) {
177 char *cdest = dest;
178 const char *csrc = src;
179 *cdest = *csrc;
180 }
181 } else {
182 dest = (char *)dest + n;
183 src = (const char *)src + n;
184 if ((long)dest & 1) {
185 char *cdest = dest;
186 const char *csrc = src;
187 *--cdest = *--csrc;
188 dest = cdest;
189 src = csrc;
190 n--;
191 }
192 if (n > 2 && (long)dest & 2) {
193 short *sdest = dest;
194 const short *ssrc = src;
195 *--sdest = *--ssrc;
196 dest = sdest;
197 src = ssrc;
198 n -= 2;
199 }
200 temp = n >> 2;
201 if (temp) {
202 long *ldest = dest;
203 const long *lsrc = src;
204 temp--;
205 do
206 *--ldest = *--lsrc;
207 while (temp--);
208 dest = ldest;
209 src = lsrc;
210 }
211 if (n & 2) {
212 short *sdest = dest;
213 const short *ssrc = src;
214 *--sdest = *--ssrc;
215 dest = sdest;
216 src = ssrc;
217 }
218 if (n & 1) {
219 char *cdest = dest;
220 const char *csrc = src;
221 *--cdest = *--csrc;
222 }
223 }
224 return xdest;
225}
226EXPORT_SYMBOL(memmove);
227
228int memcmp(const void *cs, const void *ct, size_t count)
229{
230 const unsigned char *su1, *su2;
231
232 for (su1 = cs, su2 = ct; count > 0; ++su1, ++su2, count--)
233 if (*su1 != *su2)
234 return *su1 < *su2 ? -1 : +1;
235 return 0;
236}
237EXPORT_SYMBOL(memcmp);
diff --git a/arch/m68k/mm/Makefile b/arch/m68k/mm/Makefile
index 90f1c735c110..5eaa43c4cb3c 100644
--- a/arch/m68k/mm/Makefile
+++ b/arch/m68k/mm/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux m68k-specific parts of the memory manager. 2# Makefile for the linux m68k-specific parts of the memory manager.
3# 3#
4 4
5obj-y := init.o fault.o hwtest.o 5obj-y := cache.o init.o fault.o hwtest.o
6 6
7obj-$(CONFIG_MMU_MOTOROLA) += kmap.o memory.o motorola.o 7obj-$(CONFIG_MMU_MOTOROLA) += kmap.o memory.o motorola.o
8obj-$(CONFIG_MMU_SUN3) += sun3kmap.o sun3mmu.o 8obj-$(CONFIG_MMU_SUN3) += sun3kmap.o sun3mmu.o
diff --git a/arch/m68k/mm/cache.c b/arch/m68k/mm/cache.c
new file mode 100644
index 000000000000..5437fff5fe07
--- /dev/null
+++ b/arch/m68k/mm/cache.c
@@ -0,0 +1,118 @@
1/*
2 * linux/arch/m68k/mm/cache.c
3 *
4 * Instruction cache handling
5 *
6 * Copyright (C) 1995 Hamish Macdonald
7 */
8
9#include <linux/module.h>
10#include <asm/pgalloc.h>
11#include <asm/traps.h>
12
13
14static unsigned long virt_to_phys_slow(unsigned long vaddr)
15{
16 if (CPU_IS_060) {
17 unsigned long paddr;
18
19 /* The PLPAR instruction causes an access error if the translation
20 * is not possible. To catch this we use the same exception mechanism
21 * as for user space accesses in <asm/uaccess.h>. */
22 asm volatile (".chip 68060\n"
23 "1: plpar (%0)\n"
24 ".chip 68k\n"
25 "2:\n"
26 ".section .fixup,\"ax\"\n"
27 " .even\n"
28 "3: sub.l %0,%0\n"
29 " jra 2b\n"
30 ".previous\n"
31 ".section __ex_table,\"a\"\n"
32 " .align 4\n"
33 " .long 1b,3b\n"
34 ".previous"
35 : "=a" (paddr)
36 : "0" (vaddr));
37 return paddr;
38 } else if (CPU_IS_040) {
39 unsigned long mmusr;
40
41 asm volatile (".chip 68040\n\t"
42 "ptestr (%1)\n\t"
43 "movec %%mmusr, %0\n\t"
44 ".chip 68k"
45 : "=r" (mmusr)
46 : "a" (vaddr));
47
48 if (mmusr & MMU_R_040)
49 return (mmusr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
50 } else {
51 unsigned short mmusr;
52 unsigned long *descaddr;
53
54 asm volatile ("ptestr %3,%2@,#7,%0\n\t"
55 "pmove %%psr,%1@"
56 : "=a&" (descaddr)
57 : "a" (&mmusr), "a" (vaddr), "d" (get_fs().seg));
58 if (mmusr & (MMU_I|MMU_B|MMU_L))
59 return 0;
60 descaddr = phys_to_virt((unsigned long)descaddr);
61 switch (mmusr & MMU_NUM) {
62 case 1:
63 return (*descaddr & 0xfe000000) | (vaddr & 0x01ffffff);
64 case 2:
65 return (*descaddr & 0xfffc0000) | (vaddr & 0x0003ffff);
66 case 3:
67 return (*descaddr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
68 }
69 }
70 return 0;
71}
72
73/* Push n pages at kernel virtual address and clear the icache */
74/* RZ: use cpush %bc instead of cpush %dc, cinv %ic */
75void flush_icache_range(unsigned long address, unsigned long endaddr)
76{
77
78 if (CPU_IS_040_OR_060) {
79 address &= PAGE_MASK;
80
81 do {
82 asm volatile ("nop\n\t"
83 ".chip 68040\n\t"
84 "cpushp %%bc,(%0)\n\t"
85 ".chip 68k"
86 : : "a" (virt_to_phys_slow(address)));
87 address += PAGE_SIZE;
88 } while (address < endaddr);
89 } else {
90 unsigned long tmp;
91 asm volatile ("movec %%cacr,%0\n\t"
92 "orw %1,%0\n\t"
93 "movec %0,%%cacr"
94 : "=&d" (tmp)
95 : "di" (FLUSH_I));
96 }
97}
98EXPORT_SYMBOL(flush_icache_range);
99
100void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
101 unsigned long addr, int len)
102{
103 if (CPU_IS_040_OR_060) {
104 asm volatile ("nop\n\t"
105 ".chip 68040\n\t"
106 "cpushp %%bc,(%0)\n\t"
107 ".chip 68k"
108 : : "a" (page_to_phys(page)));
109 } else {
110 unsigned long tmp;
111 asm volatile ("movec %%cacr,%0\n\t"
112 "orw %1,%0\n\t"
113 "movec %0,%%cacr"
114 : "=&d" (tmp)
115 : "di" (FLUSH_I));
116 }
117}
118
diff --git a/arch/m68k/mm/memory.c b/arch/m68k/mm/memory.c
index 1453a6013721..559942ce0e1e 100644
--- a/arch/m68k/mm/memory.c
+++ b/arch/m68k/mm/memory.c
@@ -354,110 +354,6 @@ void cache_push (unsigned long paddr, int len)
354#endif 354#endif
355} 355}
356 356
357static unsigned long virt_to_phys_slow(unsigned long vaddr)
358{
359 if (CPU_IS_060) {
360 mm_segment_t fs = get_fs();
361 unsigned long paddr;
362
363 set_fs(get_ds());
364
365 /* The PLPAR instruction causes an access error if the translation
366 * is not possible. To catch this we use the same exception mechanism
367 * as for user space accesses in <asm/uaccess.h>. */
368 asm volatile (".chip 68060\n"
369 "1: plpar (%0)\n"
370 ".chip 68k\n"
371 "2:\n"
372 ".section .fixup,\"ax\"\n"
373 " .even\n"
374 "3: sub.l %0,%0\n"
375 " jra 2b\n"
376 ".previous\n"
377 ".section __ex_table,\"a\"\n"
378 " .align 4\n"
379 " .long 1b,3b\n"
380 ".previous"
381 : "=a" (paddr)
382 : "0" (vaddr));
383 set_fs(fs);
384 return paddr;
385 } else if (CPU_IS_040) {
386 mm_segment_t fs = get_fs();
387 unsigned long mmusr;
388
389 set_fs(get_ds());
390
391 asm volatile (".chip 68040\n\t"
392 "ptestr (%1)\n\t"
393 "movec %%mmusr, %0\n\t"
394 ".chip 68k"
395 : "=r" (mmusr)
396 : "a" (vaddr));
397 set_fs(fs);
398
399 if (mmusr & MMU_R_040)
400 return (mmusr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
401 } else {
402 unsigned short mmusr;
403 unsigned long *descaddr;
404
405 asm volatile ("ptestr #5,%2@,#7,%0\n\t"
406 "pmove %%psr,%1@"
407 : "=a&" (descaddr)
408 : "a" (&mmusr), "a" (vaddr));
409 if (mmusr & (MMU_I|MMU_B|MMU_L))
410 return 0;
411 descaddr = phys_to_virt((unsigned long)descaddr);
412 switch (mmusr & MMU_NUM) {
413 case 1:
414 return (*descaddr & 0xfe000000) | (vaddr & 0x01ffffff);
415 case 2:
416 return (*descaddr & 0xfffc0000) | (vaddr & 0x0003ffff);
417 case 3:
418 return (*descaddr & PAGE_MASK) | (vaddr & ~PAGE_MASK);
419 }
420 }
421 return 0;
422}
423
424/* Push n pages at kernel virtual address and clear the icache */
425/* RZ: use cpush %bc instead of cpush %dc, cinv %ic */
426void flush_icache_range(unsigned long address, unsigned long endaddr)
427{
428 if (CPU_IS_040_OR_060) {
429 address &= PAGE_MASK;
430
431 if (address >= PAGE_OFFSET && address < (unsigned long)high_memory) {
432 do {
433 asm volatile ("nop\n\t"
434 ".chip 68040\n\t"
435 "cpushp %%bc,(%0)\n\t"
436 ".chip 68k"
437 : : "a" (virt_to_phys((void *)address)));
438 address += PAGE_SIZE;
439 } while (address < endaddr);
440 } else {
441 do {
442 asm volatile ("nop\n\t"
443 ".chip 68040\n\t"
444 "cpushp %%bc,(%0)\n\t"
445 ".chip 68k"
446 : : "a" (virt_to_phys_slow(address)));
447 address += PAGE_SIZE;
448 } while (address < endaddr);
449 }
450 } else {
451 unsigned long tmp;
452 asm volatile ("movec %%cacr,%0\n\t"
453 "orw %1,%0\n\t"
454 "movec %0,%%cacr"
455 : "=&d" (tmp)
456 : "di" (FLUSH_I));
457 }
458}
459
460
461#ifndef CONFIG_SINGLE_MEMORY_CHUNK 357#ifndef CONFIG_SINGLE_MEMORY_CHUNK
462int mm_end_of_chunk (unsigned long addr, int len) 358int mm_end_of_chunk (unsigned long addr, int len)
463{ 359{
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c
index 8a2425069088..7977eae50af2 100644
--- a/arch/m68k/mvme16x/rtc.c
+++ b/arch/m68k/mvme16x/rtc.c
@@ -161,7 +161,7 @@ static struct miscdevice rtc_dev=
161 .fops = &rtc_fops 161 .fops = &rtc_fops
162}; 162};
163 163
164int __init rtc_MK48T08_init(void) 164static int __init rtc_MK48T08_init(void)
165{ 165{
166 if (!MACH_IS_MVME16x) 166 if (!MACH_IS_MVME16x)
167 return -ENODEV; 167 return -ENODEV;
@@ -169,4 +169,4 @@ int __init rtc_MK48T08_init(void)
169 printk(KERN_INFO "MK48T08 Real Time Clock Driver v%s\n", RTC_VERSION); 169 printk(KERN_INFO "MK48T08 Real Time Clock Driver v%s\n", RTC_VERSION);
170 return misc_register(&rtc_dev); 170 return misc_register(&rtc_dev);
171} 171}
172 172module_init(rtc_MK48T08_init);