diff options
author | Len Brown <len.brown@intel.com> | 2005-09-08 01:45:47 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2005-09-08 01:45:47 -0400 |
commit | 64e47488c913ac704d465a6af86a26786d1412a5 (patch) | |
tree | d3b0148592963dcde26e4bb35ddfec8b1eaf8e23 /arch/m68k | |
parent | 4a35a46bf1cda4737c428380d1db5d15e2590d18 (diff) | |
parent | caf39e87cc1182f7dae84eefc43ca14d54c78ef9 (diff) |
Merge linux-2.6 with linux-acpi-2.6
Diffstat (limited to 'arch/m68k')
-rw-r--r-- | arch/m68k/Kconfig | 5 | ||||
-rw-r--r-- | arch/m68k/bvme6000/rtc.c | 5 | ||||
-rw-r--r-- | arch/m68k/kernel/m68k_ksyms.c | 4 | ||||
-rw-r--r-- | arch/m68k/kernel/ptrace.c | 370 | ||||
-rw-r--r-- | arch/m68k/kernel/time.c | 5 | ||||
-rw-r--r-- | arch/m68k/lib/Makefile | 2 | ||||
-rw-r--r-- | arch/m68k/lib/memcmp.c | 11 | ||||
-rw-r--r-- | arch/m68k/lib/memcpy.c | 75 | ||||
-rw-r--r-- | arch/m68k/lib/memset.c | 68 | ||||
-rw-r--r-- | arch/m68k/lib/string.c | 237 | ||||
-rw-r--r-- | arch/m68k/mm/Makefile | 2 | ||||
-rw-r--r-- | arch/m68k/mm/cache.c | 118 | ||||
-rw-r--r-- | arch/m68k/mm/memory.c | 104 | ||||
-rw-r--r-- | arch/m68k/mvme16x/rtc.c | 4 |
14 files changed, 529 insertions, 481 deletions
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 178c4a3fbb7..ba960bbc8e6 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -25,6 +25,11 @@ config GENERIC_CALIBRATE_DELAY bool default y +config ARCH_MAY_HAVE_PC_FDC + bool + depends on Q40 || (BROKEN && SUN3X) + default y + mainmenu "Linux/68k Kernel Configuration" source "init/Kconfig" diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c index c6b2a410bf9..eb63ca6ed94 100644 --- a/arch/m68k/bvme6000/rtc.c +++ b/arch/m68k/bvme6000/rtc.c @@ -14,6 +14,7 @@ #include <linux/fcntl.h> #include <linux/init.h> #include <linux/poll.h> +#include <linux/module.h> #include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */ #include <linux/smp_lock.h> #include <asm/bvme6000hw.h> @@ -171,7 +172,7 @@ static struct miscdevice rtc_dev = { .fops = &rtc_fops }; -int __init rtc_DP8570A_init(void) +static int __init rtc_DP8570A_init(void) { if (!MACH_IS_BVME6000) return -ENODEV; @@ -179,4 +180,4 @@ int __init rtc_DP8570A_init(void) printk(KERN_INFO "DP8570A Real Time Clock Driver v%s\n", RTC_VERSION); return misc_register(&rtc_dev); } - +module_init(rtc_DP8570A_init); diff --git a/arch/m68k/kernel/m68k_ksyms.c b/arch/m68k/kernel/m68k_ksyms.c index fe837e31afb..73e2f5e168d 100644 --- a/arch/m68k/kernel/m68k_ksyms.c +++ b/arch/m68k/kernel/m68k_ksyms.c @@ -74,10 +74,6 @@ EXPORT_SYMBOL(vme_brdtype); EXPORT_SYMBOL(__ashldi3); EXPORT_SYMBOL(__ashrdi3); EXPORT_SYMBOL(__lshrdi3); -EXPORT_SYMBOL(memcpy); -EXPORT_SYMBOL(memset); -EXPORT_SYMBOL(memcmp); -EXPORT_SYMBOL(memscan); EXPORT_SYMBOL(__muldi3); EXPORT_SYMBOL(__down_failed); diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c index f4e1e5eb8e1..8ed1b01a6a8 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, if (regno == PT_USP) addr = &task->thread.usp; else if (regno < sizeof(regoff)/sizeof(regoff[0])) - addr = (unsigned long *) (task->thread.esp0 + regoff[regno]); + addr = (unsigned long *)(task->thread.esp0 + regoff[regno]); else return -1; *addr = data; @@ -103,48 +103,56 @@ static inline int put_reg(struct task_struct *task, int regno, } /* - * Called by kernel/ptrace.c when detaching.. - * * Make sure the single step bit is not set. */ -void ptrace_disable(struct task_struct *child) +static inline void singlestep_disable(struct task_struct *child) { - unsigned long tmp; - /* make sure the single step bit is not set. */ - tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); + unsigned long tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); put_reg(child, PT_SR, tmp); child->thread.work.delayed_trace = 0; +} + +/* + * Called by kernel/ptrace.c when detaching.. + */ +void ptrace_disable(struct task_struct *child) +{ + singlestep_disable(child); child->thread.work.syscall_trace = 0; } asmlinkage int sys_ptrace(long request, long pid, long addr, long data) { struct task_struct *child; - int ret; + unsigned long tmp; + int i, ret = 0; lock_kernel(); - ret = -EPERM; if (request == PTRACE_TRACEME) { /* are we already being traced? */ - if (current->ptrace & PT_PTRACED) + if (current->ptrace & PT_PTRACED) { + ret = -EPERM; goto out; + } /* set the ptrace bit in the process flags. */ current->ptrace |= PT_PTRACED; - ret = 0; goto out; } - ret = -ESRCH; read_lock(&tasklist_lock); child = find_task_by_pid(pid); if (child) get_task_struct(child); read_unlock(&tasklist_lock); - if (!child) + if (unlikely(!child)) { + ret = -ESRCH; goto out; + } - ret = -EPERM; - if (pid == 1) /* you may not mess with init */ + /* you may not mess with init */ + if (unlikely(pid == 1)) { + ret = -EPERM; goto out_tsk; + } if (request == PTRACE_ATTACH) { ret = ptrace_attach(child); @@ -152,227 +160,171 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) } ret = ptrace_check_attach(child, request == PTRACE_KILL); - if (ret < 0) + if (ret) goto out_tsk; switch (request) { /* when I and D space are separate, these will need to be fixed. */ - case PTRACE_PEEKTEXT: /* read word at location addr. */ - case PTRACE_PEEKDATA: { - unsigned long tmp; - int copied; - - copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0); - ret = -EIO; - if (copied != sizeof(tmp)) - break; - ret = put_user(tmp,(unsigned long *) data); - break; - } + case PTRACE_PEEKTEXT: /* read word at location addr. */ + case PTRACE_PEEKDATA: + i = access_process_vm(child, addr, &tmp, sizeof(tmp), 0); + if (i != sizeof(tmp)) + goto out_eio; + ret = put_user(tmp, (unsigned long *)data); + break; /* read the word at location addr in the USER area. */ - case PTRACE_PEEKUSR: { - unsigned long tmp; - - ret = -EIO; - if ((addr & 3) || addr < 0 || - addr > sizeof(struct user) - 3) - break; - - tmp = 0; /* Default return condition */ - addr = addr >> 2; /* temporary hack. */ - ret = -EIO; - if (addr < 19) { - tmp = get_reg(child, addr); - if (addr == PT_SR) - tmp >>= 16; - } else if (addr >= 21 && addr < 49) { - tmp = child->thread.fp[addr - 21]; -#ifdef CONFIG_M68KFPU_EMU - /* Convert internal fpu reg representation - * into long double format - */ - if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) - tmp = ((tmp & 0xffff0000) << 15) | - ((tmp & 0x0000ffff) << 16); -#endif - } else - break; - ret = put_user(tmp,(unsigned long *) data); - break; - } - - /* when I and D space are separate, this will have to be fixed. */ - case PTRACE_POKETEXT: /* write the word at location addr. */ - case PTRACE_POKEDATA: - ret = 0; - if (access_process_vm(child, addr, &data, sizeof(data), 1) == sizeof(data)) - break; - ret = -EIO; - break; - - case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ - ret = -EIO; - if ((addr & 3) || addr < 0 || - addr > sizeof(struct user) - 3) - break; - - addr = addr >> 2; /* temporary hack. */ - - if (addr == PT_SR) { - data &= SR_MASK; - data <<= 16; - data |= get_reg(child, PT_SR) & ~(SR_MASK << 16); - } - if (addr < 19) { - if (put_reg(child, addr, data)) - break; - ret = 0; - break; - } - if (addr >= 21 && addr < 48) - { -#ifdef CONFIG_M68KFPU_EMU - /* Convert long double format - * into internal fpu reg representation - */ - if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) { - data = (unsigned long)data << 15; - data = (data & 0xffff0000) | - ((data & 0x0000ffff) >> 1); - } -#endif - child->thread.fp[addr - 21] = data; - ret = 0; - } + case PTRACE_PEEKUSR: + if (addr & 3) + goto out_eio; + addr >>= 2; /* temporary hack. */ + + if (addr >= 0 && addr < 19) { + tmp = get_reg(child, addr); + if (addr == PT_SR) + tmp >>= 16; + } else if (addr >= 21 && addr < 49) { + tmp = child->thread.fp[addr - 21]; + /* Convert internal fpu reg representation + * into long double format + */ + if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) + tmp = ((tmp & 0xffff0000) << 15) | + ((tmp & 0x0000ffff) << 16); + } else break; - - case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ - case PTRACE_CONT: { /* restart after signal. */ - long tmp; - - ret = -EIO; - if (!valid_signal(data)) - break; - if (request == PTRACE_SYSCALL) { - child->thread.work.syscall_trace = ~0; - } else { - child->thread.work.syscall_trace = 0; + ret = put_user(tmp, (unsigned long *)data); + break; + + /* when I and D space are separate, this will have to be fixed. */ + case PTRACE_POKETEXT: /* write the word at location addr. */ + case PTRACE_POKEDATA: + if (access_process_vm(child, addr, &data, sizeof(data), 1) != sizeof(data)) + goto out_eio; + break; + + case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ + if (addr & 3) + goto out_eio; + addr >>= 2; /* temporary hack. */ + + if (addr == PT_SR) { + data &= SR_MASK; + data <<= 16; + data |= get_reg(child, PT_SR) & ~(SR_MASK << 16); + } else if (addr >= 0 && addr < 19) { + if (put_reg(child, addr, data)) + goto out_eio; + } else if (addr >= 21 && addr < 48) { + /* Convert long double format + * into internal fpu reg representation + */ + if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) { + data = (unsigned long)data << 15; + data = (data & 0xffff0000) | + ((data & 0x0000ffff) >> 1); } - child->exit_code = data; - /* make sure the single step bit is not set. */ - tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); - put_reg(child, PT_SR, tmp); - child->thread.work.delayed_trace = 0; - wake_up_process(child); - ret = 0; - break; - } - -/* - * make the child exit. Best I can do is send it a sigkill. - * perhaps it should be put in the status that it wants to - * exit. - */ - case PTRACE_KILL: { - long tmp; - - ret = 0; - if (child->exit_state == EXIT_ZOMBIE) /* already dead */ - break; - child->exit_code = SIGKILL; - /* make sure the single step bit is not set. */ - tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); - put_reg(child, PT_SR, tmp); - child->thread.work.delayed_trace = 0; - wake_up_process(child); - break; - } - - case PTRACE_SINGLESTEP: { /* set the trap flag. */ - long tmp; - - ret = -EIO; - if (!valid_signal(data)) - break; + child->thread.fp[addr - 21] = data; + } else + goto out_eio; + break; + + case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ + case PTRACE_CONT: /* restart after signal. */ + if (!valid_signal(data)) + goto out_eio; + + if (request == PTRACE_SYSCALL) + child->thread.work.syscall_trace = ~0; + else child->thread.work.syscall_trace = 0; - tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); - put_reg(child, PT_SR, tmp); - child->thread.work.delayed_trace = 1; - - child->exit_code = data; - /* give it a chance to run. */ - wake_up_process(child); - ret = 0; - break; - } + child->exit_code = data; + singlestep_disable(child); + wake_up_process(child); + break; - case PTRACE_DETACH: /* detach a process that was attached. */ - ret = ptrace_detach(child, data); + /* + * make the child exit. Best I can do is send it a sigkill. + * perhaps it should be put in the status that it wants to + * exit. + */ + case PTRACE_KILL: + if (child->exit_state == EXIT_ZOMBIE) /* already dead */ break; - - case PTRACE_GETREGS: { /* Get all gp regs from the child. */ - int i; - unsigned long tmp; - for (i = 0; i < 19; i++) { - tmp = get_reg(child, i); - if (i == PT_SR) + child->exit_code = SIGKILL; + singlestep_disable(child); + wake_up_process(child); + break; + + case PTRACE_SINGLESTEP: /* set the trap flag. */ + if (!valid_signal(data)) + goto out_eio; + + child->thread.work.syscall_trace = 0; + tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); + put_reg(child, PT_SR, tmp); + child->thread.work.delayed_trace = 1; + + child->exit_code = data; + /* give it a chance to run. */ + wake_up_process(child); + break; + + case PTRACE_DETACH: /* detach a process that was attached. */ + ret = ptrace_detach(child, data); + break; + + case PTRACE_GETREGS: /* Get all gp regs from the child. */ + for (i = 0; i < 19; i++) { + tmp = get_reg(child, i); + if (i == PT_SR) tmp >>= 16; - if (put_user(tmp, (unsigned long *) data)) { - ret = -EFAULT; + ret = put_user(tmp, (unsigned long *)data); + if (ret) break; - } - data += sizeof(long); - } - ret = 0; - break; + data += sizeof(long); } + break; - case PTRACE_SETREGS: { /* Set all gp regs in the child. */ - int i; - unsigned long tmp; - for (i = 0; i < 19; i++) { - if (get_user(tmp, (unsigned long *) data)) { - ret = -EFAULT; + case PTRACE_SETREGS: /* Set all gp regs in the child. */ + for (i = 0; i < 19; i++) { + ret = get_user(tmp, (unsigned long *)data); + if (ret) break; - } - if (i == PT_SR) { + if (i == PT_SR) { tmp &= SR_MASK; tmp <<= 16; tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16); - } - put_reg(child, i, tmp); - data += sizeof(long); } - ret = 0; - break; + put_reg(child, i, tmp); + data += sizeof(long); } - - case PTRACE_GETFPREGS: { /* Get the child FPU state. */ - ret = 0; - if (copy_to_user((void *)data, &child->thread.fp, - sizeof(struct user_m68kfp_struct))) - ret = -EFAULT; - break; - } - - case PTRACE_SETFPREGS: { /* Set the child FPU state. */ - ret = 0; - if (copy_from_user(&child->thread.fp, (void *)data, - sizeof(struct user_m68kfp_struct))) - ret = -EFAULT; - break; - } - - default: - ret = ptrace_request(child, request, addr, data); - break; + break; + + case PTRACE_GETFPREGS: /* Get the child FPU state. */ + if (copy_to_user((void *)data, &child->thread.fp, + sizeof(struct user_m68kfp_struct))) + ret = -EFAULT; + break; + + case PTRACE_SETFPREGS: /* Set the child FPU state. */ + if (copy_from_user(&child->thread.fp, (void *)data, + sizeof(struct user_m68kfp_struct))) + ret = -EFAULT; + break; + + default: + ret = ptrace_request(child, request, addr, data); + break; } out_tsk: put_task_struct(child); out: unlock_kernel(); return ret; +out_eio: + ret = -EIO; + goto out_tsk; } asmlinkage void syscall_trace(void) diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c index e47e1958852..4ec95e3cb87 100644 --- a/arch/m68k/kernel/time.c +++ b/arch/m68k/kernel/time.c @@ -166,10 +166,7 @@ int do_settimeofday(struct timespec *tv) set_normalized_timespec(&xtime, sec, nsec); set_normalized_timespec(&wall_to_monotonic, wtm_sec, wtm_nsec); - time_adjust = 0; /* stop active adjtime() */ - time_status |= STA_UNSYNC; - time_maxerror = NTP_PHASE_LIMIT; - time_esterror = NTP_PHASE_LIMIT; + ntp_clear(); write_sequnlock_irq(&xtime_lock); clock_was_set(); return 0; diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile index 34b6dbc29c8..ebe51a51381 100644 --- a/arch/m68k/lib/Makefile +++ b/arch/m68k/lib/Makefile @@ -5,4 +5,4 @@ EXTRA_AFLAGS := -traditional lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ - checksum.o memcmp.o memcpy.o memset.o semaphore.o + 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 f4796febb77..00000000000 --- a/arch/m68k/lib/memcmp.c +++ /dev/null @@ -1,11 +0,0 @@ -#include <linux/types.h> - -int memcmp(const void * cs,const void * ct,size_t count) -{ - const unsigned char *su1, *su2; - - for( su1 = cs, su2 = ct; 0 < count; ++su1, ++su2, count--) - if (*su1 != *su2) - return((*su1 < *su2) ? -1 : +1); - return(0); -} diff --git a/arch/m68k/lib/memcpy.c b/arch/m68k/lib/memcpy.c deleted file mode 100644 index 73e181823d9..00000000000 --- a/arch/m68k/lib/memcpy.c +++ /dev/null @@ -1,75 +0,0 @@ -#include <linux/types.h> - -void * memcpy(void * to, const void * from, size_t n) -{ - void *xto = to; - size_t temp, temp1; - - if (!n) - return xto; - if ((long) to & 1) - { - char *cto = to; - const char *cfrom = from; - *cto++ = *cfrom++; - to = cto; - from = cfrom; - n--; - } - if (n > 2 && (long) to & 2) - { - short *sto = to; - const short *sfrom = from; - *sto++ = *sfrom++; - to = sto; - from = sfrom; - n -= 2; - } - temp = n >> 2; - if (temp) - { - long *lto = to; - const long *lfrom = from; - - __asm__ __volatile__("movel %2,%3\n\t" - "andw #7,%3\n\t" - "lsrl #3,%2\n\t" - "negw %3\n\t" - "jmp %%pc@(1f,%3:w:2)\n\t" - "4:\t" - "movel %0@+,%1@+\n\t" - "movel %0@+,%1@+\n\t" - "movel %0@+,%1@+\n\t" - "movel %0@+,%1@+\n\t" - "movel %0@+,%1@+\n\t" - "movel %0@+,%1@+\n\t" - "movel %0@+,%1@+\n\t" - "movel %0@+,%1@+\n\t" - "1:\t" - "dbra %2,4b\n\t" - "clrw %2\n\t" - "subql #1,%2\n\t" - "jpl 4b\n\t" - : "=a" (lfrom), "=a" (lto), "=d" (temp), - "=&d" (temp1) - : "0" (lfrom), "1" (lto), "2" (temp) - ); - to = lto; - from = lfrom; - } - if (n & 2) - { - short *sto = to; - const short *sfrom = from; - *sto++ = *sfrom++; - to = sto; - from = sfrom; - } - if (n & 1) - { - char *cto = to; - const char *cfrom = from; - *cto = *cfrom; - } - return xto; -} diff --git a/arch/m68k/lib/memset.c b/arch/m68k/lib/memset.c deleted file mode 100644 index d55fdb2ee9d..00000000000 --- a/arch/m68k/lib/memset.c +++ /dev/null @@ -1,68 +0,0 @@ -#include <linux/types.h> - -void * memset(void * s, int c, size_t count) -{ - void *xs = s; - size_t temp, temp1; - - if (!count) - return xs; - c &= 0xff; - c |= c << 8; - c |= c << 16; - if ((long) s & 1) - { - char *cs = s; - *cs++ = c; - s = cs; - count--; - } - if (count > 2 && (long) s & 2) - { - short *ss = s; - *ss++ = c; - s = ss; - count -= 2; - } - temp = count >> 2; - if (temp) - { - long *ls = s; - - __asm__ __volatile__("movel %1,%2\n\t" - "andw #7,%2\n\t" - "lsrl #3,%1\n\t" - "negw %2\n\t" - "jmp %%pc@(2f,%2:w:2)\n\t" - "1:\t" - "movel %3,%0@+\n\t" - "movel %3,%0@+\n\t" - "movel %3,%0@+\n\t" - "movel %3,%0@+\n\t" - "movel %3,%0@+\n\t" - "movel %3,%0@+\n\t" - "movel %3,%0@+\n\t" - "movel %3,%0@+\n\t" - "2:\t" - "dbra %1,1b\n\t" - "clrw %1\n\t" - "subql #1,%1\n\t" - "jpl 1b\n\t" - : "=a" (ls), "=d" (temp), "=&d" (temp1) - : "d" (c), "0" (ls), "1" (temp) - ); - s = ls; - } - if (count & 2) - { - short *ss = s; - *ss++ = c; - s = ss; - } - if (count & 1) - { - char *cs = s; - *cs = c; - } - return xs; -} diff --git a/arch/m68k/lib/string.c b/arch/m68k/lib/string.c new file mode 100644 index 00000000000..b92b89e1ea0 --- /dev/null +++ b/arch/m68k/lib/string.c @@ -0,0 +1,237 @@ + +#include <linux/types.h> +#include <linux/module.h> + +void *memset(void *s, int c, size_t count) +{ + void *xs = s; + size_t temp, temp1; + + if (!count) + return xs; + c &= 0xff; + c |= c << 8; + c |= c << 16; + if ((long)s & 1) { + char *cs = s; + *cs++ = c; + s = cs; + count--; + } + if (count > 2 && (long)s & 2) { + short *ss = s; + *ss++ = c; + s = ss; + count -= 2; + } + temp = count >> 2; + if (temp) { + long *ls = s; + + asm volatile ( + " movel %1,%2\n" + " andw #7,%2\n" + " lsrl #3,%1\n" + " negw %2\n" + " jmp %%pc@(2f,%2:w:2)\n" + "1: movel %3,%0@+\n" + " movel %3,%0@+\n" + " movel %3,%0@+\n" + " movel %3,%0@+\n" + " movel %3,%0@+\n" + " movel %3,%0@+\n" + " movel %3,%0@+\n" + " movel %3,%0@+\n" + "2: dbra %1,1b\n" + " clrw %1\n" + " subql #1,%1\n" + " jpl 1b" + : "=a" (ls), "=d" (temp), "=&d" (temp1) + : "d" (c), "0" (ls), "1" (temp)); + s = ls; + } + if (count & 2) { + short *ss = s; + *ss++ = c; + s = ss; + } + if (count & 1) { + char *cs = s; + *cs = c; + } + return xs; +} +EXPORT_SYMBOL(memset); + +void *memcpy(void *to, const void *from, size_t n) +{ + void *xto = to; + size_t temp, temp1; + + if (!n) + return xto; + if ((long)to & 1) { + char *cto = to; + const char *cfrom = from; + *cto++ = *cfrom++; + to = cto; + from = cfrom; + n--; + } + if (n > 2 && (long)to & 2) { + short *sto = to; + const short *sfrom = from; + *sto++ = *sfrom++; + to = sto; + from = sfrom; + n -= 2; + } + temp = n >> 2; + if (temp) { + long *lto = to; + const long *lfrom = from; + + asm volatile ( + " movel %2,%3\n" + " andw #7,%3\n" + " lsrl #3,%2\n" + " negw %3\n" + " jmp %%pc@(1f,%3:w:2)\n" + "4: movel %0@+,%1@+\n" + " movel %0@+,%1@+\n" + " movel %0@+,%1@+\n" + " movel %0@+,%1@+\n" + " movel %0@+,%1@+\n" + " movel %0@+,%1@+\n" + " movel %0@+,%1@+\n" + " movel %0@+,%1@+\n" + "1: dbra %2,4b\n" + " clrw %2\n" + " subql #1,%2\n" + " jpl 4b" + : "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1) + : "0" (lfrom), "1" (lto), "2" (temp)); + to = lto; + from = lfrom; + } + if (n & 2) { + short *sto = to; + const short *sfrom = from; + *sto++ = *sfrom++; + to = sto; + from = sfrom; + } + if (n & 1) { + char *cto = to; + const char *cfrom = from; + *cto = *cfrom; + } + return xto; +} +EXPORT_SYMBOL(memcpy); + +void *memmove(void *dest, const void *src, size_t n) +{ + void *xdest = dest; + size_t temp; + + if (!n) + return xdest; + + if (dest < src) { + if ((long)dest & 1) { + char *cdest = dest; + const char *csrc = src; + *cdest++ = *csrc++; + dest = cdest; + src = csrc; + n--; + } + if (n > 2 && (long)dest & 2) { + short *sdest = dest; + const short *ssrc = src; + *sdest++ = *ssrc++; + dest = sdest; + src = ssrc; + n -= 2; + } + temp = n >> 2; + if (temp) { + long *ldest = dest; + const long *lsrc = src; + temp--; + do + *ldest++ = *lsrc++; + while (temp--); + dest = ldest; + src = lsrc; + } + if (n & 2) { + short *sdest = dest; + const short *ssrc = src; + *sdest++ = *ssrc++; + dest = sdest; + src = ssrc; + } + if (n & 1) { + char *cdest = dest; + const char *csrc = src; + *cdest = *csrc; + } + } else { + dest = (char *)dest + n; + src = (const char *)src + n; + if ((long)dest & 1) { + char *cdest = dest; + const char *csrc = src; + *--cdest = *--csrc; + dest = cdest; + src = csrc; + n--; + } + if (n > 2 && (long)dest & 2) { + short *sdest = dest; + const short *ssrc = src; + *--sdest = *--ssrc; + dest = sdest; + src = ssrc; + n -= 2; + } + temp = n >> 2; + if (temp) { + long *ldest = dest; + const long *lsrc = src; + temp--; + do + *--ldest = *--lsrc; + while (temp--); + dest = ldest; + src = lsrc; + } + if (n & 2) { + short *sdest = dest; + const short *ssrc = src; + *--sdest = *--ssrc; + dest = sdest; + src = ssrc; + } + if (n & 1) { + char *cdest = dest; + const char *csrc = src; + *--cdest = *--csrc; + } + } + return xdest; +} +EXPORT_SYMBOL(memmove); + +int memcmp(const void *cs, const void *ct, size_t count) +{ + const unsigned char *su1, *su2; + + for (su1 = cs, su2 = ct; count > 0; ++su1, ++su2, count--) + if (*su1 != *su2) + return *su1 < *su2 ? -1 : +1; + return 0; +} +EXPORT_SYMBOL(memcmp); diff --git a/arch/m68k/mm/Makefile b/arch/m68k/mm/Makefile index 90f1c735c11..5eaa43c4cb3 100644 --- a/arch/m68k/mm/Makefile +++ b/arch/m68k/mm/Makefile @@ -2,7 +2,7 @@ # Makefile for the linux m68k-specific parts of the memory manager. # -obj-y := init.o fault.o hwtest.o +obj-y := cache.o init.o fault.o hwtest.o obj-$(CONFIG_MMU_MOTOROLA) += kmap.o memory.o motorola.o obj-$(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 00000000000..5437fff5fe0 --- /dev/null +++ b/arch/m68k/mm/cache.c @@ -0,0 +1,118 @@ +/* + * linux/arch/m68k/mm/cache.c + * + * Instruction cache handling + * + * Copyright (C) 1995 Hamish Macdonald + */ + +#include <linux/module.h> +#include <asm/pgalloc.h> +#include <asm/traps.h> + + +static unsigned long virt_to_phys_slow(unsigned long vaddr) +{ + if (CPU_IS_060) { + unsigned long paddr; + + /* The PLPAR instruction causes an access error if the translation + * is not possible. To catch this we use the same exception mechanism + * as for user space accesses in <asm/uaccess.h>. */ + asm volatile (".chip 68060\n" + "1: plpar (%0)\n" + ".chip 68k\n" + "2:\n" + ".section .fixup,\"ax\"\n" + " .even\n" + "3: sub.l %0,%0\n" + " jra 2b\n" + ".previous\n" + ".section __ex_table,\"a\"\n" + " .align 4\n" + " .long 1b,3b\n" + ".previous" + : "=a" (paddr) + : "0" (vaddr)); + return paddr; + } else if (CPU_IS_040) { + unsigned long mmusr; + + asm volatile (".chip 68040\n\t" + "ptestr (%1)\n\t" + "movec %%mmusr, %0\n\t" + ".chip 68k" + : "=r" (mmusr) + : "a" (vaddr)); + + if (mmusr & MMU_R_040) + return (mmusr & PAGE_MASK) | (vaddr & ~PAGE_MASK); + } else { + unsigned short mmusr; + unsigned long *descaddr; + + asm volatile ("ptestr %3,%2@,#7,%0\n\t" + "pmove %%psr,%1@" + : "=a&" (descaddr) + : "a" (&mmusr), "a" (vaddr), "d" (get_fs().seg)); + if (mmusr & (MMU_I|MMU_B|MMU_L)) + return 0; + descaddr = phys_to_virt((unsigned long)descaddr); + switch (mmusr & MMU_NUM) { + case 1: + return (*descaddr & 0xfe000000) | (vaddr & 0x01ffffff); + case 2: + return (*descaddr & 0xfffc0000) | (vaddr & 0x0003ffff); + case 3: + return (*descaddr & PAGE_MASK) | (vaddr & ~PAGE_MASK); + } + } + return 0; +} + +/* Push n pages at kernel virtual address and clear the icache */ +/* RZ: use cpush %bc instead of cpush %dc, cinv %ic */ +void flush_icache_range(unsigned long address, unsigned long endaddr) +{ + + if (CPU_IS_040_OR_060) { + address &= PAGE_MASK; + + do { + asm volatile ("nop\n\t" + ".chip 68040\n\t" + "cpushp %%bc,(%0)\n\t" + ".chip 68k" + : : "a" (virt_to_phys_slow(address))); + address += PAGE_SIZE; + } while (address < endaddr); + } else { + unsigned long tmp; + asm volatile ("movec %%cacr,%0\n\t" + "orw %1,%0\n\t" + "movec %0,%%cacr" + : "=&d" (tmp) + : "di" (FLUSH_I)); + } +} +EXPORT_SYMBOL(flush_icache_range); + +void flush_icache_user_range(struct vm_area_struct *vma, struct page *page, + unsigned long addr, int len) +{ + if (CPU_IS_040_OR_060) { + asm volatile ("nop\n\t" + ".chip 68040\n\t" + "cpushp %%bc,(%0)\n\t" + ".chip 68k" + : : "a" (page_to_phys(page))); + } else { + unsigned long tmp; + asm volatile ("movec %%cacr,%0\n\t" + "orw %1,%0\n\t" + "movec %0,%%cacr" + : "=&d" (tmp) + : "di" (FLUSH_I)); + } +} + diff --git a/arch/m68k/mm/memory.c b/arch/m68k/mm/memory.c index 1453a601372..559942ce0e1 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) #endif } -static unsigned long virt_to_phys_slow(unsigned long vaddr) -{ - if (CPU_IS_060) { - mm_segment_t fs = get_fs(); - unsigned long paddr; - - set_fs(get_ds()); - - /* The PLPAR instruction causes an access error if the translation - * is not possible. To catch this we use the same exception mechanism - * as for user space accesses in <asm/uaccess.h>. */ - asm volatile (".chip 68060\n" - "1: plpar (%0)\n" - ".chip 68k\n" - "2:\n" - ".section .fixup,\"ax\"\n" - " .even\n" - "3: sub.l %0,%0\n" - " jra 2b\n" - ".previous\n" - ".section __ex_table,\"a\"\n" - " .align 4\n" - " .long 1b,3b\n" - ".previous" - : "=a" (paddr) - : "0" (vaddr)); - set_fs(fs); - return paddr; - } else if (CPU_IS_040) { - mm_segment_t fs = get_fs(); - unsigned long mmusr; - - set_fs(get_ds()); - - asm volatile (".chip 68040\n\t" - "ptestr (%1)\n\t" - "movec %%mmusr, %0\n\t" - ".chip 68k" - : "=r" (mmusr) - : "a" (vaddr)); - set_fs(fs); - - if (mmusr & MMU_R_040) - return (mmusr & PAGE_MASK) | (vaddr & ~PAGE_MASK); - } else { - unsigned short mmusr; - unsigned long *descaddr; - - asm volatile ("ptestr #5,%2@,#7,%0\n\t" - "pmove %%psr,%1@" - : "=a&" (descaddr) - : "a" (&mmusr), "a" (vaddr)); - if (mmusr & (MMU_I|MMU_B|MMU_L)) - return 0; - descaddr = phys_to_virt((unsigned long)descaddr); - switch (mmusr & MMU_NUM) { - case 1: - return (*descaddr & 0xfe000000) | (vaddr & 0x01ffffff); - case 2: - return (*descaddr & 0xfffc0000) | (vaddr & 0x0003ffff); - case 3: - return (*descaddr & PAGE_MASK) | (vaddr & ~PAGE_MASK); - } - } - return 0; -} - -/* Push n pages at kernel virtual address and clear the icache */ -/* RZ: use cpush %bc instead of cpush %dc, cinv %ic */ -void flush_icache_range(unsigned long address, unsigned long endaddr) -{ - if (CPU_IS_040_OR_060) { - address &= PAGE_MASK; - - if (address >= PAGE_OFFSET && address < (unsigned long)high_memory) { - do { - asm volatile ("nop\n\t" - ".chip 68040\n\t" - "cpushp %%bc,(%0)\n\t" - ".chip 68k" - : : "a" (virt_to_phys((void *)address))); - address += PAGE_SIZE; - } while (address < endaddr); - } else { - do { - asm volatile ("nop\n\t" - ".chip 68040\n\t" - "cpushp %%bc,(%0)\n\t" - ".chip 68k" - : : "a" (virt_to_phys_slow(address))); - address += PAGE_SIZE; - } while (address < endaddr); - } - } else { - unsigned long tmp; - asm volatile ("movec %%cacr,%0\n\t" - "orw %1,%0\n\t" - "movec %0,%%cacr" - : "=&d" (tmp) - : "di" (FLUSH_I)); - } -} - - #ifndef CONFIG_SINGLE_MEMORY_CHUNK int mm_end_of_chunk (unsigned long addr, int len) { diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c index 8a242506908..7977eae50af 100644 --- a/arch/m68k/mvme16x/rtc.c +++ b/arch/m68k/mvme16x/rtc.c @@ -161,7 +161,7 @@ static struct miscdevice rtc_dev= .fops = &rtc_fops }; -int __init rtc_MK48T08_init(void) +static int __init rtc_MK48T08_init(void) { if (!MACH_IS_MVME16x) return -ENODEV; @@ -169,4 +169,4 @@ int __init rtc_MK48T08_init(void) printk(KERN_INFO "MK48T08 Real Time Clock Driver v%s\n", RTC_VERSION); return misc_register(&rtc_dev); } - +module_init(rtc_MK48T08_init); |